public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/csky rm csky_memory_insert/remove_breakpoint
@ 2022-08-31 11:49 Jiangshuai Li
  2022-09-20 20:14 ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Jiangshuai Li @ 2022-08-31 11:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Jiangshuai Li

All the types of breakpoints and watchpoints are inserted or
removed by the gdb stub, these two functions are no longer needed.
---
 gdb/csky-tdep.c | 201 ------------------------------------------------
 1 file changed, 201 deletions(-)

diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c
index ba53c1b10ca..4db88696270 100644
--- a/gdb/csky-tdep.c
+++ b/gdb/csky-tdep.c
@@ -2016,201 +2016,6 @@ csky_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size)
     }
 }
 
-/* Implement the memory_insert_breakpoint gdbarch method.  */
-
-static int
-csky_memory_insert_breakpoint (struct gdbarch *gdbarch,
-			       struct bp_target_info *bp_tgt)
-{
-  int val;
-  const unsigned char *bp;
-  gdb_byte bp_write_record1[] = { 0, 0, 0, 0 };
-  gdb_byte bp_write_record2[] = { 0, 0, 0, 0 };
-  gdb_byte bp_record[] = { 0, 0, 0, 0 };
-
-  /* Sanity-check bp_address.  */
-  if (bp_tgt->reqstd_address % 2)
-    warning (_("Invalid breakpoint address 0x%x is an odd number."),
-	     (unsigned int) bp_tgt->reqstd_address);
-  scoped_restore restore_memory
-    = make_scoped_restore_show_memory_breakpoints (1);
-
-  /* Determine appropriate breakpoint_kind for this address.  */
-  bp_tgt->kind = csky_breakpoint_kind_from_pc (gdbarch,
-					       &bp_tgt->reqstd_address);
-
-  /* Save the memory contents.  */
-  bp_tgt->shadow_len = bp_tgt->kind;
-
-  /* Fill bp_tgt->placed_address.  */
-  bp_tgt->placed_address = bp_tgt->reqstd_address;
-
-  if (bp_tgt->kind == CSKY_INSN_SIZE16)
-    {
-      if ((bp_tgt->reqstd_address % 4) == 0)
-	{
-	  /* Read two bytes.  */
-	  val = target_read_memory (bp_tgt->reqstd_address,
-				    bp_tgt->shadow_contents, 2);
-	  if (val)
-	    return val;
-
-	  /* Read two bytes.  */
-	  val = target_read_memory (bp_tgt->reqstd_address + 2,
-				    bp_record, 2);
-	  if (val)
-	    return val;
-
-	  /* Write the breakpoint.  */
-	  bp_write_record1[2] = bp_record[0];
-	  bp_write_record1[3] = bp_record[1];
-	  bp = bp_write_record1;
-	  val = target_write_raw_memory (bp_tgt->reqstd_address, bp,
-					 CSKY_WR_BKPT_MODE);
-	}
-      else
-	{
-	  val = target_read_memory (bp_tgt->reqstd_address,
-				    bp_tgt->shadow_contents, 2);
-	  if (val)
-	    return val;
-
-	  val = target_read_memory (bp_tgt->reqstd_address - 2,
-				    bp_record, 2);
-	  if (val)
-	    return val;
-
-	  /* Write the breakpoint.  */
-	  bp_write_record1[0] = bp_record[0];
-	  bp_write_record1[1] = bp_record[1];
-	  bp = bp_write_record1;
-	  val = target_write_raw_memory (bp_tgt->reqstd_address - 2,
-					 bp, CSKY_WR_BKPT_MODE);
-	}
-    }
-  else
-    {
-      if (bp_tgt->placed_address % 4 == 0)
-	{
-	  val = target_read_memory (bp_tgt->reqstd_address,
-				    bp_tgt->shadow_contents,
-				    CSKY_WR_BKPT_MODE);
-	  if (val)
-	    return val;
-
-	  /* Write the breakpoint.  */
-	  bp = bp_write_record1;
-	  val = target_write_raw_memory (bp_tgt->reqstd_address,
-					 bp, CSKY_WR_BKPT_MODE);
-	}
-      else
-	{
-	  val = target_read_memory (bp_tgt->reqstd_address,
-				    bp_tgt->shadow_contents,
-				    CSKY_WR_BKPT_MODE);
-	  if (val)
-	    return val;
-
-	  val = target_read_memory (bp_tgt->reqstd_address - 2,
-				    bp_record, 2);
-	  if (val)
-	    return val;
-
-	  val = target_read_memory (bp_tgt->reqstd_address + 4,
-				    bp_record + 2, 2);
-	  if (val)
-	    return val;
-
-	  bp_write_record1[0] = bp_record[0];
-	  bp_write_record1[1] = bp_record[1];
-	  bp_write_record2[2] = bp_record[2];
-	  bp_write_record2[3] = bp_record[3];
-
-	  /* Write the breakpoint.  */
-	  bp = bp_write_record1;
-	  val = target_write_raw_memory (bp_tgt->reqstd_address - 2, bp,
-					 CSKY_WR_BKPT_MODE);
-	  if (val)
-	    return val;
-
-	  /* Write the breakpoint.  */
-	  bp = bp_write_record2;
-	  val = target_write_raw_memory (bp_tgt->reqstd_address + 2, bp,
-					 CSKY_WR_BKPT_MODE);
-	}
-    }
-  return val;
-}
-
-/* Restore the breakpoint shadow_contents to the target.  */
-
-static int
-csky_memory_remove_breakpoint (struct gdbarch *gdbarch,
-			       struct bp_target_info *bp_tgt)
-{
-  int val;
-  gdb_byte bp_record[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
-  /* Different for shadow_len 2 or 4.  */
-  if (bp_tgt->shadow_len == 2)
-    {
-      /* Do word-sized writes on word-aligned boundaries and read
-	 padding bytes as necessary.  */
-      if (bp_tgt->reqstd_address % 4 == 0)
-	{
-	  val = target_read_memory (bp_tgt->reqstd_address + 2,
-				    bp_record + 2, 2);
-	  if (val)
-	    return val;
-	  bp_record[0] = bp_tgt->shadow_contents[0];
-	  bp_record[1] = bp_tgt->shadow_contents[1];
-	  return target_write_raw_memory (bp_tgt->reqstd_address,
-					  bp_record, CSKY_WR_BKPT_MODE);
-	}
-      else
-	{
-	  val = target_read_memory (bp_tgt->reqstd_address - 2,
-				    bp_record, 2);
-	  if (val)
-	    return val;
-	  bp_record[2] = bp_tgt->shadow_contents[0];
-	  bp_record[3] = bp_tgt->shadow_contents[1];
-	  return target_write_raw_memory (bp_tgt->reqstd_address - 2,
-					  bp_record, CSKY_WR_BKPT_MODE);
-	}
-    }
-  else
-    {
-      /* Do word-sized writes on word-aligned boundaries and read
-	 padding bytes as necessary.  */
-      if (bp_tgt->placed_address % 4 == 0)
-	{
-	  return target_write_raw_memory (bp_tgt->reqstd_address,
-					  bp_tgt->shadow_contents,
-					  CSKY_WR_BKPT_MODE);
-	}
-      else
-	{
-	  val = target_read_memory (bp_tgt->reqstd_address - 2,
-				    bp_record, 2);
-	  if (val)
-	    return val;
-	  val = target_read_memory (bp_tgt->reqstd_address + 4,
-				    bp_record+6, 2);
-	  if (val)
-	    return val;
-
-	  bp_record[2] = bp_tgt->shadow_contents[0];
-	  bp_record[3] = bp_tgt->shadow_contents[1];
-	  bp_record[4] = bp_tgt->shadow_contents[2];
-	  bp_record[5] = bp_tgt->shadow_contents[3];
-
-	  return target_write_raw_memory (bp_tgt->reqstd_address - 2,
-					  bp_record,
-					  CSKY_WR_BKPT_MODE * 2);
-	}
-    }
-}
-
 /* Determine link register type.  */
 
 static lr_type_t
@@ -3012,12 +2817,6 @@ csky_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   frame_unwind_append_unwinder (gdbarch, &csky_stub_unwind);
   frame_unwind_append_unwinder (gdbarch, &csky_unwind_cache);
 
-  /* Breakpoints.  */
-  set_gdbarch_memory_insert_breakpoint (gdbarch,
-					csky_memory_insert_breakpoint);
-  set_gdbarch_memory_remove_breakpoint (gdbarch,
-					csky_memory_remove_breakpoint);
-
   /* Hook in ABI-specific overrides, if they have been registered.  */
   gdbarch_init_osabi (info, gdbarch);
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gdb/csky rm csky_memory_insert/remove_breakpoint
  2022-08-31 11:49 [PATCH] gdb/csky rm csky_memory_insert/remove_breakpoint Jiangshuai Li
@ 2022-09-20 20:14 ` Tom Tromey
  0 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2022-09-20 20:14 UTC (permalink / raw)
  To: Jiangshuai Li via Gdb-patches; +Cc: Jiangshuai Li

>>>>> Jiangshuai Li via Gdb-patches <gdb-patches@sourceware.org> writes:

> All the types of breakpoints and watchpoints are inserted or
> removed by the gdb stub, these two functions are no longer needed.

Does this mean this is a port that will never have a host port of gdb?

I guess it's fine in that case.  I wonder if there are other ports in
this situation.

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] gdb/csky rm csky_memory_insert/remove_breakpoint
@ 2022-09-21  8:51 jiangshuai_li
  2022-09-21  8:51 ` jiangshuai_li
  0 siblings, 1 reply; 4+ messages in thread
From: jiangshuai_li @ 2022-09-21  8:51 UTC (permalink / raw)
  To: Jiangshuai Li via Gdb-patches, Tom Tromey

>>>>>> Jiangshuai Li via Gdb-patches <gdb-patches@sourceware.org> writes:
>
>> All the types of breakpoints and watchpoints are inserted or
>> removed by the gdb stub, these two functions are no longer needed.
>
>Does this mean this is a port that will never have a host port of gdb?
You mean native gdb support? I will port native gdb later. 
The reason why I deleted these two functions is that CSKY did not use the remote protocol
provided by GDB long ago, but implemented a set of djp protocols for debugging. At this
time, these two functions are useful. And at the same time, when debugging with gdbserver,
software breakpoints are also inserted and deleted through these two interfaces.
However, the GDB Stubs used by CSKY now use the remote protocol provided by GDB, and
gdbserver also supports inserting and deleting software breakpoints, so these two functions
are no longer needed.
I haven't carefully checked whether native gdb needs these two interfaces, if necessary, add
them later.
>
>I guess it's fine in that case. I wonder if there are other ports in
>this situation.
>
 Jiangshuai Li

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] gdb/csky rm csky_memory_insert/remove_breakpoint
  2022-09-21  8:51 jiangshuai_li
@ 2022-09-21  8:51 ` jiangshuai_li
  0 siblings, 0 replies; 4+ messages in thread
From: jiangshuai_li @ 2022-09-21  8:51 UTC (permalink / raw)
  To: Jiangshuai Li via Gdb-patches, Tom Tromey

[-- Attachment #1: Type: text/plain, Size: 1104 bytes --]

>>>>>> Jiangshuai Li via Gdb-patches <gdb-patches@sourceware.org> writes:
>
>> All the types of breakpoints and watchpoints are inserted or
>> removed by the gdb stub, these two functions are no longer needed.
>
>Does this mean this is a port that will never have a host port of gdb?
You mean native gdb support? I will port native gdb later. 
The reason why I deleted these two functions is that CSKY did not use the remote protocol
provided by GDB long ago, but implemented a set of djp protocols for debugging. At this
time, these two functions are useful. And at the same time, when debugging with gdbserver,
software breakpoints are also inserted and deleted through these two interfaces.
However, the GDB Stubs used by CSKY now use the remote protocol provided by GDB, and
gdbserver also supports inserting and deleting software breakpoints, so these two functions
are no longer needed.
I haven't carefully checked whether native gdb needs these two interfaces, if necessary, add
them later.
>
>I guess it's fine in that case. I wonder if there are other ports in
>this situation.
>
 Jiangshuai Li

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-21  8:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-31 11:49 [PATCH] gdb/csky rm csky_memory_insert/remove_breakpoint Jiangshuai Li
2022-09-20 20:14 ` Tom Tromey
2022-09-21  8:51 jiangshuai_li
2022-09-21  8:51 ` jiangshuai_li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).