* Save the length of inserted breakpoints
@ 2006-03-02 22:25 Daniel Jacobowitz
2006-03-02 23:13 ` Mark Kettenis
0 siblings, 1 reply; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-03-02 22:25 UTC (permalink / raw)
To: gdb-patches
This nasty, mechanical patch adds "len" arguments to
target_remove_breakpoint and target_remove_hw_breakpoint. The goal is
to allow BREAKPOINT_FROM_PC to include heuristics, which may possibly
change between when a breakpoint is inserted and when it is removed;
in order to stay in sync, we need to always remove breakpoints in the
same way that we inserted them.
There's not much more to say about this patch. It's big, obvious, and
pretty ugly. Any comments on this? Does it look OK?
Tested on x86_64-pc-linux-gnu, and by hand on an ARM target with
the use-CPSR patch.
--
Daniel Jacobowitz
CodeSourcery
2006-03-02 Daniel Jacobowitz <dan@codesourcery.com>
* breakpoint.c (insert_bp_location): Set placed_address and
placed_size.
(delete_breakpoint): Likewise.
(remove_breakpoint): Use placed_address and placed_size.
* breakpoint.h (struct bp_location): Add placed_address and
placed_size.
* gdbarch.sh (memory_remove_breakpoint): Add len argument.
* mem-break.c (default_memory_remove_breakpoint): Add LEN argument.
Don't use BREAKPOINT_FROM_PC.
(memory_remove_breakpoint): Add len argument.
* target.c (update_current_target): Update prototype.
(debug_to_remove_breakpoint): Add len argument.
(debug_to_remove_hw_breakpoint): Likewise.
* target.h (struct target_ops): Add len argument to
to_remove_breakpoint and to_remove_hw_breakpoint.
(target_remove_breakpoint, target_remove_hw_breakpoint)
(memory_remove_breakpoint, default_memory_remove_breakpoint): Add
len argument.
* wince.c (struct thread_info_struct): Add bp_pc and bp_len.
(undoSStep): Use them.
(wince_software_single_step): Set them.
* config/i386/nm-i386.h (i386_remove_hw_breakpoint): Add len
argument.
(target_remove_hw_breakpoint): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* alpha-tdep.c (alpha_software_single_step): Save breakpoint
size for use when removing the breakpoint.
* arm-tdep.c (arm_software_single_step): Likewise. Add a note.
* cris-tdep.c (cris_software_single_step): Likewise.
* mips-tdep.c (mips_software_single_step): Likewise.
* rs6000-nat.c (exec_one_dummy_insn): Likewise.
* rs6000-tdep.c (rs6000_software_single_step): Likewise.
* sparc-tdep.c (sparc_software_single_step):
* corelow.c (ignore_remove): New.
(init_core_ops): Use it.
* exec.c (ignore_remove): New.
(init_exec_ops): Use it.
* sol-thread.c (ignore_remove): New.
(init_sol_core_ops): Use it.
* procfs.c (dbx_link_bpt_size): New.
(remove_dbx_link_breakpoint): Use it.
(insert_dbx_link_bpt_in_file): Set it.
* solib-irix.c (breakpoint_len): New.
(disable_break): Use it.
(enable_break): Set it.
* i386-nat.c (i386_remove_hw_breakpoint): Add len argument.
* ia64-tdep.c (ia64_memory_remove_breakpoint): Likewise.
* m32r-tdep.c (m32r_memory_remove_breakpoint): Likewise.
* monitor.c (monitor_remove_breakpoint): Likewise.
* nto-procfs.c (procfs_remove_breakpoint): Likewise.
(procfs_remove_hw_breakpoint): Likewise.
* ocd.c (ocd_remove_breakpoint): Likewise.
* ocd.h (ocd_remove_breakpoint): Likewise.
* ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise.
Don't use BREAKPOINT_FROM_PC.
* ppc-tdep.h (ppc_linux_memory_remove_breakpoint): Likewise.
* remote-e7000.c (e7000_remove_breakpoint): Likewise.
* remote-m32r-sdi.c (m32r_remove_breakpoint): Likewise.
* remote-mips.c (mips_remove_breakpoint): Likewise.
* remote-rdp.c (remote_rdp_remove_breakpoint): Likewise.
(rdp_step): Update.
* remote-sds.c (sds_remove_breakpoint): Likewise.
* remote-sim.c (gdbsim_remove_breakpoint): Likewise.
* remote-st.c (st2000_remove_breakpoint): Likewise.
* remote.c (remote_remove_breakpoint): Likewise.
(remote_remove_hw_breakpoint): Likewise. Don't use
BREAKPOINT_FROM_PC.
2006-03-02 Daniel Jacobowitz <dan@codesourcery.com>
* gdbint.texinfo (Watchpoints, Target Conditionals): Update remove
breakpoint prototypes.
Index: alpha-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/alpha-tdep.c,v
retrieving revision 1.153
diff -u -p -r1.153 alpha-tdep.c
--- alpha-tdep.c 15 Jan 2006 20:53:32 -0000 1.153
+++ alpha-tdep.c 2 Mar 2006 20:40:50 -0000
@@ -1496,17 +1496,21 @@ alpha_software_single_step (enum target_
typedef char binsn_quantum[BREAKPOINT_MAX];
static binsn_quantum break_mem;
CORE_ADDR pc;
+ static CORE_ADDR bp_pc;
+ static int bp_size;
if (insert_breakpoints_p)
{
pc = read_pc ();
next_pc = alpha_next_pc (pc);
+ bp_pc = next_pc;
+ BREAKPOINT_FROM_PC (&bp_pc, &bp_size);
target_insert_breakpoint (next_pc, break_mem);
}
else
{
- target_remove_breakpoint (next_pc, break_mem);
+ target_remove_breakpoint (bp_pc, bp_size, break_mem);
write_pc (next_pc);
}
}
Index: arm-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.c,v
retrieving revision 1.205
diff -u -p -r1.205 arm-tdep.c
--- arm-tdep.c 15 Feb 2006 17:36:11 -0000 1.205
+++ arm-tdep.c 2 Mar 2006 20:40:51 -0000
@@ -1845,14 +1845,22 @@ arm_software_single_step (enum target_si
{
static int next_pc; /* State between setting and unsetting. */
static char break_mem[BREAKPOINT_MAX]; /* Temporary storage for mem@bpt */
+ static CORE_ADDR bp_pc;
+ static int bp_size;
+
+ /* NOTE: This may insert the wrong breakpoint instruction when
+ single-stepping over a mode-changing instruction. */
if (insert_bpt)
{
next_pc = arm_get_next_pc (read_register (ARM_PC_REGNUM));
+
+ bp_pc = next_pc;
+ BREAKPOINT_FROM_PC (&bp_pc, &bp_size);
target_insert_breakpoint (next_pc, break_mem);
}
else
- target_remove_breakpoint (next_pc, break_mem);
+ target_remove_breakpoint (bp_pc, bp_size, break_mem);
}
#include "bfd-in2.h"
Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.223
diff -u -p -r1.223 breakpoint.c
--- breakpoint.c 9 Feb 2006 11:24:46 -0000 1.223
+++ breakpoint.c 2 Mar 2006 20:40:51 -0000
@@ -803,6 +803,9 @@ insert_bp_location (struct bp_location *
{
/* No overlay handling: just set the breakpoint. */
+ bpt->placed_address = bpt->address;
+ BREAKPOINT_FROM_PC (&bpt->placed_address, &bpt->placed_size);
+
if (bpt->loc_type == bp_loc_hardware_breakpoint)
val = target_insert_hw_breakpoint (bpt->address,
bpt->shadow_contents);
@@ -827,6 +830,8 @@ insert_bp_location (struct bp_location *
CORE_ADDR addr = overlay_unmapped_address (bpt->address,
bpt->section);
/* Set a software (trap) breakpoint at the LMA. */
+ bpt->placed_address = addr;
+ BREAKPOINT_FROM_PC (&bpt->placed_address, &bpt->placed_size);
val = target_insert_breakpoint (addr, bpt->shadow_contents);
if (val != 0)
fprintf_unfiltered (tmp_error_stream,
@@ -838,6 +843,9 @@ insert_bp_location (struct bp_location *
if (section_is_mapped (bpt->section))
{
/* Yes. This overlay section is mapped into memory. */
+ bpt->placed_address = bpt->address;
+ BREAKPOINT_FROM_PC (&bpt->placed_address, &bpt->placed_size);
+
if (bpt->loc_type == bp_loc_hardware_breakpoint)
val = target_insert_hw_breakpoint (bpt->address,
bpt->shadow_contents);
@@ -1045,6 +1053,8 @@ in which its expression is valid.\n"),
/* If we get here, we must have a callback mechanism for exception
events -- with g++ style embedded label support, we insert
ordinary breakpoints and not catchpoints. */
+ bpt->placed_address = bpt->address;
+ BREAKPOINT_FROM_PC (&bpt->placed_address, &bpt->placed_size);
val = target_insert_breakpoint (bpt->address, bpt->shadow_contents);
if (val)
{
@@ -1446,10 +1456,12 @@ remove_breakpoint (struct bp_location *b
/* No overlay handling: just remove the breakpoint. */
if (b->loc_type == bp_loc_hardware_breakpoint)
- val = target_remove_hw_breakpoint (b->address,
+ val = target_remove_hw_breakpoint (b->placed_address,
+ b->placed_size,
b->shadow_contents);
else
- val = target_remove_breakpoint (b->address, b->shadow_contents);
+ val = target_remove_breakpoint (b->placed_address, b->placed_size,
+ b->shadow_contents);
}
else
{
@@ -1465,9 +1477,13 @@ remove_breakpoint (struct bp_location *b
/* Ignore any failures: if the LMA is in ROM, we will
have already warned when we failed to insert it. */
if (b->loc_type == bp_loc_hardware_breakpoint)
- target_remove_hw_breakpoint (addr, b->shadow_contents);
+ target_remove_hw_breakpoint (b->placed_address,
+ b->placed_size,
+ b->shadow_contents);
else
- target_remove_breakpoint (addr, b->shadow_contents);
+ target_remove_breakpoint (b->placed_address,
+ b->placed_size,
+ b->shadow_contents);
}
/* Did we set a breakpoint at the VMA?
If so, we will have marked the breakpoint 'inserted'. */
@@ -1478,10 +1494,12 @@ remove_breakpoint (struct bp_location *b
unmapped, but let's not rely on that being safe. We
don't know what the overlay manager might do. */
if (b->loc_type == bp_loc_hardware_breakpoint)
- val = target_remove_hw_breakpoint (b->address,
+ val = target_remove_hw_breakpoint (b->placed_address,
+ b->placed_size,
b->shadow_contents);
else
- val = target_remove_breakpoint (b->address,
+ val = target_remove_breakpoint (b->placed_address,
+ b->placed_size,
b->shadow_contents);
}
else
@@ -1570,8 +1588,8 @@ remove_breakpoint (struct bp_location *b
&& breakpoint_enabled (b->owner)
&& !b->duplicate)
{
-
- val = target_remove_breakpoint (b->address, b->shadow_contents);
+ val = target_remove_breakpoint (b->placed_address, b->placed_size,
+ b->shadow_contents);
if (val)
return val;
b->inserted = (is == mark_inserted);
@@ -1581,8 +1599,8 @@ remove_breakpoint (struct bp_location *b
&& breakpoint_enabled (b->owner)
&& !b->duplicate)
{
-
- val = target_remove_breakpoint (b->address, b->shadow_contents);
+ val = target_remove_breakpoint (b->placed_address, b->placed_size,
+ b->shadow_contents);
if (val)
return val;
@@ -6852,6 +6870,9 @@ delete_breakpoint (struct breakpoint *bp
_("another breakpoint was inserted on top of "
"a permanent breakpoint"));
+ bpt->loc->placed_address = b->loc->address;
+ BREAKPOINT_FROM_PC (&b->loc->placed_address, &b->loc->placed_size);
+
if (b->type == bp_hardware_breakpoint)
val = target_insert_hw_breakpoint (b->loc->address, b->loc->shadow_contents);
else
Index: breakpoint.h
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.h,v
retrieving revision 1.36
diff -u -p -r1.36 breakpoint.h
--- breakpoint.h 17 Dec 2005 22:33:59 -0000 1.36
+++ breakpoint.h 2 Mar 2006 20:40:52 -0000
@@ -256,6 +256,15 @@ struct bp_location
which to place the breakpoint in order to comply with a
processor's architectual constraints. */
CORE_ADDR requested_address;
+
+ /* Address at which the breakpoint was placed. This is normally the same
+ as "address", above, except when adjustment happens in
+ BREAKPOINT_FROM_PC, usually stripping an alternate ISA marker
+ from the PC which is used to determine the correct breakpoint. */
+ CORE_ADDR placed_address;
+
+ /* Size of the placed breakpoint, according to BREAKPOINT_FROM_PC. */
+ int placed_size;
};
/* This structure is a collection of function pointers that, if available,
Index: corelow.c
===================================================================
RCS file: /cvs/src/src/gdb/corelow.c,v
retrieving revision 1.55
diff -u -p -r1.55 corelow.c
--- corelow.c 25 Feb 2006 04:36:39 -0000 1.55
+++ corelow.c 2 Mar 2006 20:40:52 -0000
@@ -608,6 +608,12 @@ ignore (CORE_ADDR addr, bfd_byte *conten
return 0;
}
+static int
+ignore_remove (CORE_ADDR addr, int len, bfd_byte *contents)
+{
+ return 0;
+}
+
/* Okay, let's be honest: threads gleaned from a core file aren't
exactly lively, are they? On the other hand, if we don't claim
@@ -639,7 +645,7 @@ init_core_ops (void)
core_ops.deprecated_xfer_memory = xfer_memory;
core_ops.to_files_info = core_files_info;
core_ops.to_insert_breakpoint = ignore;
- core_ops.to_remove_breakpoint = ignore;
+ core_ops.to_remove_breakpoint = ignore_remove;
core_ops.to_create_inferior = find_default_create_inferior;
core_ops.to_thread_alive = core_file_thread_alive;
core_ops.to_stratum = core_stratum;
Index: cris-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/cris-tdep.c,v
retrieving revision 1.134
diff -u -p -r1.134 cris-tdep.c
--- cris-tdep.c 15 Jan 2006 18:28:58 -0000 1.134
+++ cris-tdep.c 2 Mar 2006 20:40:52 -0000
@@ -2129,6 +2129,8 @@ static void
cris_software_single_step (enum target_signal ignore, int insert_breakpoints)
{
inst_env_type inst_env;
+ static CORE_ADDR bp_pc, branch_bp_pc;
+ static int bp_size, branch_bp_size;
if (insert_breakpoints)
{
@@ -2146,12 +2148,16 @@ cris_software_single_step (enum target_s
/* Insert at most two breakpoints. One for the next PC content
and possibly another one for a branch, jump, etc. */
next_pc = (CORE_ADDR) inst_env.reg[PC_REGNUM];
+ bp_pc = next_pc;
+ BREAKPOINT_FROM_PC (&bp_pc, &bp_size);
target_insert_breakpoint (next_pc, break_mem[0]);
if (inst_env.branch_found
&& (CORE_ADDR) inst_env.branch_break_address != next_pc)
{
branch_target_address =
(CORE_ADDR) inst_env.branch_break_address;
+ branch_bp_pc = branch_target_address;
+ BREAKPOINT_FROM_PC (&branch_bp_pc, &branch_bp_size);
target_insert_breakpoint (branch_target_address, break_mem[1]);
branch_break_inserted = 1;
}
@@ -2160,10 +2166,11 @@ cris_software_single_step (enum target_s
else
{
/* Remove breakpoints. */
- target_remove_breakpoint (next_pc, break_mem[0]);
+ target_remove_breakpoint (bp_pc, bp_size, break_mem[0]);
if (branch_break_inserted)
{
- target_remove_breakpoint (branch_target_address, break_mem[1]);
+ target_remove_breakpoint (branch_bp_pc, branch_bp_size,
+ break_mem[1]);
branch_break_inserted = 0;
}
}
Index: exec.c
===================================================================
RCS file: /cvs/src/src/gdb/exec.c,v
retrieving revision 1.60
diff -u -p -r1.60 exec.c
--- exec.c 25 Feb 2006 04:36:39 -0000 1.60
+++ exec.c 2 Mar 2006 20:40:52 -0000
@@ -696,6 +696,12 @@ ignore (CORE_ADDR addr, bfd_byte *conten
return 0;
}
+static int
+ignore_remove (CORE_ADDR addr, int len, bfd_byte *contents)
+{
+ return 0;
+}
+
/* Find mapped memory. */
extern void
@@ -726,7 +732,7 @@ Specify the filename of the executable f
exec_ops.deprecated_xfer_memory = xfer_memory;
exec_ops.to_files_info = exec_files_info;
exec_ops.to_insert_breakpoint = ignore;
- exec_ops.to_remove_breakpoint = ignore;
+ exec_ops.to_remove_breakpoint = ignore_remove;
exec_ops.to_create_inferior = find_default_create_inferior;
exec_ops.to_stratum = file_stratum;
exec_ops.to_has_memory = 1;
Index: gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.328
diff -u -p -r1.328 gdbarch.c
--- gdbarch.c 17 Dec 2005 22:33:59 -0000 1.328
+++ gdbarch.c 2 Mar 2006 20:40:52 -0000
@@ -1259,8 +1259,8 @@ gdbarch_dump (struct gdbarch *current_gd
#ifdef MEMORY_REMOVE_BREAKPOINT
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
- "MEMORY_REMOVE_BREAKPOINT(addr, contents_cache)",
- XSTRING (MEMORY_REMOVE_BREAKPOINT (addr, contents_cache)));
+ "MEMORY_REMOVE_BREAKPOINT(addr, len, contents_cache)",
+ XSTRING (MEMORY_REMOVE_BREAKPOINT (addr, len, contents_cache)));
#endif
fprintf_unfiltered (file,
"gdbarch_dump: memory_remove_breakpoint = <0x%lx>\n",
@@ -2951,13 +2951,13 @@ set_gdbarch_memory_insert_breakpoint (st
}
int
-gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, gdb_byte *contents_cache)
+gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, int len, gdb_byte *contents_cache)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->memory_remove_breakpoint != NULL);
if (gdbarch_debug >= 2)
fprintf_unfiltered (gdb_stdlog, "gdbarch_memory_remove_breakpoint called\n");
- return gdbarch->memory_remove_breakpoint (addr, contents_cache);
+ return gdbarch->memory_remove_breakpoint (addr, len, contents_cache);
}
void
Index: gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.284
diff -u -p -r1.284 gdbarch.h
--- gdbarch.h 17 Dec 2005 22:34:00 -0000 1.284
+++ gdbarch.h 2 Mar 2006 20:40:53 -0000
@@ -909,14 +909,14 @@ extern void set_gdbarch_memory_insert_br
#define MEMORY_INSERT_BREAKPOINT(addr, contents_cache) (gdbarch_memory_insert_breakpoint (current_gdbarch, addr, contents_cache))
#endif
-typedef int (gdbarch_memory_remove_breakpoint_ftype) (CORE_ADDR addr, gdb_byte *contents_cache);
-extern int gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, gdb_byte *contents_cache);
+typedef int (gdbarch_memory_remove_breakpoint_ftype) (CORE_ADDR addr, int len, gdb_byte *contents_cache);
+extern int gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, int len, gdb_byte *contents_cache);
extern void set_gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, gdbarch_memory_remove_breakpoint_ftype *memory_remove_breakpoint);
#if !defined (GDB_TM_FILE) && defined (MEMORY_REMOVE_BREAKPOINT)
#error "Non multi-arch definition of MEMORY_REMOVE_BREAKPOINT"
#endif
#if !defined (MEMORY_REMOVE_BREAKPOINT)
-#define MEMORY_REMOVE_BREAKPOINT(addr, contents_cache) (gdbarch_memory_remove_breakpoint (current_gdbarch, addr, contents_cache))
+#define MEMORY_REMOVE_BREAKPOINT(addr, len, contents_cache) (gdbarch_memory_remove_breakpoint (current_gdbarch, addr, len, contents_cache))
#endif
extern CORE_ADDR gdbarch_decr_pc_after_break (struct gdbarch *gdbarch);
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.363
diff -u -p -r1.363 gdbarch.sh
--- gdbarch.sh 17 Dec 2005 22:34:00 -0000 1.363
+++ gdbarch.sh 2 Mar 2006 20:40:53 -0000
@@ -550,7 +550,7 @@ f:=:int:inner_than:CORE_ADDR lhs, CORE_A
f:=:const gdb_byte *:breakpoint_from_pc:CORE_ADDR *pcptr, int *lenptr:pcptr, lenptr::0:
M::CORE_ADDR:adjust_breakpoint_address:CORE_ADDR bpaddr:bpaddr
f:=:int:memory_insert_breakpoint:CORE_ADDR addr, gdb_byte *contents_cache:addr, contents_cache:0:default_memory_insert_breakpoint::0
-f:=:int:memory_remove_breakpoint:CORE_ADDR addr, gdb_byte *contents_cache:addr, contents_cache:0:default_memory_remove_breakpoint::0
+f:=:int:memory_remove_breakpoint:CORE_ADDR addr, int len, gdb_byte *contents_cache:addr, len, contents_cache:0:default_memory_remove_breakpoint::0
v:=:CORE_ADDR:decr_pc_after_break:::0:::0
# A function can be addressed by either it's "pointer" (possibly a
Index: i386-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-nat.c,v
retrieving revision 1.13
diff -u -p -r1.13 i386-nat.c
--- i386-nat.c 17 Dec 2005 22:34:01 -0000 1.13
+++ i386-nat.c 2 Mar 2006 20:40:53 -0000
@@ -639,11 +639,11 @@ i386_insert_hw_breakpoint (CORE_ADDR add
return retval;
}
-/* Remove a hardware-assisted breakpoint at address ADDR. SHADOW is
- unused. Return 0 on success, -1 on failure. */
+/* Remove a hardware-assisted breakpoint at address ADDR. LEN and
+ SHADOW are unused. Return 0 on success, -1 on failure. */
int
-i386_remove_hw_breakpoint (CORE_ADDR addr, void *shadow)
+i386_remove_hw_breakpoint (CORE_ADDR addr, int len, void *shadow)
{
unsigned len_rw = i386_length_and_rw_bits (1, hw_execute);
int retval = i386_remove_aligned_watchpoint (addr, len_rw);
Index: ia64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ia64-tdep.c,v
retrieving revision 1.137
diff -u -p -r1.137 ia64-tdep.c
--- ia64-tdep.c 17 Dec 2005 22:34:01 -0000 1.137
+++ ia64-tdep.c 2 Mar 2006 20:40:53 -0000
@@ -583,7 +583,8 @@ ia64_memory_insert_breakpoint (CORE_ADDR
}
static int
-ia64_memory_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+ia64_memory_remove_breakpoint (CORE_ADDR addr, int len,
+ bfd_byte *contents_cache)
{
char bundle[BUNDLE_LEN];
int slotnum = (addr & 0x0f) / SLOT_MULTIPLIER;
Index: m32r-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/m32r-tdep.c,v
retrieving revision 1.40
diff -u -p -r1.40 m32r-tdep.c
--- m32r-tdep.c 17 Dec 2005 22:34:01 -0000 1.40
+++ m32r-tdep.c 2 Mar 2006 20:40:53 -0000
@@ -134,7 +134,8 @@ m32r_memory_insert_breakpoint (CORE_ADDR
}
static int
-m32r_memory_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+m32r_memory_remove_breakpoint (CORE_ADDR addr, int len,
+ bfd_byte *contents_cache)
{
int val;
gdb_byte buf[4];
Index: mem-break.c
===================================================================
RCS file: /cvs/src/src/gdb/mem-break.c,v
retrieving revision 1.11
diff -u -p -r1.11 mem-break.c
--- mem-break.c 17 Dec 2005 22:34:01 -0000 1.11
+++ mem-break.c 2 Mar 2006 20:40:53 -0000
@@ -65,17 +65,10 @@ default_memory_insert_breakpoint (CORE_A
int
-default_memory_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+default_memory_remove_breakpoint (CORE_ADDR addr, int len,
+ bfd_byte *contents_cache)
{
- const bfd_byte *bp;
- int bplen;
-
- /* Determine appropriate breakpoint contents and size for this address. */
- bp = BREAKPOINT_FROM_PC (&addr, &bplen);
- if (bp == NULL)
- error (_("Software breakpoints not implemented for this target."));
-
- return target_write_memory (addr, contents_cache, bplen);
+ return target_write_memory (addr, contents_cache, len);
}
@@ -86,7 +79,7 @@ memory_insert_breakpoint (CORE_ADDR addr
}
int
-memory_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+memory_remove_breakpoint (CORE_ADDR addr, int len, bfd_byte *contents_cache)
{
- return MEMORY_REMOVE_BREAKPOINT(addr, contents_cache);
+ return MEMORY_REMOVE_BREAKPOINT(addr, len, contents_cache);
}
Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.385
diff -u -p -r1.385 mips-tdep.c
--- mips-tdep.c 17 Dec 2005 22:34:01 -0000 1.385
+++ mips-tdep.c 2 Mar 2006 20:40:54 -0000
@@ -2192,16 +2192,20 @@ mips_software_single_step (enum target_s
typedef char binsn_quantum[BREAKPOINT_MAX];
static binsn_quantum break_mem;
CORE_ADDR pc;
+ static CORE_ADDR bp_pc;
+ static int bp_size;
if (insert_breakpoints_p)
{
pc = read_register (mips_regnum (current_gdbarch)->pc);
next_pc = mips_next_pc (pc);
+ bp_pc = next_pc;
+ BREAKPOINT_FROM_PC (&bp_pc, &bp_size);
target_insert_breakpoint (next_pc, break_mem);
}
else
- target_remove_breakpoint (next_pc, break_mem);
+ target_remove_breakpoint (bp_pc, bp_size, break_mem);
}
/* Test whether the PC points to the return instruction at the
Index: monitor.c
===================================================================
RCS file: /cvs/src/src/gdb/monitor.c,v
retrieving revision 1.63
diff -u -p -r1.63 monitor.c
--- monitor.c 24 Jan 2006 22:09:28 -0000 1.63
+++ monitor.c 2 Mar 2006 20:40:54 -0000
@@ -2071,7 +2071,7 @@ monitor_insert_breakpoint (CORE_ADDR add
/* Tell the monitor to remove a breakpoint. */
static int
-monitor_remove_breakpoint (CORE_ADDR addr, gdb_byte *shadow)
+monitor_remove_breakpoint (CORE_ADDR addr, int len, gdb_byte *shadow)
{
int i;
Index: nto-procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/nto-procfs.c,v
retrieving revision 1.17
diff -u -p -r1.17 nto-procfs.c
--- nto-procfs.c 24 Jan 2006 22:09:28 -0000 1.17
+++ nto-procfs.c 2 Mar 2006 20:40:54 -0000
@@ -78,7 +78,7 @@ static int procfs_can_use_hw_breakpoint
static int procfs_insert_hw_breakpoint (CORE_ADDR, char *);
-static int procfs_remove_hw_breakpoint (CORE_ADDR addr, char *);
+static int procfs_remove_hw_breakpoint (CORE_ADDR addr, int len, char *);
static int procfs_insert_hw_watchpoint (CORE_ADDR addr, int len, int type);
@@ -818,7 +818,7 @@ procfs_insert_breakpoint (CORE_ADDR addr
}
static int
-procfs_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
+procfs_remove_breakpoint (CORE_ADDR addr, int len, char *contents_cache)
{
return procfs_breakpoint (addr, _DEBUG_BREAK_EXEC, -1);
}
@@ -830,7 +830,7 @@ procfs_insert_hw_breakpoint (CORE_ADDR a
}
static int
-procfs_remove_hw_breakpoint (CORE_ADDR addr, char *contents_cache)
+procfs_remove_hw_breakpoint (CORE_ADDR addr, int len, char *contents_cache)
{
return procfs_breakpoint (addr, _DEBUG_BREAK_EXEC | _DEBUG_BREAK_HW, -1);
}
Index: ocd.c
===================================================================
RCS file: /cvs/src/src/gdb/ocd.c,v
retrieving revision 1.43
diff -u -p -r1.43 ocd.c
--- ocd.c 24 Jan 2006 22:09:28 -0000 1.43
+++ ocd.c 2 Mar 2006 20:40:54 -0000
@@ -1062,7 +1062,7 @@ ocd_insert_breakpoint (CORE_ADDR addr, c
}
int
-ocd_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
+ocd_remove_breakpoint (CORE_ADDR addr, int len, char *contents_cache)
{
static char break_insn[] = BDM_BREAKPOINT;
int val;
Index: ocd.h
===================================================================
RCS file: /cvs/src/src/gdb/ocd.h,v
retrieving revision 1.8
diff -u -p -r1.8 ocd.h
--- ocd.h 17 Dec 2005 22:34:01 -0000 1.8
+++ ocd.h 2 Mar 2006 20:40:54 -0000
@@ -136,7 +136,7 @@ void ocd_write_bdm_register (int bdm_reg
int ocd_wait (void);
int ocd_insert_breakpoint (CORE_ADDR addr, char *contents_cache);
-int ocd_remove_breakpoint (CORE_ADDR addr, char *contents_cache);
+int ocd_remove_breakpoint (CORE_ADDR addr, int len, char *contents_cache);
int ocd_write_bytes (CORE_ADDR memaddr, char *myaddr, int len);
Index: ppc-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v
retrieving revision 1.77
diff -u -p -r1.77 ppc-linux-tdep.c
--- ppc-linux-tdep.c 15 Jan 2006 18:28:58 -0000 1.77
+++ ppc-linux-tdep.c 2 Mar 2006 20:40:54 -0000
@@ -457,16 +457,13 @@ ppc_linux_skip_trampoline_code (CORE_ADD
regard to removing breakpoints in some potentially self modifying
code. */
int
-ppc_linux_memory_remove_breakpoint (CORE_ADDR addr,
+ppc_linux_memory_remove_breakpoint (CORE_ADDR addr, int bplen,
gdb_byte *contents_cache)
{
const unsigned char *bp;
int val;
- int bplen;
gdb_byte old_contents[BREAKPOINT_MAX];
- /* Determine appropriate breakpoint contents and size for this address. */
- bp = BREAKPOINT_FROM_PC (&addr, &bplen);
if (bp == NULL)
error (_("Software breakpoints not implemented for this target."));
Index: ppc-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/ppc-tdep.h,v
retrieving revision 1.50
diff -u -p -r1.50 ppc-tdep.h
--- ppc-tdep.h 17 Jan 2006 22:21:13 -0000 1.50
+++ ppc-tdep.h 2 Mar 2006 20:40:54 -0000
@@ -56,7 +56,7 @@ CORE_ADDR ppc64_sysv_abi_push_dummy_call
CORE_ADDR struct_addr);
CORE_ADDR ppc64_sysv_abi_adjust_breakpoint_address (struct gdbarch *gdbarch,
CORE_ADDR bpaddr);
-int ppc_linux_memory_remove_breakpoint (CORE_ADDR addr,
+int ppc_linux_memory_remove_breakpoint (CORE_ADDR addr, int len,
gdb_byte *contents_cache);
struct link_map_offsets *ppc_linux_svr4_fetch_link_map_offsets (void);
void ppc_linux_supply_gregset (struct regcache *regcache,
Index: procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/procfs.c,v
retrieving revision 1.68
diff -u -p -r1.68 procfs.c
--- procfs.c 24 Jan 2006 22:09:28 -0000 1.68
+++ procfs.c 2 Mar 2006 20:40:55 -0000
@@ -3371,11 +3371,12 @@ static int insert_dbx_link_breakpoint (p
static void remove_dbx_link_breakpoint (void);
/* On mips-irix, we need to insert a breakpoint at __dbx_link during
- the startup phase. The following two variables are used to record
- the address of the breakpoint, and the code that was replaced by
- a breakpoint. */
+ the startup phase. The following three variables are used to record
+ the address of the breakpoint, the code that was replaced by
+ a breakpoint, and the size of the breakpoint. */
static int dbx_link_bpt_addr = 0;
static char dbx_link_shadow_contents[BREAKPOINT_MAX];
+static int dbx_link_bpt_size;
/*
* Function: procfs_debug_inferior
@@ -5571,7 +5572,7 @@ remove_dbx_link_breakpoint (void)
if (dbx_link_bpt_addr == 0)
return;
- if (memory_remove_breakpoint (dbx_link_bpt_addr,
+ if (memory_remove_breakpoint (dbx_link_bpt_addr, dbx_link_bpt_size,
dbx_link_shadow_contents) != 0)
warning (_("Unable to remove __dbx_link breakpoint."));
@@ -5643,6 +5644,7 @@ insert_dbx_link_bpt_in_file (int fd, COR
{
/* Insert the breakpoint. */
dbx_link_bpt_addr = sym_addr;
+ BREAKPOINT_FROM_PC (&dbx_link_bpt_addr, &dbx_link_bpt_size);
if (target_insert_breakpoint (sym_addr, dbx_link_shadow_contents) != 0)
{
warning (_("Failed to insert dbx_link breakpoint."));
Index: remote-e7000.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-e7000.c,v
retrieving revision 1.57
diff -u -p -r1.57 remote-e7000.c
--- remote-e7000.c 24 Jan 2006 22:09:28 -0000 1.57
+++ remote-e7000.c 2 Mar 2006 20:40:55 -0000
@@ -1745,7 +1745,7 @@ e7000_insert_breakpoint (CORE_ADDR addr,
}
static int
-e7000_remove_breakpoint (CORE_ADDR addr, bfd_byte *shadow)
+e7000_remove_breakpoint (CORE_ADDR addr, int len, bfd_byte *shadow)
{
int i;
char buf[200];
Index: remote-m32r-sdi.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-m32r-sdi.c,v
retrieving revision 1.17
diff -u -p -r1.17 remote-m32r-sdi.c
--- remote-m32r-sdi.c 24 Jan 2006 22:09:28 -0000 1.17
+++ remote-m32r-sdi.c 2 Mar 2006 20:40:55 -0000
@@ -1183,7 +1183,7 @@ m32r_insert_breakpoint (CORE_ADDR addr,
}
static int
-m32r_remove_breakpoint (CORE_ADDR addr, bfd_byte *shadow)
+m32r_remove_breakpoint (CORE_ADDR addr, int len, bfd_byte *shadow)
{
int i;
Index: remote-mips.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-mips.c,v
retrieving revision 1.68
diff -u -p -r1.68 remote-mips.c
--- remote-mips.c 24 Jan 2006 22:09:28 -0000 1.68
+++ remote-mips.c 2 Mar 2006 20:40:56 -0000
@@ -2231,12 +2231,12 @@ mips_insert_breakpoint (CORE_ADDR addr,
}
static int
-mips_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
+mips_remove_breakpoint (CORE_ADDR addr, int len, char *contents_cache)
{
if (monitor_supports_breakpoints)
return clear_breakpoint (addr, MIPS_INSN32_SIZE, BREAK_FETCH);
else
- return memory_remove_breakpoint (addr, contents_cache);
+ return memory_remove_breakpoint (addr, len, contents_cache);
}
/* Tell whether this target can support a hardware breakpoint. CNT
Index: remote-rdp.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-rdp.c,v
retrieving revision 1.48
diff -u -p -r1.48 remote-rdp.c
--- remote-rdp.c 25 Feb 2006 04:36:39 -0000 1.48
+++ remote-rdp.c 2 Mar 2006 20:40:56 -0000
@@ -1074,7 +1074,7 @@ remote_rdp_insert_breakpoint (CORE_ADDR
}
static int
-remote_rdp_remove_breakpoint (CORE_ADDR addr, bfd_byte *save)
+remote_rdp_remove_breakpoint (CORE_ADDR addr, int len, bfd_byte *save)
{
int res;
if (ds.rdi_level > 0)
@@ -1109,11 +1109,15 @@ rdp_step (void)
else
{
char handle[4];
+ CORE_ADDR bp_pc;
+ int bp_len;
CORE_ADDR pc = read_register (ARM_PC_REGNUM);
pc = arm_get_next_pc (pc);
+ bp_pc = pc;
+ BREAKPOINT_FROM_PC (&bp_pc, &bp_len);
remote_rdp_insert_breakpoint (pc, handle);
rdp_execute ();
- remote_rdp_remove_breakpoint (pc, handle);
+ remote_rdp_remove_breakpoint (bp_pc, bp_len, handle);
}
}
Index: remote-sds.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-sds.c,v
retrieving revision 1.42
diff -u -p -r1.42 remote-sds.c
--- remote-sds.c 24 Jan 2006 22:09:28 -0000 1.42
+++ remote-sds.c 2 Mar 2006 20:40:56 -0000
@@ -101,7 +101,7 @@ static int read_frame (char *);
static int sds_insert_breakpoint (CORE_ADDR, char *);
-static int sds_remove_breakpoint (CORE_ADDR, char *);
+static int sds_remove_breakpoint (CORE_ADDR, int, char *);
static void init_sds_ops (void);
@@ -1026,7 +1026,7 @@ sds_insert_breakpoint (CORE_ADDR addr, c
}
static int
-sds_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
+sds_remove_breakpoint (CORE_ADDR addr, int len, char *contents_cache)
{
int i, retlen;
unsigned char *p, buf[PBUFSIZ];
Index: remote-sim.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-sim.c,v
retrieving revision 1.53
diff -u -p -r1.53 remote-sim.c
--- remote-sim.c 21 Feb 2006 18:22:26 -0000 1.53
+++ remote-sim.c 2 Mar 2006 20:40:56 -0000
@@ -812,9 +812,9 @@ gdbsim_insert_breakpoint (CORE_ADDR addr
}
static int
-gdbsim_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+gdbsim_remove_breakpoint (CORE_ADDR addr, int len, bfd_byte *contents_cache)
{
- return memory_remove_breakpoint (addr, contents_cache);
+ return memory_remove_breakpoint (addr, len, contents_cache);
}
/* Pass the command argument through to the simulator verbatim. The
Index: remote-st.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-st.c,v
retrieving revision 1.30
diff -u -p -r1.30 remote-st.c
--- remote-st.c 10 Feb 2006 22:01:43 -0000 1.30
+++ remote-st.c 2 Mar 2006 20:40:56 -0000
@@ -623,7 +623,7 @@ st2000_insert_breakpoint (CORE_ADDR addr
}
static int
-st2000_remove_breakpoint (CORE_ADDR addr, char *shadow)
+st2000_remove_breakpoint (CORE_ADDR addr, int len, char *shadow)
{
int i;
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.202
diff -u -p -r1.202 remote.c
--- remote.c 20 Feb 2006 15:19:06 -0000 1.202
+++ remote.c 2 Mar 2006 20:40:56 -0000
@@ -136,7 +136,7 @@ static long read_frame (char *buf, long
static int remote_insert_breakpoint (CORE_ADDR, bfd_byte *);
-static int remote_remove_breakpoint (CORE_ADDR, bfd_byte *);
+static int remote_remove_breakpoint (CORE_ADDR, int, bfd_byte *);
static int hexnumlen (ULONGEST num);
@@ -4369,7 +4369,7 @@ remote_insert_breakpoint (CORE_ADDR addr
}
static int
-remote_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+remote_remove_breakpoint (CORE_ADDR addr, int len, bfd_byte *contents_cache)
{
struct remote_state *rs = get_remote_state ();
int bp_size;
@@ -4397,7 +4397,7 @@ remote_remove_breakpoint (CORE_ADDR addr
#ifdef DEPRECATED_REMOTE_BREAKPOINT
return target_write_memory (addr, contents_cache, sizeof big_break_insn);
#else
- return memory_remove_breakpoint (addr, contents_cache);
+ return memory_remove_breakpoint (addr, len, contents_cache);
#endif /* DEPRECATED_REMOTE_BREAKPOINT */
}
@@ -4585,9 +4585,8 @@ remote_insert_hw_breakpoint (CORE_ADDR a
static int
-remote_remove_hw_breakpoint (CORE_ADDR addr, gdb_byte *shadow)
+remote_remove_hw_breakpoint (CORE_ADDR addr, int len, gdb_byte *shadow)
{
- int len;
struct remote_state *rs = get_remote_state ();
char *buf = alloca (rs->remote_packet_size);
char *p = buf;
@@ -4595,8 +4594,6 @@ remote_remove_hw_breakpoint (CORE_ADDR a
/* The length field should be set to the size of a breakpoint
instruction. */
- BREAKPOINT_FROM_PC (&addr, &len);
-
if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE)
error (_("Can't clear hardware breakpoint without the '%s' (%s) packet."),
remote_protocol_packets[PACKET_Z1].name,
Index: rs6000-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-nat.c,v
retrieving revision 1.60
diff -u -p -r1.60 rs6000-nat.c
--- rs6000-nat.c 17 Dec 2005 22:34:02 -0000 1.60
+++ rs6000-nat.c 2 Mar 2006 20:40:57 -0000
@@ -530,11 +530,15 @@ exec_one_dummy_insn (void)
char shadow_contents[BREAKPOINT_MAX]; /* Stash old bkpt addr contents */
int ret, status, pid;
CORE_ADDR prev_pc;
+ CORE_ADDR bp_pc,
+ int bp_len;
/* We plant one dummy breakpoint into DUMMY_INSN_ADDR address. We
assume that this address will never be executed again by the real
code. */
+ bp_pc = DUMMY_INSN_ADDR;
+ BREAKPOINT_FROM_PC (&bp_pc, &bp_len);
target_insert_breakpoint (DUMMY_INSN_ADDR, shadow_contents);
/* You might think this could be done with a single ptrace call, and
@@ -559,7 +563,7 @@ exec_one_dummy_insn (void)
while (pid != PIDGET (inferior_ptid));
write_pc (prev_pc);
- target_remove_breakpoint (DUMMY_INSN_ADDR, shadow_contents);
+ target_remove_breakpoint (bp_pc, bp_len, shadow_contents);
}
/* Fetch registers from the register section in core bfd. */
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.256
diff -u -p -r1.256 rs6000-tdep.c
--- rs6000-tdep.c 10 Feb 2006 20:56:14 -0000 1.256
+++ rs6000-tdep.c 2 Mar 2006 20:40:57 -0000
@@ -727,6 +727,8 @@ rs6000_software_single_step (enum target
CORE_ADDR loc;
CORE_ADDR breaks[2];
int opcode;
+ static CORE_ADDR bp_pc[2];
+ static int bp_size[2];
if (insert_breakpoints_p)
{
@@ -751,6 +753,8 @@ rs6000_software_single_step (enum target
/* ignore invalid breakpoint. */
if (breaks[ii] == -1)
continue;
+ bp_pc[ii] = breaks[ii];
+ BREAKPOINT_FROM_PC (&bp_pc[ii], &bp_size[ii]);
target_insert_breakpoint (breaks[ii], stepBreaks[ii].data);
stepBreaks[ii].address = breaks[ii];
}
@@ -762,7 +766,7 @@ rs6000_software_single_step (enum target
/* remove step breakpoints. */
for (ii = 0; ii < 2; ++ii)
if (stepBreaks[ii].address != 0)
- target_remove_breakpoint (stepBreaks[ii].address,
+ target_remove_breakpoint (bp_pc[ii], bp_size[ii],
stepBreaks[ii].data);
}
errno = 0; /* FIXME, don't ignore errors! */
Index: sol-thread.c
===================================================================
RCS file: /cvs/src/src/gdb/sol-thread.c,v
retrieving revision 1.51
diff -u -p -r1.51 sol-thread.c
--- sol-thread.c 17 Dec 2005 22:34:02 -0000 1.51
+++ sol-thread.c 2 Mar 2006 20:40:57 -0000
@@ -1529,6 +1529,12 @@ ignore (CORE_ADDR addr, gdb_byte *conten
return 0;
}
+static int
+ignore_remove (CORE_ADDR addr, int len, gdb_byte *contents)
+{
+ return 0;
+}
+
static void
init_sol_thread_ops (void)
{
@@ -1590,7 +1596,7 @@ init_sol_core_ops (void)
sol_core_ops.to_xfer_partial = sol_thread_xfer_partial;
sol_core_ops.to_files_info = sol_core_files_info;
sol_core_ops.to_insert_breakpoint = ignore;
- sol_core_ops.to_remove_breakpoint = ignore;
+ sol_core_ops.to_remove_breakpoint = ignore_remove;
sol_core_ops.to_create_inferior = sol_thread_create_inferior;
sol_core_ops.to_stratum = core_stratum;
sol_core_ops.to_has_memory = 1;
Index: solib-irix.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-irix.c,v
retrieving revision 1.9
diff -u -p -r1.9 solib-irix.c
--- solib-irix.c 17 Dec 2005 22:34:02 -0000 1.9
+++ solib-irix.c 2 Mar 2006 20:40:57 -0000
@@ -231,6 +231,7 @@ char shadow_contents[BREAKPOINT_MAX]; /*
static CORE_ADDR debug_base; /* Base of dynamic linker structures */
static CORE_ADDR breakpoint_addr; /* Address where end bkpt is set */
+static int breakpoint_len;
/*
@@ -319,7 +320,8 @@ disable_break (void)
/* Note that breakpoint address and original contents are in our address
space, so we just need to write the original contents back. */
- if (memory_remove_breakpoint (breakpoint_addr, shadow_contents) != 0)
+ if (memory_remove_breakpoint (breakpoint_addr, breakpoint_len,
+ shadow_contents) != 0)
{
status = 0;
}
@@ -357,6 +359,7 @@ enable_break (void)
shadow_contents) == 0)
{
breakpoint_addr = entry_point_address ();
+ BREAKPOINT_FROM_PC (&breakpoint_addr, &breakpoint_len);
return 1;
}
Index: sparc-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc-tdep.c,v
retrieving revision 1.168
diff -u -p -r1.168 sparc-tdep.c
--- sparc-tdep.c 22 Jan 2006 20:07:38 -0000 1.168
+++ sparc-tdep.c 2 Mar 2006 20:40:57 -0000
@@ -1087,6 +1087,8 @@ sparc_software_single_step (enum target_
struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
static CORE_ADDR npc, nnpc;
static gdb_byte npc_save[4], nnpc_save[4];
+ static CORE_ADDR bp_npc, bp_nnpc;
+ static int bp_nsize, bp_nnsize;
if (insert_breakpoints_p)
{
@@ -1098,9 +1100,17 @@ sparc_software_single_step (enum target_
/* Analyze the instruction at PC. */
nnpc = sparc_analyze_control_transfer (arch, pc, &npc);
if (npc != 0)
- target_insert_breakpoint (npc, npc_save);
+ {
+ bp_npc = npc;
+ BREAKPOINT_FROM_PC (&bp_npc, &bp_nsize);
+ target_insert_breakpoint (npc, npc_save);
+ }
if (nnpc != 0)
- target_insert_breakpoint (nnpc, nnpc_save);
+ {
+ bp_npc = npc;
+ BREAKPOINT_FROM_PC (&bp_npc, &bp_nsize);
+ target_insert_breakpoint (nnpc, nnpc_save);
+ }
/* Assert that we have set at least one breakpoint, and that
they're not set at the same spot - unless we're going
@@ -1111,9 +1121,9 @@ sparc_software_single_step (enum target_
else
{
if (npc != 0)
- target_remove_breakpoint (npc, npc_save);
+ target_remove_breakpoint (bp_npc, bp_nsize, npc_save);
if (nnpc != 0)
- target_remove_breakpoint (nnpc, nnpc_save);
+ target_remove_breakpoint (bp_nnpc, bp_nnsize, nnpc_save);
}
}
Index: target.c
===================================================================
RCS file: /cvs/src/src/gdb/target.c,v
retrieving revision 1.116
diff -u -p -r1.116 target.c
--- target.c 8 Feb 2006 06:43:00 -0000 1.116
+++ target.c 2 Mar 2006 20:40:58 -0000
@@ -113,13 +113,13 @@ static void debug_to_files_info (struct
static int debug_to_insert_breakpoint (CORE_ADDR, gdb_byte *);
-static int debug_to_remove_breakpoint (CORE_ADDR, gdb_byte *);
+static int debug_to_remove_breakpoint (CORE_ADDR, int, gdb_byte *);
static int debug_to_can_use_hw_breakpoint (int, int, int);
static int debug_to_insert_hw_breakpoint (CORE_ADDR, gdb_byte *);
-static int debug_to_remove_hw_breakpoint (CORE_ADDR, gdb_byte *);
+static int debug_to_remove_hw_breakpoint (CORE_ADDR, int, gdb_byte *);
static int debug_to_insert_watchpoint (CORE_ADDR, int, int);
@@ -518,7 +518,7 @@ update_current_target (void)
(int (*) (CORE_ADDR, gdb_byte *))
return_minus_one);
de_fault (to_remove_hw_breakpoint,
- (int (*) (CORE_ADDR, gdb_byte *))
+ (int (*) (CORE_ADDR, int, gdb_byte *))
return_minus_one);
de_fault (to_insert_watchpoint,
(int (*) (CORE_ADDR, int, int))
@@ -2089,15 +2089,15 @@ debug_to_insert_breakpoint (CORE_ADDR ad
}
static int
-debug_to_remove_breakpoint (CORE_ADDR addr, gdb_byte *save)
+debug_to_remove_breakpoint (CORE_ADDR addr, int len, gdb_byte *save)
{
int retval;
- retval = debug_target.to_remove_breakpoint (addr, save);
+ retval = debug_target.to_remove_breakpoint (addr, len, save);
fprintf_unfiltered (gdb_stdlog,
- "target_remove_breakpoint (0x%lx, xxx) = %ld\n",
- (unsigned long) addr,
+ "target_remove_breakpoint (0x%lx, %d, xxx) = %ld\n",
+ (unsigned long) addr, len,
(unsigned long) retval);
return retval;
}
@@ -2175,15 +2175,15 @@ debug_to_insert_hw_breakpoint (CORE_ADDR
}
static int
-debug_to_remove_hw_breakpoint (CORE_ADDR addr, gdb_byte *save)
+debug_to_remove_hw_breakpoint (CORE_ADDR addr, int len, gdb_byte *save)
{
int retval;
- retval = debug_target.to_remove_hw_breakpoint (addr, save);
+ retval = debug_target.to_remove_hw_breakpoint (addr, len, save);
fprintf_unfiltered (gdb_stdlog,
- "target_remove_hw_breakpoint (0x%lx, xxx) = %ld\n",
- (unsigned long) addr,
+ "target_remove_hw_breakpoint (0x%lx, %d, xxx) = %ld\n",
+ (unsigned long) addr, len,
(unsigned long) retval);
return retval;
}
Index: target.h
===================================================================
RCS file: /cvs/src/src/gdb/target.h,v
retrieving revision 1.81
diff -u -p -r1.81 target.h
--- target.h 21 Feb 2006 18:22:26 -0000 1.81
+++ target.h 2 Mar 2006 20:40:58 -0000
@@ -337,10 +337,10 @@ struct target_ops
void (*to_files_info) (struct target_ops *);
int (*to_insert_breakpoint) (CORE_ADDR, gdb_byte *);
- int (*to_remove_breakpoint) (CORE_ADDR, gdb_byte *);
+ int (*to_remove_breakpoint) (CORE_ADDR, int, gdb_byte *);
int (*to_can_use_hw_breakpoint) (int, int, int);
int (*to_insert_hw_breakpoint) (CORE_ADDR, gdb_byte *);
- int (*to_remove_hw_breakpoint) (CORE_ADDR, gdb_byte *);
+ int (*to_remove_hw_breakpoint) (CORE_ADDR, int, gdb_byte *);
int (*to_remove_watchpoint) (CORE_ADDR, int, int);
int (*to_insert_watchpoint) (CORE_ADDR, int, int);
int (*to_stopped_by_watchpoint) (void);
@@ -624,10 +624,13 @@ extern void print_section_info (struct t
/* Remove a breakpoint at address ADDR in the target machine.
SAVE is a pointer to the same save area
that was previously passed to target_insert_breakpoint.
+ LEN is the size of the breakpoint as indicated by
+ BREAKPOINT_FROM_PC.
+
Result is 0 for success, or an errno value. */
-#define target_remove_breakpoint(addr, save) \
- (*current_target.to_remove_breakpoint) (addr, save)
+#define target_remove_breakpoint(addr, len, save) \
+ (*current_target.to_remove_breakpoint) (addr, len, save)
/* Initialize the terminal settings we record for the inferior,
before we actually run the inferior. */
@@ -1060,8 +1063,8 @@ extern void (*deprecated_target_new_objf
#define target_insert_hw_breakpoint(addr, save) \
(*current_target.to_insert_hw_breakpoint) (addr, save)
-#define target_remove_hw_breakpoint(addr, save) \
- (*current_target.to_remove_hw_breakpoint) (addr, save)
+#define target_remove_hw_breakpoint(addr, len, save) \
+ (*current_target.to_remove_hw_breakpoint) (addr, len, save)
#endif
extern int target_stopped_data_address_p (struct target_ops *);
@@ -1142,11 +1145,11 @@ struct section_table *target_section_by_
/* From mem-break.c */
-extern int memory_remove_breakpoint (CORE_ADDR, gdb_byte *);
+extern int memory_remove_breakpoint (CORE_ADDR, int, gdb_byte *);
extern int memory_insert_breakpoint (CORE_ADDR, gdb_byte *);
-extern int default_memory_remove_breakpoint (CORE_ADDR, gdb_byte *);
+extern int default_memory_remove_breakpoint (CORE_ADDR, int, gdb_byte *);
extern int default_memory_insert_breakpoint (CORE_ADDR, gdb_byte *);
Index: wince.c
===================================================================
RCS file: /cvs/src/src/gdb/wince.c,v
retrieving revision 1.44
diff -u -p -r1.44 wince.c
--- wince.c 24 Jan 2006 22:09:28 -0000 1.44
+++ wince.c 2 Mar 2006 20:40:58 -0000
@@ -146,6 +146,8 @@ typedef struct thread_info_struct
int suspend_count;
int stepped; /* True if stepped. */
CORE_ADDR step_pc;
+ CORE_ADDR bp_pc;
+ int bp_len;
unsigned long step_prev;
CONTEXT context;
}
@@ -834,7 +836,8 @@ undoSStep (thread_info * th)
{
if (th->stepped)
{
- memory_remove_breakpoint (th->step_pc, (void *) &th->step_prev);
+ memory_remove_breakpoint (th->bp_pc, th->bp_len,
+ (void *) &th->step_prev);
th->stepped = 0;
}
}
@@ -858,6 +861,8 @@ wince_software_single_step (enum target_
pc = read_register (PC_REGNUM);
th->step_pc = mips_next_pc (pc);
th->step_prev = 0;
+ th->bp_pc = th->step_pc;
+ BREAKPOINT_FROM_PC (&th->bp_pc, &th->bp_len);
memory_insert_breakpoint (th->step_pc, (void *) &th->step_prev);
return;
}
@@ -971,7 +976,8 @@ undoSStep (thread_info * th)
{
if (th->stepped)
{
- memory_remove_breakpoint (th->step_pc, (void *) &th->step_prev);
+ memory_remove_breakpoint (th->bp_pc, th->bp_len,
+ (void *) &th->step_prev);
th->stepped = 0;
}
return;
@@ -997,6 +1003,8 @@ wince_software_single_step (enum target_
th->stepped = 1;
th->step_pc = sh_get_next_pc (&th->context);
th->step_prev = 0;
+ th->bp_pc = th->step_pc;
+ BREAKPOINT_FROM_PC (&th->bp_pc, &th->bp_len);
memory_insert_breakpoint (th->step_pc, (void *) &th->step_prev);
return;
}
@@ -1024,7 +1032,8 @@ undoSStep (thread_info * th)
{
if (th->stepped)
{
- memory_remove_breakpoint (th->step_pc, (void *) &th->step_prev);
+ memory_remove_breakpoint (th->bp_pc, th->bp_len,
+ (void *) &th->step_prev);
th->stepped = 0;
}
}
@@ -1048,6 +1057,8 @@ wince_software_single_step (enum target_
pc = read_register (PC_REGNUM);
th->step_pc = arm_get_next_pc (pc);
th->step_prev = 0;
+ th->bp_pc = th->step_pc;
+ BREAKPOINT_FROM_PC (&th->bp_pc, &th->bp_len);
memory_insert_breakpoint (th->step_pc, (void *) &th->step_prev);
return;
}
Index: config/i386/nm-i386.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/nm-i386.h,v
retrieving revision 1.7
diff -u -p -r1.7 nm-i386.h
--- config/i386/nm-i386.h 8 Oct 2004 17:30:48 -0000 1.7
+++ config/i386/nm-i386.h 2 Mar 2006 20:40:58 -0000
@@ -58,7 +58,7 @@ extern int i386_insert_hw_breakpoint (CO
/* Remove a hardware-assisted breakpoint at address ADDR. SHADOW is
unused. Return 0 on success, -1 on failure. */
-extern int i386_remove_hw_breakpoint (CORE_ADDR addr, void *shadow);
+extern int i386_remove_hw_breakpoint (CORE_ADDR addr, int len, void *shadow);
/* Returns the number of hardware watchpoints of type TYPE that we can
set. Value is positive if we can set CNT watchpoints, zero if
@@ -108,8 +108,8 @@ extern int i386_stopped_by_watchpoint (v
#define target_insert_hw_breakpoint(addr, shadow) \
i386_insert_hw_breakpoint (addr, shadow)
-#define target_remove_hw_breakpoint(addr, shadow) \
- i386_remove_hw_breakpoint (addr, shadow)
+#define target_remove_hw_breakpoint(addr, len, shadow) \
+ i386_remove_hw_breakpoint (addr, len, shadow)
/* child_post_startup_inferior used to
reset all debug registers by calling i386_cleanup_dregs (). */
Index: doc/gdbint.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v
retrieving revision 1.239
diff -u -p -r1.239 gdbint.texinfo
--- doc/gdbint.texinfo 13 Feb 2006 08:34:11 -0000 1.239
+++ doc/gdbint.texinfo 2 Mar 2006 20:40:59 -0000
@@ -491,9 +491,10 @@ These two macros should return 0 for suc
@cindex insert or remove hardware breakpoint
@findex target_remove_hw_breakpoint
@findex target_insert_hw_breakpoint
-@item target_remove_hw_breakpoint (@var{addr}, @var{shadow})
+@item target_remove_hw_breakpoint (@var{addr}, @var{len}, @var{shadow})
@itemx target_insert_hw_breakpoint (@var{addr}, @var{shadow})
Insert or remove a hardware-assisted breakpoint at address @var{addr}.
+@var{len} is the size of breakpoint that was inserted, if known.
Returns zero for success, non-zero for failure. @var{shadow} is the
real contents of the byte where the breakpoint has been inserted; it
is generally not valid when hardware breakpoints are used, but since
@@ -690,7 +691,7 @@ the count goes to zero.
@findex i386_insert_hw_breakpoint
@findex i386_remove_hw_breakpoint
@item i386_insert_hw_breakpoint (@var{addr}, @var{shadow}
-@itemx i386_remove_hw_breakpoint (@var{addr}, @var{shadow})
+@itemx i386_remove_hw_breakpoint (@var{addr}, @var{len}, @var{shadow})
These functions insert and remove hardware-assisted breakpoints. The
macros @code{target_insert_hw_breakpoint} and
@code{target_remove_hw_breakpoint} are set to call these functions.
@@ -3061,7 +3062,7 @@ instruction of the architecture.
Replaces all the other @var{BREAKPOINT} macros.
@item MEMORY_INSERT_BREAKPOINT (@var{addr}, @var{contents_cache})
-@itemx MEMORY_REMOVE_BREAKPOINT (@var{addr}, @var{contents_cache})
+@itemx MEMORY_REMOVE_BREAKPOINT (@var{addr}, @var{len}, @var{contents_cache})
@findex MEMORY_REMOVE_BREAKPOINT
@findex MEMORY_INSERT_BREAKPOINT
Insert or remove memory based breakpoints. Reasonable defaults
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-02 22:25 Save the length of inserted breakpoints Daniel Jacobowitz
@ 2006-03-02 23:13 ` Mark Kettenis
2006-03-02 23:19 ` Daniel Jacobowitz
` (2 more replies)
0 siblings, 3 replies; 52+ messages in thread
From: Mark Kettenis @ 2006-03-02 23:13 UTC (permalink / raw)
To: drow; +Cc: gdb-patches
> Date: Thu, 2 Mar 2006 17:17:11 -0500
> From: Daniel Jacobowitz <drow@false.org>
>
> This nasty, mechanical patch adds "len" arguments to
> target_remove_breakpoint and target_remove_hw_breakpoint. The goal is
> to allow BREAKPOINT_FROM_PC to include heuristics, which may possibly
> change between when a breakpoint is inserted and when it is removed;
> in order to stay in sync, we need to always remove breakpoints in the
> same way that we inserted them.
>
> There's not much more to say about this patch. It's big, obvious, and
> pretty ugly. Any comments on this? Does it look OK?
Yuck! It really is ugly. For one thing, I think it is a bit
pointless, to add a the BREAKPOINT_FROM_PC() to targets where we know
the length of a breakpoint instruction is fixed.
Another thing is that I think the order of the arguments of
target_remove_breakpoint() is wrong. I think it makes sense to see
your "len" argument as the length of the saved memory. Then it is
more logical to make "len" the last argument of
target_remove_breakpoint().
However, doesn't it make more sense to have target_insert_breakpoint()
save the length instead of using BREAKPOINT_FROM_PC() to ask for it?
Mark
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-02 23:13 ` Mark Kettenis
@ 2006-03-02 23:19 ` Daniel Jacobowitz
2006-03-03 0:08 ` Mark Kettenis
2006-03-03 13:51 ` Eli Zaretskii
2006-04-11 21:46 ` Daniel Jacobowitz
2 siblings, 1 reply; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-03-02 23:19 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
On Fri, Mar 03, 2006 at 12:01:52AM +0100, Mark Kettenis wrote:
> > Date: Thu, 2 Mar 2006 17:17:11 -0500
> > From: Daniel Jacobowitz <drow@false.org>
> >
> > This nasty, mechanical patch adds "len" arguments to
> > target_remove_breakpoint and target_remove_hw_breakpoint. The goal is
> > to allow BREAKPOINT_FROM_PC to include heuristics, which may possibly
> > change between when a breakpoint is inserted and when it is removed;
> > in order to stay in sync, we need to always remove breakpoints in the
> > same way that we inserted them.
> >
> > There's not much more to say about this patch. It's big, obvious, and
> > pretty ugly. Any comments on this? Does it look OK?
>
> Yuck! It really is ugly. For one thing, I think it is a bit
> pointless, to add a the BREAKPOINT_FROM_PC() to targets where we know
> the length of a breakpoint instruction is fixed.
>
> Another thing is that I think the order of the arguments of
> target_remove_breakpoint() is wrong. I think it makes sense to see
> your "len" argument as the length of the saved memory. Then it is
> more logical to make "len" the last argument of
> target_remove_breakpoint().
>
> However, doesn't it make more sense to have target_insert_breakpoint()
> save the length instead of using BREAKPOINT_FROM_PC() to ask for it?
If you want me to do that, I'll do that instead. It requires touching
twice as many target functions. Writing the changelog for this one
took long enough, so forgive me if I wait a while before trying it
again :-)
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-02 23:19 ` Daniel Jacobowitz
@ 2006-03-03 0:08 ` Mark Kettenis
2006-03-03 1:21 ` Daniel Jacobowitz
0 siblings, 1 reply; 52+ messages in thread
From: Mark Kettenis @ 2006-03-03 0:08 UTC (permalink / raw)
To: drow; +Cc: mark.kettenis, gdb-patches
> Date: Thu, 2 Mar 2006 18:10:42 -0500
> From: Daniel Jacobowitz <drow@false.org>
>
> On Fri, Mar 03, 2006 at 12:01:52AM +0100, Mark Kettenis wrote:
> > > Date: Thu, 2 Mar 2006 17:17:11 -0500
> > > From: Daniel Jacobowitz <drow@false.org>
> > >
> > > This nasty, mechanical patch adds "len" arguments to
> > > target_remove_breakpoint and target_remove_hw_breakpoint. The goal is
> > > to allow BREAKPOINT_FROM_PC to include heuristics, which may possibly
> > > change between when a breakpoint is inserted and when it is removed;
> > > in order to stay in sync, we need to always remove breakpoints in the
> > > same way that we inserted them.
> > >
> > > There's not much more to say about this patch. It's big, obvious, and
> > > pretty ugly. Any comments on this? Does it look OK?
> >
> > Yuck! It really is ugly. For one thing, I think it is a bit
> > pointless, to add a the BREAKPOINT_FROM_PC() to targets where we know
> > the length of a breakpoint instruction is fixed.
> >
> > Another thing is that I think the order of the arguments of
> > target_remove_breakpoint() is wrong. I think it makes sense to see
> > your "len" argument as the length of the saved memory. Then it is
> > more logical to make "len" the last argument of
> > target_remove_breakpoint().
> >
> > However, doesn't it make more sense to have target_insert_breakpoint()
> > save the length instead of using BREAKPOINT_FROM_PC() to ask for it?
>
> If you want me to do that, I'll do that instead. It requires touching
> twice as many target functions. Writing the changelog for this one
> took long enough, so forgive me if I wait a while before trying it
> again :-)
You're touching a fairly fundamental piece of the breakpoint
infrastructure here. I think it is worth thinking about this for a
bit longer. My comments certainly weren't "demands", so I'm perfectly
fine with discussing this a bit more before you rush towards changing
your patch ;-).
Mark
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-03 0:08 ` Mark Kettenis
@ 2006-03-03 1:21 ` Daniel Jacobowitz
0 siblings, 0 replies; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-03-03 1:21 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
On Fri, Mar 03, 2006 at 12:18:44AM +0100, Mark Kettenis wrote:
> > > Yuck! It really is ugly. For one thing, I think it is a bit
> > > pointless, to add a the BREAKPOINT_FROM_PC() to targets where we know
> > > the length of a breakpoint instruction is fixed.
Several of the touched targets either have variable length breakpoints,
or conceivably could in an architecture revision (e.g. I'm pretty sure
there's such an extension for PPC on paper, don't know if it's deployed
anywhere). I felt it better to be consistent.
> > > Another thing is that I think the order of the arguments of
> > > target_remove_breakpoint() is wrong. I think it makes sense to see
> > > your "len" argument as the length of the saved memory. Then it is
> > > more logical to make "len" the last argument of
> > > target_remove_breakpoint().
> > >
> > > However, doesn't it make more sense to have target_insert_breakpoint()
> > > save the length instead of using BREAKPOINT_FROM_PC() to ask for it?
> >
> > If you want me to do that, I'll do that instead. It requires touching
> > twice as many target functions. Writing the changelog for this one
> > took long enough, so forgive me if I wait a while before trying it
> > again :-)
>
> You're touching a fairly fundamental piece of the breakpoint
> infrastructure here. I think it is worth thinking about this for a
> bit longer. My comments certainly weren't "demands", so I'm perfectly
> fine with discussing this a bit more before you rush towards changing
> your patch ;-).
Nah, I agree that making it symmetric would be good. The problem is
that this entire area is riddled with hacks, duplicate ways to
accomplish the same goal, and other forms of quirk; I didn't want to
get too far into cleaning it up, especially since a third of the files
I touched are for targets that probably ought to be deleted anyway.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-02 23:13 ` Mark Kettenis
2006-03-02 23:19 ` Daniel Jacobowitz
@ 2006-03-03 13:51 ` Eli Zaretskii
2006-03-03 15:03 ` Daniel Jacobowitz
2006-04-11 21:46 ` Daniel Jacobowitz
2 siblings, 1 reply; 52+ messages in thread
From: Eli Zaretskii @ 2006-03-03 13:51 UTC (permalink / raw)
To: Mark Kettenis; +Cc: drow, gdb-patches
> Date: Fri, 3 Mar 2006 00:01:52 +0100 (CET)
> From: Mark Kettenis <mark.kettenis@xs4all.nl>
> CC: gdb-patches@sourceware.org
>
> > Date: Thu, 2 Mar 2006 17:17:11 -0500
> > From: Daniel Jacobowitz <drow@false.org>
> >
> > This nasty, mechanical patch adds "len" arguments to
> > target_remove_breakpoint and target_remove_hw_breakpoint. The goal is
> > to allow BREAKPOINT_FROM_PC to include heuristics, which may possibly
> > change between when a breakpoint is inserted and when it is removed;
> > in order to stay in sync, we need to always remove breakpoints in the
> > same way that we inserted them.
> >
> > There's not much more to say about this patch. It's big, obvious, and
> > pretty ugly. Any comments on this? Does it look OK?
>
> Yuck! It really is ugly. For one thing, I think it is a bit
> pointless, to add a the BREAKPOINT_FROM_PC() to targets where we know
> the length of a breakpoint instruction is fixed.
Was the reason for this discussed at some point? What I miss from
Daniel's patch is some kind of explanation as to the reason(s) for it.
I have my guesses, but I don't think I should do guesswork here.
Perhaps I missed the explanation in the patch, but I did look at the
comments and the gdbint.texinfo text, and didn't find anything that
explains why we need this.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-03 13:51 ` Eli Zaretskii
@ 2006-03-03 15:03 ` Daniel Jacobowitz
2006-03-03 17:56 ` Eli Zaretskii
0 siblings, 1 reply; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-03-03 15:03 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Mark Kettenis, gdb-patches
On Fri, Mar 03, 2006 at 11:09:39AM +0200, Eli Zaretskii wrote:
> Was the reason for this discussed at some point? What I miss from
> Daniel's patch is some kind of explanation as to the reason(s) for it.
> I have my guesses, but I don't think I should do guesswork here.
> Perhaps I missed the explanation in the patch, but I did look at the
> comments and the gdbint.texinfo text, and didn't find anything that
> explains why we need this.
Sorry, I should have linked to the explanation. It's here:
http://sourceware.org/ml/gdb-patches/2006-02/msg00386.html
That patch allows us to guess whether completely unknown code is ARM or
Thumb. If we are guessing based on target state and user settings,
rather than from the symbol table as we do now, it's possible for
the guess to change between when a breakpoint is inserted and when
it is removed. If that happens, we can try to remove a four byte
breakpoint as if it were a two byte breakpoint, which will lead
to memory corruption.
I tried always caching and restoring four bytes, but that doesn't
work with e.g. remote targets - we send a Z0,4 packet, and then
a z0,2 packet to remove it, which will no doubt confuse some
remote stubs.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-03 15:03 ` Daniel Jacobowitz
@ 2006-03-03 17:56 ` Eli Zaretskii
2006-03-03 18:04 ` Daniel Jacobowitz
0 siblings, 1 reply; 52+ messages in thread
From: Eli Zaretskii @ 2006-03-03 17:56 UTC (permalink / raw)
To: gdb-patches
> Date: Fri, 3 Mar 2006 09:11:24 -0500
> From: Daniel Jacobowitz <drow@false.org>
> Cc: Mark Kettenis <mark.kettenis@xs4all.nl>, gdb-patches@sourceware.org
>
> That patch allows us to guess whether completely unknown code is ARM or
> Thumb. If we are guessing based on target state and user settings,
> rather than from the symbol table as we do now, it's possible for
> the guess to change between when a breakpoint is inserted and when
> it is removed. If that happens, we can try to remove a four byte
> breakpoint as if it were a two byte breakpoint, which will lead
> to memory corruption.
Can't this be done ion the target-dependent code? Why do we need to
know, on the GDB application level, how many bytes did the breakpoint
instruction take?
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-03 17:56 ` Eli Zaretskii
@ 2006-03-03 18:04 ` Daniel Jacobowitz
2006-03-03 22:00 ` Eli Zaretskii
0 siblings, 1 reply; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-03-03 18:04 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
On Fri, Mar 03, 2006 at 07:41:37PM +0200, Eli Zaretskii wrote:
> > Date: Fri, 3 Mar 2006 09:11:24 -0500
> > From: Daniel Jacobowitz <drow@false.org>
> > Cc: Mark Kettenis <mark.kettenis@xs4all.nl>, gdb-patches@sourceware.org
> >
> > That patch allows us to guess whether completely unknown code is ARM or
> > Thumb. If we are guessing based on target state and user settings,
> > rather than from the symbol table as we do now, it's possible for
> > the guess to change between when a breakpoint is inserted and when
> > it is removed. If that happens, we can try to remove a four byte
> > breakpoint as if it were a two byte breakpoint, which will lead
> > to memory corruption.
>
> Can't this be done ion the target-dependent code? Why do we need to
> know, on the GDB application level, how many bytes did the breakpoint
> instruction take?
Because the target vector is told to remove breakpoints given only
an address and an opaque shadow-contents buffer big enough to hold
what may have been overwritten in memory.
The change of breakpoint size happens in architecture-specific code,
but the insertion and removal happens in target-specific code.
If every target cached the size of inserted breakpoints and made sure
to remove them at the same size, that would work too, but right now
most targets don't need to remember anything about the breakpoints
they've inserted; the common layer of GDB handles it.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-03 18:04 ` Daniel Jacobowitz
@ 2006-03-03 22:00 ` Eli Zaretskii
2006-03-03 22:10 ` Daniel Jacobowitz
2006-03-04 0:35 ` Steven Johnson
0 siblings, 2 replies; 52+ messages in thread
From: Eli Zaretskii @ 2006-03-03 22:00 UTC (permalink / raw)
To: gdb-patches
> Date: Fri, 3 Mar 2006 12:54:07 -0500
> From: Daniel Jacobowitz <drow@false.org>
> Cc: gdb-patches@sourceware.org
>
> If every target cached the size of inserted breakpoints and made sure
> to remove them at the same size, that would work too, but right now
> most targets don't need to remember anything about the breakpoints
> they've inserted; the common layer of GDB handles it.
That sounds like an unfortunate design. If we are to make significant
changes to handle the complications that led you to this patch,
perhaps we should consider changing the design instead.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-03 22:00 ` Eli Zaretskii
@ 2006-03-03 22:10 ` Daniel Jacobowitz
2006-03-03 22:35 ` Eli Zaretskii
2006-03-07 5:31 ` Michael Snyder
2006-03-04 0:35 ` Steven Johnson
1 sibling, 2 replies; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-03-03 22:10 UTC (permalink / raw)
To: gdb-patches
On Fri, Mar 03, 2006 at 11:39:30PM +0200, Eli Zaretskii wrote:
> > Date: Fri, 3 Mar 2006 12:54:07 -0500
> > From: Daniel Jacobowitz <drow@false.org>
> > Cc: gdb-patches@sourceware.org
> >
> > If every target cached the size of inserted breakpoints and made sure
> > to remove them at the same size, that would work too, but right now
> > most targets don't need to remember anything about the breakpoints
> > they've inserted; the common layer of GDB handles it.
>
> That sounds like an unfortunate design. If we are to make significant
> changes to handle the complications that led you to this patch,
> perhaps we should consider changing the design instead.
Well, as I said, I was trying to not redesign more of GDB than
necessary...
Do you believe it _should_ be the target vector's responsibility to
remember inserted breakpoint details? I find this a little bit
strange, since every target will have to do just about the
same thing.
Another possible interface change to solve the problem would be to
pass a "struct breakpoint" to the remove function. However, today
there are many places where breakpoints are used without a
corresponding "struct breakpoint" e.g. for software single step.
I've tried cleaning up that in the past, and it's defeated me
every single time.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-03 22:10 ` Daniel Jacobowitz
@ 2006-03-03 22:35 ` Eli Zaretskii
2006-03-03 23:01 ` Daniel Jacobowitz
2006-03-07 5:31 ` Michael Snyder
1 sibling, 1 reply; 52+ messages in thread
From: Eli Zaretskii @ 2006-03-03 22:35 UTC (permalink / raw)
To: gdb-patches
> Date: Fri, 3 Mar 2006 16:43:59 -0500
> From: Daniel Jacobowitz <drow@false.org>
>
> Do you believe it _should_ be the target vector's responsibility to
> remember inserted breakpoint details?
For details that are specific to a target, yes, I think so.
> I find this a little bit strange, since every target will have to do
> just about the same thing.
We could have a generic method that most of them could use. Those
that have peculiarities, such as those which started this thread, will
have to provide their own methods.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-03 22:35 ` Eli Zaretskii
@ 2006-03-03 23:01 ` Daniel Jacobowitz
2006-03-04 10:39 ` Eli Zaretskii
0 siblings, 1 reply; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-03-03 23:01 UTC (permalink / raw)
To: gdb-patches
On Sat, Mar 04, 2006 at 12:01:00AM +0200, Eli Zaretskii wrote:
> > I find this a little bit strange, since every target will have to do
> > just about the same thing.
>
> We could have a generic method that most of them could use. Those
> that have peculiarities, such as those which started this thread, will
> have to provide their own methods.
For the record, it is not a target with peculiarities. It's an
architecture with a feature (that on the order of four other
GDB-supported architectures have).
There's a division in GDB between the target, which is a method of
communication et cetera ("how"), and the architecture, which describes
"what" is being debugged. It's a quirk of the architecture (all of the
architectures, although none of the others do this sort of heuristic
today) that there are multiple sizes of breakpoints and we can't
statically determine which one we need. It's a requirement of most
targets that we know how big a breakpoint is when inserting or removing
it.
The architecture says "the breakpoint at 0x8000 should be 2 bytes
long". The target sets the breakpoint. The target goes to remove the
breakpoint, and needs to know how long it was when it was set.
If it were contained within either a target or an architecture, the
solution would obviously be much smaller.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-03 22:00 ` Eli Zaretskii
2006-03-03 22:10 ` Daniel Jacobowitz
@ 2006-03-04 0:35 ` Steven Johnson
2006-03-04 10:18 ` Daniel Jacobowitz
1 sibling, 1 reply; 52+ messages in thread
From: Steven Johnson @ 2006-03-04 0:35 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
Eli Zaretskii wrote:
>>Date: Fri, 3 Mar 2006 12:54:07 -0500
>>From: Daniel Jacobowitz <drow@false.org>
>>Cc: gdb-patches@sourceware.org
>>
>>If every target cached the size of inserted breakpoints and made sure
>>to remove them at the same size, that would work too, but right now
>>most targets don't need to remember anything about the breakpoints
>>they've inserted; the common layer of GDB handles it.
>>
>>
>
>That sounds like an unfortunate design. If we are to make significant
>changes to handle the complications that led you to this patch,
>perhaps we should consider changing the design instead.
>
>
>
>
I wouldn't have thought the design unfortunate. One original aim of the
target stubs (as i understand it) was to be able to keep them simple and
minimal. That would include minimizing their memory requirements.
Requiring a stub to store state about current breakpoints inserted would
be a potentially big memory requirement, because how many breakpoints is
the user going to insert? 1, 2, 50, 100's? Or do the stubs just limit
it, and say, i'm a simple stub, i can only have 5 breakpoints, try
adding 6 and I'll fail?
I think the approach to use the "effectively infinite" resources of the
host PC to cache the breakpoint information is the correct approach,
given the alternative. (For stubs that don't implement the 'z' packets).
However if a stub implement the 'z' packets, it needs to store state of
the breakpoints, so why does it need to know the size of the breakpoint
on remove? It should have already cached the data at the location, it
should already have stored how much data it cached, so surely just
"Remove the breakpoint a x' is enough for the stub to complete its job.
This doesn't fix the basic problem for simple stubs that only have
read/write memory control where GDB caches all of the info.
Steven
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-04 0:35 ` Steven Johnson
@ 2006-03-04 10:18 ` Daniel Jacobowitz
0 siblings, 0 replies; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-03-04 10:18 UTC (permalink / raw)
To: Steven Johnson; +Cc: Eli Zaretskii, gdb-patches
On Sat, Mar 04, 2006 at 09:34:55AM +1100, Steven Johnson wrote:
> I wouldn't have thought the design unfortunate. One original aim of the
> target stubs (as i understand it) was to be able to keep them simple and
> minimal. That would include minimizing their memory requirements.
> Requiring a stub to store state about current breakpoints inserted would
> be a potentially big memory requirement, because how many breakpoints is
> the user going to insert? 1, 2, 50, 100's? Or do the stubs just limit
> it, and say, i'm a simple stub, i can only have 5 breakpoints, try
> adding 6 and I'll fail?
Wrong layer: I'm talking about entirely within GDB, rather than
between GDB and the stub. I took it as a given that we needed to be
able to tell the remote target z0,2 or z0,4, so the remote layer would
have to cache the data itself.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-03 23:01 ` Daniel Jacobowitz
@ 2006-03-04 10:39 ` Eli Zaretskii
2006-03-04 14:58 ` Daniel Jacobowitz
0 siblings, 1 reply; 52+ messages in thread
From: Eli Zaretskii @ 2006-03-04 10:39 UTC (permalink / raw)
To: gdb-patches
> Date: Fri, 3 Mar 2006 17:10:03 -0500
> From: Daniel Jacobowitz <drow@false.org>
>
> For the record, it is not a target with peculiarities. It's an
> architecture with a feature
I don't see the difference. One man's feature is another's
peculiarity.
> There's a division in GDB between the target, which is a method of
> communication et cetera ("how"), and the architecture, which describes
> "what" is being debugged.
Btw, is this division described anywhere?
> The architecture says "the breakpoint at 0x8000 should be 2 bytes
> long". The target sets the breakpoint. The target goes to remove the
> breakpoint, and needs to know how long it was when it was set.
If the issue at hand is just between the architecture and the target,
then why you had to touch breakpoint.[ch] in your patch? AFAIK,
breakpoint.c belongs to the higher-level GDB layer, above both the
target and the architecture, isn't that so?
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-04 10:39 ` Eli Zaretskii
@ 2006-03-04 14:58 ` Daniel Jacobowitz
2006-03-04 15:05 ` Eli Zaretskii
0 siblings, 1 reply; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-03-04 14:58 UTC (permalink / raw)
To: gdb-patches
On Sat, Mar 04, 2006 at 11:23:04AM +0200, Eli Zaretskii wrote:
> > Date: Fri, 3 Mar 2006 17:10:03 -0500
> > From: Daniel Jacobowitz <drow@false.org>
> >
> > For the record, it is not a target with peculiarities. It's an
> > architecture with a feature
>
> I don't see the difference. One man's feature is another's
> peculiarity.
My real point was that it's not a target but an architecture.
> > There's a division in GDB between the target, which is a method of
> > communication et cetera ("how"), and the architecture, which describes
> > "what" is being debugged.
>
> Btw, is this division described anywhere?
Yes, extensively, in gdbint.
> > The architecture says "the breakpoint at 0x8000 should be 2 bytes
> > long". The target sets the breakpoint. The target goes to remove the
> > breakpoint, and needs to know how long it was when it was set.
>
> If the issue at hand is just between the architecture and the target,
> then why you had to touch breakpoint.[ch] in your patch? AFAIK,
> breakpoint.c belongs to the higher-level GDB layer, above both the
> target and the architecture, isn't that so?
Targets and architectures try to be completely independent from each
other. The core of GDB uses targets, and uses architectures (and
they use each other, but to a lesser degree, and through the
architecture and target vector abstractions).
The architecture doesn't call target_remove_breakpoint, so if we
want to pass more information from one to the other, it has to go
through breakpoint.c.
Anyway, the horse is dead! Mark didn't like the patch, and had some
suggestions. You didn't like the patch either. I'll find another way.
It will probably be an even larger diff.
The CPSR support is turning out to be a remarkable pain for such a
simple change.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-04 14:58 ` Daniel Jacobowitz
@ 2006-03-04 15:05 ` Eli Zaretskii
2006-03-04 15:11 ` Daniel Jacobowitz
0 siblings, 1 reply; 52+ messages in thread
From: Eli Zaretskii @ 2006-03-04 15:05 UTC (permalink / raw)
To: gdb-patches
> Date: Sat, 4 Mar 2006 09:43:30 -0500
> From: Daniel Jacobowitz <drow@false.org>
>
> > > There's a division in GDB between the target, which is a method of
> > > communication et cetera ("how"), and the architecture, which describes
> > > "what" is being debugged.
> >
> > Btw, is this division described anywhere?
>
> Yes, extensively, in gdbint.
I looked there before asking, so please tell what is the section name
that describes this. Sorry for being blind.
> The CPSR support is turning out to be a remarkable pain for such a
> simple change.
That's why I thought we should discuss the design aspects here.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-04 15:05 ` Eli Zaretskii
@ 2006-03-04 15:11 ` Daniel Jacobowitz
2006-03-06 19:49 ` Eli Zaretskii
0 siblings, 1 reply; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-03-04 15:11 UTC (permalink / raw)
To: gdb-patches
On Sat, Mar 04, 2006 at 04:54:04PM +0200, Eli Zaretskii wrote:
> > Date: Sat, 4 Mar 2006 09:43:30 -0500
> > From: Daniel Jacobowitz <drow@false.org>
> >
> > > > There's a division in GDB between the target, which is a method of
> > > > communication et cetera ("how"), and the architecture, which describes
> > > > "what" is being debugged.
> > >
> > > Btw, is this division described anywhere?
> >
> > Yes, extensively, in gdbint.
>
> I looked there before asking, so please tell what is the section name
> that describes this. Sorry for being blind.
They have their own chapters: Target Architecture Definition and Target
Vector Definition. Perhaps the titles could be clarified.
GDB's target architecture defines what sort of machine-language
programs GDB can work with, and how it works with them.
versus
The target vector defines the interface between GDB's abstract handling
of target systems, and the nitty-gritty code that actually exercises
control over a process or a serial port.
> > The CPSR support is turning out to be a remarkable pain for such a
> > simple change.
>
> That's why I thought we should discuss the design aspects here.
Do you have any suggestions for the design? Mark suggested a more
symmetric interface, which I agreed to implement. You suggested not
modifying the interface and instead having targets keep track. I've
tried to explain why I don't think that's a good idea, but if you
aren't convinced, I'll do it that way instead.
Heh... another way I could make the interface more symmetric would be
to bump up the size of the shadow contents vector, and have targets
which care about the size store the length in there when inserting
the breakpoint.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-04 15:11 ` Daniel Jacobowitz
@ 2006-03-06 19:49 ` Eli Zaretskii
0 siblings, 0 replies; 52+ messages in thread
From: Eli Zaretskii @ 2006-03-06 19:49 UTC (permalink / raw)
To: gdb-patches
> Date: Sat, 4 Mar 2006 10:05:14 -0500
> From: Daniel Jacobowitz <drow@false.org>
>
> On Sat, Mar 04, 2006 at 04:54:04PM +0200, Eli Zaretskii wrote:
> > > Date: Sat, 4 Mar 2006 09:43:30 -0500
> > > From: Daniel Jacobowitz <drow@false.org>
> > >
> > > > > There's a division in GDB between the target, which is a method of
> > > > > communication et cetera ("how"), and the architecture, which describes
> > > > > "what" is being debugged.
> > > >
> > > > Btw, is this division described anywhere?
> > >
> > > Yes, extensively, in gdbint.
> >
> > I looked there before asking, so please tell what is the section name
> > that describes this. Sorry for being blind.
>
> They have their own chapters: Target Architecture Definition and Target
> Vector Definition. Perhaps the titles could be clarified.
>
> GDB's target architecture defines what sort of machine-language
> programs GDB can work with, and how it works with them.
>
> versus
>
> The target vector defines the interface between GDB's abstract handling
> of target systems, and the nitty-gritty code that actually exercises
> control over a process or a serial port.
I saw these. The definition of the target vector is quite specific,
while that of the architecture, IMNSHO, doesn't explain anything. In
particular, the usual meaning of the word ``architecture'' does not go
well with ``the sort of machine-language programs''. The fact that
both terms use the word ``target'' (target architecture vs target
vector) doesn't help, either.
Perhaps a more elaborate description which lists at least the more
important parts of the architecture and, respectively, the target
vector, will make the docs better. Would someone ``in the know'' care
to write it?
> > > The CPSR support is turning out to be a remarkable pain for such a
> > > simple change.
> >
> > That's why I thought we should discuss the design aspects here.
>
> Do you have any suggestions for the design?
Well, you say that this issue is between the target and the
architecture, so keeping the info in those layers seems like a good
start. Does this make sense?
> Heh... another way I could make the interface more symmetric would be
> to bump up the size of the shadow contents vector, and have targets
> which care about the size store the length in there when inserting
> the breakpoint.
Sounds a bit unclean to me.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-03 22:10 ` Daniel Jacobowitz
2006-03-03 22:35 ` Eli Zaretskii
@ 2006-03-07 5:31 ` Michael Snyder
1 sibling, 0 replies; 52+ messages in thread
From: Michael Snyder @ 2006-03-07 5:31 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
Daniel Jacobowitz wrote:
> On Fri, Mar 03, 2006 at 11:39:30PM +0200, Eli Zaretskii wrote:
>
>>>Date: Fri, 3 Mar 2006 12:54:07 -0500
>>>From: Daniel Jacobowitz <drow@false.org>
>>>Cc: gdb-patches@sourceware.org
>>>
>>>If every target cached the size of inserted breakpoints and made sure
>>>to remove them at the same size, that would work too, but right now
>>>most targets don't need to remember anything about the breakpoints
>>>they've inserted; the common layer of GDB handles it.
>>
>>That sounds like an unfortunate design. If we are to make significant
>>changes to handle the complications that led you to this patch,
>>perhaps we should consider changing the design instead.
>
>
> Well, as I said, I was trying to not redesign more of GDB than
> necessary...
>
> Do you believe it _should_ be the target vector's responsibility to
> remember inserted breakpoint details? I find this a little bit
> strange, since every target will have to do just about the
> same thing.
That's not unusual, though. Just means that we export
a "default" method, and targets that need to do it differently
can override the default.
Not weighing in on the question, mind you...
> Another possible interface change to solve the problem would be to
> pass a "struct breakpoint" to the remove function. However, today
> there are many places where breakpoints are used without a
> corresponding "struct breakpoint" e.g. for software single step.
> I've tried cleaning up that in the past, and it's defeated me
> every single time.
>
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-03-02 23:13 ` Mark Kettenis
2006-03-02 23:19 ` Daniel Jacobowitz
2006-03-03 13:51 ` Eli Zaretskii
@ 2006-04-11 21:46 ` Daniel Jacobowitz
2006-04-11 22:32 ` David S. Miller
` (2 more replies)
2 siblings, 3 replies; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-04-11 21:46 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
On Fri, Mar 03, 2006 at 12:01:52AM +0100, Mark Kettenis wrote:
> Yuck! It really is ugly. For one thing, I think it is a bit
> pointless, to add a the BREAKPOINT_FROM_PC() to targets where we know
> the length of a breakpoint instruction is fixed.
>
> Another thing is that I think the order of the arguments of
> target_remove_breakpoint() is wrong. I think it makes sense to see
> your "len" argument as the length of the saved memory. Then it is
> more logical to make "len" the last argument of
> target_remove_breakpoint().
>
> However, doesn't it make more sense to have target_insert_breakpoint()
> save the length instead of using BREAKPOINT_FROM_PC() to ask for it?
All true. Do you like this version better? I think it's much
more elegant. target_insert_breakpoint et al. now take the
struct bp_location, instead of just the shadow contents cache.
They can fill in whatever they choose.
I added some helper functions for the other common breakpoint
activities while I was there. This should consolidate all the actual
inserting and removing of breakpoints within breakpoint.c, and
allow future cleanups.
I sure hope you like this version better. If not, I'm going to do
future versions without updating all the targets, and teach myself to
abridge changelog entries more aggressively. The patch itself was
worthwhile, but the last couple of hours have just been stupid.
I should've done just "* foo-tdep.c, bar-tdep.c: Update.".
I'm throwing this on another branch I've been working on, meanwhile,
since I am reasonably confident that it is correct.
--
Daniel Jacobowitz
CodeSourcery
2006-04-11 Daniel Jacobowitz <dan@codesourcery.com>
* breakpoint.c (insert_bp_location, reattach_breakpoints)
(remove_breakpoint, delete_breakpoint): Update calls to changed
methods.
(deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint)
(single_step_breakpoints, insert_single_step_breakpoint)
(remove_single_step_breakpoints): New.
* breakpoint.h (struct bp_location): Add placed_address and
placed_size. Move shadow_contents below the new comment.
(deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint)
(insert_single_step_breakpoint, remove_single_step_breakpoints): New
prototypes.
* gdbarch.sh: Forward struct bp_location in gdbarch.h.
(memory_insert_breakpoint, memory_remove_breakpoint): Update second
argument.
* mem-break.c (default_memory_insert_breakpoint): Update. Set
placed_address and placed_size.
(default_memory_remove_breakpoint): Update. Don't use
BREAKPOINT_FROM_PC.
(memory_insert_breakpoint, memory_remove_breakpoint): Update.
* target.c (update_current_target): Update prototypes for changed
functions.
(debug_to_insert_breakpoint, debug_to_remove_breakpoint)
(debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint):
Update.
* target.h: Forward declare struct bp_location.
(struct target_ops): Use a bp_location argument for
to_insert_breakpoint, to_remove_breakpoint,
to_insert_hw_breakpoint, and to_remove_hw_breakpoint.
(target_insert_breakpoint, target_remove_breakpoint)
(target_insert_hw_breakpoint, target_remove_hw_breakpoint)
(memory_insert_breakpoint, memory_remove_breakpoint)
(default_memory_insert_breakpoint, default_memory_remove_breakpoint):
Update.
* config/i386/nm-i386.h: Forward declare struct bp_location.
(i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update.
(target_insert_hw_breakpoint, target_remove_hw_breakpoint): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* alpha-tdep.c (alpha_software_single_step): Use
insert_single_step_breakpoint and remove_single_step_breakpoints.
Remove unused statics.
* arm-tdep.c (arm_software_single_step): Likewise. Add a note.
* cris-tdep.c (cris_software_single_step): Likewise.
* mips-tdep.c (mips_software_single_step): Likewise.
* rs6000-tdep.c (rs6000_software_single_step): Likewise.
* sparc-tdep.c (sparc_software_single_step): Likewise.
* wince.c (struct thread_info_struct): Remove step_prev.
(undoSStep): Use remove_single_step_breakpoints.
(wince_software_single_step): Use insert_single_step_breakpoint.
* corelow.c (ignore): Remove unneeded prototype. Update second
argument.
* exec.c (ignore): Likewise.
* sol-thread.c (ignore): Likewise.
* procfs.c (dbx_link_bpt_addr, dbx_link_shadow_contents): Delete.
(dbx_link_bpt): New.
(procfs_wait): Check it.
(procfs_mourn_inferior): Remove it if necessary.
(remove_dbx_link_breakpoint): Use it.
(insert_dbx_link_bpt_in_file): Set it.
(procfs_init_inferior): Don't update dbx_link_bpt_addr.
* rs6000-nat.c (exec_one_dummy_insn): Use
deprecated_insert_raw_breakpoint and
deprecated_remove_raw_breakpoint.
* solib-irix.c (shadow_contents, breakpoint_addr): Delete.
(base_breakpoint): New.
(disable_break): Use it.
(enable_break): Set it.
* i386-nat.c (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint):
Update.
* ia64-tdep.c (ia64_memory_insert_breakpoint)
(ia64_memory_remove_breakpoint): Likewise.
* m32r-tdep.c (m32r_memory_insert_breakpoint)
(m32r_memory_remove_breakpoint): Likewise.
* monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint):
Likewise. Remove unnecessary prototypes. Use placed_address
and placed_size. Removed useless read from memory.
* nto-procfs.c (procfs_insert_breakpoint)
(procfs_remove_breakpoint, procfs_insert_hw_breakpoint)
(procfs_remove_hw_breakpoint): Update.
* ocd.c (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise.
* ocd.h (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise.
* ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise.
* ppc-tdep.h (ppc_linux_memory_remove_breakpoint): Likewise.
* remote-e7000.c (e7000_insert_breakpoint)
(e7000_remove_breakpoint): Likewise.
* remote-m32r-sdi.c (m32r_insert_breakpoint)
(m32r_remove_breakpoint): Likewise.
* remote-mips.c (mips_insert_breakpoint)
(mips_remove_breakpoint): Likewise.
* remote-rdp.c (remote_rdp_insert_breakpoint)
(remote_rdp_remove_breakpoint): Likewise.
(rdp_step): Use deprecated_insert_raw_breakpoint and
deprecated_remove_raw_breakpoint.
* remote-sds.c (sds_insert_breakpoint, sds_remove_breakpoint):
Update.
* remote-sim.c (gdbsim_insert_breakpoint, gdbsim_remove_breakpoint):
Delete.
(init_gdbsim_ops): Use memory_insert_breakpoint and
memory_remove_breakpoint.
* remote-st.c (st2000_insert_breakpoint)
(st2000_remove_breakpoint): Update. Remove unused
BREAKPOINT_FROM_PC.
* remote.c (remote_insert_breakpoint, remote_remove_breakpoint):
Update. Use placed_address and placed_size.
(remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Likewise.
2006-04-11 Daniel Jacobowitz <dan@codesourcery.com>
* gdbint.texinfo (Watchpoints, Target Conditionals): Update insert
and remove breakpoint prototypes.
Index: alpha-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/alpha-tdep.c,v
retrieving revision 1.153
diff -u -p -r1.153 alpha-tdep.c
--- alpha-tdep.c 15 Jan 2006 20:53:32 -0000 1.153
+++ alpha-tdep.c 11 Apr 2006 21:16:34 -0000
@@ -1493,8 +1493,6 @@ void
alpha_software_single_step (enum target_signal sig, int insert_breakpoints_p)
{
static CORE_ADDR next_pc;
- typedef char binsn_quantum[BREAKPOINT_MAX];
- static binsn_quantum break_mem;
CORE_ADDR pc;
if (insert_breakpoints_p)
@@ -1502,11 +1500,11 @@ alpha_software_single_step (enum target_
pc = read_pc ();
next_pc = alpha_next_pc (pc);
- target_insert_breakpoint (next_pc, break_mem);
+ insert_single_step_breakpoint (next_pc);
}
else
{
- target_remove_breakpoint (next_pc, break_mem);
+ remove_single_step_breakpoints ();
write_pc (next_pc);
}
}
Index: arm-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.c,v
retrieving revision 1.207
diff -u -p -r1.207 arm-tdep.c
--- arm-tdep.c 30 Mar 2006 16:48:47 -0000 1.207
+++ arm-tdep.c 11 Apr 2006 21:16:35 -0000
@@ -1849,16 +1849,18 @@ arm_get_next_pc (CORE_ADDR pc)
static void
arm_software_single_step (enum target_signal sig, int insert_bpt)
{
- static int next_pc; /* State between setting and unsetting. */
- static char break_mem[BREAKPOINT_MAX]; /* Temporary storage for mem@bpt */
+ /* NOTE: This may insert the wrong breakpoint instruction when
+ single-stepping over a mode-changing instruction, if the
+ CPSR heuristics are used. */
if (insert_bpt)
{
- next_pc = arm_get_next_pc (read_register (ARM_PC_REGNUM));
- target_insert_breakpoint (next_pc, break_mem);
+ CORE_ADDR next_pc = arm_get_next_pc (read_register (ARM_PC_REGNUM));
+
+ insert_single_step_breakpoint (next_pc);
}
else
- target_remove_breakpoint (next_pc, break_mem);
+ remove_single_step_breakpoints ();
}
#include "bfd-in2.h"
Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.224
diff -u -p -r1.224 breakpoint.c
--- breakpoint.c 6 Apr 2006 18:33:05 -0000 1.224
+++ breakpoint.c 11 Apr 2006 21:16:36 -0000
@@ -804,11 +804,9 @@ insert_bp_location (struct bp_location *
/* No overlay handling: just set the breakpoint. */
if (bpt->loc_type == bp_loc_hardware_breakpoint)
- val = target_insert_hw_breakpoint (bpt->address,
- bpt->shadow_contents);
+ val = target_insert_hw_breakpoint (bpt->address, bpt);
else
- val = target_insert_breakpoint (bpt->address,
- bpt->shadow_contents);
+ val = target_insert_breakpoint (bpt->address, bpt);
}
else
{
@@ -827,7 +825,7 @@ insert_bp_location (struct bp_location *
CORE_ADDR addr = overlay_unmapped_address (bpt->address,
bpt->section);
/* Set a software (trap) breakpoint at the LMA. */
- val = target_insert_breakpoint (addr, bpt->shadow_contents);
+ val = target_insert_breakpoint (addr, bpt);
if (val != 0)
fprintf_unfiltered (tmp_error_stream,
"Overlay breakpoint %d failed: in ROM?",
@@ -839,11 +837,9 @@ insert_bp_location (struct bp_location *
{
/* Yes. This overlay section is mapped into memory. */
if (bpt->loc_type == bp_loc_hardware_breakpoint)
- val = target_insert_hw_breakpoint (bpt->address,
- bpt->shadow_contents);
+ val = target_insert_hw_breakpoint (bpt->address, bpt);
else
- val = target_insert_breakpoint (bpt->address,
- bpt->shadow_contents);
+ val = target_insert_breakpoint (bpt->address, bpt);
}
else
{
@@ -1045,7 +1041,7 @@ in which its expression is valid.\n"),
/* If we get here, we must have a callback mechanism for exception
events -- with g++ style embedded label support, we insert
ordinary breakpoints and not catchpoints. */
- val = target_insert_breakpoint (bpt->address, bpt->shadow_contents);
+ val = target_insert_breakpoint (bpt->address, bpt);
if (val)
{
/* Couldn't set breakpoint for some reason */
@@ -1240,9 +1236,9 @@ reattach_breakpoints (int pid)
{
remove_breakpoint (b, mark_inserted);
if (b->loc_type == bp_loc_hardware_breakpoint)
- val = target_insert_hw_breakpoint (b->address, b->shadow_contents);
+ val = target_insert_hw_breakpoint (b->address, b);
else
- val = target_insert_breakpoint (b->address, b->shadow_contents);
+ val = target_insert_breakpoint (b->address, b);
/* FIXME drow/2003-10-07: This doesn't handle any other kinds of
breakpoints. It's wrong for watchpoints, for example. */
if (val != 0)
@@ -1446,10 +1442,9 @@ remove_breakpoint (struct bp_location *b
/* No overlay handling: just remove the breakpoint. */
if (b->loc_type == bp_loc_hardware_breakpoint)
- val = target_remove_hw_breakpoint (b->address,
- b->shadow_contents);
+ val = target_remove_hw_breakpoint (b->address, b);
else
- val = target_remove_breakpoint (b->address, b->shadow_contents);
+ val = target_remove_breakpoint (b->address, b);
}
else
{
@@ -1465,9 +1460,9 @@ remove_breakpoint (struct bp_location *b
/* Ignore any failures: if the LMA is in ROM, we will
have already warned when we failed to insert it. */
if (b->loc_type == bp_loc_hardware_breakpoint)
- target_remove_hw_breakpoint (addr, b->shadow_contents);
+ target_remove_hw_breakpoint (addr, b);
else
- target_remove_breakpoint (addr, b->shadow_contents);
+ target_remove_breakpoint (addr, b);
}
/* Did we set a breakpoint at the VMA?
If so, we will have marked the breakpoint 'inserted'. */
@@ -1478,11 +1473,9 @@ remove_breakpoint (struct bp_location *b
unmapped, but let's not rely on that being safe. We
don't know what the overlay manager might do. */
if (b->loc_type == bp_loc_hardware_breakpoint)
- val = target_remove_hw_breakpoint (b->address,
- b->shadow_contents);
+ val = target_remove_hw_breakpoint (b->address, b);
else
- val = target_remove_breakpoint (b->address,
- b->shadow_contents);
+ val = target_remove_breakpoint (b->address, b);
}
else
{
@@ -1570,8 +1563,7 @@ remove_breakpoint (struct bp_location *b
&& breakpoint_enabled (b->owner)
&& !b->duplicate)
{
-
- val = target_remove_breakpoint (b->address, b->shadow_contents);
+ val = target_remove_breakpoint (b->address, b);
if (val)
return val;
b->inserted = (is == mark_inserted);
@@ -1581,8 +1573,7 @@ remove_breakpoint (struct bp_location *b
&& breakpoint_enabled (b->owner)
&& !b->duplicate)
{
-
- val = target_remove_breakpoint (b->address, b->shadow_contents);
+ val = target_remove_breakpoint (b->address, b);
if (val)
return val;
@@ -6853,9 +6844,9 @@ delete_breakpoint (struct breakpoint *bp
"a permanent breakpoint"));
if (b->type == bp_hardware_breakpoint)
- val = target_insert_hw_breakpoint (b->loc->address, b->loc->shadow_contents);
+ val = target_insert_hw_breakpoint (b->loc->address, b->loc);
else
- val = target_insert_breakpoint (b->loc->address, b->loc->shadow_contents);
+ val = target_insert_breakpoint (b->loc->address, b->loc);
/* If there was an error in the insert, print a message, then stop execution. */
if (val != 0)
@@ -7658,6 +7649,109 @@ decode_line_spec_1 (char *string, int fu
error (_("Junk at end of line specification: %s"), string);
return sals;
}
+
+/* Create and insert a raw software breakpoint at PC. This is the only place
+ besides set_raw_breakpoint that allocates a breakpoint; it should be
+ eliminated someday. */
+
+struct breakpoint *
+deprecated_insert_raw_breakpoint (CORE_ADDR pc)
+{
+ struct breakpoint *b;
+
+ b = xmalloc (sizeof (struct breakpoint));
+ memset (b, 0, sizeof (struct breakpoint));
+
+ b->loc = xmalloc (sizeof (struct bp_location));
+ memset (b->loc, 0, sizeof (struct bp_location));
+ b->loc->owner = b;
+ b->loc->loc_type = bp_loc_software_breakpoint;
+
+ /* We don't bother with adjust_breakpoint_address here, but it
+ would presumably be harmless to do so. */
+ b->loc->requested_address = pc;
+ b->loc->address = b->loc->requested_address;
+
+ b->type = bp_breakpoint;
+ b->thread = -1;
+ b->enable_state = bp_enabled;
+
+ if (target_insert_breakpoint (b->loc->address, b->loc) != 0)
+ {
+ /* Could not insert the breakpoint. */
+ xfree (b->loc);
+ xfree (b);
+ return NULL;
+ }
+
+ return b;
+}
+
+/* Remove a breakpoint B inserted by deprecated_insert_raw_breakpoint. */
+
+int
+deprecated_remove_raw_breakpoint (struct breakpoint *b)
+{
+ int ret;
+
+ ret = target_remove_breakpoint (b->loc->address, b->loc);
+ xfree (b->loc);
+ xfree (b);
+
+ return ret;
+}
+
+/* One (or perhaps two) breakpoints used for software single stepping. */
+
+static struct breakpoint *single_step_breakpoints[2];
+
+/* Create and insert a breakpoint for software single step. */
+
+void
+insert_single_step_breakpoint (CORE_ADDR next_pc)
+{
+ struct breakpoint **bpt_p;
+
+ if (single_step_breakpoints[0] == NULL)
+ bpt_p = &single_step_breakpoints[0];
+ else
+ {
+ gdb_assert (single_step_breakpoints[1] == NULL);
+ bpt_p = &single_step_breakpoints[1];
+ }
+
+ /* NOTE drow/2006-04-11: A future improvement to this function would be
+ to only create the breakpoints once, and actually put them on the
+ breakpoint chain. That would let us use set_raw_breakpoint. We could
+ adjust the addresses each time they were needed. Doing this requires
+ corresponding changes elsewhere where single step breakpoints are
+ handled, however. So, for now, we use this. */
+
+ *bpt_p = deprecated_insert_raw_breakpoint (next_pc);
+ if (*bpt_p == NULL)
+ warning (_("Could not insert single-step breakpoint at 0x%s"),
+ paddr_nz (next_pc));
+}
+
+/* Remove and delete any breakpoints used for software single step. */
+
+void
+remove_single_step_breakpoints (void)
+{
+ gdb_assert (single_step_breakpoints[0] != NULL);
+
+ /* See insert_single_step_breakpoint for more about this deprecated
+ call. */
+ deprecated_remove_raw_breakpoint (single_step_breakpoints[0]);
+ single_step_breakpoints[0] = NULL;
+
+ if (single_step_breakpoints[1] != NULL)
+ {
+ deprecated_remove_raw_breakpoint (single_step_breakpoints[1]);
+ single_step_breakpoints[1] = NULL;
+ }
+}
+
\f
/* This help string is used for the break, hbreak, tbreak and thbreak commands.
It is defined as a macro to prevent duplication.
Index: breakpoint.h
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.h,v
retrieving revision 1.36
diff -u -p -r1.36 breakpoint.h
--- breakpoint.h 17 Dec 2005 22:33:59 -0000 1.36
+++ breakpoint.h 11 Apr 2006 21:16:36 -0000
@@ -242,13 +242,6 @@ struct bp_location
associated with the address. Used primarily for overlay debugging. */
asection *section;
- /* "Real" contents of byte where breakpoint has been inserted.
- Valid only when breakpoints are in the program. Under the complete
- control of the target insert_breakpoint and remove_breakpoint routines.
- No other code should assume anything about the value(s) here.
- Valid only for bp_loc_software_breakpoint. */
- gdb_byte shadow_contents[BREAKPOINT_MAX];
-
/* Address at which breakpoint was requested, either by the user or
by GDB for internal breakpoints. This will usually be the same
as ``address'' (above) except for cases in which
@@ -256,6 +249,27 @@ struct bp_location
which to place the breakpoint in order to comply with a
processor's architectual constraints. */
CORE_ADDR requested_address;
+
+ /* The members after this point are only set or read by the target's
+ insert and remove methods, for its own purposes. Any which the
+ insert method does not set, the remove method should not read.
+ Nothing besides the target should access these! */
+
+ /* "Real" contents of byte where breakpoint has been inserted.
+ Valid only when breakpoints are in the program. Under the complete
+ control of the target insert_breakpoint and remove_breakpoint routines.
+ No other code should assume anything about the value(s) here.
+ Valid only for bp_loc_software_breakpoint. */
+ gdb_byte shadow_contents[BREAKPOINT_MAX];
+
+ /* Address at which the breakpoint was placed. This is normally the same
+ as "address", above, except when adjustment happens in
+ BREAKPOINT_FROM_PC, usually stripping an alternate ISA marker
+ from the PC which is used to determine the correct breakpoint. */
+ CORE_ADDR placed_address;
+
+ /* Size of the placed breakpoint, according to BREAKPOINT_FROM_PC. */
+ int placed_size;
};
/* This structure is a collection of function pointers that, if available,
@@ -796,6 +810,16 @@ extern void delete_command (char *arg, i
remove fails. */
extern int remove_hw_watchpoints (void);
+/* Manage a software single step breakpoint (or two). Insert may be called
+ twice before remove is called. */
+extern void insert_single_step_breakpoint (CORE_ADDR);
+extern void remove_single_step_breakpoints (void);
+
+/* Manage manual breakpoints, separate from the normal chain of
+ breakpoints. These functions are used in murky target-specific
+ ways. Please do not add more uses! */
+extern struct breakpoint *deprecated_insert_raw_breakpoint (CORE_ADDR);
+extern int deprecated_remove_raw_breakpoint (struct breakpoint *);
/* Indicator of whether exception catchpoints should be nuked between
runs of a program. */
Index: corelow.c
===================================================================
RCS file: /cvs/src/src/gdb/corelow.c,v
retrieving revision 1.55
diff -u -p -r1.55 corelow.c
--- corelow.c 25 Feb 2006 04:36:39 -0000 1.55
+++ corelow.c 11 Apr 2006 21:16:36 -0000
@@ -86,8 +86,6 @@ static void get_core_registers (int);
static void add_to_thread_list (bfd *, asection *, void *);
-static int ignore (CORE_ADDR, bfd_byte *);
-
static int core_file_thread_alive (ptid_t tid);
static void init_core_ops (void);
@@ -603,7 +601,7 @@ core_xfer_partial (struct target_ops *op
`gdb internal error' (since generic_mourn calls breakpoint_init_inferior). */
static int
-ignore (CORE_ADDR addr, bfd_byte *contents)
+ignore (CORE_ADDR addr, struct bp_location *bpt)
{
return 0;
}
Index: cris-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/cris-tdep.c,v
retrieving revision 1.135
diff -u -p -r1.135 cris-tdep.c
--- cris-tdep.c 5 Apr 2006 20:01:19 -0000 1.135
+++ cris-tdep.c 11 Apr 2006 21:16:36 -0000
@@ -558,15 +558,6 @@ struct instruction_environment
int disable_interrupt;
} inst_env_type;
-/* Save old breakpoints in order to restore the state before a single_step.
- At most, two breakpoints will have to be remembered. */
-typedef
-char binsn_quantum[BREAKPOINT_MAX];
-static binsn_quantum break_mem[2];
-static CORE_ADDR next_pc = 0;
-static CORE_ADDR branch_target_address = 0;
-static unsigned char branch_break_inserted = 0;
-
/* Machine-dependencies in CRIS for opcodes. */
/* Instruction sizes. */
@@ -2130,7 +2121,7 @@ static void
cris_software_single_step (enum target_signal ignore, int insert_breakpoints)
{
inst_env_type inst_env;
-
+
if (insert_breakpoints)
{
/* Analyse the present instruction environment and insert
@@ -2146,28 +2137,19 @@ cris_software_single_step (enum target_s
{
/* Insert at most two breakpoints. One for the next PC content
and possibly another one for a branch, jump, etc. */
- next_pc = (CORE_ADDR) inst_env.reg[PC_REGNUM];
- target_insert_breakpoint (next_pc, break_mem[0]);
+ CORE_ADDR next_pc = (CORE_ADDR) inst_env.reg[PC_REGNUM];
+ insert_single_step_breakpoint (next_pc);
if (inst_env.branch_found
&& (CORE_ADDR) inst_env.branch_break_address != next_pc)
{
- branch_target_address =
- (CORE_ADDR) inst_env.branch_break_address;
- target_insert_breakpoint (branch_target_address, break_mem[1]);
- branch_break_inserted = 1;
+ CORE_ADDR branch_target_address
+ = (CORE_ADDR) inst_env.branch_break_address;
+ insert_single_step_breakpoint (branch_target_address);
}
}
}
else
- {
- /* Remove breakpoints. */
- target_remove_breakpoint (next_pc, break_mem[0]);
- if (branch_break_inserted)
- {
- target_remove_breakpoint (branch_target_address, break_mem[1]);
- branch_break_inserted = 0;
- }
- }
+ remove_single_step_breakpoints ();
}
/* Calculates the prefix value for quick offset addressing mode. */
Index: exec.c
===================================================================
RCS file: /cvs/src/src/gdb/exec.c,v
retrieving revision 1.60
diff -u -p -r1.60 exec.c
--- exec.c 25 Feb 2006 04:36:39 -0000 1.60
+++ exec.c 11 Apr 2006 21:16:36 -0000
@@ -59,8 +59,6 @@ static void set_section_command (char *,
static void exec_files_info (struct target_ops *);
-static int ignore (CORE_ADDR, bfd_byte *);
-
static void init_exec_ops (void);
void _initialize_exec (void);
@@ -691,7 +689,7 @@ exec_set_section_address (const char *fi
breakpoint_init_inferior). */
static int
-ignore (CORE_ADDR addr, bfd_byte *contents)
+ignore (CORE_ADDR addr, struct bp_location *bpt)
{
return 0;
}
Index: gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.328
diff -u -p -r1.328 gdbarch.c
--- gdbarch.c 17 Dec 2005 22:33:59 -0000 1.328
+++ gdbarch.c 11 Apr 2006 21:16:37 -0000
@@ -1250,8 +1250,8 @@ gdbarch_dump (struct gdbarch *current_gd
#ifdef MEMORY_INSERT_BREAKPOINT
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
- "MEMORY_INSERT_BREAKPOINT(addr, contents_cache)",
- XSTRING (MEMORY_INSERT_BREAKPOINT (addr, contents_cache)));
+ "MEMORY_INSERT_BREAKPOINT(addr, bpt)",
+ XSTRING (MEMORY_INSERT_BREAKPOINT (addr, bpt)));
#endif
fprintf_unfiltered (file,
"gdbarch_dump: memory_insert_breakpoint = <0x%lx>\n",
@@ -1259,8 +1259,8 @@ gdbarch_dump (struct gdbarch *current_gd
#ifdef MEMORY_REMOVE_BREAKPOINT
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
- "MEMORY_REMOVE_BREAKPOINT(addr, contents_cache)",
- XSTRING (MEMORY_REMOVE_BREAKPOINT (addr, contents_cache)));
+ "MEMORY_REMOVE_BREAKPOINT(addr, bpt)",
+ XSTRING (MEMORY_REMOVE_BREAKPOINT (addr, bpt)));
#endif
fprintf_unfiltered (file,
"gdbarch_dump: memory_remove_breakpoint = <0x%lx>\n",
@@ -2934,13 +2934,13 @@ set_gdbarch_adjust_breakpoint_address (s
}
int
-gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, gdb_byte *contents_cache)
+gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, struct bp_location *bpt)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->memory_insert_breakpoint != NULL);
if (gdbarch_debug >= 2)
fprintf_unfiltered (gdb_stdlog, "gdbarch_memory_insert_breakpoint called\n");
- return gdbarch->memory_insert_breakpoint (addr, contents_cache);
+ return gdbarch->memory_insert_breakpoint (addr, bpt);
}
void
@@ -2951,13 +2951,13 @@ set_gdbarch_memory_insert_breakpoint (st
}
int
-gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, gdb_byte *contents_cache)
+gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, struct bp_location *bpt)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->memory_remove_breakpoint != NULL);
if (gdbarch_debug >= 2)
fprintf_unfiltered (gdb_stdlog, "gdbarch_memory_remove_breakpoint called\n");
- return gdbarch->memory_remove_breakpoint (addr, contents_cache);
+ return gdbarch->memory_remove_breakpoint (addr, bpt);
}
void
Index: gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.284
diff -u -p -r1.284 gdbarch.h
--- gdbarch.h 17 Dec 2005 22:34:00 -0000 1.284
+++ gdbarch.h 11 Apr 2006 21:16:37 -0000
@@ -49,6 +49,7 @@ struct regset;
struct disassemble_info;
struct target_ops;
struct obstack;
+struct bp_location;
extern struct gdbarch *current_gdbarch;
@@ -899,24 +900,24 @@ typedef CORE_ADDR (gdbarch_adjust_breakp
extern CORE_ADDR gdbarch_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr);
extern void set_gdbarch_adjust_breakpoint_address (struct gdbarch *gdbarch, gdbarch_adjust_breakpoint_address_ftype *adjust_breakpoint_address);
-typedef int (gdbarch_memory_insert_breakpoint_ftype) (CORE_ADDR addr, gdb_byte *contents_cache);
-extern int gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, gdb_byte *contents_cache);
+typedef int (gdbarch_memory_insert_breakpoint_ftype) (CORE_ADDR addr, struct bp_location *bpt);
+extern int gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, struct bp_location *bpt);
extern void set_gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, gdbarch_memory_insert_breakpoint_ftype *memory_insert_breakpoint);
#if !defined (GDB_TM_FILE) && defined (MEMORY_INSERT_BREAKPOINT)
#error "Non multi-arch definition of MEMORY_INSERT_BREAKPOINT"
#endif
#if !defined (MEMORY_INSERT_BREAKPOINT)
-#define MEMORY_INSERT_BREAKPOINT(addr, contents_cache) (gdbarch_memory_insert_breakpoint (current_gdbarch, addr, contents_cache))
+#define MEMORY_INSERT_BREAKPOINT(addr, bpt) (gdbarch_memory_insert_breakpoint (current_gdbarch, addr, bpt))
#endif
-typedef int (gdbarch_memory_remove_breakpoint_ftype) (CORE_ADDR addr, gdb_byte *contents_cache);
-extern int gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, gdb_byte *contents_cache);
+typedef int (gdbarch_memory_remove_breakpoint_ftype) (CORE_ADDR addr, struct bp_location *bpt);
+extern int gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, struct bp_location *bpt);
extern void set_gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, gdbarch_memory_remove_breakpoint_ftype *memory_remove_breakpoint);
#if !defined (GDB_TM_FILE) && defined (MEMORY_REMOVE_BREAKPOINT)
#error "Non multi-arch definition of MEMORY_REMOVE_BREAKPOINT"
#endif
#if !defined (MEMORY_REMOVE_BREAKPOINT)
-#define MEMORY_REMOVE_BREAKPOINT(addr, contents_cache) (gdbarch_memory_remove_breakpoint (current_gdbarch, addr, contents_cache))
+#define MEMORY_REMOVE_BREAKPOINT(addr, bpt) (gdbarch_memory_remove_breakpoint (current_gdbarch, addr, bpt))
#endif
extern CORE_ADDR gdbarch_decr_pc_after_break (struct gdbarch *gdbarch);
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.363
diff -u -p -r1.363 gdbarch.sh
--- gdbarch.sh 17 Dec 2005 22:34:00 -0000 1.363
+++ gdbarch.sh 11 Apr 2006 21:16:37 -0000
@@ -549,8 +549,8 @@ f:=:CORE_ADDR:skip_prologue:CORE_ADDR ip
f:=:int:inner_than:CORE_ADDR lhs, CORE_ADDR rhs:lhs, rhs:0:0
f:=:const gdb_byte *:breakpoint_from_pc:CORE_ADDR *pcptr, int *lenptr:pcptr, lenptr::0:
M::CORE_ADDR:adjust_breakpoint_address:CORE_ADDR bpaddr:bpaddr
-f:=:int:memory_insert_breakpoint:CORE_ADDR addr, gdb_byte *contents_cache:addr, contents_cache:0:default_memory_insert_breakpoint::0
-f:=:int:memory_remove_breakpoint:CORE_ADDR addr, gdb_byte *contents_cache:addr, contents_cache:0:default_memory_remove_breakpoint::0
+f:=:int:memory_insert_breakpoint:CORE_ADDR addr, struct bp_location *bpt:addr, bpt:0:default_memory_insert_breakpoint::0
+f:=:int:memory_remove_breakpoint:CORE_ADDR addr, struct bp_location *bpt:addr, bpt:0:default_memory_remove_breakpoint::0
v:=:CORE_ADDR:decr_pc_after_break:::0:::0
# A function can be addressed by either it's "pointer" (possibly a
@@ -771,6 +771,7 @@ struct regset;
struct disassemble_info;
struct target_ops;
struct obstack;
+struct bp_location;
extern struct gdbarch *current_gdbarch;
EOF
Index: i386-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-nat.c,v
retrieving revision 1.13
diff -u -p -r1.13 i386-nat.c
--- i386-nat.c 17 Dec 2005 22:34:01 -0000 1.13
+++ i386-nat.c 11 Apr 2006 21:16:37 -0000
@@ -625,10 +625,10 @@ i386_stopped_by_hwbp (void)
return 0;
}
-/* Insert a hardware-assisted breakpoint at address ADDR. SHADOW is
+/* Insert a hardware-assisted breakpoint at address ADDR. BPT is
unused. Return 0 on success, EBUSY on failure. */
int
-i386_insert_hw_breakpoint (CORE_ADDR addr, void *shadow)
+i386_insert_hw_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
unsigned len_rw = i386_length_and_rw_bits (1, hw_execute);
int retval = i386_insert_aligned_watchpoint (addr, len_rw) ? EBUSY : 0;
@@ -639,11 +639,11 @@ i386_insert_hw_breakpoint (CORE_ADDR add
return retval;
}
-/* Remove a hardware-assisted breakpoint at address ADDR. SHADOW is
+/* Remove a hardware-assisted breakpoint at address ADDR. BPT is
unused. Return 0 on success, -1 on failure. */
int
-i386_remove_hw_breakpoint (CORE_ADDR addr, void *shadow)
+i386_remove_hw_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
unsigned len_rw = i386_length_and_rw_bits (1, hw_execute);
int retval = i386_remove_aligned_watchpoint (addr, len_rw);
Index: ia64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ia64-tdep.c,v
retrieving revision 1.138
diff -u -p -r1.138 ia64-tdep.c
--- ia64-tdep.c 8 Mar 2006 15:28:17 -0000 1.138
+++ ia64-tdep.c 11 Apr 2006 21:16:38 -0000
@@ -550,7 +550,7 @@ fetch_instruction (CORE_ADDR addr, instr
#define IA64_BREAKPOINT 0x00003333300LL
static int
-ia64_memory_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+ia64_memory_insert_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
char bundle[BUNDLE_LEN];
int slotnum = (int) (addr & 0x0f) / SLOT_MULTIPLIER;
@@ -574,7 +574,7 @@ ia64_memory_insert_breakpoint (CORE_ADDR
}
instr = slotN_contents (bundle, slotnum);
- memcpy(contents_cache, &instr, sizeof(instr));
+ memcpy (bpt->shadow_contents, &instr, sizeof (instr));
replace_slotN_contents (bundle, IA64_BREAKPOINT, slotnum);
if (val == 0)
target_write_memory (addr, bundle, BUNDLE_LEN);
@@ -583,7 +583,7 @@ ia64_memory_insert_breakpoint (CORE_ADDR
}
static int
-ia64_memory_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+ia64_memory_remove_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
char bundle[BUNDLE_LEN];
int slotnum = (addr & 0x0f) / SLOT_MULTIPLIER;
@@ -603,7 +603,7 @@ ia64_memory_remove_breakpoint (CORE_ADDR
slotnum = 2;
}
- memcpy (&instr, contents_cache, sizeof instr);
+ memcpy (&instr, bpt->shadow_contents, sizeof instr);
replace_slotN_contents (bundle, instr, slotnum);
if (val == 0)
target_write_memory (addr, bundle, BUNDLE_LEN);
Index: m32r-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/m32r-tdep.c,v
retrieving revision 1.40
diff -u -p -r1.40 m32r-tdep.c
--- m32r-tdep.c 17 Dec 2005 22:34:01 -0000 1.40
+++ m32r-tdep.c 11 Apr 2006 21:16:38 -0000
@@ -81,10 +81,11 @@ m32r_frame_align (struct gdbarch *gdbarc
The following functions take care of this behavior. */
static int
-m32r_memory_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+m32r_memory_insert_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
int val;
gdb_byte buf[4];
+ gdb_byte *contents_cache = bpt->shadow_contents;
gdb_byte bp_entry[] = { 0x10, 0xf1 }; /* dpt */
/* Save the memory contents. */
@@ -134,10 +135,11 @@ m32r_memory_insert_breakpoint (CORE_ADDR
}
static int
-m32r_memory_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+m32r_memory_remove_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
int val;
gdb_byte buf[4];
+ gdb_byte *contents_cache = bpt->shadow_contents;
buf[0] = contents_cache[0];
buf[1] = contents_cache[1];
Index: mem-break.c
===================================================================
RCS file: /cvs/src/src/gdb/mem-break.c,v
retrieving revision 1.11
diff -u -p -r1.11 mem-break.c
--- mem-break.c 17 Dec 2005 22:34:01 -0000 1.11
+++ mem-break.c 11 Apr 2006 21:16:38 -0000
@@ -36,13 +36,14 @@
/* Insert a breakpoint on targets that don't have any better breakpoint
support. We read the contents of the target location and stash it,
then overwrite it with a breakpoint instruction. ADDR is the target
- location in the target machine. CONTENTS_CACHE is a pointer to
- memory allocated for saving the target contents. It is guaranteed
- by the caller to be long enough to save BREAKPOINT_LEN bytes (this
- is accomplished via BREAKPOINT_MAX). */
+ location in the target machine. BPT is a pointer to the breakpoint
+ location being inserted, which contains some memory allocated for
+ saving the target contents. It is guaranteed by the caller to be
+ long enough to save BREAKPOINT_LEN bytes (this is accomplished via
+ BREAKPOINT_MAX). */
int
-default_memory_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+default_memory_insert_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
int val;
const unsigned char *bp;
@@ -54,7 +55,9 @@ default_memory_insert_breakpoint (CORE_A
error (_("Software breakpoints not implemented for this target."));
/* Save the memory contents. */
- val = target_read_memory (addr, contents_cache, bplen);
+ bpt->placed_address = addr;
+ bpt->placed_size = bplen;
+ val = target_read_memory (addr, bpt->shadow_contents, bplen);
/* Write the breakpoint. */
if (val == 0)
@@ -65,28 +68,21 @@ default_memory_insert_breakpoint (CORE_A
int
-default_memory_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+default_memory_remove_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
- const bfd_byte *bp;
- int bplen;
-
- /* Determine appropriate breakpoint contents and size for this address. */
- bp = BREAKPOINT_FROM_PC (&addr, &bplen);
- if (bp == NULL)
- error (_("Software breakpoints not implemented for this target."));
-
- return target_write_memory (addr, contents_cache, bplen);
+ return target_write_memory (bpt->placed_address, bpt->shadow_contents,
+ bpt->placed_size);
}
int
-memory_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+memory_insert_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
- return MEMORY_INSERT_BREAKPOINT(addr, contents_cache);
+ return MEMORY_INSERT_BREAKPOINT (addr, bpt);
}
int
-memory_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+memory_remove_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
- return MEMORY_REMOVE_BREAKPOINT(addr, contents_cache);
+ return MEMORY_REMOVE_BREAKPOINT (addr, bpt);
}
Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.388
diff -u -p -r1.388 mips-tdep.c
--- mips-tdep.c 15 Mar 2006 16:59:54 -0000 1.388
+++ mips-tdep.c 11 Apr 2006 21:16:38 -0000
@@ -2188,20 +2188,17 @@ mips_addr_bits_remove (CORE_ADDR addr)
void
mips_software_single_step (enum target_signal sig, int insert_breakpoints_p)
{
- static CORE_ADDR next_pc;
- typedef char binsn_quantum[BREAKPOINT_MAX];
- static binsn_quantum break_mem;
- CORE_ADDR pc;
+ CORE_ADDR pc, next_pc;
if (insert_breakpoints_p)
{
pc = read_register (mips_regnum (current_gdbarch)->pc);
next_pc = mips_next_pc (pc);
- target_insert_breakpoint (next_pc, break_mem);
+ insert_single_step_breakpoint (next_pc);
}
else
- target_remove_breakpoint (next_pc, break_mem);
+ remove_single_step_breakpoints ();
}
/* Test whether the PC points to the return instruction at the
Index: monitor.c
===================================================================
RCS file: /cvs/src/src/gdb/monitor.c,v
retrieving revision 1.63
diff -u -p -r1.63 monitor.c
--- monitor.c 24 Jan 2006 22:09:28 -0000 1.63
+++ monitor.c 11 Apr 2006 21:16:38 -0000
@@ -85,8 +85,6 @@ static int monitor_xfer_memory (CORE_ADD
struct mem_attrib *attrib,
struct target_ops *target);
static void monitor_files_info (struct target_ops *ops);
-static int monitor_insert_breakpoint (CORE_ADDR addr, gdb_byte *shadow);
-static int monitor_remove_breakpoint (CORE_ADDR addr, gdb_byte *shadow);
static void monitor_kill (void);
static void monitor_load (char *file, int from_tty);
static void monitor_mourn_inferior (void);
@@ -2037,7 +2035,7 @@ monitor_mourn_inferior (void)
/* Tell the monitor to add a breakpoint. */
static int
-monitor_insert_breakpoint (CORE_ADDR addr, gdb_byte *shadow)
+monitor_insert_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
int i;
const unsigned char *bp;
@@ -2052,13 +2050,14 @@ monitor_insert_breakpoint (CORE_ADDR add
/* Determine appropriate breakpoint size for this address. */
bp = gdbarch_breakpoint_from_pc (current_gdbarch, &addr, &bplen);
+ bpt->placed_address = addr;
+ bpt->placed_size = bplen;
for (i = 0; i < current_monitor->num_breakpoints; i++)
{
if (breakaddr[i] == 0)
{
breakaddr[i] = addr;
- monitor_read_memory (addr, shadow, bplen);
monitor_printf (current_monitor->set_break, addr);
monitor_expect_prompt (NULL, 0);
return 0;
@@ -2071,7 +2070,7 @@ monitor_insert_breakpoint (CORE_ADDR add
/* Tell the monitor to remove a breakpoint. */
static int
-monitor_remove_breakpoint (CORE_ADDR addr, gdb_byte *shadow)
+monitor_remove_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
int i;
@@ -2079,8 +2078,7 @@ monitor_remove_breakpoint (CORE_ADDR add
if (current_monitor->clr_break == NULL)
error (_("No clr_break defined for this monitor"));
- if (current_monitor->flags & MO_ADDR_BITS_REMOVE)
- addr = ADDR_BITS_REMOVE (addr);
+ addr = bpt->placed_address;
for (i = 0; i < current_monitor->num_breakpoints; i++)
{
Index: nto-procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/nto-procfs.c,v
retrieving revision 1.17
diff -u -p -r1.17 nto-procfs.c
--- nto-procfs.c 24 Jan 2006 22:09:28 -0000 1.17
+++ nto-procfs.c 11 Apr 2006 21:16:38 -0000
@@ -76,10 +76,6 @@ static ptid_t do_attach (ptid_t ptid);
static int procfs_can_use_hw_breakpoint (int, int, int);
-static int procfs_insert_hw_breakpoint (CORE_ADDR, char *);
-
-static int procfs_remove_hw_breakpoint (CORE_ADDR addr, char *);
-
static int procfs_insert_hw_watchpoint (CORE_ADDR addr, int len, int type);
static int procfs_remove_hw_watchpoint (CORE_ADDR addr, int len, int type);
@@ -812,25 +808,25 @@ procfs_breakpoint (CORE_ADDR addr, int t
}
static int
-procfs_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
+procfs_insert_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
return procfs_breakpoint (addr, _DEBUG_BREAK_EXEC, 0);
}
static int
-procfs_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
+procfs_remove_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
return procfs_breakpoint (addr, _DEBUG_BREAK_EXEC, -1);
}
static int
-procfs_insert_hw_breakpoint (CORE_ADDR addr, char *contents_cache)
+procfs_insert_hw_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
return procfs_breakpoint (addr, _DEBUG_BREAK_EXEC | _DEBUG_BREAK_HW, 0);
}
static int
-procfs_remove_hw_breakpoint (CORE_ADDR addr, char *contents_cache)
+procfs_remove_hw_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
return procfs_breakpoint (addr, _DEBUG_BREAK_EXEC | _DEBUG_BREAK_HW, -1);
}
Index: ocd.c
===================================================================
RCS file: /cvs/src/src/gdb/ocd.c,v
retrieving revision 1.43
diff -u -p -r1.43 ocd.c
--- ocd.c 24 Jan 2006 22:09:28 -0000 1.43
+++ ocd.c 11 Apr 2006 21:16:39 -0000
@@ -1048,12 +1048,12 @@ ocd_load (char *args, int from_tty)
/* BDM (at least on CPU32) uses a different breakpoint */
int
-ocd_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
+ocd_insert_breakpoint (CORE_ADDR addr, struct bpt_location *bpt)
{
static char break_insn[] = BDM_BREAKPOINT;
int val;
- val = target_read_memory (addr, contents_cache, sizeof (break_insn));
+ val = target_read_memory (addr, bpt->shadow_contents, sizeof (break_insn));
if (val == 0)
val = target_write_memory (addr, break_insn, sizeof (break_insn));
@@ -1062,12 +1062,12 @@ ocd_insert_breakpoint (CORE_ADDR addr, c
}
int
-ocd_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
+ocd_remove_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
static char break_insn[] = BDM_BREAKPOINT;
int val;
- val = target_write_memory (addr, contents_cache, sizeof (break_insn));
+ val = target_write_memory (addr, bpt->shadow_contents, sizeof (break_insn));
return val;
}
Index: ocd.h
===================================================================
RCS file: /cvs/src/src/gdb/ocd.h,v
retrieving revision 1.8
diff -u -p -r1.8 ocd.h
--- ocd.h 17 Dec 2005 22:34:01 -0000 1.8
+++ ocd.h 11 Apr 2006 21:16:39 -0000
@@ -135,8 +135,8 @@ void ocd_write_bdm_register (int bdm_reg
int ocd_wait (void);
-int ocd_insert_breakpoint (CORE_ADDR addr, char *contents_cache);
-int ocd_remove_breakpoint (CORE_ADDR addr, char *contents_cache);
+int ocd_insert_breakpoint (CORE_ADDR addr, struct bp_location *bpt);
+int ocd_remove_breakpoint (CORE_ADDR addr, struct bp_location *bpt);
int ocd_write_bytes (CORE_ADDR memaddr, char *myaddr, int len);
Index: ppc-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v
retrieving revision 1.77
diff -u -p -r1.77 ppc-linux-tdep.c
--- ppc-linux-tdep.c 15 Jan 2006 18:28:58 -0000 1.77
+++ ppc-linux-tdep.c 11 Apr 2006 21:16:39 -0000
@@ -457,8 +457,7 @@ ppc_linux_skip_trampoline_code (CORE_ADD
regard to removing breakpoints in some potentially self modifying
code. */
int
-ppc_linux_memory_remove_breakpoint (CORE_ADDR addr,
- gdb_byte *contents_cache)
+ppc_linux_memory_remove_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
const unsigned char *bp;
int val;
@@ -476,7 +475,7 @@ ppc_linux_memory_remove_breakpoint (CORE
program modified the code on us, so it is wrong to put back the
old value */
if (val == 0 && memcmp (bp, old_contents, bplen) == 0)
- val = target_write_memory (addr, contents_cache, bplen);
+ val = target_write_memory (addr, bpt->shadow_contents, bplen);
return val;
}
Index: ppc-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/ppc-tdep.h,v
retrieving revision 1.50
diff -u -p -r1.50 ppc-tdep.h
--- ppc-tdep.h 17 Jan 2006 22:21:13 -0000 1.50
+++ ppc-tdep.h 11 Apr 2006 21:16:39 -0000
@@ -57,7 +57,7 @@ CORE_ADDR ppc64_sysv_abi_push_dummy_call
CORE_ADDR ppc64_sysv_abi_adjust_breakpoint_address (struct gdbarch *gdbarch,
CORE_ADDR bpaddr);
int ppc_linux_memory_remove_breakpoint (CORE_ADDR addr,
- gdb_byte *contents_cache);
+ struct bp_location *bpt);
struct link_map_offsets *ppc_linux_svr4_fetch_link_map_offsets (void);
void ppc_linux_supply_gregset (struct regcache *regcache,
int regnum, const void *gregs, size_t size,
Index: procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/procfs.c,v
retrieving revision 1.68
diff -u -p -r1.68 procfs.c
--- procfs.c 24 Jan 2006 22:09:28 -0000 1.68
+++ procfs.c 11 Apr 2006 21:16:39 -0000
@@ -3371,11 +3371,8 @@ static int insert_dbx_link_breakpoint (p
static void remove_dbx_link_breakpoint (void);
/* On mips-irix, we need to insert a breakpoint at __dbx_link during
- the startup phase. The following two variables are used to record
- the address of the breakpoint, and the code that was replaced by
- a breakpoint. */
-static int dbx_link_bpt_addr = 0;
-static char dbx_link_shadow_contents[BREAKPOINT_MAX];
+ the startup phase. */
+static struct breakpoint *dbx_link_bpt;
/*
* Function: procfs_debug_inferior
@@ -4207,8 +4204,8 @@ wait_again:
/* If we hit our __dbx_link() internal breakpoint,
then remove it. See comments in procfs_init_inferior()
for more details. */
- if (dbx_link_bpt_addr != 0
- && dbx_link_bpt_addr == read_pc ())
+ if (dbx_link_bpt != NULL
+ && dbx_link_bpt->loc->address == read_pc ())
remove_dbx_link_breakpoint ();
wstat = (SIGTRAP << 8) | 0177;
@@ -4777,6 +4774,13 @@ procfs_mourn_inferior (void)
destroy_procinfo (pi);
}
unpush_target (&procfs_ops);
+
+ if (dbx_link_bpt != NULL)
+ {
+ deprecated_remove_raw_breakpoint (dbx_link_bpt);
+ dbx_link_bpt = NULL;
+ }
+
generic_mourn_inferior ();
}
@@ -4886,7 +4890,6 @@ procfs_init_inferior (int pid)
has been inserted, the syssgi() notifications are no longer necessary,
so they should be canceled. */
proc_trace_syscalls_1 (pi, SYS_syssgi, PR_SYSEXIT, FLAG_SET, 0);
- dbx_link_bpt_addr = 0;
#endif
}
@@ -5568,14 +5571,13 @@ proc_find_memory_regions (int (*func) (C
static void
remove_dbx_link_breakpoint (void)
{
- if (dbx_link_bpt_addr == 0)
+ if (dbx_link_bpt == NULL)
return;
- if (memory_remove_breakpoint (dbx_link_bpt_addr,
- dbx_link_shadow_contents) != 0)
+ if (deprecated_remove_raw_breakpoint (dbx_link_bpt) != 0)
warning (_("Unable to remove __dbx_link breakpoint."));
- dbx_link_bpt_addr = 0;
+ dbx_link_bpt = NULL;
}
/* Return the address of the __dbx_link() function in the file
@@ -5642,8 +5644,8 @@ insert_dbx_link_bpt_in_file (int fd, COR
if (sym_addr != 0)
{
/* Insert the breakpoint. */
- dbx_link_bpt_addr = sym_addr;
- if (target_insert_breakpoint (sym_addr, dbx_link_shadow_contents) != 0)
+ dbx_link_bpt = deprecated_insert_raw_breakpoint (sym_addr);
+ if (dbx_link_bpt == NULL)
{
warning (_("Failed to insert dbx_link breakpoint."));
bfd_close (abfd);
Index: remote-e7000.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-e7000.c,v
retrieving revision 1.57
diff -u -p -r1.57 remote-e7000.c
--- remote-e7000.c 24 Jan 2006 22:09:28 -0000 1.57
+++ remote-e7000.c 11 Apr 2006 21:16:39 -0000
@@ -1702,7 +1702,7 @@ static CORE_ADDR breakaddr[MAX_BREAKPOIN
{0};
static int
-e7000_insert_breakpoint (CORE_ADDR addr, bfd_byte *shadow)
+e7000_insert_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
int i;
char buf[200];
@@ -1728,7 +1728,7 @@ e7000_insert_breakpoint (CORE_ADDR addr,
}
#else
#if 0
- e7000_read_inferior_memory (addr, shadow, 2);
+ e7000_read_inferior_memory (addr, bpt->shadow_contents, 2);
e7000_write_inferior_memory (addr, nop, 2);
#endif
@@ -1745,7 +1745,7 @@ e7000_insert_breakpoint (CORE_ADDR addr,
}
static int
-e7000_remove_breakpoint (CORE_ADDR addr, bfd_byte *shadow)
+e7000_remove_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
int i;
char buf[200];
@@ -1773,7 +1773,7 @@ e7000_remove_breakpoint (CORE_ADDR addr,
#if 0
/* Replace the insn under the break */
- e7000_write_inferior_memory (addr, shadow, 2);
+ e7000_write_inferior_memory (addr, bpt->shadow_contents, 2);
#endif
#endif
Index: remote-m32r-sdi.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-m32r-sdi.c,v
retrieving revision 1.17
diff -u -p -r1.17 remote-m32r-sdi.c
--- remote-m32r-sdi.c 24 Jan 2006 22:09:28 -0000 1.17
+++ remote-m32r-sdi.c 11 Apr 2006 21:16:40 -0000
@@ -1141,15 +1141,15 @@ m32r_mourn_inferior (void)
}
static int
-m32r_insert_breakpoint (CORE_ADDR addr, bfd_byte *shadow)
+m32r_insert_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
int ib_breakpoints;
unsigned char buf[13];
int i, c;
if (remote_debug)
- fprintf_unfiltered (gdb_stdlog, "m32r_insert_breakpoint(%08lx,\"%s\")\n",
- addr, shadow);
+ fprintf_unfiltered (gdb_stdlog, "m32r_insert_breakpoint(%08lx,...)\n",
+ addr);
if (use_ib_breakpoints)
ib_breakpoints = max_ib_breakpoints;
@@ -1183,13 +1183,13 @@ m32r_insert_breakpoint (CORE_ADDR addr,
}
static int
-m32r_remove_breakpoint (CORE_ADDR addr, bfd_byte *shadow)
+m32r_remove_breakpoint (CORE_ADDR addr, int len, struct bp_location *bpt)
{
int i;
if (remote_debug)
- fprintf_unfiltered (gdb_stdlog, "m32r_remove_breakpoint(%08lx,\"%s\")\n",
- addr, shadow);
+ fprintf_unfiltered (gdb_stdlog, "m32r_remove_breakpoint(%08lx)\n",
+ addr);
for (i = 0; i < MAX_BREAKPOINTS; i++)
{
Index: remote-mips.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-mips.c,v
retrieving revision 1.68
diff -u -p -r1.68 remote-mips.c
--- remote-mips.c 24 Jan 2006 22:09:28 -0000 1.68
+++ remote-mips.c 11 Apr 2006 21:16:40 -0000
@@ -2216,27 +2216,26 @@ mips_mourn_inferior (void)
/* Insert a breakpoint. On targets that don't have built-in
breakpoint support, we read the contents of the target location and
stash it, then overwrite it with a breakpoint instruction. ADDR is
- the target location in the target machine. CONTENTS_CACHE is a
- pointer to memory allocated for saving the target contents. It is
- guaranteed by the caller to be long enough to save the breakpoint
- length returned by BREAKPOINT_FROM_PC. */
+ the target location in the target machine. BPT is the breakpoint
+ being inserted or removed, which contains memory for saving the
+ target contents. */
static int
-mips_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
+mips_insert_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
if (monitor_supports_breakpoints)
return set_breakpoint (addr, MIPS_INSN32_SIZE, BREAK_FETCH);
else
- return memory_insert_breakpoint (addr, contents_cache);
+ return memory_insert_breakpoint (addr, bpt);
}
static int
-mips_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
+mips_remove_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
if (monitor_supports_breakpoints)
return clear_breakpoint (addr, MIPS_INSN32_SIZE, BREAK_FETCH);
else
- return memory_remove_breakpoint (addr, contents_cache);
+ return memory_remove_breakpoint (addr, bpt);
}
/* Tell whether this target can support a hardware breakpoint. CNT
Index: remote-rdp.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-rdp.c,v
retrieving revision 1.49
diff -u -p -r1.49 remote-rdp.c
--- remote-rdp.c 3 Mar 2006 23:08:12 -0000 1.49
+++ remote-rdp.c 11 Apr 2006 21:16:40 -0000
@@ -1050,7 +1050,7 @@ rdp_execute (void)
}
static int
-remote_rdp_insert_breakpoint (CORE_ADDR addr, bfd_byte *save)
+remote_rdp_insert_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
int res;
if (ds.rdi_level > 0)
@@ -1059,7 +1059,7 @@ remote_rdp_insert_breakpoint (CORE_ADDR
RDP_SET_BREAK,
addr,
RDP_SET_BREAK_TYPE_PC_EQUAL | RDP_SET_BREAK_TYPE_GET_HANDLE,
- save,
+ bpt->shadow_contents,
&res);
}
else
@@ -1074,14 +1074,14 @@ remote_rdp_insert_breakpoint (CORE_ADDR
}
static int
-remote_rdp_remove_breakpoint (CORE_ADDR addr, bfd_byte *save)
+remote_rdp_remove_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
int res;
if (ds.rdi_level > 0)
{
send_rdp ("b-p-S-B",
RDP_CLEAR_BREAK,
- save, 4,
+ bpt->shadow_contents, 4,
&res);
}
else
@@ -1108,12 +1108,12 @@ rdp_step (void)
}
else
{
- char handle[4];
+ struct breakpoint *b;
CORE_ADDR pc = read_register (ARM_PC_REGNUM);
pc = arm_get_next_pc (pc);
- remote_rdp_insert_breakpoint (pc, handle);
+ b = deprecated_insert_raw_breakpoint (pc);
rdp_execute ();
- remote_rdp_remove_breakpoint (pc, handle);
+ deprecated_remove_raw_breakpoint (b);
}
}
Index: remote-sds.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-sds.c,v
retrieving revision 1.42
diff -u -p -r1.42 remote-sds.c
--- remote-sds.c 24 Jan 2006 22:09:28 -0000 1.42
+++ remote-sds.c 11 Apr 2006 21:16:40 -0000
@@ -99,10 +99,6 @@ static void interrupt_query (void);
static int read_frame (char *);
-static int sds_insert_breakpoint (CORE_ADDR, char *);
-
-static int sds_remove_breakpoint (CORE_ADDR, char *);
-
static void init_sds_ops (void);
static void sds_command (char *args, int from_tty);
@@ -1004,7 +1000,7 @@ sds_load (char *filename, int from_tty)
replaced instruction back to the debugger. */
static int
-sds_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
+sds_insert_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
int i, retlen;
unsigned char *p, buf[PBUFSIZ];
@@ -1020,13 +1016,13 @@ sds_insert_breakpoint (CORE_ADDR addr, c
retlen = sds_send (buf, p - buf);
for (i = 0; i < 4; ++i)
- contents_cache[i] = buf[i + 2];
+ bpt->shadow_contents[i] = buf[i + 2];
return 0;
}
static int
-sds_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
+sds_remove_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
int i, retlen;
unsigned char *p, buf[PBUFSIZ];
@@ -1039,7 +1035,7 @@ sds_remove_breakpoint (CORE_ADDR addr, c
*p++ = (int) (addr >> 8) & 0xff;
*p++ = (int) (addr) & 0xff;
for (i = 0; i < 4; ++i)
- *p++ = contents_cache[i];
+ *p++ = bpt->shadow_contents[i];
retlen = sds_send (buf, p - buf);
Index: remote-sim.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-sim.c,v
retrieving revision 1.53
diff -u -p -r1.53 remote-sim.c
--- remote-sim.c 21 Feb 2006 18:22:26 -0000 1.53
+++ remote-sim.c 11 Apr 2006 21:16:40 -0000
@@ -805,18 +805,6 @@ gdbsim_mourn_inferior (void)
generic_mourn_inferior ();
}
-static int
-gdbsim_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
-{
- return memory_insert_breakpoint (addr, contents_cache);
-}
-
-static int
-gdbsim_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
-{
- return memory_remove_breakpoint (addr, contents_cache);
-}
-
/* Pass the command argument through to the simulator verbatim. The
simulator must do any command interpretation work. */
@@ -866,8 +854,8 @@ init_gdbsim_ops (void)
gdbsim_ops.to_prepare_to_store = gdbsim_prepare_to_store;
gdbsim_ops.deprecated_xfer_memory = gdbsim_xfer_inferior_memory;
gdbsim_ops.to_files_info = gdbsim_files_info;
- gdbsim_ops.to_insert_breakpoint = gdbsim_insert_breakpoint;
- gdbsim_ops.to_remove_breakpoint = gdbsim_remove_breakpoint;
+ gdbsim_ops.to_insert_breakpoint = memory_insert_breakpoint;
+ gdbsim_ops.to_remove_breakpoint = memory_remove_breakpoint;
gdbsim_ops.to_kill = gdbsim_kill;
gdbsim_ops.to_load = gdbsim_load;
gdbsim_ops.to_create_inferior = gdbsim_create_inferior;
Index: remote-st.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-st.c,v
retrieving revision 1.30
diff -u -p -r1.30 remote-st.c
--- remote-st.c 10 Feb 2006 22:01:43 -0000 1.30
+++ remote-st.c 11 Apr 2006 21:16:40 -0000
@@ -599,20 +599,15 @@ static CORE_ADDR breakaddr[MAX_STDEBUG_B
{0};
static int
-st2000_insert_breakpoint (CORE_ADDR addr, char *shadow)
+st2000_insert_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
int i;
- CORE_ADDR bp_addr = addr;
- int bp_size = 0;
-
- BREAKPOINT_FROM_PC (&bp_addr, &bp_size);
for (i = 0; i <= MAX_STDEBUG_BREAKPOINTS; i++)
if (breakaddr[i] == 0)
{
breakaddr[i] = addr;
- st2000_read_inferior_memory (bp_addr, shadow, bp_size);
printf_stdebug ("BR %x H\r", addr);
expect_prompt (1);
return 0;
@@ -623,7 +618,7 @@ st2000_insert_breakpoint (CORE_ADDR addr
}
static int
-st2000_remove_breakpoint (CORE_ADDR addr, char *shadow)
+st2000_remove_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
int i;
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.206
diff -u -p -r1.206 remote.c
--- remote.c 7 Apr 2006 16:15:58 -0000 1.206
+++ remote.c 11 Apr 2006 21:16:41 -0000
@@ -136,10 +136,6 @@ static void skip_frame (void);
static long read_frame (char **buf_p, long *sizeof_buf);
-static int remote_insert_breakpoint (CORE_ADDR, bfd_byte *);
-
-static int remote_remove_breakpoint (CORE_ADDR, bfd_byte *);
-
static int hexnumlen (ULONGEST num);
static void init_remote_ops (void);
@@ -4359,19 +4355,17 @@ static unsigned char little_break_insn[]
/* Insert a breakpoint on targets that don't have any better
breakpoint support. We read the contents of the target location
and stash it, then overwrite it with a breakpoint instruction.
- ADDR is the target location in the target machine. CONTENTS_CACHE
- is a pointer to memory allocated for saving the target contents.
- It is guaranteed by the caller to be long enough to save the number
- of bytes returned by BREAKPOINT_FROM_PC. */
+ ADDR is the target location in the target machine. BPT is the breakpoint
+ being inserted or removed, which contains memory for saving the
+ target contents. */
static int
-remote_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+remote_insert_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
struct remote_state *rs = get_remote_state ();
#ifdef DEPRECATED_REMOTE_BREAKPOINT
int val;
#endif
- int bp_size;
/* Try the "Z" s/w breakpoint packet if it is not already disabled.
If it succeeds, then set the support to PACKET_ENABLE. If it
@@ -4382,13 +4376,14 @@ remote_insert_breakpoint (CORE_ADDR addr
{
char *p = rs->buf;
- addr = remote_address_masked (addr);
*(p++) = 'Z';
*(p++) = '0';
*(p++) = ',';
- p += hexnumstr (p, (ULONGEST) addr);
- BREAKPOINT_FROM_PC (&addr, &bp_size);
- sprintf (p, ",%d", bp_size);
+ bpt->placed_address = addr;
+ BREAKPOINT_FROM_PC (&bpt->placed_address, &bpt->placed_size);
+ addr = (ULONGEST) remote_address_masked (bpt->placed_address);
+ p += hexnumstr (p, addr);
+ sprintf (p, ",%d", bpt->placed_size);
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
@@ -4405,7 +4400,7 @@ remote_insert_breakpoint (CORE_ADDR addr
}
#ifdef DEPRECATED_REMOTE_BREAKPOINT
- val = target_read_memory (addr, contents_cache, sizeof big_break_insn);
+ val = target_read_memory (addr, bpt->shadow_contents, sizeof big_break_insn);
if (val == 0)
{
@@ -4419,12 +4414,12 @@ remote_insert_breakpoint (CORE_ADDR addr
return val;
#else
- return memory_insert_breakpoint (addr, contents_cache);
+ return memory_insert_breakpoint (addr, bpt);
#endif /* DEPRECATED_REMOTE_BREAKPOINT */
}
static int
-remote_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+remote_remove_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
struct remote_state *rs = get_remote_state ();
int bp_size;
@@ -4437,10 +4432,9 @@ remote_remove_breakpoint (CORE_ADDR addr
*(p++) = '0';
*(p++) = ',';
- addr = remote_address_masked (addr);
- p += hexnumstr (p, (ULONGEST) addr);
- BREAKPOINT_FROM_PC (&addr, &bp_size);
- sprintf (p, ",%d", bp_size);
+ addr = (ULONGEST) remote_address_masked (bpt->placed_address);
+ p += hexnumstr (p, addr);
+ sprintf (p, ",%d", bpt->placed_size);
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
@@ -4449,9 +4443,9 @@ remote_remove_breakpoint (CORE_ADDR addr
}
#ifdef DEPRECATED_REMOTE_BREAKPOINT
- return target_write_memory (addr, contents_cache, sizeof big_break_insn);
+ return target_write_memory (addr, bpt->shadow_contents, sizeof big_break_insn);
#else
- return memory_remove_breakpoint (addr, contents_cache);
+ return memory_remove_breakpoint (addr, bpt);
#endif /* DEPRECATED_REMOTE_BREAKPOINT */
}
@@ -4595,16 +4589,16 @@ remote_stopped_data_address (struct targ
static int
-remote_insert_hw_breakpoint (CORE_ADDR addr, gdb_byte *shadow)
+remote_insert_hw_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
- int len = 0;
struct remote_state *rs = get_remote_state ();
char *p = rs->buf;
/* The length field should be set to the size of a breakpoint
instruction. */
- BREAKPOINT_FROM_PC (&addr, &len);
+ bpt->placed_address = addr;
+ BREAKPOINT_FROM_PC (&bpt->placed_address, &bpt->placed_size);
if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE)
error (_("Can't set hardware breakpoint without the '%s' (%s) packet."),
@@ -4615,9 +4609,9 @@ remote_insert_hw_breakpoint (CORE_ADDR a
*(p++) = '1';
*(p++) = ',';
- addr = remote_address_masked (addr);
+ addr = remote_address_masked (bpt->placed_address);
p += hexnumstr (p, (ULONGEST) addr);
- sprintf (p, ",%x", len);
+ sprintf (p, ",%x", bpt->placed_size);
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
@@ -4636,17 +4630,14 @@ remote_insert_hw_breakpoint (CORE_ADDR a
static int
-remote_remove_hw_breakpoint (CORE_ADDR addr, gdb_byte *shadow)
+remote_remove_hw_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
- int len;
struct remote_state *rs = get_remote_state ();
char *p = rs->buf;
/* The length field should be set to the size of a breakpoint
instruction. */
- BREAKPOINT_FROM_PC (&addr, &len);
-
if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE)
error (_("Can't clear hardware breakpoint without the '%s' (%s) packet."),
remote_protocol_packets[PACKET_Z1].name,
@@ -4656,9 +4647,9 @@ remote_remove_hw_breakpoint (CORE_ADDR a
*(p++) = '1';
*(p++) = ',';
- addr = remote_address_masked (addr);
+ addr = remote_address_masked (bpt->placed_address);
p += hexnumstr (p, (ULONGEST) addr);
- sprintf (p, ",%x", len);
+ sprintf (p, ",%x", bpt->placed_size);
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
Index: rs6000-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-nat.c,v
retrieving revision 1.60
diff -u -p -r1.60 rs6000-nat.c
--- rs6000-nat.c 17 Dec 2005 22:34:02 -0000 1.60
+++ rs6000-nat.c 11 Apr 2006 21:16:41 -0000
@@ -527,15 +527,15 @@ exec_one_dummy_insn (void)
{
#define DUMMY_INSN_ADDR (TEXT_SEGMENT_BASE)+0x200
- char shadow_contents[BREAKPOINT_MAX]; /* Stash old bkpt addr contents */
int ret, status, pid;
CORE_ADDR prev_pc;
+ struct breakpoint *b;
/* We plant one dummy breakpoint into DUMMY_INSN_ADDR address. We
assume that this address will never be executed again by the real
code. */
- target_insert_breakpoint (DUMMY_INSN_ADDR, shadow_contents);
+ b = deprecated_insert_raw_breakpoint (DUMMY_INSN_ADDR);
/* You might think this could be done with a single ptrace call, and
you'd be correct for just about every platform I've ever worked
@@ -559,7 +559,7 @@ exec_one_dummy_insn (void)
while (pid != PIDGET (inferior_ptid));
write_pc (prev_pc);
- target_remove_breakpoint (DUMMY_INSN_ADDR, shadow_contents);
+ deprecated_remove_raw_breakpoint (b);
}
/* Fetch registers from the register section in core bfd. */
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.256
diff -u -p -r1.256 rs6000-tdep.c
--- rs6000-tdep.c 10 Feb 2006 20:56:14 -0000 1.256
+++ rs6000-tdep.c 11 Apr 2006 21:16:41 -0000
@@ -110,17 +110,6 @@ struct reg
register number. */
};
-/* Breakpoint shadows for the single step instructions will be kept here. */
-
-static struct sstep_breaks
-{
- /* Address, or 0 if this is not in use. */
- CORE_ADDR address;
- /* Shadow contents. */
- gdb_byte data[4];
-}
-stepBreaks[2];
-
/* Hook for determining the TOC address when calling functions in the
inferior under AIX. The initialization code in rs6000-nat.c sets
this hook to point to find_toc_address. */
@@ -730,7 +719,6 @@ rs6000_software_single_step (enum target
if (insert_breakpoints_p)
{
-
loc = read_pc ();
insn = read_memory_integer (loc, 4);
@@ -743,28 +731,17 @@ rs6000_software_single_step (enum target
if (breaks[1] == breaks[0])
breaks[1] = -1;
- stepBreaks[1].address = 0;
-
for (ii = 0; ii < 2; ++ii)
{
-
/* ignore invalid breakpoint. */
if (breaks[ii] == -1)
continue;
- target_insert_breakpoint (breaks[ii], stepBreaks[ii].data);
- stepBreaks[ii].address = breaks[ii];
+ insert_single_step_breakpoint (breaks[ii]);
}
-
}
else
- {
+ remove_single_step_breakpoints ();
- /* remove step breakpoints. */
- for (ii = 0; ii < 2; ++ii)
- if (stepBreaks[ii].address != 0)
- target_remove_breakpoint (stepBreaks[ii].address,
- stepBreaks[ii].data);
- }
errno = 0; /* FIXME, don't ignore errors! */
/* What errors? {read,write}_memory call error(). */
}
Index: sol-thread.c
===================================================================
RCS file: /cvs/src/src/gdb/sol-thread.c,v
retrieving revision 1.51
diff -u -p -r1.51 sol-thread.c
--- sol-thread.c 17 Dec 2005 22:34:02 -0000 1.51
+++ sol-thread.c 11 Apr 2006 21:16:42 -0000
@@ -1524,7 +1524,7 @@ sol_make_note_section (bfd *obfd, int *n
}
static int
-ignore (CORE_ADDR addr, gdb_byte *contents)
+ignore (CORE_ADDR addr, struct bp_location *bpt)
{
return 0;
}
Index: solib-irix.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-irix.c,v
retrieving revision 1.9
diff -u -p -r1.9 solib-irix.c
--- solib-irix.c 17 Dec 2005 22:34:02 -0000 1.9
+++ solib-irix.c 11 Apr 2006 21:16:42 -0000
@@ -227,10 +227,9 @@ fetch_lm_info (CORE_ADDR addr)
/* The symbol which starts off the list of shared libraries. */
#define DEBUG_BASE "__rld_obj_head"
-char shadow_contents[BREAKPOINT_MAX]; /* Stash old bkpt addr contents */
+static struct breakpoint *base_breakpoint;
static CORE_ADDR debug_base; /* Base of dynamic linker structures */
-static CORE_ADDR breakpoint_addr; /* Address where end bkpt is set */
/*
@@ -319,11 +318,13 @@ disable_break (void)
/* Note that breakpoint address and original contents are in our address
space, so we just need to write the original contents back. */
- if (memory_remove_breakpoint (breakpoint_addr, shadow_contents) != 0)
+ if (deprecated_remove_raw_breakpoint (base_breakpoint) != 0)
{
status = 0;
}
+ base_breakpoint = NULL;
+
/* Note that it is possible that we have stopped at a location that
is different from the location where we inserted our breakpoint.
On mips-irix, we can actually land in __dbx_init(), so we should
@@ -352,12 +353,13 @@ disable_break (void)
static int
enable_break (void)
{
- if (symfile_objfile != NULL
- && target_insert_breakpoint (entry_point_address (),
- shadow_contents) == 0)
+ if (symfile_objfile != NULL)
{
- breakpoint_addr = entry_point_address ();
- return 1;
+ base_breakpoint
+ = deprecated_insert_raw_breakpoint (entry_point_address ());
+
+ if (base_breakpoint != NULL)
+ return 1;
}
return 0;
Index: sparc-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc-tdep.c,v
retrieving revision 1.171
diff -u -p -r1.171 sparc-tdep.c
--- sparc-tdep.c 9 Apr 2006 08:22:43 -0000 1.171
+++ sparc-tdep.c 11 Apr 2006 21:16:42 -0000
@@ -1136,8 +1136,7 @@ sparc_software_single_step (enum target_
{
struct gdbarch *arch = current_gdbarch;
struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
- static CORE_ADDR npc, nnpc;
- static gdb_byte npc_save[4], nnpc_save[4];
+ CORE_ADDR npc, nnpc;
if (insert_breakpoints_p)
{
@@ -1149,9 +1148,10 @@ sparc_software_single_step (enum target_
/* Analyze the instruction at PC. */
nnpc = sparc_analyze_control_transfer (arch, pc, &npc);
if (npc != 0)
- target_insert_breakpoint (npc, npc_save);
+ insert_single_step_breakpoint (npc);
+
if (nnpc != 0)
- target_insert_breakpoint (nnpc, nnpc_save);
+ insert_single_step_breakpoint (nnpc);
/* Assert that we have set at least one breakpoint, and that
they're not set at the same spot - unless we're going
@@ -1160,12 +1160,7 @@ sparc_software_single_step (enum target_
gdb_assert (nnpc != npc || orig_npc == 0);
}
else
- {
- if (npc != 0)
- target_remove_breakpoint (npc, npc_save);
- if (nnpc != 0)
- target_remove_breakpoint (nnpc, nnpc_save);
- }
+ remove_single_step_breakpoints ();
}
static void
Index: target.c
===================================================================
RCS file: /cvs/src/src/gdb/target.c,v
retrieving revision 1.117
diff -u -p -r1.117 target.c
--- target.c 17 Mar 2006 00:30:34 -0000 1.117
+++ target.c 11 Apr 2006 21:16:42 -0000
@@ -111,15 +111,15 @@ static void debug_to_prepare_to_store (v
static void debug_to_files_info (struct target_ops *);
-static int debug_to_insert_breakpoint (CORE_ADDR, gdb_byte *);
+static int debug_to_insert_breakpoint (CORE_ADDR, struct bp_location *);
-static int debug_to_remove_breakpoint (CORE_ADDR, gdb_byte *);
+static int debug_to_remove_breakpoint (CORE_ADDR, struct bp_location *);
static int debug_to_can_use_hw_breakpoint (int, int, int);
-static int debug_to_insert_hw_breakpoint (CORE_ADDR, gdb_byte *);
+static int debug_to_insert_hw_breakpoint (CORE_ADDR, struct bp_location *);
-static int debug_to_remove_hw_breakpoint (CORE_ADDR, gdb_byte *);
+static int debug_to_remove_hw_breakpoint (CORE_ADDR, struct bp_location *);
static int debug_to_insert_watchpoint (CORE_ADDR, int, int);
@@ -515,10 +515,10 @@ update_current_target (void)
(int (*) (int, int, int))
return_zero);
de_fault (to_insert_hw_breakpoint,
- (int (*) (CORE_ADDR, gdb_byte *))
+ (int (*) (CORE_ADDR, struct bp_location *))
return_minus_one);
de_fault (to_remove_hw_breakpoint,
- (int (*) (CORE_ADDR, gdb_byte *))
+ (int (*) (CORE_ADDR, struct bp_location *))
return_minus_one);
de_fault (to_insert_watchpoint,
(int (*) (CORE_ADDR, int, int))
@@ -2075,11 +2075,11 @@ debug_to_files_info (struct target_ops *
}
static int
-debug_to_insert_breakpoint (CORE_ADDR addr, gdb_byte *save)
+debug_to_insert_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
int retval;
- retval = debug_target.to_insert_breakpoint (addr, save);
+ retval = debug_target.to_insert_breakpoint (addr, bpt);
fprintf_unfiltered (gdb_stdlog,
"target_insert_breakpoint (0x%lx, xxx) = %ld\n",
@@ -2089,11 +2089,11 @@ debug_to_insert_breakpoint (CORE_ADDR ad
}
static int
-debug_to_remove_breakpoint (CORE_ADDR addr, gdb_byte *save)
+debug_to_remove_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
int retval;
- retval = debug_target.to_remove_breakpoint (addr, save);
+ retval = debug_target.to_remove_breakpoint (addr, bpt);
fprintf_unfiltered (gdb_stdlog,
"target_remove_breakpoint (0x%lx, xxx) = %ld\n",
@@ -2161,11 +2161,11 @@ debug_to_stopped_data_address (struct ta
}
static int
-debug_to_insert_hw_breakpoint (CORE_ADDR addr, gdb_byte *save)
+debug_to_insert_hw_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
int retval;
- retval = debug_target.to_insert_hw_breakpoint (addr, save);
+ retval = debug_target.to_insert_hw_breakpoint (addr, bpt);
fprintf_unfiltered (gdb_stdlog,
"target_insert_hw_breakpoint (0x%lx, xxx) = %ld\n",
@@ -2175,11 +2175,11 @@ debug_to_insert_hw_breakpoint (CORE_ADDR
}
static int
-debug_to_remove_hw_breakpoint (CORE_ADDR addr, gdb_byte *save)
+debug_to_remove_hw_breakpoint (CORE_ADDR addr, struct bp_location *bpt)
{
int retval;
- retval = debug_target.to_remove_hw_breakpoint (addr, save);
+ retval = debug_target.to_remove_hw_breakpoint (addr, bpt);
fprintf_unfiltered (gdb_stdlog,
"target_remove_hw_breakpoint (0x%lx, xxx) = %ld\n",
Index: target.h
===================================================================
RCS file: /cvs/src/src/gdb/target.h,v
retrieving revision 1.81
diff -u -p -r1.81 target.h
--- target.h 21 Feb 2006 18:22:26 -0000 1.81
+++ target.h 11 Apr 2006 21:16:42 -0000
@@ -30,6 +30,7 @@ struct objfile;
struct ui_file;
struct mem_attrib;
struct target_ops;
+struct bp_location;
/* This include file defines the interface between the main part
of the debugger, and the part which is target-specific, or
@@ -336,11 +337,11 @@ struct target_ops
struct target_ops *target);
void (*to_files_info) (struct target_ops *);
- int (*to_insert_breakpoint) (CORE_ADDR, gdb_byte *);
- int (*to_remove_breakpoint) (CORE_ADDR, gdb_byte *);
+ int (*to_insert_breakpoint) (CORE_ADDR, struct bp_location *);
+ int (*to_remove_breakpoint) (CORE_ADDR, struct bp_location *);
int (*to_can_use_hw_breakpoint) (int, int, int);
- int (*to_insert_hw_breakpoint) (CORE_ADDR, gdb_byte *);
- int (*to_remove_hw_breakpoint) (CORE_ADDR, gdb_byte *);
+ int (*to_insert_hw_breakpoint) (CORE_ADDR, struct bp_location *);
+ int (*to_remove_hw_breakpoint) (CORE_ADDR, struct bp_location *);
int (*to_remove_watchpoint) (CORE_ADDR, int, int);
int (*to_insert_watchpoint) (CORE_ADDR, int, int);
int (*to_stopped_by_watchpoint) (void);
@@ -612,22 +613,23 @@ extern void print_section_info (struct t
#define target_files_info() \
(*current_target.to_files_info) (¤t_target)
-/* Insert a breakpoint at address ADDR in the target machine. SAVE is
- a pointer to memory allocated for saving the target contents. It
- is guaranteed by the caller to be long enough to save the number of
- breakpoint bytes indicated by BREAKPOINT_FROM_PC. Result is 0 for
- success, or an errno value. */
+/* Insert a breakpoint at address ADDR in the target machine. BPT is
+ a struct bp_location *, which contains some memory for saving the
+ target contents. It is guaranteed to be long enough to save the
+ number of breakpoint bytes indicated by BREAKPOINT_FROM_PC. Result
+ is 0 for success, or an errno value. */
-#define target_insert_breakpoint(addr, save) \
- (*current_target.to_insert_breakpoint) (addr, save)
+#define target_insert_breakpoint(addr, bpt) \
+ (*current_target.to_insert_breakpoint) (addr, bpt)
/* Remove a breakpoint at address ADDR in the target machine.
- SAVE is a pointer to the same save area
+ BPT is a pointer to the same save area
that was previously passed to target_insert_breakpoint.
+
Result is 0 for success, or an errno value. */
-#define target_remove_breakpoint(addr, save) \
- (*current_target.to_remove_breakpoint) (addr, save)
+#define target_remove_breakpoint(addr, bpt) \
+ (*current_target.to_remove_breakpoint) (addr, bpt)
/* Initialize the terminal settings we record for the inferior,
before we actually run the inferior. */
@@ -1057,11 +1059,11 @@ extern void (*deprecated_target_new_objf
#endif
#ifndef target_insert_hw_breakpoint
-#define target_insert_hw_breakpoint(addr, save) \
- (*current_target.to_insert_hw_breakpoint) (addr, save)
+#define target_insert_hw_breakpoint(addr, bpt) \
+ (*current_target.to_insert_hw_breakpoint) (addr, bpt)
-#define target_remove_hw_breakpoint(addr, save) \
- (*current_target.to_remove_hw_breakpoint) (addr, save)
+#define target_remove_hw_breakpoint(addr, bpt) \
+ (*current_target.to_remove_hw_breakpoint) (addr, bpt)
#endif
extern int target_stopped_data_address_p (struct target_ops *);
@@ -1142,13 +1144,13 @@ struct section_table *target_section_by_
/* From mem-break.c */
-extern int memory_remove_breakpoint (CORE_ADDR, gdb_byte *);
+extern int memory_remove_breakpoint (CORE_ADDR, struct bp_location *);
-extern int memory_insert_breakpoint (CORE_ADDR, gdb_byte *);
+extern int memory_insert_breakpoint (CORE_ADDR, struct bp_location *);
-extern int default_memory_remove_breakpoint (CORE_ADDR, gdb_byte *);
+extern int default_memory_remove_breakpoint (CORE_ADDR, struct bp_location *);
-extern int default_memory_insert_breakpoint (CORE_ADDR, gdb_byte *);
+extern int default_memory_insert_breakpoint (CORE_ADDR, struct bp_location *);
/* From target.c */
Index: wince.c
===================================================================
RCS file: /cvs/src/src/gdb/wince.c,v
retrieving revision 1.44
diff -u -p -r1.44 wince.c
--- wince.c 24 Jan 2006 22:09:28 -0000 1.44
+++ wince.c 11 Apr 2006 21:16:43 -0000
@@ -146,7 +146,6 @@ typedef struct thread_info_struct
int suspend_count;
int stepped; /* True if stepped. */
CORE_ADDR step_pc;
- unsigned long step_prev;
CONTEXT context;
}
thread_info;
@@ -834,7 +833,7 @@ undoSStep (thread_info * th)
{
if (th->stepped)
{
- memory_remove_breakpoint (th->step_pc, (void *) &th->step_prev);
+ remove_single_step_breakpoints ();
th->stepped = 0;
}
}
@@ -857,8 +856,7 @@ wince_software_single_step (enum target_
th->stepped = 1;
pc = read_register (PC_REGNUM);
th->step_pc = mips_next_pc (pc);
- th->step_prev = 0;
- memory_insert_breakpoint (th->step_pc, (void *) &th->step_prev);
+ insert_single_step_breakpoint (th->step_pc);
return;
}
#elif SHx
@@ -971,7 +969,7 @@ undoSStep (thread_info * th)
{
if (th->stepped)
{
- memory_remove_breakpoint (th->step_pc, (void *) &th->step_prev);
+ remove_single_step_breakpoints ();
th->stepped = 0;
}
return;
@@ -996,8 +994,7 @@ wince_software_single_step (enum target_
th->stepped = 1;
th->step_pc = sh_get_next_pc (&th->context);
- th->step_prev = 0;
- memory_insert_breakpoint (th->step_pc, (void *) &th->step_prev);
+ insert_single_step_breakpoint (th->step_pc);
return;
}
#elif defined (ARM)
@@ -1024,7 +1021,7 @@ undoSStep (thread_info * th)
{
if (th->stepped)
{
- memory_remove_breakpoint (th->step_pc, (void *) &th->step_prev);
+ remove_single_step_breakpoints ();
th->stepped = 0;
}
}
@@ -1047,8 +1044,7 @@ wince_software_single_step (enum target_
th->stepped = 1;
pc = read_register (PC_REGNUM);
th->step_pc = arm_get_next_pc (pc);
- th->step_prev = 0;
- memory_insert_breakpoint (th->step_pc, (void *) &th->step_prev);
+ insert_single_step_breakpoint (th->step_pc);
return;
}
#endif
Index: config/i386/nm-i386.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/nm-i386.h,v
retrieving revision 1.7
diff -u -p -r1.7 nm-i386.h
--- config/i386/nm-i386.h 8 Oct 2004 17:30:48 -0000 1.7
+++ config/i386/nm-i386.h 11 Apr 2006 21:16:43 -0000
@@ -52,13 +52,16 @@ extern int i386_stopped_by_hwbp (void);
true. Otherwise, return false. */
extern int i386_stopped_data_address (CORE_ADDR *);
-/* Insert a hardware-assisted breakpoint at address ADDR. SHADOW is
+/* Insert a hardware-assisted breakpoint at address ADDR. BPT is
unused. Return 0 on success, EBUSY on failure. */
-extern int i386_insert_hw_breakpoint (CORE_ADDR addr, void *shadow);
+struct bp_location;
+extern int i386_insert_hw_breakpoint (CORE_ADDR addr,
+ struct bp_location *bpt);
-/* Remove a hardware-assisted breakpoint at address ADDR. SHADOW is
+/* Remove a hardware-assisted breakpoint at address ADDR. BPT is
unused. Return 0 on success, -1 on failure. */
-extern int i386_remove_hw_breakpoint (CORE_ADDR addr, void *shadow);
+extern int i386_remove_hw_breakpoint (CORE_ADDR addr,
+ struct bp_location *bpt);
/* Returns the number of hardware watchpoints of type TYPE that we can
set. Value is positive if we can set CNT watchpoints, zero if
@@ -105,11 +108,11 @@ extern int i386_stopped_by_watchpoint (v
#define target_remove_watchpoint(addr, len, type) \
i386_remove_watchpoint (addr, len, type)
-#define target_insert_hw_breakpoint(addr, shadow) \
- i386_insert_hw_breakpoint (addr, shadow)
+#define target_insert_hw_breakpoint(addr, bpt) \
+ i386_insert_hw_breakpoint (addr, bpt)
-#define target_remove_hw_breakpoint(addr, shadow) \
- i386_remove_hw_breakpoint (addr, shadow)
+#define target_remove_hw_breakpoint(addr, bpt) \
+ i386_remove_hw_breakpoint (addr, bpt)
/* child_post_startup_inferior used to
reset all debug registers by calling i386_cleanup_dregs (). */
Index: doc/gdbint.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v
retrieving revision 1.240
diff -u -p -r1.240 gdbint.texinfo
--- doc/gdbint.texinfo 28 Mar 2006 19:19:16 -0000 1.240
+++ doc/gdbint.texinfo 11 Apr 2006 21:16:44 -0000
@@ -660,10 +660,11 @@ These two macros should return 0 for suc
@cindex insert or remove hardware breakpoint
@findex target_remove_hw_breakpoint
@findex target_insert_hw_breakpoint
-@item target_remove_hw_breakpoint (@var{addr}, @var{shadow})
-@itemx target_insert_hw_breakpoint (@var{addr}, @var{shadow})
+@item target_remove_hw_breakpoint (@var{addr}, @var{bpt})
+@itemx target_insert_hw_breakpoint (@var{addr}, @var{bpt})
Insert or remove a hardware-assisted breakpoint at address @var{addr}.
-Returns zero for success, non-zero for failure. @var{shadow} is the
+Returns zero for success, non-zero for failure. @var{bpt} is the
+breakpoint location. @code{@var{bpt}->shadow_contents} is the
real contents of the byte where the breakpoint has been inserted; it
is generally not valid when hardware breakpoints are used, but since
no other code touches these values, the implementations of the above
@@ -858,8 +859,8 @@ the count goes to zero.
@findex i386_insert_hw_breakpoint
@findex i386_remove_hw_breakpoint
-@item i386_insert_hw_breakpoint (@var{addr}, @var{shadow}
-@itemx i386_remove_hw_breakpoint (@var{addr}, @var{shadow})
+@item i386_insert_hw_breakpoint (@var{addr}, @var{bpt})
+@itemx i386_remove_hw_breakpoint (@var{addr}, @var{bpt})
These functions insert and remove hardware-assisted breakpoints. The
macros @code{target_insert_hw_breakpoint} and
@code{target_remove_hw_breakpoint} are set to call these functions.
@@ -3229,8 +3230,8 @@ instruction of the architecture.
Replaces all the other @var{BREAKPOINT} macros.
-@item MEMORY_INSERT_BREAKPOINT (@var{addr}, @var{contents_cache})
-@itemx MEMORY_REMOVE_BREAKPOINT (@var{addr}, @var{contents_cache})
+@item MEMORY_INSERT_BREAKPOINT (@var{addr}, @var{bpt})
+@itemx MEMORY_REMOVE_BREAKPOINT (@var{addr}, @var{len}, @var{bpt})
@findex MEMORY_REMOVE_BREAKPOINT
@findex MEMORY_INSERT_BREAKPOINT
Insert or remove memory based breakpoints. Reasonable defaults
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-11 21:46 ` Daniel Jacobowitz
@ 2006-04-11 22:32 ` David S. Miller
2006-04-12 7:30 ` Eli Zaretskii
2006-04-12 9:44 ` Mark Kettenis
2 siblings, 0 replies; 52+ messages in thread
From: David S. Miller @ 2006-04-11 22:32 UTC (permalink / raw)
To: drow; +Cc: mark.kettenis, gdb-patches
From: Daniel Jacobowitz <drow@false.org>
Date: Tue, 11 Apr 2006 17:46:13 -0400
> All true. Do you like this version better? I think it's much
> more elegant. target_insert_breakpoint et al. now take the
> struct bp_location, instead of just the shadow contents cache.
> They can fill in whatever they choose.
>
> I added some helper functions for the other common breakpoint
> activities while I was there. This should consolidate all the actual
> inserting and removing of breakpoints within breakpoint.c, and
> allow future cleanups.
I've regression tested this on sparc-*-linux-gnu, no new
failures.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-11 21:46 ` Daniel Jacobowitz
2006-04-11 22:32 ` David S. Miller
@ 2006-04-12 7:30 ` Eli Zaretskii
2006-04-12 9:44 ` Mark Kettenis
2 siblings, 0 replies; 52+ messages in thread
From: Eli Zaretskii @ 2006-04-12 7:30 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
> Date: Tue, 11 Apr 2006 17:46:13 -0400
> From: Daniel Jacobowitz <drow@false.org>
> Cc: gdb-patches@sourceware.org
>
> All true. Do you like this version better? I think it's much
> more elegant. target_insert_breakpoint et al. now take the
> struct bp_location, instead of just the shadow contents cache.
> They can fill in whatever they choose.
The gdbint.texinfo patch is okay with me.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-11 21:46 ` Daniel Jacobowitz
2006-04-11 22:32 ` David S. Miller
2006-04-12 7:30 ` Eli Zaretskii
@ 2006-04-12 9:44 ` Mark Kettenis
2006-04-12 12:57 ` Daniel Jacobowitz
2 siblings, 1 reply; 52+ messages in thread
From: Mark Kettenis @ 2006-04-12 9:44 UTC (permalink / raw)
To: drow; +Cc: gdb-patches
> Date: Tue, 11 Apr 2006 17:46:13 -0400
> From: Daniel Jacobowitz <drow@false.org>
>
> On Fri, Mar 03, 2006 at 12:01:52AM +0100, Mark Kettenis wrote:
> > Yuck! It really is ugly. For one thing, I think it is a bit
> > pointless, to add a the BREAKPOINT_FROM_PC() to targets where we know
> > the length of a breakpoint instruction is fixed.
> >
> > Another thing is that I think the order of the arguments of
> > target_remove_breakpoint() is wrong. I think it makes sense to see
> > your "len" argument as the length of the saved memory. Then it is
> > more logical to make "len" the last argument of
> > target_remove_breakpoint().
> >
> > However, doesn't it make more sense to have target_insert_breakpoint()
> > save the length instead of using BREAKPOINT_FROM_PC() to ask for it?
>
> All true. Do you like this version better? I think it's much
> more elegant. target_insert_breakpoint et al. now take the
> struct bp_location, instead of just the shadow contents cache.
> They can fill in whatever they choose.
I'm very sorry Daniel, but I think this is a bad idea. Passing down
struct bp_location makes the interface between the low-level tdep code
and the high-level breakpoint code much less clear. The low-level
code really should not know about the details of the breakpoint
implementation because people will be tempted to abuse it. And
changing the breakpoint interface will become a pain because suddenly
we will need to change all targets as well.
Mark
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-12 9:44 ` Mark Kettenis
@ 2006-04-12 12:57 ` Daniel Jacobowitz
2006-04-12 18:38 ` Mark Kettenis
0 siblings, 1 reply; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-04-12 12:57 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
On Wed, Apr 12, 2006 at 11:43:34AM +0200, Mark Kettenis wrote:
> I'm very sorry Daniel, but I think this is a bad idea. Passing down
> struct bp_location makes the interface between the low-level tdep code
> and the high-level breakpoint code much less clear. The low-level
> code really should not know about the details of the breakpoint
> implementation because people will be tempted to abuse it. And
> changing the breakpoint interface will become a pain because suddenly
> we will need to change all targets as well.
Do you have a suggestion, then? I need some guidance; I've tried
several versions of this patch and you haven't liked them.
Would a new "struct bp_target_info", defined and allocated centrally
for convenience, allay this concern? [Conveniently I can do the bulk
of the changes for that with sed :-)]
I'd prefer to define and allocate it centrally, rather than completely
per-target, since the requirements of targets seem to be so similar.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-12 12:57 ` Daniel Jacobowitz
@ 2006-04-12 18:38 ` Mark Kettenis
2006-04-12 18:47 ` Daniel Jacobowitz
0 siblings, 1 reply; 52+ messages in thread
From: Mark Kettenis @ 2006-04-12 18:38 UTC (permalink / raw)
To: drow; +Cc: gdb-patches
> Date: Wed, 12 Apr 2006 08:57:13 -0400
> From: Daniel Jacobowitz <drow@false.org>
>
> On Wed, Apr 12, 2006 at 11:43:34AM +0200, Mark Kettenis wrote:
> > I'm very sorry Daniel, but I think this is a bad idea. Passing down
> > struct bp_location makes the interface between the low-level tdep code
> > and the high-level breakpoint code much less clear. The low-level
> > code really should not know about the details of the breakpoint
> > implementation because people will be tempted to abuse it. And
> > changing the breakpoint interface will become a pain because suddenly
> > we will need to change all targets as well.
>
> Do you have a suggestion, then? I need some guidance; I've tried
> several versions of this patch and you haven't liked them.
I'm sorry about that.
> Would a new "struct bp_target_info", defined and allocated centrally
> for convenience, allay this concern? [Conveniently I can do the bulk
> of the changes for that with sed :-)]
Why hide things away if all you're going to need is a buffer and a
length? I've tried really hard to see why one would need more than
that, but failed completely.
So I think we should have:
int target_insert_breakpoint(CORE_ADDR addr, gdb_byte *buf, int *size);
int target_remove_breakpoint(CORE_ADDR addr, gdb_byte *buf, int size);
> I'd prefer to define and allocate it centrally, rather than completely
> per-target, since the requirements of targets seem to be so similar.
Indeed.
Mark
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-12 18:38 ` Mark Kettenis
@ 2006-04-12 18:47 ` Daniel Jacobowitz
2006-04-13 8:12 ` Eli Zaretskii
2006-04-13 21:57 ` Michael Snyder
0 siblings, 2 replies; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-04-12 18:47 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
On Wed, Apr 12, 2006 at 08:37:22PM +0200, Mark Kettenis wrote:
> > Would a new "struct bp_target_info", defined and allocated centrally
> > for convenience, allay this concern? [Conveniently I can do the bulk
> > of the changes for that with sed :-)]
>
> Why hide things away if all you're going to need is a buffer and a
> length? I've tried really hard to see why one would need more than
> that, but failed completely.
>
> So I think we should have:
>
> int target_insert_breakpoint(CORE_ADDR addr, gdb_byte *buf, int *size);
> int target_remove_breakpoint(CORE_ADDR addr, gdb_byte *buf, int size);
And then if you come up with a reason, you're going to need to hand
edit every one of these targets again. It's not a bundle of fun. Is
that really necessary?
You need an address because the address at which the breakpoint is
inserted may not match the requested address. This happens in several
different places in the breakpoint infrastructure (I believe I counted
three disjoint hooks for it), but I am particularly looking at
BREAKPOINT_FROM_PC, which takes the PC by reference. In the ARM case,
given 0x4001, it strips the low bit off and returns a two byte
breakpoint. If we don't allow the target to save the
actually-inserted-at address, then it has to call BREAKPOINT_FROM_PC
again. It feels much more robust to me to save this address when we
initially adjust it. Here's where we inserted the breakpoint, so
that's where we should remove it from.
I can think of plenty of other places where another constant might
be useful. You might want to record which hardware breakpoint
registers were used, for instance, instead of digging around
to figure out which ones to clear. Adding a new member to
"struct bp_target" for that would be easy.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-12 18:47 ` Daniel Jacobowitz
@ 2006-04-13 8:12 ` Eli Zaretskii
2006-04-13 22:13 ` Mark Kettenis
2006-04-13 21:57 ` Michael Snyder
1 sibling, 1 reply; 52+ messages in thread
From: Eli Zaretskii @ 2006-04-13 8:12 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
> Date: Wed, 12 Apr 2006 14:47:17 -0400
> From: Daniel Jacobowitz <drow@false.org>
> Cc: gdb-patches@sourceware.org
>
> > int target_insert_breakpoint(CORE_ADDR addr, gdb_byte *buf, int *size);
> > int target_remove_breakpoint(CORE_ADDR addr, gdb_byte *buf, int size);
>
> And then if you come up with a reason, you're going to need to hand
> edit every one of these targets again. It's not a bundle of fun. Is
> that really necessary?
>
> You need an address because the address at which the breakpoint is
> inserted may not match the requested address. This happens in several
> different places in the breakpoint infrastructure (I believe I counted
> three disjoint hooks for it), but I am particularly looking at
> BREAKPOINT_FROM_PC, which takes the PC by reference. In the ARM case,
> given 0x4001, it strips the low bit off and returns a two byte
> breakpoint. If we don't allow the target to save the
> actually-inserted-at address, then it has to call BREAKPOINT_FROM_PC
> again. It feels much more robust to me to save this address when we
> initially adjust it. Here's where we inserted the breakpoint, so
> that's where we should remove it from.
>
> I can think of plenty of other places where another constant might
> be useful. You might want to record which hardware breakpoint
> registers were used, for instance, instead of digging around
> to figure out which ones to clear. Adding a new member to
> "struct bp_target" for that would be easy.
FWIW, I agree with Daniel: it is better to pass a struct than its
individual members, especially if we expect different targets to use
different members of that struct. In other words, passing a struct
eases future maintenance pains.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-12 18:47 ` Daniel Jacobowitz
2006-04-13 8:12 ` Eli Zaretskii
@ 2006-04-13 21:57 ` Michael Snyder
2006-04-13 22:59 ` Daniel Jacobowitz
2006-04-16 23:50 ` Mark Kettenis
1 sibling, 2 replies; 52+ messages in thread
From: Michael Snyder @ 2006-04-13 21:57 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Mark Kettenis, gdb-patches
Daniel Jacobowitz wrote:
> On Wed, Apr 12, 2006 at 08:37:22PM +0200, Mark Kettenis wrote:
>
>>>Would a new "struct bp_target_info", defined and allocated centrally
>>>for convenience, allay this concern? [Conveniently I can do the bulk
>>>of the changes for that with sed :-)]
>>
>>Why hide things away if all you're going to need is a buffer and a
>>length? I've tried really hard to see why one would need more than
>>that, but failed completely.
>>
>>So I think we should have:
>>
>>int target_insert_breakpoint(CORE_ADDR addr, gdb_byte *buf, int *size);
>>int target_remove_breakpoint(CORE_ADDR addr, gdb_byte *buf, int size);
>
>
> And then if you come up with a reason, you're going to need to hand
> edit every one of these targets again. It's not a bundle of fun. Is
> that really necessary?
>
> You need an address because the address at which the breakpoint is
> inserted may not match the requested address. This happens in several
> different places in the breakpoint infrastructure (I believe I counted
> three disjoint hooks for it), but I am particularly looking at
> BREAKPOINT_FROM_PC, which takes the PC by reference. In the ARM case,
> given 0x4001, it strips the low bit off and returns a two byte
> breakpoint. If we don't allow the target to save the
> actually-inserted-at address, then it has to call BREAKPOINT_FROM_PC
> again. It feels much more robust to me to save this address when we
> initially adjust it. Here's where we inserted the breakpoint, so
> that's where we should remove it from.
>
> I can think of plenty of other places where another constant might
> be useful. You might want to record which hardware breakpoint
> registers were used, for instance, instead of digging around
> to figure out which ones to clear. Adding a new member to
> "struct bp_target" for that would be easy.
I haven't followed this discussion closely, so forgive me
if I'm recapitulating something that's already been said.
What about something like "void *target_data" in the breakpoint struct?
The target can add whatever it likes, and the core breakpoint code
doesn't need to know what it is. If it's non-null when the bp is
freed, then the target should be given an opportunity to delete it.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-13 8:12 ` Eli Zaretskii
@ 2006-04-13 22:13 ` Mark Kettenis
2006-04-13 22:59 ` Daniel Jacobowitz
2006-04-14 8:04 ` Eli Zaretskii
0 siblings, 2 replies; 52+ messages in thread
From: Mark Kettenis @ 2006-04-13 22:13 UTC (permalink / raw)
To: eliz; +Cc: gdb-patches
> Date: Thu, 13 Apr 2006 11:12:36 +0300
> From: Eli Zaretskii <eliz@gnu.org>
>
> > Date: Wed, 12 Apr 2006 14:47:17 -0400
> > From: Daniel Jacobowitz <drow@false.org>
> > Cc: gdb-patches@sourceware.org
> >
> > > int target_insert_breakpoint(CORE_ADDR addr, gdb_byte *buf, int *size);
> > > int target_remove_breakpoint(CORE_ADDR addr, gdb_byte *buf, int size);
> >
> > And then if you come up with a reason, you're going to need to hand
> > edit every one of these targets again. It's not a bundle of fun. Is
> > that really necessary?
It's a minor effort compared to all the brain cycles spent
understanding a more obfuscated interface.
> > You need an address because the address at which the breakpoint is
> > inserted may not match the requested address. This happens in several
> > different places in the breakpoint infrastructure (I believe I counted
> > three disjoint hooks for it), but I am particularly looking at
> > BREAKPOINT_FROM_PC, which takes the PC by reference. In the ARM case,
> > given 0x4001, it strips the low bit off and returns a two byte
> > breakpoint. If we don't allow the target to save the
> > actually-inserted-at address, then it has to call BREAKPOINT_FROM_PC
> > again. It feels much more robust to me to save this address when we
> > initially adjust it. Here's where we inserted the breakpoint, so
> > that's where we should remove it from.
> >
> > I can think of plenty of other places where another constant might
> > be useful. You might want to record which hardware breakpoint
> > registers were used, for instance, instead of digging around
> > to figure out which ones to clear. Adding a new member to
> > "struct bp_target" for that would be easy.
But we're talking specifically about the interface for software
breakpoints here aren't we? Or are we redesigning the target
breakpoint interface here? If we are, I think we should try to come
up with a design of some sort before rushing to implement it.
> FWIW, I agree with Daniel: it is better to pass a struct than its
> individual members, especially if we expect different targets to use
> different members of that struct. In other words, passing a struct
> eases future maintenance pains.
And it obfuscates the interface. Unnecessary layers of abstraction
make software difficult to understand and therefore difficult to
maintain. So unless someone can make a reasonable case why we need a
more general interface, I'm against it.
Mark
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-13 21:57 ` Michael Snyder
@ 2006-04-13 22:59 ` Daniel Jacobowitz
2006-04-16 23:53 ` Mark Kettenis
2006-04-16 23:50 ` Mark Kettenis
1 sibling, 1 reply; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-04-13 22:59 UTC (permalink / raw)
To: Michael Snyder; +Cc: Mark Kettenis, gdb-patches
On Thu, Apr 13, 2006 at 02:57:27PM -0700, Michael Snyder wrote:
> I haven't followed this discussion closely, so forgive me
> if I'm recapitulating something that's already been said.
>
> What about something like "void *target_data" in the breakpoint struct?
> The target can add whatever it likes, and the core breakpoint code
> doesn't need to know what it is. If it's non-null when the bp is
> freed, then the target should be given an opportunity to delete it.
I'd be fine with that too; personally I think it's about the same,
except a bit of additional complexity for deallocation.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-13 22:13 ` Mark Kettenis
@ 2006-04-13 22:59 ` Daniel Jacobowitz
2006-04-13 23:30 ` Daniel Jacobowitz
2006-04-14 8:10 ` Eli Zaretskii
2006-04-14 8:04 ` Eli Zaretskii
1 sibling, 2 replies; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-04-13 22:59 UTC (permalink / raw)
To: Mark Kettenis; +Cc: eliz, gdb-patches
On Fri, Apr 14, 2006 at 12:13:40AM +0200, Mark Kettenis wrote:
> > > I can think of plenty of other places where another constant might
> > > be useful. You might want to record which hardware breakpoint
> > > registers were used, for instance, instead of digging around
> > > to figure out which ones to clear. Adding a new member to
> > > "struct bp_target" for that would be easy.
>
> But we're talking specifically about the interface for software
> breakpoints here aren't we? Or are we redesigning the target
> breakpoint interface here? If we are, I think we should try to come
> up with a design of some sort before rushing to implement it.
I'm sure you realize that we already pass the shadow contents buffer
to the hardware breakpoint insertion routines. I simply updated that.
See below for my comments on redesigning interfaces.
> > FWIW, I agree with Daniel: it is better to pass a struct than its
> > individual members, especially if we expect different targets to use
> > different members of that struct. In other words, passing a struct
> > eases future maintenance pains.
>
> And it obfuscates the interface. Unnecessary layers of abstraction
> make software difficult to understand and therefore difficult to
> maintain. So unless someone can make a reasonable case why we need a
> more general interface, I'm against it.
I think it is far clearer to pass a "bp_target_info" structure to the
"target insert a breakpoint" and "target remove a breakpoint" routines
than a length. Why the heck do they need a length? Many of them don't
even look at it. But it's a target breakpoint and so passing along
some target breakpoint information makes perfect sense. It'll use
whatever it needs.
I'm way tired of discussing this patch, however. I'd like to remind
the audience that I'm not trying to clean up the target breakpoint
interface; I was trying to fix a nasty debugging problem for ARM
where it's perfectly obvious to the user what mode some code is in,
but GDB gets lost. My first version was too limited to the problem
case and was dismissed as hopelessly ugly. So I cleaned it up,
added some abstraction, and now it's "obfuscated". Every time I
have to overhaul an interface to fix a bug, I get a little bit
more frustrated. The bug took an hour, and this has taken days.
By the way, as a general note on my frustration level right
now: if instead of this patch, I had posted a clear proposal
for an overhauled target breakpoint interface (something
I have no interest in doing, if you're wondering), my recent
experiences suggest that no one would have been interested
in discussing the proposal anyway.
I do not think the abstraction is at all unnecessary, or I wouldn't
have added it. I presented three reasons why it could be useful: one
practical concern with the address modifications performed by the
existing BREAKPOINT_FROM_PC interface, one potential use case for
hardware breakpoints, and the considerable simplification of future
changes to these specific functions.
Here's another one. Many monitors have their own table of breakpoints.
Perhaps we need to save a breakpoint index returned by the monitor
in order to remove the breakpoint. I wouldn't be ashamed to write
a monitor that worked that way; creating the breakpoint gives you
a handle, to remove the breakpoint you need the handle. This would
be a fine place to record the handle.
Would you still prefer I just pass address and length?
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-13 22:59 ` Daniel Jacobowitz
@ 2006-04-13 23:30 ` Daniel Jacobowitz
2006-04-14 8:10 ` Eli Zaretskii
1 sibling, 0 replies; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-04-13 23:30 UTC (permalink / raw)
To: gdb-patches; +Cc: Mark Kettenis, eliz
Sorry. I don't think that was a very productive message, although I
stand by the content.
I will let this patch simmer for a while; it's not as if there aren't a
dozen or more unreviewed patches and unanswered questions waiting on
the lists to spend time on meanwhile.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-13 22:13 ` Mark Kettenis
2006-04-13 22:59 ` Daniel Jacobowitz
@ 2006-04-14 8:04 ` Eli Zaretskii
2006-04-14 8:51 ` David S. Miller
2006-04-16 23:58 ` Mark Kettenis
1 sibling, 2 replies; 52+ messages in thread
From: Eli Zaretskii @ 2006-04-14 8:04 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
> Date: Fri, 14 Apr 2006 00:13:40 +0200 (CEST)
> From: Mark Kettenis <mark.kettenis@xs4all.nl>
> CC: gdb-patches@sourceware.org
>
> > FWIW, I agree with Daniel: it is better to pass a struct than its
> > individual members, especially if we expect different targets to use
> > different members of that struct. In other words, passing a struct
> > eases future maintenance pains.
>
> And it obfuscates the interface.
I can't believe you really think that passing a struct instead of its
several members obfuscates the interface in any significant way; GDB's
code is replete with instances of passing a struct of which the caller
uses only a small part.
I understand that you want to make a point, but let's not exaggerate
our arguments to such a ridiculous degree.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-13 22:59 ` Daniel Jacobowitz
2006-04-13 23:30 ` Daniel Jacobowitz
@ 2006-04-14 8:10 ` Eli Zaretskii
2006-04-14 8:52 ` David S. Miller
1 sibling, 1 reply; 52+ messages in thread
From: Eli Zaretskii @ 2006-04-14 8:10 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
> Date: Thu, 13 Apr 2006 18:59:17 -0400
> From: Daniel Jacobowitz <drow@false.org>
> Cc: eliz@gnu.org, gdb-patches@sourceware.org
>
> I'm way tired of discussing this patch, however. I'd like to remind
> the audience that I'm not trying to clean up the target breakpoint
> interface; I was trying to fix a nasty debugging problem for ARM
> where it's perfectly obvious to the user what mode some code is in,
> but GDB gets lost. My first version was too limited to the problem
> case and was dismissed as hopelessly ugly. So I cleaned it up,
> added some abstraction, and now it's "obfuscated". Every time I
> have to overhaul an interface to fix a bug, I get a little bit
> more frustrated. The bug took an hour, and this has taken days.
And therein lies the real problem.
Mark, is your objection really so serious as to leave this bug
unfixed rather than fixed as Daniel suggested?
If it is, I'd like to hear opinions of others; if you are the only one
who objects, I'd recommend to commit the patch over your objections.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-14 8:04 ` Eli Zaretskii
@ 2006-04-14 8:51 ` David S. Miller
2006-04-16 23:58 ` Mark Kettenis
1 sibling, 0 replies; 52+ messages in thread
From: David S. Miller @ 2006-04-14 8:51 UTC (permalink / raw)
To: eliz; +Cc: mark.kettenis, gdb-patches
From: Eli Zaretskii <eliz@gnu.org>
Date: Fri, 14 Apr 2006 11:04:15 +0300
> I understand that you want to make a point, but let's not exaggerate
> our arguments to such a ridiculous degree.
I agree. In fack I think Mark is being very unreasonable with Daniel,
to be frank.
I think Daniel has gone way beyond the call of duty to fix his bug.
You shouldn't be required to overhaul an entire piece of
infrastructure just because in the long run that's the "utopian" way
to solve the problem.
Short term reasonable solutions are fine, and I think Daniel's
proposal(s) are beyond reasonable.
Being overly difficult is how you lose volunteers, and last I checked
GDB didn't exactly have an excess of people helping out.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-14 8:10 ` Eli Zaretskii
@ 2006-04-14 8:52 ` David S. Miller
0 siblings, 0 replies; 52+ messages in thread
From: David S. Miller @ 2006-04-14 8:52 UTC (permalink / raw)
To: eliz; +Cc: mark.kettenis, gdb-patches
From: Eli Zaretskii <eliz@gnu.org>
Date: Fri, 14 Apr 2006 11:10:34 +0300
> Mark, is your objection really so serious as to leave this bug
> unfixed rather than fixed as Daniel suggested?
>
> If it is, I'd like to hear opinions of others; if you are the only one
> who objects, I'd recommend to commit the patch over your objections.
I totally agree and think that Daniel's patch should go in.
Mark is being totally unreasonable.
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-13 21:57 ` Michael Snyder
2006-04-13 22:59 ` Daniel Jacobowitz
@ 2006-04-16 23:50 ` Mark Kettenis
2006-04-17 1:41 ` Daniel Jacobowitz
1 sibling, 1 reply; 52+ messages in thread
From: Mark Kettenis @ 2006-04-16 23:50 UTC (permalink / raw)
To: msnyder; +Cc: drow, mark.kettenis, gdb-patches
> Date: Thu, 13 Apr 2006 14:57:27 -0700
> From: Michael Snyder <msnyder@redhat.com>
>
> Daniel Jacobowitz wrote:
> > On Wed, Apr 12, 2006 at 08:37:22PM +0200, Mark Kettenis wrote:
> >
> >>>Would a new "struct bp_target_info", defined and allocated centrally
> >>>for convenience, allay this concern? [Conveniently I can do the bulk
> >>>of the changes for that with sed :-)]
> >>
> >>Why hide things away if all you're going to need is a buffer and a
> >>length? I've tried really hard to see why one would need more than
> >>that, but failed completely.
> >>
> >>So I think we should have:
> >>
> >>int target_insert_breakpoint(CORE_ADDR addr, gdb_byte *buf, int *size);
> >>int target_remove_breakpoint(CORE_ADDR addr, gdb_byte *buf, int size);
> >
> >
> > And then if you come up with a reason, you're going to need to hand
> > edit every one of these targets again. It's not a bundle of fun. Is
> > that really necessary?
> >
> > You need an address because the address at which the breakpoint is
> > inserted may not match the requested address. This happens in several
> > different places in the breakpoint infrastructure (I believe I counted
> > three disjoint hooks for it), but I am particularly looking at
> > BREAKPOINT_FROM_PC, which takes the PC by reference. In the ARM case,
> > given 0x4001, it strips the low bit off and returns a two byte
> > breakpoint. If we don't allow the target to save the
> > actually-inserted-at address, then it has to call BREAKPOINT_FROM_PC
> > again. It feels much more robust to me to save this address when we
> > initially adjust it. Here's where we inserted the breakpoint, so
> > that's where we should remove it from.
> >
> > I can think of plenty of other places where another constant might
> > be useful. You might want to record which hardware breakpoint
> > registers were used, for instance, instead of digging around
> > to figure out which ones to clear. Adding a new member to
> > "struct bp_target" for that would be easy.
>
> I haven't followed this discussion closely, so forgive me
> if I'm recapitulating something that's already been said.
>
> What about something like "void *target_data" in the breakpoint struct?
> The target can add whatever it likes, and the core breakpoint code
> doesn't need to know what it is. If it's non-null when the bp is
> freed, then the target should be given an opportunity to delete it.
And I presume only TARGET_DATA would be passed down to the target.
That's certainly better than passing down "struct bp_location" to the
target, exposing the internals of the high-level breakpoint code to
the low-level target code.
However, my point is that we're creating needless abstraction layers
here, and opening the way for potentially big changes in the target
interface. We currently have a well defined interface that inserts a
software breakpoint at a specific address, and saves the contents into
a buffer provided by the high-level code. That interface has a
problem in the sense that it doesn't record actually how many valid
bytes are in that buffer. This simplest fix is simply adding that
missing length to the interface.
Mark
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-13 22:59 ` Daniel Jacobowitz
@ 2006-04-16 23:53 ` Mark Kettenis
0 siblings, 0 replies; 52+ messages in thread
From: Mark Kettenis @ 2006-04-16 23:53 UTC (permalink / raw)
To: drow; +Cc: msnyder, mark.kettenis, gdb-patches
> Date: Thu, 13 Apr 2006 18:59:45 -0400
> From: Daniel Jacobowitz <drow@false.org>
>
> On Thu, Apr 13, 2006 at 02:57:27PM -0700, Michael Snyder wrote:
> > I haven't followed this discussion closely, so forgive me
> > if I'm recapitulating something that's already been said.
> >
> > What about something like "void *target_data" in the breakpoint struct?
> > The target can add whatever it likes, and the core breakpoint code
> > doesn't need to know what it is. If it's non-null when the bp is
> > freed, then the target should be given an opportunity to delete it.
>
> I'd be fine with that too; personally I think it's about the same,
> except a bit of additional complexity for deallocation.
Which is a complecity we should try very hard to avoid. There are too
many memory leaks in GDB already (so far I've been too scared to look
at the resulrs for the Coverity scan for GDB).
Mark
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-14 8:04 ` Eli Zaretskii
2006-04-14 8:51 ` David S. Miller
@ 2006-04-16 23:58 ` Mark Kettenis
2006-04-17 7:07 ` Eli Zaretskii
1 sibling, 1 reply; 52+ messages in thread
From: Mark Kettenis @ 2006-04-16 23:58 UTC (permalink / raw)
To: eliz; +Cc: gdb-patches
> Date: Fri, 14 Apr 2006 11:04:15 +0300
> From: Eli Zaretskii <eliz@gnu.org>
>
> > Date: Fri, 14 Apr 2006 00:13:40 +0200 (CEST)
> > From: Mark Kettenis <mark.kettenis@xs4all.nl>
> > CC: gdb-patches@sourceware.org
> >
> > > FWIW, I agree with Daniel: it is better to pass a struct than its
> > > individual members, especially if we expect different targets to use
> > > different members of that struct. In other words, passing a struct
> > > eases future maintenance pains.
> >
> > And it obfuscates the interface.
>
> I can't believe you really think that passing a struct instead of its
> several members obfuscates the interface in any significant way; GDB's
> code is replete with instances of passing a struct of which the caller
> uses only a small part.
>
> I understand that you want to make a point, but let's not exaggerate
> our arguments to such a ridiculous degree.
If we don't try to make are interfaces as clean and simple as
possible, GDB will get more difficult to maintain. Better spend a
little more effort now than trying to clean up the mess later on.
I'm willing to do the legwork to change the interface the way I
proposed.
Mark
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-16 23:50 ` Mark Kettenis
@ 2006-04-17 1:41 ` Daniel Jacobowitz
2006-04-17 13:09 ` Mark Kettenis
0 siblings, 1 reply; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-04-17 1:41 UTC (permalink / raw)
To: Mark Kettenis; +Cc: msnyder, gdb-patches
On Mon, Apr 17, 2006 at 01:49:23AM +0200, Mark Kettenis wrote:
> However, my point is that we're creating needless abstraction layers
> here, and opening the way for potentially big changes in the target
> interface. We currently have a well defined interface that inserts a
> software breakpoint at a specific address, and saves the contents into
> a buffer provided by the high-level code. That interface has a
> problem in the sense that it doesn't record actually how many valid
> bytes are in that buffer. This simplest fix is simply adding that
> missing length to the interface.
Have you read any of my arguments as to why the abstraction is not
needless? I haven't seen a response to any of them, just a dismissal.
I think I gave some useful examples; I'm a little frustrated that you
keep ignoring them.
The interface is not so well defined as your paragraph suggests. In
fact, the target MAY save the contents, not DOES. I'm pretty sure that
some don't. I let this mislead me into thinking that saving the
contents was optional. In fact it isn't. deprecated_read_memory_nobpt
uses the shadow contents, and uses BREAKPOINT_FROM_PC. Whatever we
decide on, I'll make sure that gets fixed.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-16 23:58 ` Mark Kettenis
@ 2006-04-17 7:07 ` Eli Zaretskii
0 siblings, 0 replies; 52+ messages in thread
From: Eli Zaretskii @ 2006-04-17 7:07 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
> Date: Mon, 17 Apr 2006 01:58:19 +0200 (CEST)
> From: Mark Kettenis <mark.kettenis@xs4all.nl>
> CC: gdb-patches@sourceware.org
>
> > > And it obfuscates the interface.
> >
> > I can't believe you really think that passing a struct instead of its
> > several members obfuscates the interface in any significant way; GDB's
> > code is replete with instances of passing a struct of which the caller
> > uses only a small part.
> >
> > I understand that you want to make a point, but let's not exaggerate
> > our arguments to such a ridiculous degree.
>
> If we don't try to make are interfaces as clean and simple as
> possible, GDB will get more difficult to maintain.
We do try to make our interfaces clean, it just happens that in this
case your notion of cleanness is very different from that of others.
In any case, ``unclean'' and ``obfuscated'' are two very different
things. Which one is it?
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-17 1:41 ` Daniel Jacobowitz
@ 2006-04-17 13:09 ` Mark Kettenis
2006-04-17 13:37 ` Daniel Jacobowitz
0 siblings, 1 reply; 52+ messages in thread
From: Mark Kettenis @ 2006-04-17 13:09 UTC (permalink / raw)
To: drow; +Cc: msnyder, gdb-patches
> Date: Sun, 16 Apr 2006 21:41:33 -0400
> From: Daniel Jacobowitz <drow@false.org>
>
> On Mon, Apr 17, 2006 at 01:49:23AM +0200, Mark Kettenis wrote:
> > However, my point is that we're creating needless abstraction layers
> > here, and opening the way for potentially big changes in the target
> > interface. We currently have a well defined interface that inserts a
> > software breakpoint at a specific address, and saves the contents into
> > a buffer provided by the high-level code. That interface has a
> > problem in the sense that it doesn't record actually how many valid
> > bytes are in that buffer. This simplest fix is simply adding that
> > missing length to the interface.
>
> Have you read any of my arguments as to why the abstraction is not
> needless? I haven't seen a response to any of them, just a dismissal.
> I think I gave some useful examples; I'm a little frustrated that you
> keep ignoring them.
Sorry. Came home to a flurry of messages about the subject and
semi-randomly chose to reply to some of them. Citing from your
earlier message:
> I do not think the abstraction is at all unnecessary, or I wouldn't
> have added it. I presented three reasons why it could be useful:
> one practical concern with the address modifications performed by
> the existing BREAKPOINT_FROM_PC interface, one potential use case
> for hardware breakpoints, and the considerable simplification of
> future changes to these specific functions.
I don't think the hardware breakpoints should be a concern here. But
the BREAKPOINT_FROM_PC issue is indeed pretty much a showstopper.
> The interface is not so well defined as your paragraph suggests. In
> fact, the target MAY save the contents, not DOES. I'm pretty sure that
> some don't. I let this mislead me into thinking that saving the
> contents was optional. In fact it isn't. deprecated_read_memory_nobpt
> uses the shadow contents, and uses BREAKPOINT_FROM_PC. Whatever we
> decide on, I'll make sure that gets fixed.
But this means that actually we should try to make the interface
stricter, instead of looser. And the fact that the shadow contents
are needed makes it impossible to use an opaque struct. That in
combination with the possibility that BREAKPOINT_FROM_PC adjusts the
breakpoint address means that besides the length we also need to pass
back the address. At that point indeed passing a struct is perhaps a
better option. And we should remove the usage of BREAKPOINT_FROM_PC
from deprecated_read_memory_nobpt() altogether.
I still think we should maintain a strict seperation between the
high-level breakpoint code and the low-level target code. So I'd
really appreciate it if you'd be willing to change your patch such
that instead of struct bp_location, you used a different struct, which
for now would have three members: the saved contents, the length and
the address. It's perfectly ok with me to make that new struct part
of struct bp_location to avoid all memory allocation problems.
Mark
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-17 13:09 ` Mark Kettenis
@ 2006-04-17 13:37 ` Daniel Jacobowitz
2006-04-17 13:50 ` Mark Kettenis
0 siblings, 1 reply; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-04-17 13:37 UTC (permalink / raw)
To: Mark Kettenis; +Cc: msnyder, gdb-patches
On Mon, Apr 17, 2006 at 03:08:52PM +0200, Mark Kettenis wrote:
> But this means that actually we should try to make the interface
> stricter, instead of looser. And the fact that the shadow contents
> are needed makes it impossible to use an opaque struct. That in
> combination with the possibility that BREAKPOINT_FROM_PC adjusts the
> breakpoint address means that besides the length we also need to pass
> back the address. At that point indeed passing a struct is perhaps a
> better option. And we should remove the usage of BREAKPOINT_FROM_PC
> from deprecated_read_memory_nobpt() altogether.
Yes, absolutely - that's how I plan to fix it.
> I still think we should maintain a strict seperation between the
> high-level breakpoint code and the low-level target code. So I'd
> really appreciate it if you'd be willing to change your patch such
> that instead of struct bp_location, you used a different struct, which
> for now would have three members: the saved contents, the length and
> the address. It's perfectly ok with me to make that new struct part
> of struct bp_location to avoid all memory allocation problems.
Sounds perfect! While the argument was a little wearing, I am entirely
happy with this result. I'll post a patch for this shortly.
I've been thinking about having target methods which don't need the
shadow contents (there are definitely several) record the "length" of
the breakpoint as zero; then deprecated_read_memory_nobpt can do the
right thing. Does this sound reasonable? The alternative is to do an
unnecessary read from the target.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-17 13:37 ` Daniel Jacobowitz
@ 2006-04-17 13:50 ` Mark Kettenis
2006-04-17 19:08 ` Daniel Jacobowitz
0 siblings, 1 reply; 52+ messages in thread
From: Mark Kettenis @ 2006-04-17 13:50 UTC (permalink / raw)
To: drow; +Cc: msnyder, gdb-patches
> Date: Mon, 17 Apr 2006 09:37:48 -0400
> From: Daniel Jacobowitz <drow@false.org>
>
> > I still think we should maintain a strict seperation between the
> > high-level breakpoint code and the low-level target code. So I'd
> > really appreciate it if you'd be willing to change your patch such
> > that instead of struct bp_location, you used a different struct, which
> > for now would have three members: the saved contents, the length and
> > the address. It's perfectly ok with me to make that new struct part
> > of struct bp_location to avoid all memory allocation problems.
>
> Sounds perfect! While the argument was a little wearing, I am entirely
> happy with this result. I'll post a patch for this shortly.
Sorry about that. I was a bit annoyed by some of the replies, and I
guess me wanting to make a point here made my subsequent replies a bit
unconstructive.
> I've been thinking about having target methods which don't need the
> shadow contents (there are definitely several) record the "length" of
> the breakpoint as zero; then deprecated_read_memory_nobpt can do the
> right thing. Does this sound reasonable? The alternative is to do an
> unnecessary read from the target.
Absolutely. If the length is zero there are no shadow contents to
worry about. But it is probably better to address
deprecated_read_memory_nobpt in a seperate patch.
Mark
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-17 13:50 ` Mark Kettenis
@ 2006-04-17 19:08 ` Daniel Jacobowitz
2006-04-17 20:25 ` Mark Kettenis
2006-04-18 8:59 ` Eli Zaretskii
0 siblings, 2 replies; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-04-17 19:08 UTC (permalink / raw)
To: Mark Kettenis; +Cc: msnyder, gdb-patches
On Mon, Apr 17, 2006 at 03:49:29PM +0200, Mark Kettenis wrote:
> > I've been thinking about having target methods which don't need the
> > shadow contents (there are definitely several) record the "length" of
> > the breakpoint as zero; then deprecated_read_memory_nobpt can do the
> > right thing. Does this sound reasonable? The alternative is to do an
> > unnecessary read from the target.
>
> Absolutely. If the length is zero there are no shadow contents to
> worry about. But it is probably better to address
> deprecated_read_memory_nobpt in a seperate patch.
Well, otherwise I get compilation errors. So I've fixed it together
with this.
On the documentation front, I am quite mortified; I wrote this
ChangeLog entry at least twice for earlier versions of the patch:
* gdbint.texinfo (Watchpoints, Target Conditionals): Update insert
and remove breakpoint prototypes.
While they often use the underlying watchpoint registers, hardware
breakpoints are breakpoints. I've moved these to the Breakpoints
section, and added some more bits there. Eli, could you take a look
at that?
I turned out to need a fourth element in the struct :-( But I think
the result is fairly clear, esp. with the comments and documentation.
Here's struct bp_target_info:
/* Information used by targets to insert and remove breakpoints. */
struct bp_target_info
{
/* Address at which the breakpoint was placed. This is normally the
same as ADDRESS from the bp_location, except when adjustment
happens in BREAKPOINT_FROM_PC. The most common form of
adjustment is stripping an alternate ISA marker from the PC which
is used to determine the type of breakpoint to insert. */
CORE_ADDR placed_address;
/* If the breakpoint lives in memory and reading that memory would
give back the breakpoint, instead of the original contents, then
the original contents are cached here. Only SHADOW_LEN bytes of
this buffer are valid, and only when the breakpoint is inserted. */
gdb_byte shadow_contents[BREAKPOINT_MAX];
/* The length of the data cached in SHADOW_CONTENTS. */
int shadow_len;
/* The size of the placed breakpoint, according to
BREAKPOINT_FROM_PC, when the breakpoint was inserted. This is
generally the same as SHADOW_LEN, unless we did not need
to read from the target to implement the memory breakpoint
(e.g. if a remote stub handled the details). We may still
need the size to remove the breakpoint safely. */
int placed_size;
};
Stubs which do read from the target set shadow_len, as of course does
the generic memory_insert_breakpoint. The remote Z0 support does not;
one of the benefits of using Z0 is that getting the target memory
correct is not GDB's problem.
OK?
--
Daniel Jacobowitz
CodeSourcery
2006-04-17 Daniel Jacobowitz <dan@codesourcery.com>
* breakpoint.c (deprecated_read_memory_nobpt): Update to use
shadow_len.
(insert_bp_location, reattach_breakpoints, remove_breakpoint)
(delete_breakpoint): Update calls to changed methods.
(deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint)
(single_step_breakpoints, insert_single_step_breakpoint)
(remove_single_step_breakpoints): New.
* breakpoint.h (struct bp_target_info): New.
(struct bp_location): Replace shadow_contents with
target_info and overlay_target_info.
(deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint)
(insert_single_step_breakpoint, remove_single_step_breakpoints): New
prototypes.
* gdbarch.sh: Forward declare struct bp_target_info in gdbarch.h.
(memory_insert_breakpoint, memory_remove_breakpoint): Update second
argument.
* mem-break.c (default_memory_insert_breakpoint): Update. Set
placed_address, placed_size, and shadow_len.
(default_memory_remove_breakpoint): Update. Don't use
BREAKPOINT_FROM_PC.
(memory_insert_breakpoint, memory_remove_breakpoint): Update.
* target.c (update_current_target): Update prototypes for changed
functions.
(debug_to_insert_breakpoint, debug_to_remove_breakpoint)
(debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint):
Update.
* target.h: Forward declare struct bp_target_info.
(struct target_ops): Use a bp_target_info argument for
to_insert_breakpoint, to_remove_breakpoint,
to_insert_hw_breakpoint, and to_remove_hw_breakpoint.
(target_insert_breakpoint, target_remove_breakpoint)
(target_insert_hw_breakpoint, target_remove_hw_breakpoint)
(memory_insert_breakpoint, memory_remove_breakpoint)
(default_memory_insert_breakpoint, default_memory_remove_breakpoint):
Update.
* config/i386/nm-i386.h: Forward declare struct bp_target_info.
(i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update.
(target_insert_hw_breakpoint, target_remove_hw_breakpoint): Likewise.
* gdbarch.c, gdbarch.h: Regenerated.
* alpha-tdep.c (alpha_software_single_step): Use
insert_single_step_breakpoint and remove_single_step_breakpoints.
Remove unused statics.
* arm-tdep.c (arm_software_single_step): Likewise. Add a note.
* cris-tdep.c (cris_software_single_step): Likewise.
* mips-tdep.c (mips_software_single_step): Likewise.
* rs6000-tdep.c (rs6000_software_single_step): Likewise.
* sparc-tdep.c (sparc_software_single_step): Likewise.
* wince.c (struct thread_info_struct): Remove step_prev.
(undoSStep): Use remove_single_step_breakpoints.
(wince_software_single_step): Use insert_single_step_breakpoint.
* corelow.c (ignore): Remove unneeded prototype. Update arguments.
* exec.c (ignore): Likewise.
* sol-thread.c (ignore): Likewise.
* procfs.c (dbx_link_shadow_contents): Delete.
(dbx_link_bpt): New.
(procfs_mourn_inferior): Remove it if necessary.
(remove_dbx_link_breakpoint): Use it.
(insert_dbx_link_bpt_in_file): Set it.
(procfs_init_inferior): Don't update dbx_link_bpt_addr.
* rs6000-nat.c (exec_one_dummy_insn): Use
deprecated_insert_raw_breakpoint and
deprecated_remove_raw_breakpoint.
* solib-irix.c (shadow_contents, breakpoint_addr): Delete.
(base_breakpoint): New.
(disable_break): Use it.
(enable_break): Set it.
* i386-nat.c (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint):
Update.
* ia64-tdep.c (ia64_memory_insert_breakpoint)
(ia64_memory_remove_breakpoint): Likewise.
* m32r-tdep.c (m32r_memory_insert_breakpoint)
(m32r_memory_remove_breakpoint): Likewise.
* monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint):
Likewise. Remove unnecessary prototypes. Use placed_address
and placed_size. Removed useless read from memory.
* nto-procfs.c (procfs_insert_breakpoint)
(procfs_remove_breakpoint, procfs_insert_hw_breakpoint)
(procfs_remove_hw_breakpoint): Update.
* ocd.c (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise.
* ocd.h (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise.
* ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise.
* ppc-tdep.h (ppc_linux_memory_remove_breakpoint): Likewise.
* remote-e7000.c (e7000_insert_breakpoint)
(e7000_remove_breakpoint): Likewise.
* remote-m32r-sdi.c (m32r_insert_breakpoint)
(m32r_remove_breakpoint): Likewise.
* remote-mips.c (mips_insert_breakpoint)
(mips_remove_breakpoint): Likewise.
* remote-rdp.c (remote_rdp_insert_breakpoint)
(remote_rdp_remove_breakpoint): Likewise.
(rdp_step): Use deprecated_insert_raw_breakpoint and
deprecated_remove_raw_breakpoint.
* remote-sds.c (sds_insert_breakpoint, sds_remove_breakpoint):
Update.
* remote-sim.c (gdbsim_insert_breakpoint, gdbsim_remove_breakpoint):
Delete.
(init_gdbsim_ops): Use memory_insert_breakpoint and
memory_remove_breakpoint.
* remote-st.c (st2000_insert_breakpoint)
(st2000_remove_breakpoint): Update. Remove unused
BREAKPOINT_FROM_PC.
* remote.c (remote_insert_breakpoint, remote_remove_breakpoint):
Update. Use placed_address and placed_size.
(remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Likewise.
2006-04-17 Daniel Jacobowitz <dan@codesourcery.com>
* gdbint.texinfo (x86 Watchpoints, Target Conditionals): Update insert
and remove breakpoint prototypes.
(Watchpoints): Move description of target_insert_hw_breakpoint and
target_remove_hw_breakpoint ...
(Breakpoints): ... to here. Document target_insert_breakpoint and
target_remove_breakpoint.
? remove-breakpoint-supply-length-v2.patch
? remove-breakpoint-supply-length-v3.patch
Index: alpha-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/alpha-tdep.c,v
retrieving revision 1.153
diff -u -p -r1.153 alpha-tdep.c
--- alpha-tdep.c 15 Jan 2006 20:53:32 -0000 1.153
+++ alpha-tdep.c 17 Apr 2006 19:03:19 -0000
@@ -1493,8 +1493,6 @@ void
alpha_software_single_step (enum target_signal sig, int insert_breakpoints_p)
{
static CORE_ADDR next_pc;
- typedef char binsn_quantum[BREAKPOINT_MAX];
- static binsn_quantum break_mem;
CORE_ADDR pc;
if (insert_breakpoints_p)
@@ -1502,11 +1500,11 @@ alpha_software_single_step (enum target_
pc = read_pc ();
next_pc = alpha_next_pc (pc);
- target_insert_breakpoint (next_pc, break_mem);
+ insert_single_step_breakpoint (next_pc);
}
else
{
- target_remove_breakpoint (next_pc, break_mem);
+ remove_single_step_breakpoints ();
write_pc (next_pc);
}
}
Index: arm-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.c,v
retrieving revision 1.207
diff -u -p -r1.207 arm-tdep.c
--- arm-tdep.c 30 Mar 2006 16:48:47 -0000 1.207
+++ arm-tdep.c 17 Apr 2006 19:03:19 -0000
@@ -1849,16 +1849,18 @@ arm_get_next_pc (CORE_ADDR pc)
static void
arm_software_single_step (enum target_signal sig, int insert_bpt)
{
- static int next_pc; /* State between setting and unsetting. */
- static char break_mem[BREAKPOINT_MAX]; /* Temporary storage for mem@bpt */
+ /* NOTE: This may insert the wrong breakpoint instruction when
+ single-stepping over a mode-changing instruction, if the
+ CPSR heuristics are used. */
if (insert_bpt)
{
- next_pc = arm_get_next_pc (read_register (ARM_PC_REGNUM));
- target_insert_breakpoint (next_pc, break_mem);
+ CORE_ADDR next_pc = arm_get_next_pc (read_register (ARM_PC_REGNUM));
+
+ insert_single_step_breakpoint (next_pc);
}
else
- target_remove_breakpoint (next_pc, break_mem);
+ remove_single_step_breakpoints ();
}
#include "bfd-in2.h"
Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.224
diff -u -p -r1.224 breakpoint.c
--- breakpoint.c 6 Apr 2006 18:33:05 -0000 1.224
+++ breakpoint.c 17 Apr 2006 19:03:20 -0000
@@ -663,16 +663,10 @@ deprecated_read_memory_nobpt (CORE_ADDR
continue;
/* Addresses and length of the part of the breakpoint that
we need to copy. */
- /* XXXX The m68k, sh and h8300 have different local and remote
- breakpoint values. BREAKPOINT_FROM_PC still manages to
- correctly determine the breakpoints memory address and size
- for these targets. */
- bp_addr = b->address;
- bp_size = 0;
- if (BREAKPOINT_FROM_PC (&bp_addr, &bp_size) == NULL)
- continue;
+ bp_addr = b->target_info.placed_address;
+ bp_size = b->target_info.shadow_len;
if (bp_size == 0)
- /* bp isn't valid */
+ /* bp isn't valid, or doesn't shadow memory. */
continue;
if (bp_addr + bp_size <= memaddr)
/* The breakpoint is entirely before the chunk of memory we
@@ -703,7 +697,7 @@ deprecated_read_memory_nobpt (CORE_ADDR
}
memcpy (myaddr + bp_addr - memaddr,
- b->shadow_contents + bptoffset, bp_size);
+ b->target_info.shadow_contents + bptoffset, bp_size);
if (bp_addr > memaddr)
{
@@ -793,6 +787,10 @@ insert_bp_location (struct bp_location *
if (bpt->inserted || bpt->duplicate)
return 0;
+ /* Initialize the target-specific information. */
+ memset (&bpt->target_info, 0, sizeof (bpt->target_info));
+ bpt->target_info.placed_address = bpt->address;
+
if (bpt->loc_type == bp_loc_software_breakpoint
|| bpt->loc_type == bp_loc_hardware_breakpoint)
{
@@ -804,11 +802,9 @@ insert_bp_location (struct bp_location *
/* No overlay handling: just set the breakpoint. */
if (bpt->loc_type == bp_loc_hardware_breakpoint)
- val = target_insert_hw_breakpoint (bpt->address,
- bpt->shadow_contents);
+ val = target_insert_hw_breakpoint (&bpt->target_info);
else
- val = target_insert_breakpoint (bpt->address,
- bpt->shadow_contents);
+ val = target_insert_breakpoint (&bpt->target_info);
}
else
{
@@ -827,7 +823,9 @@ insert_bp_location (struct bp_location *
CORE_ADDR addr = overlay_unmapped_address (bpt->address,
bpt->section);
/* Set a software (trap) breakpoint at the LMA. */
- val = target_insert_breakpoint (addr, bpt->shadow_contents);
+ bpt->overlay_target_info = bpt->target_info;
+ bpt->overlay_target_info.placed_address = addr;
+ val = target_insert_breakpoint (&bpt->overlay_target_info);
if (val != 0)
fprintf_unfiltered (tmp_error_stream,
"Overlay breakpoint %d failed: in ROM?",
@@ -839,11 +837,9 @@ insert_bp_location (struct bp_location *
{
/* Yes. This overlay section is mapped into memory. */
if (bpt->loc_type == bp_loc_hardware_breakpoint)
- val = target_insert_hw_breakpoint (bpt->address,
- bpt->shadow_contents);
+ val = target_insert_hw_breakpoint (&bpt->target_info);
else
- val = target_insert_breakpoint (bpt->address,
- bpt->shadow_contents);
+ val = target_insert_breakpoint (&bpt->target_info);
}
else
{
@@ -1045,7 +1041,7 @@ in which its expression is valid.\n"),
/* If we get here, we must have a callback mechanism for exception
events -- with g++ style embedded label support, we insert
ordinary breakpoints and not catchpoints. */
- val = target_insert_breakpoint (bpt->address, bpt->shadow_contents);
+ val = target_insert_breakpoint (&bpt->target_info);
if (val)
{
/* Couldn't set breakpoint for some reason */
@@ -1240,9 +1236,9 @@ reattach_breakpoints (int pid)
{
remove_breakpoint (b, mark_inserted);
if (b->loc_type == bp_loc_hardware_breakpoint)
- val = target_insert_hw_breakpoint (b->address, b->shadow_contents);
+ val = target_insert_hw_breakpoint (&b->target_info);
else
- val = target_insert_breakpoint (b->address, b->shadow_contents);
+ val = target_insert_breakpoint (&b->target_info);
/* FIXME drow/2003-10-07: This doesn't handle any other kinds of
breakpoints. It's wrong for watchpoints, for example. */
if (val != 0)
@@ -1446,10 +1442,9 @@ remove_breakpoint (struct bp_location *b
/* No overlay handling: just remove the breakpoint. */
if (b->loc_type == bp_loc_hardware_breakpoint)
- val = target_remove_hw_breakpoint (b->address,
- b->shadow_contents);
+ val = target_remove_hw_breakpoint (&b->target_info);
else
- val = target_remove_breakpoint (b->address, b->shadow_contents);
+ val = target_remove_breakpoint (&b->target_info);
}
else
{
@@ -1460,14 +1455,12 @@ remove_breakpoint (struct bp_location *b
/* Yes -- overlay event support is not active, so we
should have set a breakpoint at the LMA. Remove it.
*/
- CORE_ADDR addr = overlay_unmapped_address (b->address,
- b->section);
/* Ignore any failures: if the LMA is in ROM, we will
have already warned when we failed to insert it. */
if (b->loc_type == bp_loc_hardware_breakpoint)
- target_remove_hw_breakpoint (addr, b->shadow_contents);
+ target_remove_hw_breakpoint (&b->overlay_target_info);
else
- target_remove_breakpoint (addr, b->shadow_contents);
+ target_remove_breakpoint (&b->overlay_target_info);
}
/* Did we set a breakpoint at the VMA?
If so, we will have marked the breakpoint 'inserted'. */
@@ -1478,11 +1471,9 @@ remove_breakpoint (struct bp_location *b
unmapped, but let's not rely on that being safe. We
don't know what the overlay manager might do. */
if (b->loc_type == bp_loc_hardware_breakpoint)
- val = target_remove_hw_breakpoint (b->address,
- b->shadow_contents);
+ val = target_remove_hw_breakpoint (&b->target_info);
else
- val = target_remove_breakpoint (b->address,
- b->shadow_contents);
+ val = target_remove_breakpoint (&b->target_info);
}
else
{
@@ -1570,8 +1561,7 @@ remove_breakpoint (struct bp_location *b
&& breakpoint_enabled (b->owner)
&& !b->duplicate)
{
-
- val = target_remove_breakpoint (b->address, b->shadow_contents);
+ val = target_remove_breakpoint (&b->target_info);
if (val)
return val;
b->inserted = (is == mark_inserted);
@@ -1581,8 +1571,7 @@ remove_breakpoint (struct bp_location *b
&& breakpoint_enabled (b->owner)
&& !b->duplicate)
{
-
- val = target_remove_breakpoint (b->address, b->shadow_contents);
+ val = target_remove_breakpoint (&b->target_info);
if (val)
return val;
@@ -6852,10 +6841,12 @@ delete_breakpoint (struct breakpoint *bp
_("another breakpoint was inserted on top of "
"a permanent breakpoint"));
+ memset (&b->loc->target_info, 0, sizeof (b->loc->target_info));
+ b->loc->target_info.placed_address = b->loc->address;
if (b->type == bp_hardware_breakpoint)
- val = target_insert_hw_breakpoint (b->loc->address, b->loc->shadow_contents);
+ val = target_insert_hw_breakpoint (&b->loc->target_info);
else
- val = target_insert_breakpoint (b->loc->address, b->loc->shadow_contents);
+ val = target_insert_breakpoint (&b->loc->target_info);
/* If there was an error in the insert, print a message, then stop execution. */
if (val != 0)
@@ -7658,6 +7649,97 @@ decode_line_spec_1 (char *string, int fu
error (_("Junk at end of line specification: %s"), string);
return sals;
}
+
+/* Create and insert a raw software breakpoint at PC. Return an
+ identifier, which should be used to remove the breakpoint later.
+ In general, places which call this should be using something on the
+ breakpoint chain instead; this function should be eliminated
+ someday. */
+
+void *
+deprecated_insert_raw_breakpoint (CORE_ADDR pc)
+{
+ struct bp_target_info *bp_tgt;
+
+ bp_tgt = xmalloc (sizeof (struct bp_target_info));
+ memset (bp_tgt, 0, sizeof (struct bp_target_info));
+
+ bp_tgt->placed_address = pc;
+ if (target_insert_breakpoint (bp_tgt) != 0)
+ {
+ /* Could not insert the breakpoint. */
+ xfree (bp_tgt);
+ return NULL;
+ }
+
+ return bp_tgt;
+}
+
+/* Remove a breakpoint BP inserted by deprecated_insert_raw_breakpoint. */
+
+int
+deprecated_remove_raw_breakpoint (void *bp)
+{
+ struct bp_target_info *bp_tgt = bp;
+ int ret;
+
+ ret = target_remove_breakpoint (bp_tgt);
+ xfree (bp_tgt);
+
+ return ret;
+}
+
+/* One (or perhaps two) breakpoints used for software single stepping. */
+
+static void *single_step_breakpoints[2];
+
+/* Create and insert a breakpoint for software single step. */
+
+void
+insert_single_step_breakpoint (CORE_ADDR next_pc)
+{
+ void **bpt_p;
+
+ if (single_step_breakpoints[0] == NULL)
+ bpt_p = &single_step_breakpoints[0];
+ else
+ {
+ gdb_assert (single_step_breakpoints[1] == NULL);
+ bpt_p = &single_step_breakpoints[1];
+ }
+
+ /* NOTE drow/2006-04-11: A future improvement to this function would be
+ to only create the breakpoints once, and actually put them on the
+ breakpoint chain. That would let us use set_raw_breakpoint. We could
+ adjust the addresses each time they were needed. Doing this requires
+ corresponding changes elsewhere where single step breakpoints are
+ handled, however. So, for now, we use this. */
+
+ *bpt_p = deprecated_insert_raw_breakpoint (next_pc);
+ if (*bpt_p == NULL)
+ warning (_("Could not insert single-step breakpoint at 0x%s"),
+ paddr_nz (next_pc));
+}
+
+/* Remove and delete any breakpoints used for software single step. */
+
+void
+remove_single_step_breakpoints (void)
+{
+ gdb_assert (single_step_breakpoints[0] != NULL);
+
+ /* See insert_single_step_breakpoint for more about this deprecated
+ call. */
+ deprecated_remove_raw_breakpoint (single_step_breakpoints[0]);
+ single_step_breakpoints[0] = NULL;
+
+ if (single_step_breakpoints[1] != NULL)
+ {
+ deprecated_remove_raw_breakpoint (single_step_breakpoints[1]);
+ single_step_breakpoints[1] = NULL;
+ }
+}
+
\f
/* This help string is used for the break, hbreak, tbreak and thbreak commands.
It is defined as a macro to prevent duplication.
Index: breakpoint.h
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.h,v
retrieving revision 1.36
diff -u -p -r1.36 breakpoint.h
--- breakpoint.h 17 Dec 2005 22:33:59 -0000 1.36
+++ breakpoint.h 17 Apr 2006 19:03:20 -0000
@@ -185,6 +185,36 @@ enum target_hw_bp_type
hw_execute = 3 /* Execute HW breakpoint */
};
+
+/* Information used by targets to insert and remove breakpoints. */
+
+struct bp_target_info
+{
+ /* Address at which the breakpoint was placed. This is normally the
+ same as ADDRESS from the bp_location, except when adjustment
+ happens in BREAKPOINT_FROM_PC. The most common form of
+ adjustment is stripping an alternate ISA marker from the PC which
+ is used to determine the type of breakpoint to insert. */
+ CORE_ADDR placed_address;
+
+ /* If the breakpoint lives in memory and reading that memory would
+ give back the breakpoint, instead of the original contents, then
+ the original contents are cached here. Only SHADOW_LEN bytes of
+ this buffer are valid, and only when the breakpoint is inserted. */
+ gdb_byte shadow_contents[BREAKPOINT_MAX];
+
+ /* The length of the data cached in SHADOW_CONTENTS. */
+ int shadow_len;
+
+ /* The size of the placed breakpoint, according to
+ BREAKPOINT_FROM_PC, when the breakpoint was inserted. This is
+ generally the same as SHADOW_LEN, unless we did not need
+ to read from the target to implement the memory breakpoint
+ (e.g. if a remote stub handled the details). We may still
+ need the size to remove the breakpoint safely. */
+ int placed_size;
+};
+
/* GDB maintains two types of information about each breakpoint (or
watchpoint, or other related event). The first type corresponds
to struct breakpoint; this is a relatively high-level structure
@@ -242,13 +272,6 @@ struct bp_location
associated with the address. Used primarily for overlay debugging. */
asection *section;
- /* "Real" contents of byte where breakpoint has been inserted.
- Valid only when breakpoints are in the program. Under the complete
- control of the target insert_breakpoint and remove_breakpoint routines.
- No other code should assume anything about the value(s) here.
- Valid only for bp_loc_software_breakpoint. */
- gdb_byte shadow_contents[BREAKPOINT_MAX];
-
/* Address at which breakpoint was requested, either by the user or
by GDB for internal breakpoints. This will usually be the same
as ``address'' (above) except for cases in which
@@ -256,6 +279,12 @@ struct bp_location
which to place the breakpoint in order to comply with a
processor's architectual constraints. */
CORE_ADDR requested_address;
+
+ /* Details of the placed breakpoint, when inserted. */
+ struct bp_target_info target_info;
+
+ /* Similarly, for the breakpoint at an overlay's LMA, if necessary. */
+ struct bp_target_info overlay_target_info;
};
/* This structure is a collection of function pointers that, if available,
@@ -796,6 +825,16 @@ extern void delete_command (char *arg, i
remove fails. */
extern int remove_hw_watchpoints (void);
+/* Manage a software single step breakpoint (or two). Insert may be called
+ twice before remove is called. */
+extern void insert_single_step_breakpoint (CORE_ADDR);
+extern void remove_single_step_breakpoints (void);
+
+/* Manage manual breakpoints, separate from the normal chain of
+ breakpoints. These functions are used in murky target-specific
+ ways. Please do not add more uses! */
+extern void *deprecated_insert_raw_breakpoint (CORE_ADDR);
+extern int deprecated_remove_raw_breakpoint (void *);
/* Indicator of whether exception catchpoints should be nuked between
runs of a program. */
Index: corelow.c
===================================================================
RCS file: /cvs/src/src/gdb/corelow.c,v
retrieving revision 1.55
diff -u -p -r1.55 corelow.c
--- corelow.c 25 Feb 2006 04:36:39 -0000 1.55
+++ corelow.c 17 Apr 2006 19:03:20 -0000
@@ -86,8 +86,6 @@ static void get_core_registers (int);
static void add_to_thread_list (bfd *, asection *, void *);
-static int ignore (CORE_ADDR, bfd_byte *);
-
static int core_file_thread_alive (ptid_t tid);
static void init_core_ops (void);
@@ -603,7 +601,7 @@ core_xfer_partial (struct target_ops *op
`gdb internal error' (since generic_mourn calls breakpoint_init_inferior). */
static int
-ignore (CORE_ADDR addr, bfd_byte *contents)
+ignore (struct bp_target_info *bp_tgt)
{
return 0;
}
Index: cris-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/cris-tdep.c,v
retrieving revision 1.135
diff -u -p -r1.135 cris-tdep.c
--- cris-tdep.c 5 Apr 2006 20:01:19 -0000 1.135
+++ cris-tdep.c 17 Apr 2006 19:03:21 -0000
@@ -558,15 +558,6 @@ struct instruction_environment
int disable_interrupt;
} inst_env_type;
-/* Save old breakpoints in order to restore the state before a single_step.
- At most, two breakpoints will have to be remembered. */
-typedef
-char binsn_quantum[BREAKPOINT_MAX];
-static binsn_quantum break_mem[2];
-static CORE_ADDR next_pc = 0;
-static CORE_ADDR branch_target_address = 0;
-static unsigned char branch_break_inserted = 0;
-
/* Machine-dependencies in CRIS for opcodes. */
/* Instruction sizes. */
@@ -2130,7 +2121,7 @@ static void
cris_software_single_step (enum target_signal ignore, int insert_breakpoints)
{
inst_env_type inst_env;
-
+
if (insert_breakpoints)
{
/* Analyse the present instruction environment and insert
@@ -2146,28 +2137,19 @@ cris_software_single_step (enum target_s
{
/* Insert at most two breakpoints. One for the next PC content
and possibly another one for a branch, jump, etc. */
- next_pc = (CORE_ADDR) inst_env.reg[PC_REGNUM];
- target_insert_breakpoint (next_pc, break_mem[0]);
+ CORE_ADDR next_pc = (CORE_ADDR) inst_env.reg[PC_REGNUM];
+ insert_single_step_breakpoint (next_pc);
if (inst_env.branch_found
&& (CORE_ADDR) inst_env.branch_break_address != next_pc)
{
- branch_target_address =
- (CORE_ADDR) inst_env.branch_break_address;
- target_insert_breakpoint (branch_target_address, break_mem[1]);
- branch_break_inserted = 1;
+ CORE_ADDR branch_target_address
+ = (CORE_ADDR) inst_env.branch_break_address;
+ insert_single_step_breakpoint (branch_target_address);
}
}
}
else
- {
- /* Remove breakpoints. */
- target_remove_breakpoint (next_pc, break_mem[0]);
- if (branch_break_inserted)
- {
- target_remove_breakpoint (branch_target_address, break_mem[1]);
- branch_break_inserted = 0;
- }
- }
+ remove_single_step_breakpoints ();
}
/* Calculates the prefix value for quick offset addressing mode. */
Index: exec.c
===================================================================
RCS file: /cvs/src/src/gdb/exec.c,v
retrieving revision 1.60
diff -u -p -r1.60 exec.c
--- exec.c 25 Feb 2006 04:36:39 -0000 1.60
+++ exec.c 17 Apr 2006 19:03:21 -0000
@@ -59,8 +59,6 @@ static void set_section_command (char *,
static void exec_files_info (struct target_ops *);
-static int ignore (CORE_ADDR, bfd_byte *);
-
static void init_exec_ops (void);
void _initialize_exec (void);
@@ -691,7 +689,7 @@ exec_set_section_address (const char *fi
breakpoint_init_inferior). */
static int
-ignore (CORE_ADDR addr, bfd_byte *contents)
+ignore (struct bp_target_info *bp_tgt)
{
return 0;
}
Index: gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.328
diff -u -p -r1.328 gdbarch.c
--- gdbarch.c 17 Dec 2005 22:33:59 -0000 1.328
+++ gdbarch.c 17 Apr 2006 19:03:21 -0000
@@ -1250,8 +1250,8 @@ gdbarch_dump (struct gdbarch *current_gd
#ifdef MEMORY_INSERT_BREAKPOINT
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
- "MEMORY_INSERT_BREAKPOINT(addr, contents_cache)",
- XSTRING (MEMORY_INSERT_BREAKPOINT (addr, contents_cache)));
+ "MEMORY_INSERT_BREAKPOINT(bp_tgt)",
+ XSTRING (MEMORY_INSERT_BREAKPOINT (bp_tgt)));
#endif
fprintf_unfiltered (file,
"gdbarch_dump: memory_insert_breakpoint = <0x%lx>\n",
@@ -1259,8 +1259,8 @@ gdbarch_dump (struct gdbarch *current_gd
#ifdef MEMORY_REMOVE_BREAKPOINT
fprintf_unfiltered (file,
"gdbarch_dump: %s # %s\n",
- "MEMORY_REMOVE_BREAKPOINT(addr, contents_cache)",
- XSTRING (MEMORY_REMOVE_BREAKPOINT (addr, contents_cache)));
+ "MEMORY_REMOVE_BREAKPOINT(bp_tgt)",
+ XSTRING (MEMORY_REMOVE_BREAKPOINT (bp_tgt)));
#endif
fprintf_unfiltered (file,
"gdbarch_dump: memory_remove_breakpoint = <0x%lx>\n",
@@ -2934,13 +2934,13 @@ set_gdbarch_adjust_breakpoint_address (s
}
int
-gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, gdb_byte *contents_cache)
+gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->memory_insert_breakpoint != NULL);
if (gdbarch_debug >= 2)
fprintf_unfiltered (gdb_stdlog, "gdbarch_memory_insert_breakpoint called\n");
- return gdbarch->memory_insert_breakpoint (addr, contents_cache);
+ return gdbarch->memory_insert_breakpoint (bp_tgt);
}
void
@@ -2951,13 +2951,13 @@ set_gdbarch_memory_insert_breakpoint (st
}
int
-gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, gdb_byte *contents_cache)
+gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->memory_remove_breakpoint != NULL);
if (gdbarch_debug >= 2)
fprintf_unfiltered (gdb_stdlog, "gdbarch_memory_remove_breakpoint called\n");
- return gdbarch->memory_remove_breakpoint (addr, contents_cache);
+ return gdbarch->memory_remove_breakpoint (bp_tgt);
}
void
Index: gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.284
diff -u -p -r1.284 gdbarch.h
--- gdbarch.h 17 Dec 2005 22:34:00 -0000 1.284
+++ gdbarch.h 17 Apr 2006 19:03:21 -0000
@@ -49,6 +49,7 @@ struct regset;
struct disassemble_info;
struct target_ops;
struct obstack;
+struct bp_target_info;
extern struct gdbarch *current_gdbarch;
@@ -899,24 +900,24 @@ typedef CORE_ADDR (gdbarch_adjust_breakp
extern CORE_ADDR gdbarch_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr);
extern void set_gdbarch_adjust_breakpoint_address (struct gdbarch *gdbarch, gdbarch_adjust_breakpoint_address_ftype *adjust_breakpoint_address);
-typedef int (gdbarch_memory_insert_breakpoint_ftype) (CORE_ADDR addr, gdb_byte *contents_cache);
-extern int gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, gdb_byte *contents_cache);
+typedef int (gdbarch_memory_insert_breakpoint_ftype) (struct bp_target_info *bp_tgt);
+extern int gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt);
extern void set_gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, gdbarch_memory_insert_breakpoint_ftype *memory_insert_breakpoint);
#if !defined (GDB_TM_FILE) && defined (MEMORY_INSERT_BREAKPOINT)
#error "Non multi-arch definition of MEMORY_INSERT_BREAKPOINT"
#endif
#if !defined (MEMORY_INSERT_BREAKPOINT)
-#define MEMORY_INSERT_BREAKPOINT(addr, contents_cache) (gdbarch_memory_insert_breakpoint (current_gdbarch, addr, contents_cache))
+#define MEMORY_INSERT_BREAKPOINT(bp_tgt) (gdbarch_memory_insert_breakpoint (current_gdbarch, bp_tgt))
#endif
-typedef int (gdbarch_memory_remove_breakpoint_ftype) (CORE_ADDR addr, gdb_byte *contents_cache);
-extern int gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, gdb_byte *contents_cache);
+typedef int (gdbarch_memory_remove_breakpoint_ftype) (struct bp_target_info *bp_tgt);
+extern int gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt);
extern void set_gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, gdbarch_memory_remove_breakpoint_ftype *memory_remove_breakpoint);
#if !defined (GDB_TM_FILE) && defined (MEMORY_REMOVE_BREAKPOINT)
#error "Non multi-arch definition of MEMORY_REMOVE_BREAKPOINT"
#endif
#if !defined (MEMORY_REMOVE_BREAKPOINT)
-#define MEMORY_REMOVE_BREAKPOINT(addr, contents_cache) (gdbarch_memory_remove_breakpoint (current_gdbarch, addr, contents_cache))
+#define MEMORY_REMOVE_BREAKPOINT(bp_tgt) (gdbarch_memory_remove_breakpoint (current_gdbarch, bp_tgt))
#endif
extern CORE_ADDR gdbarch_decr_pc_after_break (struct gdbarch *gdbarch);
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.363
diff -u -p -r1.363 gdbarch.sh
--- gdbarch.sh 17 Dec 2005 22:34:00 -0000 1.363
+++ gdbarch.sh 17 Apr 2006 19:03:22 -0000
@@ -549,8 +549,8 @@ f:=:CORE_ADDR:skip_prologue:CORE_ADDR ip
f:=:int:inner_than:CORE_ADDR lhs, CORE_ADDR rhs:lhs, rhs:0:0
f:=:const gdb_byte *:breakpoint_from_pc:CORE_ADDR *pcptr, int *lenptr:pcptr, lenptr::0:
M::CORE_ADDR:adjust_breakpoint_address:CORE_ADDR bpaddr:bpaddr
-f:=:int:memory_insert_breakpoint:CORE_ADDR addr, gdb_byte *contents_cache:addr, contents_cache:0:default_memory_insert_breakpoint::0
-f:=:int:memory_remove_breakpoint:CORE_ADDR addr, gdb_byte *contents_cache:addr, contents_cache:0:default_memory_remove_breakpoint::0
+f:=:int:memory_insert_breakpoint:struct bp_target_info *bp_tgt:bp_tgt:0:default_memory_insert_breakpoint::0
+f:=:int:memory_remove_breakpoint:struct bp_target_info *bp_tgt:bp_tgt:0:default_memory_remove_breakpoint::0
v:=:CORE_ADDR:decr_pc_after_break:::0:::0
# A function can be addressed by either it's "pointer" (possibly a
@@ -771,6 +771,7 @@ struct regset;
struct disassemble_info;
struct target_ops;
struct obstack;
+struct bp_target_info;
extern struct gdbarch *current_gdbarch;
EOF
Index: i386-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-nat.c,v
retrieving revision 1.13
diff -u -p -r1.13 i386-nat.c
--- i386-nat.c 17 Dec 2005 22:34:01 -0000 1.13
+++ i386-nat.c 17 Apr 2006 19:03:22 -0000
@@ -625,12 +625,13 @@ i386_stopped_by_hwbp (void)
return 0;
}
-/* Insert a hardware-assisted breakpoint at address ADDR. SHADOW is
- unused. Return 0 on success, EBUSY on failure. */
+/* Insert a hardware-assisted breakpoint at BP_TGT->placed_address.
+ Return 0 on success, EBUSY on failure. */
int
-i386_insert_hw_breakpoint (CORE_ADDR addr, void *shadow)
+i386_insert_hw_breakpoint (struct bp_target_info *bp_tgt)
{
unsigned len_rw = i386_length_and_rw_bits (1, hw_execute);
+ CORE_ADDR addr = bp_tgt->placed_address;
int retval = i386_insert_aligned_watchpoint (addr, len_rw) ? EBUSY : 0;
if (maint_show_dr)
@@ -639,13 +640,14 @@ i386_insert_hw_breakpoint (CORE_ADDR add
return retval;
}
-/* Remove a hardware-assisted breakpoint at address ADDR. SHADOW is
- unused. Return 0 on success, -1 on failure. */
+/* Remove a hardware-assisted breakpoint at BP_TGT->placed_address.
+ Return 0 on success, -1 on failure. */
int
-i386_remove_hw_breakpoint (CORE_ADDR addr, void *shadow)
+i386_remove_hw_breakpoint (struct bp_target_info *bp_tgt)
{
unsigned len_rw = i386_length_and_rw_bits (1, hw_execute);
+ CORE_ADDR addr = bp_tgt->placed_address;
int retval = i386_remove_aligned_watchpoint (addr, len_rw);
if (maint_show_dr)
Index: ia64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ia64-tdep.c,v
retrieving revision 1.138
diff -u -p -r1.138 ia64-tdep.c
--- ia64-tdep.c 8 Mar 2006 15:28:17 -0000 1.138
+++ ia64-tdep.c 17 Apr 2006 19:03:22 -0000
@@ -550,8 +550,9 @@ fetch_instruction (CORE_ADDR addr, instr
#define IA64_BREAKPOINT 0x00003333300LL
static int
-ia64_memory_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+ia64_memory_insert_breakpoint (struct bp_target_info *bp_tgt)
{
+ CORE_ADDR addr = bp_tgt->placed_address;
char bundle[BUNDLE_LEN];
int slotnum = (int) (addr & 0x0f) / SLOT_MULTIPLIER;
long long instr;
@@ -574,7 +575,8 @@ ia64_memory_insert_breakpoint (CORE_ADDR
}
instr = slotN_contents (bundle, slotnum);
- memcpy(contents_cache, &instr, sizeof(instr));
+ memcpy (bp_tgt->shadow_contents, &instr, sizeof (instr));
+ bp_tgt->placed_size = bp_tgt->shadow_len = sizeof (instr);
replace_slotN_contents (bundle, IA64_BREAKPOINT, slotnum);
if (val == 0)
target_write_memory (addr, bundle, BUNDLE_LEN);
@@ -583,8 +585,9 @@ ia64_memory_insert_breakpoint (CORE_ADDR
}
static int
-ia64_memory_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+ia64_memory_remove_breakpoint (struct bp_target_info *bp_tgt)
{
+ CORE_ADDR addr = bp_tgt->placed_address;
char bundle[BUNDLE_LEN];
int slotnum = (addr & 0x0f) / SLOT_MULTIPLIER;
long long instr;
@@ -603,7 +606,7 @@ ia64_memory_remove_breakpoint (CORE_ADDR
slotnum = 2;
}
- memcpy (&instr, contents_cache, sizeof instr);
+ memcpy (&instr, bp_tgt->shadow_contents, sizeof instr);
replace_slotN_contents (bundle, instr, slotnum);
if (val == 0)
target_write_memory (addr, bundle, BUNDLE_LEN);
Index: m32r-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/m32r-tdep.c,v
retrieving revision 1.40
diff -u -p -r1.40 m32r-tdep.c
--- m32r-tdep.c 17 Dec 2005 22:34:01 -0000 1.40
+++ m32r-tdep.c 17 Apr 2006 19:03:22 -0000
@@ -81,10 +81,12 @@ m32r_frame_align (struct gdbarch *gdbarc
The following functions take care of this behavior. */
static int
-m32r_memory_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+m32r_memory_insert_breakpoint (struct bp_target_info *bp_tgt)
{
+ CORE_ADDR addr = bp_tgt->placed_address;
int val;
gdb_byte buf[4];
+ gdb_byte *contents_cache = bp_tgt->shadow_contents;
gdb_byte bp_entry[] = { 0x10, 0xf1 }; /* dpt */
/* Save the memory contents. */
@@ -92,6 +94,8 @@ m32r_memory_insert_breakpoint (CORE_ADDR
if (val != 0)
return val; /* return error */
+ bp_tgt->placed_size = bp_tgt->shadow_len = 4;
+
/* Determine appropriate breakpoint contents and size for this address. */
if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
{
@@ -134,10 +138,12 @@ m32r_memory_insert_breakpoint (CORE_ADDR
}
static int
-m32r_memory_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+m32r_memory_remove_breakpoint (struct bp_target_info *bp_tgt)
{
+ CORE_ADDR addr = bp_tgt->placed_address;
int val;
gdb_byte buf[4];
+ gdb_byte *contents_cache = bp_tgt->shadow_contents;
buf[0] = contents_cache[0];
buf[1] = contents_cache[1];
Index: mem-break.c
===================================================================
RCS file: /cvs/src/src/gdb/mem-break.c,v
retrieving revision 1.11
diff -u -p -r1.11 mem-break.c
--- mem-break.c 17 Dec 2005 22:34:01 -0000 1.11
+++ mem-break.c 17 Apr 2006 19:03:22 -0000
@@ -33,60 +33,57 @@
#include "target.h"
-/* Insert a breakpoint on targets that don't have any better breakpoint
- support. We read the contents of the target location and stash it,
- then overwrite it with a breakpoint instruction. ADDR is the target
- location in the target machine. CONTENTS_CACHE is a pointer to
- memory allocated for saving the target contents. It is guaranteed
- by the caller to be long enough to save BREAKPOINT_LEN bytes (this
- is accomplished via BREAKPOINT_MAX). */
+/* Insert a breakpoint on targets that don't have any better
+ breakpoint support. We read the contents of the target location
+ and stash it, then overwrite it with a breakpoint instruction.
+ BP_TGT->placed_address is the target location in the target
+ machine. BP_TGT->shadow_contents is some memory allocated for
+ saving the target contents. It is guaranteed by the caller to be
+ long enough to save BREAKPOINT_LEN bytes (this is accomplished via
+ BREAKPOINT_MAX). */
int
-default_memory_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+default_memory_insert_breakpoint (struct bp_target_info *bp_tgt)
{
int val;
const unsigned char *bp;
int bplen;
/* Determine appropriate breakpoint contents and size for this address. */
- bp = BREAKPOINT_FROM_PC (&addr, &bplen);
+ bp = BREAKPOINT_FROM_PC (&bp_tgt->placed_address, &bp_tgt->placed_size);
if (bp == NULL)
error (_("Software breakpoints not implemented for this target."));
/* Save the memory contents. */
- val = target_read_memory (addr, contents_cache, bplen);
+ bp_tgt->shadow_len = bp_tgt->placed_size;
+ val = target_read_memory (bp_tgt->placed_address, bp_tgt->shadow_contents,
+ bp_tgt->placed_size);
/* Write the breakpoint. */
if (val == 0)
- val = target_write_memory (addr, bp, bplen);
+ val = target_write_memory (bp_tgt->placed_address, bp,
+ bp_tgt->placed_size);
return val;
}
int
-default_memory_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+default_memory_remove_breakpoint (struct bp_target_info *bp_tgt)
{
- const bfd_byte *bp;
- int bplen;
-
- /* Determine appropriate breakpoint contents and size for this address. */
- bp = BREAKPOINT_FROM_PC (&addr, &bplen);
- if (bp == NULL)
- error (_("Software breakpoints not implemented for this target."));
-
- return target_write_memory (addr, contents_cache, bplen);
+ return target_write_memory (bp_tgt->placed_address, bp_tgt->shadow_contents,
+ bp_tgt->placed_size);
}
int
-memory_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+memory_insert_breakpoint (struct bp_target_info *bp_tgt)
{
- return MEMORY_INSERT_BREAKPOINT(addr, contents_cache);
+ return MEMORY_INSERT_BREAKPOINT (bp_tgt);
}
int
-memory_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+memory_remove_breakpoint (struct bp_target_info *bp_tgt)
{
- return MEMORY_REMOVE_BREAKPOINT(addr, contents_cache);
+ return MEMORY_REMOVE_BREAKPOINT (bp_tgt);
}
Index: mips-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-tdep.c,v
retrieving revision 1.388
diff -u -p -r1.388 mips-tdep.c
--- mips-tdep.c 15 Mar 2006 16:59:54 -0000 1.388
+++ mips-tdep.c 17 Apr 2006 19:03:23 -0000
@@ -2188,20 +2188,17 @@ mips_addr_bits_remove (CORE_ADDR addr)
void
mips_software_single_step (enum target_signal sig, int insert_breakpoints_p)
{
- static CORE_ADDR next_pc;
- typedef char binsn_quantum[BREAKPOINT_MAX];
- static binsn_quantum break_mem;
- CORE_ADDR pc;
+ CORE_ADDR pc, next_pc;
if (insert_breakpoints_p)
{
pc = read_register (mips_regnum (current_gdbarch)->pc);
next_pc = mips_next_pc (pc);
- target_insert_breakpoint (next_pc, break_mem);
+ insert_single_step_breakpoint (next_pc);
}
else
- target_remove_breakpoint (next_pc, break_mem);
+ remove_single_step_breakpoints ();
}
/* Test whether the PC points to the return instruction at the
Index: monitor.c
===================================================================
RCS file: /cvs/src/src/gdb/monitor.c,v
retrieving revision 1.63
diff -u -p -r1.63 monitor.c
--- monitor.c 24 Jan 2006 22:09:28 -0000 1.63
+++ monitor.c 17 Apr 2006 19:03:23 -0000
@@ -85,8 +85,6 @@ static int monitor_xfer_memory (CORE_ADD
struct mem_attrib *attrib,
struct target_ops *target);
static void monitor_files_info (struct target_ops *ops);
-static int monitor_insert_breakpoint (CORE_ADDR addr, gdb_byte *shadow);
-static int monitor_remove_breakpoint (CORE_ADDR addr, gdb_byte *shadow);
static void monitor_kill (void);
static void monitor_load (char *file, int from_tty);
static void monitor_mourn_inferior (void);
@@ -2037,8 +2035,9 @@ monitor_mourn_inferior (void)
/* Tell the monitor to add a breakpoint. */
static int
-monitor_insert_breakpoint (CORE_ADDR addr, gdb_byte *shadow)
+monitor_insert_breakpoint (struct bp_target_info *bp_tgt)
{
+ CORE_ADDR addr = bp_tgt->placed_address;
int i;
const unsigned char *bp;
int bplen;
@@ -2052,13 +2051,14 @@ monitor_insert_breakpoint (CORE_ADDR add
/* Determine appropriate breakpoint size for this address. */
bp = gdbarch_breakpoint_from_pc (current_gdbarch, &addr, &bplen);
+ bp_tgt->placed_address = addr;
+ bp_tgt->placed_size = bplen;
for (i = 0; i < current_monitor->num_breakpoints; i++)
{
if (breakaddr[i] == 0)
{
breakaddr[i] = addr;
- monitor_read_memory (addr, shadow, bplen);
monitor_printf (current_monitor->set_break, addr);
monitor_expect_prompt (NULL, 0);
return 0;
@@ -2071,17 +2071,15 @@ monitor_insert_breakpoint (CORE_ADDR add
/* Tell the monitor to remove a breakpoint. */
static int
-monitor_remove_breakpoint (CORE_ADDR addr, gdb_byte *shadow)
+monitor_remove_breakpoint (struct bp_target_info *bp_tgt)
{
+ CORE_ADDR addr = bp_tgt->placed_address;
int i;
monitor_debug ("MON rmbkpt %s\n", paddr (addr));
if (current_monitor->clr_break == NULL)
error (_("No clr_break defined for this monitor"));
- if (current_monitor->flags & MO_ADDR_BITS_REMOVE)
- addr = ADDR_BITS_REMOVE (addr);
-
for (i = 0; i < current_monitor->num_breakpoints; i++)
{
if (breakaddr[i] == addr)
Index: nto-procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/nto-procfs.c,v
retrieving revision 1.17
diff -u -p -r1.17 nto-procfs.c
--- nto-procfs.c 24 Jan 2006 22:09:28 -0000 1.17
+++ nto-procfs.c 17 Apr 2006 19:03:23 -0000
@@ -76,10 +76,6 @@ static ptid_t do_attach (ptid_t ptid);
static int procfs_can_use_hw_breakpoint (int, int, int);
-static int procfs_insert_hw_breakpoint (CORE_ADDR, char *);
-
-static int procfs_remove_hw_breakpoint (CORE_ADDR addr, char *);
-
static int procfs_insert_hw_watchpoint (CORE_ADDR addr, int len, int type);
static int procfs_remove_hw_watchpoint (CORE_ADDR addr, int len, int type);
@@ -812,27 +808,29 @@ procfs_breakpoint (CORE_ADDR addr, int t
}
static int
-procfs_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
+procfs_insert_breakpoint (struct bp_target_info *bp_tgt)
{
- return procfs_breakpoint (addr, _DEBUG_BREAK_EXEC, 0);
+ return procfs_breakpoint (bp_tgt->placed_address, _DEBUG_BREAK_EXEC, 0);
}
static int
-procfs_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
+procfs_remove_breakpoint (struct bp_target_info *bp_tgt)
{
- return procfs_breakpoint (addr, _DEBUG_BREAK_EXEC, -1);
+ return procfs_breakpoint (bp_tgt->placed_address, _DEBUG_BREAK_EXEC, -1);
}
static int
-procfs_insert_hw_breakpoint (CORE_ADDR addr, char *contents_cache)
+procfs_insert_hw_breakpoint (struct bp_target_info *bp_tgt)
{
- return procfs_breakpoint (addr, _DEBUG_BREAK_EXEC | _DEBUG_BREAK_HW, 0);
+ return procfs_breakpoint (bp_tgt->placed_address,
+ _DEBUG_BREAK_EXEC | _DEBUG_BREAK_HW, 0);
}
static int
-procfs_remove_hw_breakpoint (CORE_ADDR addr, char *contents_cache)
+procfs_remove_hw_breakpoint (struct bp_target_info *bp_tgt)
{
- return procfs_breakpoint (addr, _DEBUG_BREAK_EXEC | _DEBUG_BREAK_HW, -1);
+ return procfs_breakpoint (bp_tgt->placed_address,
+ _DEBUG_BREAK_EXEC | _DEBUG_BREAK_HW, -1);
}
static void
Index: ocd.c
===================================================================
RCS file: /cvs/src/src/gdb/ocd.c,v
retrieving revision 1.43
diff -u -p -r1.43 ocd.c
--- ocd.c 24 Jan 2006 22:09:28 -0000 1.43
+++ ocd.c 17 Apr 2006 19:03:23 -0000
@@ -1048,28 +1048,27 @@ ocd_load (char *args, int from_tty)
/* BDM (at least on CPU32) uses a different breakpoint */
int
-ocd_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
+ocd_insert_breakpoint (struct bp_target_info *bp_tgt)
{
static char break_insn[] = BDM_BREAKPOINT;
int val;
- val = target_read_memory (addr, contents_cache, sizeof (break_insn));
+ bp_tgt->placed_size = bp_tgt->shadow_len = sizeof (break_insn);
+ val = target_read_memory (bp_tgt->placed_address, bp_tgt->shadow_contents,
+ bp_tgt->placed_size);
if (val == 0)
- val = target_write_memory (addr, break_insn, sizeof (break_insn));
+ val = target_write_memory (bp_tgt->placed_address, break_insn,
+ bp_tgt->placed_size);
return val;
}
int
-ocd_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
+ocd_remove_breakpoint (struct bp_target_info *bp_tgt)
{
- static char break_insn[] = BDM_BREAKPOINT;
- int val;
-
- val = target_write_memory (addr, contents_cache, sizeof (break_insn));
-
- return val;
+ return target_write_memory (bp_tgt->placed_address, bp_tgt->shadow_contents,
+ bp_tgt->placed_size);
}
static void
Index: ocd.h
===================================================================
RCS file: /cvs/src/src/gdb/ocd.h,v
retrieving revision 1.8
diff -u -p -r1.8 ocd.h
--- ocd.h 17 Dec 2005 22:34:01 -0000 1.8
+++ ocd.h 17 Apr 2006 19:03:23 -0000
@@ -135,8 +135,8 @@ void ocd_write_bdm_register (int bdm_reg
int ocd_wait (void);
-int ocd_insert_breakpoint (CORE_ADDR addr, char *contents_cache);
-int ocd_remove_breakpoint (CORE_ADDR addr, char *contents_cache);
+int ocd_insert_breakpoint (struct bp_target_info *bp_tgt);
+int ocd_remove_breakpoint (struct bp_target_info *bp_tgt);
int ocd_write_bytes (CORE_ADDR memaddr, char *myaddr, int len);
Index: ppc-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v
retrieving revision 1.77
diff -u -p -r1.77 ppc-linux-tdep.c
--- ppc-linux-tdep.c 15 Jan 2006 18:28:58 -0000 1.77
+++ ppc-linux-tdep.c 17 Apr 2006 19:03:23 -0000
@@ -457,9 +457,9 @@ ppc_linux_skip_trampoline_code (CORE_ADD
regard to removing breakpoints in some potentially self modifying
code. */
int
-ppc_linux_memory_remove_breakpoint (CORE_ADDR addr,
- gdb_byte *contents_cache)
+ppc_linux_memory_remove_breakpoint (struct bp_target_info *bp_tgt)
{
+ CORE_ADDR addr = bp_tgt->placed_address;
const unsigned char *bp;
int val;
int bplen;
@@ -476,7 +476,7 @@ ppc_linux_memory_remove_breakpoint (CORE
program modified the code on us, so it is wrong to put back the
old value */
if (val == 0 && memcmp (bp, old_contents, bplen) == 0)
- val = target_write_memory (addr, contents_cache, bplen);
+ val = target_write_memory (addr, bp_tgt->shadow_contents, bplen);
return val;
}
Index: ppc-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/ppc-tdep.h,v
retrieving revision 1.50
diff -u -p -r1.50 ppc-tdep.h
--- ppc-tdep.h 17 Jan 2006 22:21:13 -0000 1.50
+++ ppc-tdep.h 17 Apr 2006 19:03:24 -0000
@@ -56,8 +56,7 @@ CORE_ADDR ppc64_sysv_abi_push_dummy_call
CORE_ADDR struct_addr);
CORE_ADDR ppc64_sysv_abi_adjust_breakpoint_address (struct gdbarch *gdbarch,
CORE_ADDR bpaddr);
-int ppc_linux_memory_remove_breakpoint (CORE_ADDR addr,
- gdb_byte *contents_cache);
+int ppc_linux_memory_remove_breakpoint (struct bp_target_info *bp_tgt);
struct link_map_offsets *ppc_linux_svr4_fetch_link_map_offsets (void);
void ppc_linux_supply_gregset (struct regcache *regcache,
int regnum, const void *gregs, size_t size,
Index: procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/procfs.c,v
retrieving revision 1.68
diff -u -p -r1.68 procfs.c
--- procfs.c 24 Jan 2006 22:09:28 -0000 1.68
+++ procfs.c 17 Apr 2006 19:03:25 -0000
@@ -3375,7 +3375,7 @@ static void remove_dbx_link_breakpoint (
the address of the breakpoint, and the code that was replaced by
a breakpoint. */
static int dbx_link_bpt_addr = 0;
-static char dbx_link_shadow_contents[BREAKPOINT_MAX];
+static void *dbx_link_bpt;
/*
* Function: procfs_debug_inferior
@@ -4777,6 +4777,14 @@ procfs_mourn_inferior (void)
destroy_procinfo (pi);
}
unpush_target (&procfs_ops);
+
+ if (dbx_link_bpt != NULL)
+ {
+ deprecated_remove_raw_breakpoint (dbx_link_bpt);
+ dbx_link_bpt_addr = 0;
+ dbx_link_bpt = NULL;
+ }
+
generic_mourn_inferior ();
}
@@ -4886,7 +4894,6 @@ procfs_init_inferior (int pid)
has been inserted, the syssgi() notifications are no longer necessary,
so they should be canceled. */
proc_trace_syscalls_1 (pi, SYS_syssgi, PR_SYSEXIT, FLAG_SET, 0);
- dbx_link_bpt_addr = 0;
#endif
}
@@ -5571,11 +5578,11 @@ remove_dbx_link_breakpoint (void)
if (dbx_link_bpt_addr == 0)
return;
- if (memory_remove_breakpoint (dbx_link_bpt_addr,
- dbx_link_shadow_contents) != 0)
+ if (deprecated_remove_raw_breakpoint (dbx_link_bpt) != 0)
warning (_("Unable to remove __dbx_link breakpoint."));
dbx_link_bpt_addr = 0;
+ dbx_link_bpt = NULL;
}
/* Return the address of the __dbx_link() function in the file
@@ -5643,7 +5650,8 @@ insert_dbx_link_bpt_in_file (int fd, COR
{
/* Insert the breakpoint. */
dbx_link_bpt_addr = sym_addr;
- if (target_insert_breakpoint (sym_addr, dbx_link_shadow_contents) != 0)
+ dbx_link_bpt = deprecated_insert_raw_breakpoint (sym_addr);
+ if (dbx_link_bpt == NULL)
{
warning (_("Failed to insert dbx_link breakpoint."));
bfd_close (abfd);
Index: remote-e7000.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-e7000.c,v
retrieving revision 1.57
diff -u -p -r1.57 remote-e7000.c
--- remote-e7000.c 24 Jan 2006 22:09:28 -0000 1.57
+++ remote-e7000.c 17 Apr 2006 19:03:25 -0000
@@ -1702,8 +1702,9 @@ static CORE_ADDR breakaddr[MAX_BREAKPOIN
{0};
static int
-e7000_insert_breakpoint (CORE_ADDR addr, bfd_byte *shadow)
+e7000_insert_breakpoint (struct bp_target_info *bp_tgt)
{
+ CORE_ADDR addr = bp_tgt->placed_address;
int i;
char buf[200];
#if 0
@@ -1728,7 +1729,8 @@ e7000_insert_breakpoint (CORE_ADDR addr,
}
#else
#if 0
- e7000_read_inferior_memory (addr, shadow, 2);
+ bp_tgt->shadow_len = 2;
+ e7000_read_inferior_memory (addr, bp_tgt->shadow_contents, 2);
e7000_write_inferior_memory (addr, nop, 2);
#endif
@@ -1745,8 +1747,9 @@ e7000_insert_breakpoint (CORE_ADDR addr,
}
static int
-e7000_remove_breakpoint (CORE_ADDR addr, bfd_byte *shadow)
+e7000_remove_breakpoint (struct bp_target_info *bp_tgt)
{
+ CORE_ADDR addr = bp_tgt->placed_address;
int i;
char buf[200];
@@ -1773,7 +1776,8 @@ e7000_remove_breakpoint (CORE_ADDR addr,
#if 0
/* Replace the insn under the break */
- e7000_write_inferior_memory (addr, shadow, 2);
+ e7000_write_inferior_memory (addr, bp_tgt->shadow_contents,
+ bp_tgt->shadow_len);
#endif
#endif
Index: remote-m32r-sdi.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-m32r-sdi.c,v
retrieving revision 1.17
diff -u -p -r1.17 remote-m32r-sdi.c
--- remote-m32r-sdi.c 24 Jan 2006 22:09:28 -0000 1.17
+++ remote-m32r-sdi.c 17 Apr 2006 19:03:25 -0000
@@ -1141,15 +1141,16 @@ m32r_mourn_inferior (void)
}
static int
-m32r_insert_breakpoint (CORE_ADDR addr, bfd_byte *shadow)
+m32r_insert_breakpoint (struct bp_target_info *bp_tgt)
{
+ CORE_ADDR addr = bp_tgt->placed_address;
int ib_breakpoints;
unsigned char buf[13];
int i, c;
if (remote_debug)
- fprintf_unfiltered (gdb_stdlog, "m32r_insert_breakpoint(%08lx,\"%s\")\n",
- addr, shadow);
+ fprintf_unfiltered (gdb_stdlog, "m32r_insert_breakpoint(%08lx,...)\n",
+ addr);
if (use_ib_breakpoints)
ib_breakpoints = max_ib_breakpoints;
@@ -1183,13 +1184,14 @@ m32r_insert_breakpoint (CORE_ADDR addr,
}
static int
-m32r_remove_breakpoint (CORE_ADDR addr, bfd_byte *shadow)
+m32r_remove_breakpoint (struct bp_target_info *bp_tgt)
{
+ CORE_ADDR addr = bp_tgt->placed_address;
int i;
if (remote_debug)
- fprintf_unfiltered (gdb_stdlog, "m32r_remove_breakpoint(%08lx,\"%s\")\n",
- addr, shadow);
+ fprintf_unfiltered (gdb_stdlog, "m32r_remove_breakpoint(%08lx)\n",
+ addr);
for (i = 0; i < MAX_BREAKPOINTS; i++)
{
Index: remote-mips.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-mips.c,v
retrieving revision 1.68
diff -u -p -r1.68 remote-mips.c
--- remote-mips.c 24 Jan 2006 22:09:28 -0000 1.68
+++ remote-mips.c 17 Apr 2006 19:03:26 -0000
@@ -2216,27 +2216,28 @@ mips_mourn_inferior (void)
/* Insert a breakpoint. On targets that don't have built-in
breakpoint support, we read the contents of the target location and
stash it, then overwrite it with a breakpoint instruction. ADDR is
- the target location in the target machine. CONTENTS_CACHE is a
- pointer to memory allocated for saving the target contents. It is
- guaranteed by the caller to be long enough to save the breakpoint
- length returned by BREAKPOINT_FROM_PC. */
+ the target location in the target machine. BPT is the breakpoint
+ being inserted or removed, which contains memory for saving the
+ target contents. */
static int
-mips_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
+mips_insert_breakpoint (struct bp_target_info *bp_tgt)
{
if (monitor_supports_breakpoints)
- return set_breakpoint (addr, MIPS_INSN32_SIZE, BREAK_FETCH);
+ return set_breakpoint (bp_tgt->placed_address, MIPS_INSN32_SIZE,
+ BREAK_FETCH);
else
- return memory_insert_breakpoint (addr, contents_cache);
+ return memory_insert_breakpoint (bp_tgt);
}
static int
-mips_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
+mips_remove_breakpoint (struct bp_target_info *bp_tgt)
{
if (monitor_supports_breakpoints)
- return clear_breakpoint (addr, MIPS_INSN32_SIZE, BREAK_FETCH);
+ return clear_breakpoint (bp_tgt->placed_address, MIPS_INSN32_SIZE,
+ BREAK_FETCH);
else
- return memory_remove_breakpoint (addr, contents_cache);
+ return memory_remove_breakpoint (bp_tgt);
}
/* Tell whether this target can support a hardware breakpoint. CNT
Index: remote-rdp.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-rdp.c,v
retrieving revision 1.49
diff -u -p -r1.49 remote-rdp.c
--- remote-rdp.c 3 Mar 2006 23:08:12 -0000 1.49
+++ remote-rdp.c 17 Apr 2006 19:03:26 -0000
@@ -1050,8 +1050,10 @@ rdp_execute (void)
}
static int
-remote_rdp_insert_breakpoint (CORE_ADDR addr, bfd_byte *save)
+remote_rdp_insert_breakpoint (struct bp_target_info *bp_tgt)
{
+ CORE_ADDR addr = bp_tgt->placed_address;
+
int res;
if (ds.rdi_level > 0)
{
@@ -1059,7 +1061,7 @@ remote_rdp_insert_breakpoint (CORE_ADDR
RDP_SET_BREAK,
addr,
RDP_SET_BREAK_TYPE_PC_EQUAL | RDP_SET_BREAK_TYPE_GET_HANDLE,
- save,
+ bp_tgt->shadow_contents,
&res);
}
else
@@ -1074,14 +1076,15 @@ remote_rdp_insert_breakpoint (CORE_ADDR
}
static int
-remote_rdp_remove_breakpoint (CORE_ADDR addr, bfd_byte *save)
+remote_rdp_remove_breakpoint (struct bp_target_info *bp_tgt)
{
+ CORE_ADDR addr = bp_tgt->placed_address;
int res;
if (ds.rdi_level > 0)
{
send_rdp ("b-p-S-B",
RDP_CLEAR_BREAK,
- save, 4,
+ bp_tgt->shadow_contents, 4,
&res);
}
else
@@ -1108,12 +1111,12 @@ rdp_step (void)
}
else
{
- char handle[4];
+ void *b;
CORE_ADDR pc = read_register (ARM_PC_REGNUM);
pc = arm_get_next_pc (pc);
- remote_rdp_insert_breakpoint (pc, handle);
+ b = deprecated_insert_raw_breakpoint (pc);
rdp_execute ();
- remote_rdp_remove_breakpoint (pc, handle);
+ deprecated_remove_raw_breakpoint (b);
}
}
Index: remote-sds.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-sds.c,v
retrieving revision 1.42
diff -u -p -r1.42 remote-sds.c
--- remote-sds.c 24 Jan 2006 22:09:28 -0000 1.42
+++ remote-sds.c 17 Apr 2006 19:03:26 -0000
@@ -99,10 +99,6 @@ static void interrupt_query (void);
static int read_frame (char *);
-static int sds_insert_breakpoint (CORE_ADDR, char *);
-
-static int sds_remove_breakpoint (CORE_ADDR, char *);
-
static void init_sds_ops (void);
static void sds_command (char *args, int from_tty);
@@ -1004,8 +1000,9 @@ sds_load (char *filename, int from_tty)
replaced instruction back to the debugger. */
static int
-sds_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
+sds_insert_breakpoint (struct bp_target_info *bp_tgt)
{
+ CORE_ADDR addr = bp_tgt->placed_address;
int i, retlen;
unsigned char *p, buf[PBUFSIZ];
@@ -1020,14 +1017,15 @@ sds_insert_breakpoint (CORE_ADDR addr, c
retlen = sds_send (buf, p - buf);
for (i = 0; i < 4; ++i)
- contents_cache[i] = buf[i + 2];
+ bp_tgt->shadow_contents[i] = buf[i + 2];
return 0;
}
static int
-sds_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
+sds_remove_breakpoint (struct bp_target_info *bp_tgt)
{
+ CORE_ADDR addr = bp_tgt->placed_address;
int i, retlen;
unsigned char *p, buf[PBUFSIZ];
@@ -1039,7 +1037,7 @@ sds_remove_breakpoint (CORE_ADDR addr, c
*p++ = (int) (addr >> 8) & 0xff;
*p++ = (int) (addr) & 0xff;
for (i = 0; i < 4; ++i)
- *p++ = contents_cache[i];
+ *p++ = bp_tgt->shadow_contents[i];
retlen = sds_send (buf, p - buf);
Index: remote-sim.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-sim.c,v
retrieving revision 1.53
diff -u -p -r1.53 remote-sim.c
--- remote-sim.c 21 Feb 2006 18:22:26 -0000 1.53
+++ remote-sim.c 17 Apr 2006 19:03:26 -0000
@@ -805,18 +805,6 @@ gdbsim_mourn_inferior (void)
generic_mourn_inferior ();
}
-static int
-gdbsim_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
-{
- return memory_insert_breakpoint (addr, contents_cache);
-}
-
-static int
-gdbsim_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
-{
- return memory_remove_breakpoint (addr, contents_cache);
-}
-
/* Pass the command argument through to the simulator verbatim. The
simulator must do any command interpretation work. */
@@ -866,8 +854,8 @@ init_gdbsim_ops (void)
gdbsim_ops.to_prepare_to_store = gdbsim_prepare_to_store;
gdbsim_ops.deprecated_xfer_memory = gdbsim_xfer_inferior_memory;
gdbsim_ops.to_files_info = gdbsim_files_info;
- gdbsim_ops.to_insert_breakpoint = gdbsim_insert_breakpoint;
- gdbsim_ops.to_remove_breakpoint = gdbsim_remove_breakpoint;
+ gdbsim_ops.to_insert_breakpoint = memory_insert_breakpoint;
+ gdbsim_ops.to_remove_breakpoint = memory_remove_breakpoint;
gdbsim_ops.to_kill = gdbsim_kill;
gdbsim_ops.to_load = gdbsim_load;
gdbsim_ops.to_create_inferior = gdbsim_create_inferior;
Index: remote-st.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-st.c,v
retrieving revision 1.30
diff -u -p -r1.30 remote-st.c
--- remote-st.c 10 Feb 2006 22:01:43 -0000 1.30
+++ remote-st.c 17 Apr 2006 19:03:26 -0000
@@ -599,20 +599,16 @@ static CORE_ADDR breakaddr[MAX_STDEBUG_B
{0};
static int
-st2000_insert_breakpoint (CORE_ADDR addr, char *shadow)
+st2000_insert_breakpoint (struct bp_target_info *bp_tgt)
{
+ CORE_ADDR addr = bp_tgt->placed_address;
int i;
- CORE_ADDR bp_addr = addr;
- int bp_size = 0;
-
- BREAKPOINT_FROM_PC (&bp_addr, &bp_size);
for (i = 0; i <= MAX_STDEBUG_BREAKPOINTS; i++)
if (breakaddr[i] == 0)
{
breakaddr[i] = addr;
- st2000_read_inferior_memory (bp_addr, shadow, bp_size);
printf_stdebug ("BR %x H\r", addr);
expect_prompt (1);
return 0;
@@ -623,8 +619,9 @@ st2000_insert_breakpoint (CORE_ADDR addr
}
static int
-st2000_remove_breakpoint (CORE_ADDR addr, char *shadow)
+st2000_remove_breakpoint (struct bp_target_info *bp_tgt)
{
+ CORE_ADDR addr = bp_tgt->placed_address;
int i;
for (i = 0; i < MAX_STDEBUG_BREAKPOINTS; i++)
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.207
diff -u -p -r1.207 remote.c
--- remote.c 12 Apr 2006 14:27:40 -0000 1.207
+++ remote.c 17 Apr 2006 19:03:27 -0000
@@ -136,10 +136,6 @@ static void skip_frame (void);
static long read_frame (char **buf_p, long *sizeof_buf);
-static int remote_insert_breakpoint (CORE_ADDR, bfd_byte *);
-
-static int remote_remove_breakpoint (CORE_ADDR, bfd_byte *);
-
static int hexnumlen (ULONGEST num);
static void init_remote_ops (void);
@@ -4356,22 +4352,18 @@ static unsigned char little_break_insn[]
#endif /* DEPRECATED_REMOTE_BREAKPOINT */
-/* Insert a breakpoint on targets that don't have any better
- breakpoint support. We read the contents of the target location
- and stash it, then overwrite it with a breakpoint instruction.
- ADDR is the target location in the target machine. CONTENTS_CACHE
- is a pointer to memory allocated for saving the target contents.
- It is guaranteed by the caller to be long enough to save the number
- of bytes returned by BREAKPOINT_FROM_PC. */
+/* Insert a breakpoint. On targets that have software breakpoint
+ support, we ask the remote target to do the work; on targets
+ which don't, we insert a traditional memory breakpoint. */
static int
-remote_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+remote_insert_breakpoint (struct bp_target_info *bp_tgt)
{
+ CORE_ADDR addr = bp_tgt->placed_address;
struct remote_state *rs = get_remote_state ();
#ifdef DEPRECATED_REMOTE_BREAKPOINT
int val;
#endif
- int bp_size;
/* Try the "Z" s/w breakpoint packet if it is not already disabled.
If it succeeds, then set the support to PACKET_ENABLE. If it
@@ -4382,13 +4374,13 @@ remote_insert_breakpoint (CORE_ADDR addr
{
char *p = rs->buf;
- addr = remote_address_masked (addr);
*(p++) = 'Z';
*(p++) = '0';
*(p++) = ',';
- p += hexnumstr (p, (ULONGEST) addr);
- BREAKPOINT_FROM_PC (&addr, &bp_size);
- sprintf (p, ",%d", bp_size);
+ BREAKPOINT_FROM_PC (&bp_tgt->placed_address, &bp_tgt->placed_size);
+ addr = (ULONGEST) remote_address_masked (bp_tgt->placed_address);
+ p += hexnumstr (p, addr);
+ sprintf (p, ",%d", bp_tgt->placed_size);
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
@@ -4405,7 +4397,8 @@ remote_insert_breakpoint (CORE_ADDR addr
}
#ifdef DEPRECATED_REMOTE_BREAKPOINT
- val = target_read_memory (addr, contents_cache, sizeof big_break_insn);
+ bp_tgt->placed_size = bp_tgt->shadow_len = sizeof big_break_insn;
+ val = target_read_memory (addr, bp_tgt->shadow_contents, bp_tgt->shadow_len);
if (val == 0)
{
@@ -4419,13 +4412,14 @@ remote_insert_breakpoint (CORE_ADDR addr
return val;
#else
- return memory_insert_breakpoint (addr, contents_cache);
+ return memory_insert_breakpoint (bp_tgt);
#endif /* DEPRECATED_REMOTE_BREAKPOINT */
}
static int
-remote_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
+remote_remove_breakpoint (struct bp_target_info *bp_tgt)
{
+ CORE_ADDR addr = bp_tgt->placed_address;
struct remote_state *rs = get_remote_state ();
int bp_size;
@@ -4437,10 +4431,9 @@ remote_remove_breakpoint (CORE_ADDR addr
*(p++) = '0';
*(p++) = ',';
- addr = remote_address_masked (addr);
- p += hexnumstr (p, (ULONGEST) addr);
- BREAKPOINT_FROM_PC (&addr, &bp_size);
- sprintf (p, ",%d", bp_size);
+ addr = (ULONGEST) remote_address_masked (bp_tgt->placed_address);
+ p += hexnumstr (p, addr);
+ sprintf (p, ",%d", bp_tgt->placed_size);
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
@@ -4449,9 +4442,10 @@ remote_remove_breakpoint (CORE_ADDR addr
}
#ifdef DEPRECATED_REMOTE_BREAKPOINT
- return target_write_memory (addr, contents_cache, sizeof big_break_insn);
+ return target_write_memory (bp_tgt->placed_address, bp_tgt->shadow_contents,
+ bp_tgt->shadow_len);
#else
- return memory_remove_breakpoint (addr, contents_cache);
+ return memory_remove_breakpoint (bp_tgt);
#endif /* DEPRECATED_REMOTE_BREAKPOINT */
}
@@ -4595,16 +4589,16 @@ remote_stopped_data_address (struct targ
static int
-remote_insert_hw_breakpoint (CORE_ADDR addr, gdb_byte *shadow)
+remote_insert_hw_breakpoint (struct bp_target_info *bp_tgt)
{
- int len = 0;
+ CORE_ADDR addr;
struct remote_state *rs = get_remote_state ();
char *p = rs->buf;
/* The length field should be set to the size of a breakpoint
- instruction. */
+ instruction, even though we aren't inserting one ourselves. */
- BREAKPOINT_FROM_PC (&addr, &len);
+ BREAKPOINT_FROM_PC (&bp_tgt->placed_address, &bp_tgt->placed_size);
if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE)
error (_("Can't set hardware breakpoint without the '%s' (%s) packet."),
@@ -4615,9 +4609,9 @@ remote_insert_hw_breakpoint (CORE_ADDR a
*(p++) = '1';
*(p++) = ',';
- addr = remote_address_masked (addr);
+ addr = remote_address_masked (bp_tgt->placed_address);
p += hexnumstr (p, (ULONGEST) addr);
- sprintf (p, ",%x", len);
+ sprintf (p, ",%x", bp_tgt->placed_size);
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
@@ -4636,17 +4630,12 @@ remote_insert_hw_breakpoint (CORE_ADDR a
static int
-remote_remove_hw_breakpoint (CORE_ADDR addr, gdb_byte *shadow)
+remote_remove_hw_breakpoint (struct bp_target_info *bp_tgt)
{
- int len;
+ CORE_ADDR addr;
struct remote_state *rs = get_remote_state ();
char *p = rs->buf;
- /* The length field should be set to the size of a breakpoint
- instruction. */
-
- BREAKPOINT_FROM_PC (&addr, &len);
-
if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE)
error (_("Can't clear hardware breakpoint without the '%s' (%s) packet."),
remote_protocol_packets[PACKET_Z1].name,
@@ -4656,9 +4645,9 @@ remote_remove_hw_breakpoint (CORE_ADDR a
*(p++) = '1';
*(p++) = ',';
- addr = remote_address_masked (addr);
+ addr = remote_address_masked (bp_tgt->placed_address);
p += hexnumstr (p, (ULONGEST) addr);
- sprintf (p, ",%x", len);
+ sprintf (p, ",%x", bp_tgt->placed_size);
putpkt (rs->buf);
getpkt (&rs->buf, &rs->buf_size, 0);
Index: rs6000-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-nat.c,v
retrieving revision 1.60
diff -u -p -r1.60 rs6000-nat.c
--- rs6000-nat.c 17 Dec 2005 22:34:02 -0000 1.60
+++ rs6000-nat.c 17 Apr 2006 19:03:27 -0000
@@ -527,15 +527,15 @@ exec_one_dummy_insn (void)
{
#define DUMMY_INSN_ADDR (TEXT_SEGMENT_BASE)+0x200
- char shadow_contents[BREAKPOINT_MAX]; /* Stash old bkpt addr contents */
int ret, status, pid;
CORE_ADDR prev_pc;
+ void *bp;
/* We plant one dummy breakpoint into DUMMY_INSN_ADDR address. We
assume that this address will never be executed again by the real
code. */
- target_insert_breakpoint (DUMMY_INSN_ADDR, shadow_contents);
+ bp = deprecated_insert_raw_breakpoint (DUMMY_INSN_ADDR);
/* You might think this could be done with a single ptrace call, and
you'd be correct for just about every platform I've ever worked
@@ -559,7 +559,7 @@ exec_one_dummy_insn (void)
while (pid != PIDGET (inferior_ptid));
write_pc (prev_pc);
- target_remove_breakpoint (DUMMY_INSN_ADDR, shadow_contents);
+ deprecated_remove_raw_breakpoint (bp);
}
/* Fetch registers from the register section in core bfd. */
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.256
diff -u -p -r1.256 rs6000-tdep.c
--- rs6000-tdep.c 10 Feb 2006 20:56:14 -0000 1.256
+++ rs6000-tdep.c 17 Apr 2006 19:03:27 -0000
@@ -110,17 +110,6 @@ struct reg
register number. */
};
-/* Breakpoint shadows for the single step instructions will be kept here. */
-
-static struct sstep_breaks
-{
- /* Address, or 0 if this is not in use. */
- CORE_ADDR address;
- /* Shadow contents. */
- gdb_byte data[4];
-}
-stepBreaks[2];
-
/* Hook for determining the TOC address when calling functions in the
inferior under AIX. The initialization code in rs6000-nat.c sets
this hook to point to find_toc_address. */
@@ -730,7 +719,6 @@ rs6000_software_single_step (enum target
if (insert_breakpoints_p)
{
-
loc = read_pc ();
insn = read_memory_integer (loc, 4);
@@ -743,28 +731,17 @@ rs6000_software_single_step (enum target
if (breaks[1] == breaks[0])
breaks[1] = -1;
- stepBreaks[1].address = 0;
-
for (ii = 0; ii < 2; ++ii)
{
-
/* ignore invalid breakpoint. */
if (breaks[ii] == -1)
continue;
- target_insert_breakpoint (breaks[ii], stepBreaks[ii].data);
- stepBreaks[ii].address = breaks[ii];
+ insert_single_step_breakpoint (breaks[ii]);
}
-
}
else
- {
+ remove_single_step_breakpoints ();
- /* remove step breakpoints. */
- for (ii = 0; ii < 2; ++ii)
- if (stepBreaks[ii].address != 0)
- target_remove_breakpoint (stepBreaks[ii].address,
- stepBreaks[ii].data);
- }
errno = 0; /* FIXME, don't ignore errors! */
/* What errors? {read,write}_memory call error(). */
}
Index: sol-thread.c
===================================================================
RCS file: /cvs/src/src/gdb/sol-thread.c,v
retrieving revision 1.51
diff -u -p -r1.51 sol-thread.c
--- sol-thread.c 17 Dec 2005 22:34:02 -0000 1.51
+++ sol-thread.c 17 Apr 2006 19:03:27 -0000
@@ -1524,7 +1524,7 @@ sol_make_note_section (bfd *obfd, int *n
}
static int
-ignore (CORE_ADDR addr, gdb_byte *contents)
+ignore (struct bp_target_info *bp_tgt)
{
return 0;
}
Index: solib-irix.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-irix.c,v
retrieving revision 1.9
diff -u -p -r1.9 solib-irix.c
--- solib-irix.c 17 Dec 2005 22:34:02 -0000 1.9
+++ solib-irix.c 17 Apr 2006 19:03:28 -0000
@@ -227,10 +227,9 @@ fetch_lm_info (CORE_ADDR addr)
/* The symbol which starts off the list of shared libraries. */
#define DEBUG_BASE "__rld_obj_head"
-char shadow_contents[BREAKPOINT_MAX]; /* Stash old bkpt addr contents */
+static void *base_breakpoint;
static CORE_ADDR debug_base; /* Base of dynamic linker structures */
-static CORE_ADDR breakpoint_addr; /* Address where end bkpt is set */
/*
@@ -319,11 +318,13 @@ disable_break (void)
/* Note that breakpoint address and original contents are in our address
space, so we just need to write the original contents back. */
- if (memory_remove_breakpoint (breakpoint_addr, shadow_contents) != 0)
+ if (deprecated_remove_raw_breakpoint (base_breakpoint) != 0)
{
status = 0;
}
+ base_breakpoint = NULL;
+
/* Note that it is possible that we have stopped at a location that
is different from the location where we inserted our breakpoint.
On mips-irix, we can actually land in __dbx_init(), so we should
@@ -352,12 +353,13 @@ disable_break (void)
static int
enable_break (void)
{
- if (symfile_objfile != NULL
- && target_insert_breakpoint (entry_point_address (),
- shadow_contents) == 0)
+ if (symfile_objfile != NULL)
{
- breakpoint_addr = entry_point_address ();
- return 1;
+ base_breakpoint
+ = deprecated_insert_raw_breakpoint (entry_point_address ());
+
+ if (base_breakpoint != NULL)
+ return 1;
}
return 0;
Index: sparc-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc-tdep.c,v
retrieving revision 1.171
diff -u -p -r1.171 sparc-tdep.c
--- sparc-tdep.c 9 Apr 2006 08:22:43 -0000 1.171
+++ sparc-tdep.c 17 Apr 2006 19:03:28 -0000
@@ -1136,8 +1136,7 @@ sparc_software_single_step (enum target_
{
struct gdbarch *arch = current_gdbarch;
struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
- static CORE_ADDR npc, nnpc;
- static gdb_byte npc_save[4], nnpc_save[4];
+ CORE_ADDR npc, nnpc;
if (insert_breakpoints_p)
{
@@ -1149,9 +1148,10 @@ sparc_software_single_step (enum target_
/* Analyze the instruction at PC. */
nnpc = sparc_analyze_control_transfer (arch, pc, &npc);
if (npc != 0)
- target_insert_breakpoint (npc, npc_save);
+ insert_single_step_breakpoint (npc);
+
if (nnpc != 0)
- target_insert_breakpoint (nnpc, nnpc_save);
+ insert_single_step_breakpoint (nnpc);
/* Assert that we have set at least one breakpoint, and that
they're not set at the same spot - unless we're going
@@ -1160,12 +1160,7 @@ sparc_software_single_step (enum target_
gdb_assert (nnpc != npc || orig_npc == 0);
}
else
- {
- if (npc != 0)
- target_remove_breakpoint (npc, npc_save);
- if (nnpc != 0)
- target_remove_breakpoint (nnpc, nnpc_save);
- }
+ remove_single_step_breakpoints ();
}
static void
Index: target.c
===================================================================
RCS file: /cvs/src/src/gdb/target.c,v
retrieving revision 1.117
diff -u -p -r1.117 target.c
--- target.c 17 Mar 2006 00:30:34 -0000 1.117
+++ target.c 17 Apr 2006 19:03:28 -0000
@@ -111,15 +111,15 @@ static void debug_to_prepare_to_store (v
static void debug_to_files_info (struct target_ops *);
-static int debug_to_insert_breakpoint (CORE_ADDR, gdb_byte *);
+static int debug_to_insert_breakpoint (struct bp_target_info *);
-static int debug_to_remove_breakpoint (CORE_ADDR, gdb_byte *);
+static int debug_to_remove_breakpoint (struct bp_target_info *);
static int debug_to_can_use_hw_breakpoint (int, int, int);
-static int debug_to_insert_hw_breakpoint (CORE_ADDR, gdb_byte *);
+static int debug_to_insert_hw_breakpoint (struct bp_target_info *);
-static int debug_to_remove_hw_breakpoint (CORE_ADDR, gdb_byte *);
+static int debug_to_remove_hw_breakpoint (struct bp_target_info *);
static int debug_to_insert_watchpoint (CORE_ADDR, int, int);
@@ -515,10 +515,10 @@ update_current_target (void)
(int (*) (int, int, int))
return_zero);
de_fault (to_insert_hw_breakpoint,
- (int (*) (CORE_ADDR, gdb_byte *))
+ (int (*) (struct bp_target_info *))
return_minus_one);
de_fault (to_remove_hw_breakpoint,
- (int (*) (CORE_ADDR, gdb_byte *))
+ (int (*) (struct bp_target_info *))
return_minus_one);
de_fault (to_insert_watchpoint,
(int (*) (CORE_ADDR, int, int))
@@ -2075,29 +2075,29 @@ debug_to_files_info (struct target_ops *
}
static int
-debug_to_insert_breakpoint (CORE_ADDR addr, gdb_byte *save)
+debug_to_insert_breakpoint (struct bp_target_info *bp_tgt)
{
int retval;
- retval = debug_target.to_insert_breakpoint (addr, save);
+ retval = debug_target.to_insert_breakpoint (bp_tgt);
fprintf_unfiltered (gdb_stdlog,
"target_insert_breakpoint (0x%lx, xxx) = %ld\n",
- (unsigned long) addr,
+ (unsigned long) bp_tgt->placed_address,
(unsigned long) retval);
return retval;
}
static int
-debug_to_remove_breakpoint (CORE_ADDR addr, gdb_byte *save)
+debug_to_remove_breakpoint (struct bp_target_info *bp_tgt)
{
int retval;
- retval = debug_target.to_remove_breakpoint (addr, save);
+ retval = debug_target.to_remove_breakpoint (bp_tgt);
fprintf_unfiltered (gdb_stdlog,
"target_remove_breakpoint (0x%lx, xxx) = %ld\n",
- (unsigned long) addr,
+ (unsigned long) bp_tgt->placed_address,
(unsigned long) retval);
return retval;
}
@@ -2161,29 +2161,29 @@ debug_to_stopped_data_address (struct ta
}
static int
-debug_to_insert_hw_breakpoint (CORE_ADDR addr, gdb_byte *save)
+debug_to_insert_hw_breakpoint (struct bp_target_info *bp_tgt)
{
int retval;
- retval = debug_target.to_insert_hw_breakpoint (addr, save);
+ retval = debug_target.to_insert_hw_breakpoint (bp_tgt);
fprintf_unfiltered (gdb_stdlog,
"target_insert_hw_breakpoint (0x%lx, xxx) = %ld\n",
- (unsigned long) addr,
+ (unsigned long) bp_tgt->placed_address,
(unsigned long) retval);
return retval;
}
static int
-debug_to_remove_hw_breakpoint (CORE_ADDR addr, gdb_byte *save)
+debug_to_remove_hw_breakpoint (struct bp_target_info *bp_tgt)
{
int retval;
- retval = debug_target.to_remove_hw_breakpoint (addr, save);
+ retval = debug_target.to_remove_hw_breakpoint (bp_tgt);
fprintf_unfiltered (gdb_stdlog,
"target_remove_hw_breakpoint (0x%lx, xxx) = %ld\n",
- (unsigned long) addr,
+ (unsigned long) bp_tgt->placed_address,
(unsigned long) retval);
return retval;
}
Index: target.h
===================================================================
RCS file: /cvs/src/src/gdb/target.h,v
retrieving revision 1.81
diff -u -p -r1.81 target.h
--- target.h 21 Feb 2006 18:22:26 -0000 1.81
+++ target.h 17 Apr 2006 19:03:28 -0000
@@ -30,6 +30,7 @@ struct objfile;
struct ui_file;
struct mem_attrib;
struct target_ops;
+struct bp_target_info;
/* This include file defines the interface between the main part
of the debugger, and the part which is target-specific, or
@@ -336,11 +337,11 @@ struct target_ops
struct target_ops *target);
void (*to_files_info) (struct target_ops *);
- int (*to_insert_breakpoint) (CORE_ADDR, gdb_byte *);
- int (*to_remove_breakpoint) (CORE_ADDR, gdb_byte *);
+ int (*to_insert_breakpoint) (struct bp_target_info *);
+ int (*to_remove_breakpoint) (struct bp_target_info *);
int (*to_can_use_hw_breakpoint) (int, int, int);
- int (*to_insert_hw_breakpoint) (CORE_ADDR, gdb_byte *);
- int (*to_remove_hw_breakpoint) (CORE_ADDR, gdb_byte *);
+ int (*to_insert_hw_breakpoint) (struct bp_target_info *);
+ int (*to_remove_hw_breakpoint) (struct bp_target_info *);
int (*to_remove_watchpoint) (CORE_ADDR, int, int);
int (*to_insert_watchpoint) (CORE_ADDR, int, int);
int (*to_stopped_by_watchpoint) (void);
@@ -612,22 +613,17 @@ extern void print_section_info (struct t
#define target_files_info() \
(*current_target.to_files_info) (¤t_target)
-/* Insert a breakpoint at address ADDR in the target machine. SAVE is
- a pointer to memory allocated for saving the target contents. It
- is guaranteed by the caller to be long enough to save the number of
- breakpoint bytes indicated by BREAKPOINT_FROM_PC. Result is 0 for
- success, or an errno value. */
-
-#define target_insert_breakpoint(addr, save) \
- (*current_target.to_insert_breakpoint) (addr, save)
-
-/* Remove a breakpoint at address ADDR in the target machine.
- SAVE is a pointer to the same save area
- that was previously passed to target_insert_breakpoint.
- Result is 0 for success, or an errno value. */
+/* Insert a breakpoint at address BP_TGT->placed_address in the target
+ machine. Result is 0 for success, or an errno value. */
-#define target_remove_breakpoint(addr, save) \
- (*current_target.to_remove_breakpoint) (addr, save)
+#define target_insert_breakpoint(bp_tgt) \
+ (*current_target.to_insert_breakpoint) (bp_tgt)
+
+/* Remove a breakpoint at address BP_TGT->placed_address in the target
+ machine. Result is 0 for success, or an errno value. */
+
+#define target_remove_breakpoint(bp_tgt) \
+ (*current_target.to_remove_breakpoint) (bp_tgt)
/* Initialize the terminal settings we record for the inferior,
before we actually run the inferior. */
@@ -1057,11 +1053,11 @@ extern void (*deprecated_target_new_objf
#endif
#ifndef target_insert_hw_breakpoint
-#define target_insert_hw_breakpoint(addr, save) \
- (*current_target.to_insert_hw_breakpoint) (addr, save)
+#define target_insert_hw_breakpoint(bp_tgt) \
+ (*current_target.to_insert_hw_breakpoint) (bp_tgt)
-#define target_remove_hw_breakpoint(addr, save) \
- (*current_target.to_remove_hw_breakpoint) (addr, save)
+#define target_remove_hw_breakpoint(bp_tgt) \
+ (*current_target.to_remove_hw_breakpoint) (bp_tgt)
#endif
extern int target_stopped_data_address_p (struct target_ops *);
@@ -1142,13 +1138,13 @@ struct section_table *target_section_by_
/* From mem-break.c */
-extern int memory_remove_breakpoint (CORE_ADDR, gdb_byte *);
+extern int memory_remove_breakpoint (struct bp_target_info *);
-extern int memory_insert_breakpoint (CORE_ADDR, gdb_byte *);
+extern int memory_insert_breakpoint (struct bp_target_info *);
-extern int default_memory_remove_breakpoint (CORE_ADDR, gdb_byte *);
+extern int default_memory_remove_breakpoint (struct bp_target_info *);
-extern int default_memory_insert_breakpoint (CORE_ADDR, gdb_byte *);
+extern int default_memory_insert_breakpoint (struct bp_target_info *);
/* From target.c */
Index: wince.c
===================================================================
RCS file: /cvs/src/src/gdb/wince.c,v
retrieving revision 1.44
diff -u -p -r1.44 wince.c
--- wince.c 24 Jan 2006 22:09:28 -0000 1.44
+++ wince.c 17 Apr 2006 19:03:28 -0000
@@ -146,7 +146,6 @@ typedef struct thread_info_struct
int suspend_count;
int stepped; /* True if stepped. */
CORE_ADDR step_pc;
- unsigned long step_prev;
CONTEXT context;
}
thread_info;
@@ -834,7 +833,7 @@ undoSStep (thread_info * th)
{
if (th->stepped)
{
- memory_remove_breakpoint (th->step_pc, (void *) &th->step_prev);
+ remove_single_step_breakpoints ();
th->stepped = 0;
}
}
@@ -857,8 +856,7 @@ wince_software_single_step (enum target_
th->stepped = 1;
pc = read_register (PC_REGNUM);
th->step_pc = mips_next_pc (pc);
- th->step_prev = 0;
- memory_insert_breakpoint (th->step_pc, (void *) &th->step_prev);
+ insert_single_step_breakpoint (th->step_pc);
return;
}
#elif SHx
@@ -971,7 +969,7 @@ undoSStep (thread_info * th)
{
if (th->stepped)
{
- memory_remove_breakpoint (th->step_pc, (void *) &th->step_prev);
+ remove_single_step_breakpoints ();
th->stepped = 0;
}
return;
@@ -996,8 +994,7 @@ wince_software_single_step (enum target_
th->stepped = 1;
th->step_pc = sh_get_next_pc (&th->context);
- th->step_prev = 0;
- memory_insert_breakpoint (th->step_pc, (void *) &th->step_prev);
+ insert_single_step_breakpoint (th->step_pc);
return;
}
#elif defined (ARM)
@@ -1024,7 +1021,7 @@ undoSStep (thread_info * th)
{
if (th->stepped)
{
- memory_remove_breakpoint (th->step_pc, (void *) &th->step_prev);
+ remove_single_step_breakpoints ();
th->stepped = 0;
}
}
@@ -1047,8 +1044,7 @@ wince_software_single_step (enum target_
th->stepped = 1;
pc = read_register (PC_REGNUM);
th->step_pc = arm_get_next_pc (pc);
- th->step_prev = 0;
- memory_insert_breakpoint (th->step_pc, (void *) &th->step_prev);
+ insert_single_step_breakpoint (th->step_pc);
return;
}
#endif
Index: config/i386/nm-i386.h
===================================================================
RCS file: /cvs/src/src/gdb/config/i386/nm-i386.h,v
retrieving revision 1.7
diff -u -p -r1.7 nm-i386.h
--- config/i386/nm-i386.h 8 Oct 2004 17:30:48 -0000 1.7
+++ config/i386/nm-i386.h 17 Apr 2006 19:03:28 -0000
@@ -52,13 +52,14 @@ extern int i386_stopped_by_hwbp (void);
true. Otherwise, return false. */
extern int i386_stopped_data_address (CORE_ADDR *);
-/* Insert a hardware-assisted breakpoint at address ADDR. SHADOW is
- unused. Return 0 on success, EBUSY on failure. */
-extern int i386_insert_hw_breakpoint (CORE_ADDR addr, void *shadow);
-
-/* Remove a hardware-assisted breakpoint at address ADDR. SHADOW is
- unused. Return 0 on success, -1 on failure. */
-extern int i386_remove_hw_breakpoint (CORE_ADDR addr, void *shadow);
+/* Insert a hardware-assisted breakpoint at BP_TGT->placed_address.
+ Return 0 on success, EBUSY on failure. */
+struct bp_target_info;
+extern int i386_insert_hw_breakpoint (struct bp_target_info *bp_tgt);
+
+/* Remove a hardware-assisted breakpoint at BP_TGT->placed_address.
+ Return 0 on success, -1 on failure. */
+extern int i386_remove_hw_breakpoint (struct bp_target_info *bp_tgt);
/* Returns the number of hardware watchpoints of type TYPE that we can
set. Value is positive if we can set CNT watchpoints, zero if
@@ -105,11 +106,11 @@ extern int i386_stopped_by_watchpoint (v
#define target_remove_watchpoint(addr, len, type) \
i386_remove_watchpoint (addr, len, type)
-#define target_insert_hw_breakpoint(addr, shadow) \
- i386_insert_hw_breakpoint (addr, shadow)
+#define target_insert_hw_breakpoint(bp_tgt) \
+ i386_insert_hw_breakpoint (bp_tgt)
-#define target_remove_hw_breakpoint(addr, shadow) \
- i386_remove_hw_breakpoint (addr, shadow)
+#define target_remove_hw_breakpoint(bp_tgt) \
+ i386_remove_hw_breakpoint (bp_tgt)
/* child_post_startup_inferior used to
reset all debug registers by calling i386_cleanup_dregs (). */
Index: doc/gdbint.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v
retrieving revision 1.240
diff -u -p -r1.240 gdbint.texinfo
--- doc/gdbint.texinfo 28 Mar 2006 19:19:16 -0000 1.240
+++ doc/gdbint.texinfo 17 Apr 2006 19:03:30 -0000
@@ -527,6 +527,44 @@ The basic definition of the software bre
Basic breakpoint object handling is in @file{breakpoint.c}. However,
much of the interesting breakpoint action is in @file{infrun.c}.
+@table @code
+@cindex insert or remove software breakpoint
+@findex target_remove_breakpoint
+@findex target_insert_breakpoint
+@item target_remove_breakpoint (@var{bp_tgt})
+@itemx target_insert_breakpoint (@var{bp_tgt})
+Insert or remove a software breakpoint at address
+@code{@var{bp_tgt}->placed_address}. Returns zero for success,
+non-zero for failure. On input, @var{bp_tgt} contains the address of the
+breakpoint, and is otherwise initialized to zero. @var{bp_tgt} is updated
+to contain other information about the breakpoint on output:
+@code{placed_address} may be updated if the breakpoint was placed at a
+related address; @code{shadow_contents} is the real contents of the bytes
+where the breakpoint has been inserted, if reading memory would return
+the breakpoint instead of the underlying memory; @code{shadow_len} is the
+length of memory cached in @code{shadow_contents}, if any; and
+@code{placed_size} is optionally set and used by the target, if
+it could differ from @code{shadow_len}.
+
+For example, the remote target @samp{Z0} packet does not require
+shadowing memory, so @code{shadow_len} is left at zero. However,
+the length reported by @code{BREAKPOINT_FROM_PC} is cached in
+@code{placed_size}, so that a matching @samp{z0} packet can be
+used to remove the breakpoint.
+
+@cindex insert or remove hardware breakpoint
+@findex target_remove_hw_breakpoint
+@findex target_insert_hw_breakpoint
+@item target_remove_hw_breakpoint (@var{bp_tgt})
+@itemx target_insert_hw_breakpoint (@var{bp_tgt})
+Insert or remove a hardware-assisted breakpoint at address
+@code{@var{bp_tgt}->placed_address}. Returns zero for success,
+non-zero for failure. See @code{target_insert_breakpoint} for
+a description of @var{bp_tgt}; the @code{shadow_contents} and
+@code{shadow_len} members are not used for hardware breakpoints,
+but @code{placed_size} may be.
+@end table
+
@section Single Stepping
@section Signal Handling
@@ -657,18 +695,6 @@ defined by @file{breakpoint.h} as follow
@noindent
These two macros should return 0 for success, non-zero for failure.
-@cindex insert or remove hardware breakpoint
-@findex target_remove_hw_breakpoint
-@findex target_insert_hw_breakpoint
-@item target_remove_hw_breakpoint (@var{addr}, @var{shadow})
-@itemx target_insert_hw_breakpoint (@var{addr}, @var{shadow})
-Insert or remove a hardware-assisted breakpoint at address @var{addr}.
-Returns zero for success, non-zero for failure. @var{shadow} is the
-real contents of the byte where the breakpoint has been inserted; it
-is generally not valid when hardware breakpoints are used, but since
-no other code touches these values, the implementations of the above
-two macros can use them for their internal purposes.
-
@findex target_stopped_data_address
@item target_stopped_data_address (@var{addr_p})
If the inferior has some watchpoint that triggered, place the address
@@ -858,8 +884,8 @@ the count goes to zero.
@findex i386_insert_hw_breakpoint
@findex i386_remove_hw_breakpoint
-@item i386_insert_hw_breakpoint (@var{addr}, @var{shadow}
-@itemx i386_remove_hw_breakpoint (@var{addr}, @var{shadow})
+@item i386_insert_hw_breakpoint (@var{bp_tgt})
+@itemx i386_remove_hw_breakpoint (@var{bp_tgt})
These functions insert and remove hardware-assisted breakpoints. The
macros @code{target_insert_hw_breakpoint} and
@code{target_remove_hw_breakpoint} are set to call these functions.
@@ -3229,8 +3255,8 @@ instruction of the architecture.
Replaces all the other @var{BREAKPOINT} macros.
-@item MEMORY_INSERT_BREAKPOINT (@var{addr}, @var{contents_cache})
-@itemx MEMORY_REMOVE_BREAKPOINT (@var{addr}, @var{contents_cache})
+@item MEMORY_INSERT_BREAKPOINT (@var{bp_tgt})
+@itemx MEMORY_REMOVE_BREAKPOINT (@var{bp_tgt})
@findex MEMORY_REMOVE_BREAKPOINT
@findex MEMORY_INSERT_BREAKPOINT
Insert or remove memory based breakpoints. Reasonable defaults
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-17 19:08 ` Daniel Jacobowitz
@ 2006-04-17 20:25 ` Mark Kettenis
2006-04-17 21:50 ` Daniel Jacobowitz
2006-04-18 8:59 ` Eli Zaretskii
1 sibling, 1 reply; 52+ messages in thread
From: Mark Kettenis @ 2006-04-17 20:25 UTC (permalink / raw)
To: drow; +Cc: msnyder, gdb-patches
> Date: Mon, 17 Apr 2006 15:08:08 -0400
> From: Daniel Jacobowitz <drow@false.org>
>
> On Mon, Apr 17, 2006 at 03:49:29PM +0200, Mark Kettenis wrote:
> > > I've been thinking about having target methods which don't need the
> > > shadow contents (there are definitely several) record the "length" of
> > > the breakpoint as zero; then deprecated_read_memory_nobpt can do the
> > > right thing. Does this sound reasonable? The alternative is to do an
> > > unnecessary read from the target.
> >
> > Absolutely. If the length is zero there are no shadow contents to
> > worry about. But it is probably better to address
> > deprecated_read_memory_nobpt in a seperate patch.
>
> Well, otherwise I get compilation errors. So I've fixed it together
> with this.
>
> On the documentation front, I am quite mortified; I wrote this
> ChangeLog entry at least twice for earlier versions of the patch:
>
> * gdbint.texinfo (Watchpoints, Target Conditionals): Update insert
> and remove breakpoint prototypes.
>
> While they often use the underlying watchpoint registers, hardware
> breakpoints are breakpoints. I've moved these to the Breakpoints
> section, and added some more bits there. Eli, could you take a look
> at that?
>
> I turned out to need a fourth element in the struct :-( But I think
> the result is fairly clear, esp. with the comments and documentation.
> Here's struct bp_target_info:
>
> /* Information used by targets to insert and remove breakpoints. */
>
> struct bp_target_info
> {
> /* Address at which the breakpoint was placed. This is normally the
> same as ADDRESS from the bp_location, except when adjustment
> happens in BREAKPOINT_FROM_PC. The most common form of
> adjustment is stripping an alternate ISA marker from the PC which
> is used to determine the type of breakpoint to insert. */
> CORE_ADDR placed_address;
>
> /* If the breakpoint lives in memory and reading that memory would
> give back the breakpoint, instead of the original contents, then
> the original contents are cached here. Only SHADOW_LEN bytes of
> this buffer are valid, and only when the breakpoint is inserted. */
> gdb_byte shadow_contents[BREAKPOINT_MAX];
>
> /* The length of the data cached in SHADOW_CONTENTS. */
> int shadow_len;
>
> /* The size of the placed breakpoint, according to
> BREAKPOINT_FROM_PC, when the breakpoint was inserted. This is
> generally the same as SHADOW_LEN, unless we did not need
> to read from the target to implement the memory breakpoint
> (e.g. if a remote stub handled the details). We may still
> need the size to remove the breakpoint safely. */
> int placed_size;
> };
>
> Stubs which do read from the target set shadow_len, as of course does
> the generic memory_insert_breakpoint. The remote Z0 support does not;
> one of the benefits of using Z0 is that getting the target memory
> correct is not GDB's problem.
Hmm, if I understand things correctly, the only reason why you need
placed_size, is because we want shadow_len to tell is whether we've
actually saved the contents or not. This is eh, a wee bit ugly.
Actually I think the z0 packet should not include the length of the
breakpoint. The remote stub will have to keep track of the length of
the inserted breakpoint anyway, exactly because it has get the the
target memory correct.
I'm still thinking about a more elegant solution. One would be to
allocate the shadow contents dynamically and make it a NULL pointer if
GDB didn't actually save any shadow contents. Meanwhile, I spropose
you check this in. This issue has been on the table long enough now.
Mark
P.S. Someone should really get rid of tm-sh.h and
DEPRECATED_{BIG|LITTLE}_BREAKPOINT.
> Daniel Jacobowitz
> CodeSourcery
>
> 2006-04-17 Daniel Jacobowitz <dan@codesourcery.com>
>
> * breakpoint.c (deprecated_read_memory_nobpt): Update to use
> shadow_len.
> (insert_bp_location, reattach_breakpoints, remove_breakpoint)
> (delete_breakpoint): Update calls to changed methods.
> (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint)
> (single_step_breakpoints, insert_single_step_breakpoint)
> (remove_single_step_breakpoints): New.
> * breakpoint.h (struct bp_target_info): New.
> (struct bp_location): Replace shadow_contents with
> target_info and overlay_target_info.
> (deprecated_insert_raw_breakpoint, deprecated_remove_raw_breakpoint)
> (insert_single_step_breakpoint, remove_single_step_breakpoints): New
> prototypes.
> * gdbarch.sh: Forward declare struct bp_target_info in gdbarch.h.
> (memory_insert_breakpoint, memory_remove_breakpoint): Update second
> argument.
> * mem-break.c (default_memory_insert_breakpoint): Update. Set
> placed_address, placed_size, and shadow_len.
> (default_memory_remove_breakpoint): Update. Don't use
> BREAKPOINT_FROM_PC.
> (memory_insert_breakpoint, memory_remove_breakpoint): Update.
> * target.c (update_current_target): Update prototypes for changed
> functions.
> (debug_to_insert_breakpoint, debug_to_remove_breakpoint)
> (debug_to_insert_hw_breakpoint, debug_to_remove_hw_breakpoint):
> Update.
> * target.h: Forward declare struct bp_target_info.
> (struct target_ops): Use a bp_target_info argument for
> to_insert_breakpoint, to_remove_breakpoint,
> to_insert_hw_breakpoint, and to_remove_hw_breakpoint.
> (target_insert_breakpoint, target_remove_breakpoint)
> (target_insert_hw_breakpoint, target_remove_hw_breakpoint)
> (memory_insert_breakpoint, memory_remove_breakpoint)
> (default_memory_insert_breakpoint, default_memory_remove_breakpoint):
> Update.
> * config/i386/nm-i386.h: Forward declare struct bp_target_info.
> (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint): Update.
> (target_insert_hw_breakpoint, target_remove_hw_breakpoint): Likewise.
>
> * gdbarch.c, gdbarch.h: Regenerated.
>
> * alpha-tdep.c (alpha_software_single_step): Use
> insert_single_step_breakpoint and remove_single_step_breakpoints.
> Remove unused statics.
> * arm-tdep.c (arm_software_single_step): Likewise. Add a note.
> * cris-tdep.c (cris_software_single_step): Likewise.
> * mips-tdep.c (mips_software_single_step): Likewise.
> * rs6000-tdep.c (rs6000_software_single_step): Likewise.
> * sparc-tdep.c (sparc_software_single_step): Likewise.
> * wince.c (struct thread_info_struct): Remove step_prev.
> (undoSStep): Use remove_single_step_breakpoints.
> (wince_software_single_step): Use insert_single_step_breakpoint.
>
> * corelow.c (ignore): Remove unneeded prototype. Update arguments.
> * exec.c (ignore): Likewise.
> * sol-thread.c (ignore): Likewise.
>
> * procfs.c (dbx_link_shadow_contents): Delete.
> (dbx_link_bpt): New.
> (procfs_mourn_inferior): Remove it if necessary.
> (remove_dbx_link_breakpoint): Use it.
> (insert_dbx_link_bpt_in_file): Set it.
> (procfs_init_inferior): Don't update dbx_link_bpt_addr.
> * rs6000-nat.c (exec_one_dummy_insn): Use
> deprecated_insert_raw_breakpoint and
> deprecated_remove_raw_breakpoint.
> * solib-irix.c (shadow_contents, breakpoint_addr): Delete.
> (base_breakpoint): New.
> (disable_break): Use it.
> (enable_break): Set it.
>
> * i386-nat.c (i386_insert_hw_breakpoint, i386_remove_hw_breakpoint):
> Update.
> * ia64-tdep.c (ia64_memory_insert_breakpoint)
> (ia64_memory_remove_breakpoint): Likewise.
> * m32r-tdep.c (m32r_memory_insert_breakpoint)
> (m32r_memory_remove_breakpoint): Likewise.
> * monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint):
> Likewise. Remove unnecessary prototypes. Use placed_address
> and placed_size. Removed useless read from memory.
> * nto-procfs.c (procfs_insert_breakpoint)
> (procfs_remove_breakpoint, procfs_insert_hw_breakpoint)
> (procfs_remove_hw_breakpoint): Update.
> * ocd.c (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise.
> * ocd.h (ocd_insert_breakpoint, ocd_remove_breakpoint): Likewise.
> * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Likewise.
> * ppc-tdep.h (ppc_linux_memory_remove_breakpoint): Likewise.
> * remote-e7000.c (e7000_insert_breakpoint)
> (e7000_remove_breakpoint): Likewise.
> * remote-m32r-sdi.c (m32r_insert_breakpoint)
> (m32r_remove_breakpoint): Likewise.
> * remote-mips.c (mips_insert_breakpoint)
> (mips_remove_breakpoint): Likewise.
> * remote-rdp.c (remote_rdp_insert_breakpoint)
> (remote_rdp_remove_breakpoint): Likewise.
> (rdp_step): Use deprecated_insert_raw_breakpoint and
> deprecated_remove_raw_breakpoint.
> * remote-sds.c (sds_insert_breakpoint, sds_remove_breakpoint):
> Update.
> * remote-sim.c (gdbsim_insert_breakpoint, gdbsim_remove_breakpoint):
> Delete.
> (init_gdbsim_ops): Use memory_insert_breakpoint and
> memory_remove_breakpoint.
> * remote-st.c (st2000_insert_breakpoint)
> (st2000_remove_breakpoint): Update. Remove unused
> BREAKPOINT_FROM_PC.
> * remote.c (remote_insert_breakpoint, remote_remove_breakpoint):
> Update. Use placed_address and placed_size.
> (remote_insert_hw_breakpoint, remote_remove_hw_breakpoint): Likewise.
>
> 2006-04-17 Daniel Jacobowitz <dan@codesourcery.com>
>
> * gdbint.texinfo (x86 Watchpoints, Target Conditionals): Update insert
> and remove breakpoint prototypes.
> (Watchpoints): Move description of target_insert_hw_breakpoint and
> target_remove_hw_breakpoint ...
> (Breakpoints): ... to here. Document target_insert_breakpoint and
> target_remove_breakpoint.
>
> ? remove-breakpoint-supply-length-v2.patch
> ? remove-breakpoint-supply-length-v3.patch
> Index: alpha-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/alpha-tdep.c,v
> retrieving revision 1.153
> diff -u -p -r1.153 alpha-tdep.c
> --- alpha-tdep.c 15 Jan 2006 20:53:32 -0000 1.153
> +++ alpha-tdep.c 17 Apr 2006 19:03:19 -0000
> @@ -1493,8 +1493,6 @@ void
> alpha_software_single_step (enum target_signal sig, int insert_breakpoints_p)
> {
> static CORE_ADDR next_pc;
> - typedef char binsn_quantum[BREAKPOINT_MAX];
> - static binsn_quantum break_mem;
> CORE_ADDR pc;
>
> if (insert_breakpoints_p)
> @@ -1502,11 +1500,11 @@ alpha_software_single_step (enum target_
> pc = read_pc ();
> next_pc = alpha_next_pc (pc);
>
> - target_insert_breakpoint (next_pc, break_mem);
> + insert_single_step_breakpoint (next_pc);
> }
> else
> {
> - target_remove_breakpoint (next_pc, break_mem);
> + remove_single_step_breakpoints ();
> write_pc (next_pc);
> }
> }
> Index: arm-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/arm-tdep.c,v
> retrieving revision 1.207
> diff -u -p -r1.207 arm-tdep.c
> --- arm-tdep.c 30 Mar 2006 16:48:47 -0000 1.207
> +++ arm-tdep.c 17 Apr 2006 19:03:19 -0000
> @@ -1849,16 +1849,18 @@ arm_get_next_pc (CORE_ADDR pc)
> static void
> arm_software_single_step (enum target_signal sig, int insert_bpt)
> {
> - static int next_pc; /* State between setting and unsetting. */
> - static char break_mem[BREAKPOINT_MAX]; /* Temporary storage for mem@bpt */
> + /* NOTE: This may insert the wrong breakpoint instruction when
> + single-stepping over a mode-changing instruction, if the
> + CPSR heuristics are used. */
>
> if (insert_bpt)
> {
> - next_pc = arm_get_next_pc (read_register (ARM_PC_REGNUM));
> - target_insert_breakpoint (next_pc, break_mem);
> + CORE_ADDR next_pc = arm_get_next_pc (read_register (ARM_PC_REGNUM));
> +
> + insert_single_step_breakpoint (next_pc);
> }
> else
> - target_remove_breakpoint (next_pc, break_mem);
> + remove_single_step_breakpoints ();
> }
>
> #include "bfd-in2.h"
> Index: breakpoint.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/breakpoint.c,v
> retrieving revision 1.224
> diff -u -p -r1.224 breakpoint.c
> --- breakpoint.c 6 Apr 2006 18:33:05 -0000 1.224
> +++ breakpoint.c 17 Apr 2006 19:03:20 -0000
> @@ -663,16 +663,10 @@ deprecated_read_memory_nobpt (CORE_ADDR
> continue;
> /* Addresses and length of the part of the breakpoint that
> we need to copy. */
> - /* XXXX The m68k, sh and h8300 have different local and remote
> - breakpoint values. BREAKPOINT_FROM_PC still manages to
> - correctly determine the breakpoints memory address and size
> - for these targets. */
> - bp_addr = b->address;
> - bp_size = 0;
> - if (BREAKPOINT_FROM_PC (&bp_addr, &bp_size) == NULL)
> - continue;
> + bp_addr = b->target_info.placed_address;
> + bp_size = b->target_info.shadow_len;
> if (bp_size == 0)
> - /* bp isn't valid */
> + /* bp isn't valid, or doesn't shadow memory. */
> continue;
> if (bp_addr + bp_size <= memaddr)
> /* The breakpoint is entirely before the chunk of memory we
> @@ -703,7 +697,7 @@ deprecated_read_memory_nobpt (CORE_ADDR
> }
>
> memcpy (myaddr + bp_addr - memaddr,
> - b->shadow_contents + bptoffset, bp_size);
> + b->target_info.shadow_contents + bptoffset, bp_size);
>
> if (bp_addr > memaddr)
> {
> @@ -793,6 +787,10 @@ insert_bp_location (struct bp_location *
> if (bpt->inserted || bpt->duplicate)
> return 0;
>
> + /* Initialize the target-specific information. */
> + memset (&bpt->target_info, 0, sizeof (bpt->target_info));
> + bpt->target_info.placed_address = bpt->address;
> +
> if (bpt->loc_type == bp_loc_software_breakpoint
> || bpt->loc_type == bp_loc_hardware_breakpoint)
> {
> @@ -804,11 +802,9 @@ insert_bp_location (struct bp_location *
> /* No overlay handling: just set the breakpoint. */
>
> if (bpt->loc_type == bp_loc_hardware_breakpoint)
> - val = target_insert_hw_breakpoint (bpt->address,
> - bpt->shadow_contents);
> + val = target_insert_hw_breakpoint (&bpt->target_info);
> else
> - val = target_insert_breakpoint (bpt->address,
> - bpt->shadow_contents);
> + val = target_insert_breakpoint (&bpt->target_info);
> }
> else
> {
> @@ -827,7 +823,9 @@ insert_bp_location (struct bp_location *
> CORE_ADDR addr = overlay_unmapped_address (bpt->address,
> bpt->section);
> /* Set a software (trap) breakpoint at the LMA. */
> - val = target_insert_breakpoint (addr, bpt->shadow_contents);
> + bpt->overlay_target_info = bpt->target_info;
> + bpt->overlay_target_info.placed_address = addr;
> + val = target_insert_breakpoint (&bpt->overlay_target_info);
> if (val != 0)
> fprintf_unfiltered (tmp_error_stream,
> "Overlay breakpoint %d failed: in ROM?",
> @@ -839,11 +837,9 @@ insert_bp_location (struct bp_location *
> {
> /* Yes. This overlay section is mapped into memory. */
> if (bpt->loc_type == bp_loc_hardware_breakpoint)
> - val = target_insert_hw_breakpoint (bpt->address,
> - bpt->shadow_contents);
> + val = target_insert_hw_breakpoint (&bpt->target_info);
> else
> - val = target_insert_breakpoint (bpt->address,
> - bpt->shadow_contents);
> + val = target_insert_breakpoint (&bpt->target_info);
> }
> else
> {
> @@ -1045,7 +1041,7 @@ in which its expression is valid.\n"),
> /* If we get here, we must have a callback mechanism for exception
> events -- with g++ style embedded label support, we insert
> ordinary breakpoints and not catchpoints. */
> - val = target_insert_breakpoint (bpt->address, bpt->shadow_contents);
> + val = target_insert_breakpoint (&bpt->target_info);
> if (val)
> {
> /* Couldn't set breakpoint for some reason */
> @@ -1240,9 +1236,9 @@ reattach_breakpoints (int pid)
> {
> remove_breakpoint (b, mark_inserted);
> if (b->loc_type == bp_loc_hardware_breakpoint)
> - val = target_insert_hw_breakpoint (b->address, b->shadow_contents);
> + val = target_insert_hw_breakpoint (&b->target_info);
> else
> - val = target_insert_breakpoint (b->address, b->shadow_contents);
> + val = target_insert_breakpoint (&b->target_info);
> /* FIXME drow/2003-10-07: This doesn't handle any other kinds of
> breakpoints. It's wrong for watchpoints, for example. */
> if (val != 0)
> @@ -1446,10 +1442,9 @@ remove_breakpoint (struct bp_location *b
> /* No overlay handling: just remove the breakpoint. */
>
> if (b->loc_type == bp_loc_hardware_breakpoint)
> - val = target_remove_hw_breakpoint (b->address,
> - b->shadow_contents);
> + val = target_remove_hw_breakpoint (&b->target_info);
> else
> - val = target_remove_breakpoint (b->address, b->shadow_contents);
> + val = target_remove_breakpoint (&b->target_info);
> }
> else
> {
> @@ -1460,14 +1455,12 @@ remove_breakpoint (struct bp_location *b
> /* Yes -- overlay event support is not active, so we
> should have set a breakpoint at the LMA. Remove it.
> */
> - CORE_ADDR addr = overlay_unmapped_address (b->address,
> - b->section);
> /* Ignore any failures: if the LMA is in ROM, we will
> have already warned when we failed to insert it. */
> if (b->loc_type == bp_loc_hardware_breakpoint)
> - target_remove_hw_breakpoint (addr, b->shadow_contents);
> + target_remove_hw_breakpoint (&b->overlay_target_info);
> else
> - target_remove_breakpoint (addr, b->shadow_contents);
> + target_remove_breakpoint (&b->overlay_target_info);
> }
> /* Did we set a breakpoint at the VMA?
> If so, we will have marked the breakpoint 'inserted'. */
> @@ -1478,11 +1471,9 @@ remove_breakpoint (struct bp_location *b
> unmapped, but let's not rely on that being safe. We
> don't know what the overlay manager might do. */
> if (b->loc_type == bp_loc_hardware_breakpoint)
> - val = target_remove_hw_breakpoint (b->address,
> - b->shadow_contents);
> + val = target_remove_hw_breakpoint (&b->target_info);
> else
> - val = target_remove_breakpoint (b->address,
> - b->shadow_contents);
> + val = target_remove_breakpoint (&b->target_info);
> }
> else
> {
> @@ -1570,8 +1561,7 @@ remove_breakpoint (struct bp_location *b
> && breakpoint_enabled (b->owner)
> && !b->duplicate)
> {
> -
> - val = target_remove_breakpoint (b->address, b->shadow_contents);
> + val = target_remove_breakpoint (&b->target_info);
> if (val)
> return val;
> b->inserted = (is == mark_inserted);
> @@ -1581,8 +1571,7 @@ remove_breakpoint (struct bp_location *b
> && breakpoint_enabled (b->owner)
> && !b->duplicate)
> {
> -
> - val = target_remove_breakpoint (b->address, b->shadow_contents);
> + val = target_remove_breakpoint (&b->target_info);
> if (val)
> return val;
>
> @@ -6852,10 +6841,12 @@ delete_breakpoint (struct breakpoint *bp
> _("another breakpoint was inserted on top of "
> "a permanent breakpoint"));
>
> + memset (&b->loc->target_info, 0, sizeof (b->loc->target_info));
> + b->loc->target_info.placed_address = b->loc->address;
> if (b->type == bp_hardware_breakpoint)
> - val = target_insert_hw_breakpoint (b->loc->address, b->loc->shadow_contents);
> + val = target_insert_hw_breakpoint (&b->loc->target_info);
> else
> - val = target_insert_breakpoint (b->loc->address, b->loc->shadow_contents);
> + val = target_insert_breakpoint (&b->loc->target_info);
>
> /* If there was an error in the insert, print a message, then stop execution. */
> if (val != 0)
> @@ -7658,6 +7649,97 @@ decode_line_spec_1 (char *string, int fu
> error (_("Junk at end of line specification: %s"), string);
> return sals;
> }
> +
> +/* Create and insert a raw software breakpoint at PC. Return an
> + identifier, which should be used to remove the breakpoint later.
> + In general, places which call this should be using something on the
> + breakpoint chain instead; this function should be eliminated
> + someday. */
> +
> +void *
> +deprecated_insert_raw_breakpoint (CORE_ADDR pc)
> +{
> + struct bp_target_info *bp_tgt;
> +
> + bp_tgt = xmalloc (sizeof (struct bp_target_info));
> + memset (bp_tgt, 0, sizeof (struct bp_target_info));
> +
> + bp_tgt->placed_address = pc;
> + if (target_insert_breakpoint (bp_tgt) != 0)
> + {
> + /* Could not insert the breakpoint. */
> + xfree (bp_tgt);
> + return NULL;
> + }
> +
> + return bp_tgt;
> +}
> +
> +/* Remove a breakpoint BP inserted by deprecated_insert_raw_breakpoint. */
> +
> +int
> +deprecated_remove_raw_breakpoint (void *bp)
> +{
> + struct bp_target_info *bp_tgt = bp;
> + int ret;
> +
> + ret = target_remove_breakpoint (bp_tgt);
> + xfree (bp_tgt);
> +
> + return ret;
> +}
> +
> +/* One (or perhaps two) breakpoints used for software single stepping. */
> +
> +static void *single_step_breakpoints[2];
> +
> +/* Create and insert a breakpoint for software single step. */
> +
> +void
> +insert_single_step_breakpoint (CORE_ADDR next_pc)
> +{
> + void **bpt_p;
> +
> + if (single_step_breakpoints[0] == NULL)
> + bpt_p = &single_step_breakpoints[0];
> + else
> + {
> + gdb_assert (single_step_breakpoints[1] == NULL);
> + bpt_p = &single_step_breakpoints[1];
> + }
> +
> + /* NOTE drow/2006-04-11: A future improvement to this function would be
> + to only create the breakpoints once, and actually put them on the
> + breakpoint chain. That would let us use set_raw_breakpoint. We could
> + adjust the addresses each time they were needed. Doing this requires
> + corresponding changes elsewhere where single step breakpoints are
> + handled, however. So, for now, we use this. */
> +
> + *bpt_p = deprecated_insert_raw_breakpoint (next_pc);
> + if (*bpt_p == NULL)
> + warning (_("Could not insert single-step breakpoint at 0x%s"),
> + paddr_nz (next_pc));
> +}
> +
> +/* Remove and delete any breakpoints used for software single step. */
> +
> +void
> +remove_single_step_breakpoints (void)
> +{
> + gdb_assert (single_step_breakpoints[0] != NULL);
> +
> + /* See insert_single_step_breakpoint for more about this deprecated
> + call. */
> + deprecated_remove_raw_breakpoint (single_step_breakpoints[0]);
> + single_step_breakpoints[0] = NULL;
> +
> + if (single_step_breakpoints[1] != NULL)
> + {
> + deprecated_remove_raw_breakpoint (single_step_breakpoints[1]);
> + single_step_breakpoints[1] = NULL;
> + }
> +}
> +
> \f
> /* This help string is used for the break, hbreak, tbreak and thbreak commands.
> It is defined as a macro to prevent duplication.
> Index: breakpoint.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/breakpoint.h,v
> retrieving revision 1.36
> diff -u -p -r1.36 breakpoint.h
> --- breakpoint.h 17 Dec 2005 22:33:59 -0000 1.36
> +++ breakpoint.h 17 Apr 2006 19:03:20 -0000
> @@ -185,6 +185,36 @@ enum target_hw_bp_type
> hw_execute = 3 /* Execute HW breakpoint */
> };
>
> +
> +/* Information used by targets to insert and remove breakpoints. */
> +
> +struct bp_target_info
> +{
> + /* Address at which the breakpoint was placed. This is normally the
> + same as ADDRESS from the bp_location, except when adjustment
> + happens in BREAKPOINT_FROM_PC. The most common form of
> + adjustment is stripping an alternate ISA marker from the PC which
> + is used to determine the type of breakpoint to insert. */
> + CORE_ADDR placed_address;
> +
> + /* If the breakpoint lives in memory and reading that memory would
> + give back the breakpoint, instead of the original contents, then
> + the original contents are cached here. Only SHADOW_LEN bytes of
> + this buffer are valid, and only when the breakpoint is inserted. */
> + gdb_byte shadow_contents[BREAKPOINT_MAX];
> +
> + /* The length of the data cached in SHADOW_CONTENTS. */
> + int shadow_len;
> +
> + /* The size of the placed breakpoint, according to
> + BREAKPOINT_FROM_PC, when the breakpoint was inserted. This is
> + generally the same as SHADOW_LEN, unless we did not need
> + to read from the target to implement the memory breakpoint
> + (e.g. if a remote stub handled the details). We may still
> + need the size to remove the breakpoint safely. */
> + int placed_size;
> +};
> +
> /* GDB maintains two types of information about each breakpoint (or
> watchpoint, or other related event). The first type corresponds
> to struct breakpoint; this is a relatively high-level structure
> @@ -242,13 +272,6 @@ struct bp_location
> associated with the address. Used primarily for overlay debugging. */
> asection *section;
>
> - /* "Real" contents of byte where breakpoint has been inserted.
> - Valid only when breakpoints are in the program. Under the complete
> - control of the target insert_breakpoint and remove_breakpoint routines.
> - No other code should assume anything about the value(s) here.
> - Valid only for bp_loc_software_breakpoint. */
> - gdb_byte shadow_contents[BREAKPOINT_MAX];
> -
> /* Address at which breakpoint was requested, either by the user or
> by GDB for internal breakpoints. This will usually be the same
> as ``address'' (above) except for cases in which
> @@ -256,6 +279,12 @@ struct bp_location
> which to place the breakpoint in order to comply with a
> processor's architectual constraints. */
> CORE_ADDR requested_address;
> +
> + /* Details of the placed breakpoint, when inserted. */
> + struct bp_target_info target_info;
> +
> + /* Similarly, for the breakpoint at an overlay's LMA, if necessary. */
> + struct bp_target_info overlay_target_info;
> };
>
> /* This structure is a collection of function pointers that, if available,
> @@ -796,6 +825,16 @@ extern void delete_command (char *arg, i
> remove fails. */
> extern int remove_hw_watchpoints (void);
>
> +/* Manage a software single step breakpoint (or two). Insert may be called
> + twice before remove is called. */
> +extern void insert_single_step_breakpoint (CORE_ADDR);
> +extern void remove_single_step_breakpoints (void);
> +
> +/* Manage manual breakpoints, separate from the normal chain of
> + breakpoints. These functions are used in murky target-specific
> + ways. Please do not add more uses! */
> +extern void *deprecated_insert_raw_breakpoint (CORE_ADDR);
> +extern int deprecated_remove_raw_breakpoint (void *);
>
> /* Indicator of whether exception catchpoints should be nuked between
> runs of a program. */
> Index: corelow.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/corelow.c,v
> retrieving revision 1.55
> diff -u -p -r1.55 corelow.c
> --- corelow.c 25 Feb 2006 04:36:39 -0000 1.55
> +++ corelow.c 17 Apr 2006 19:03:20 -0000
> @@ -86,8 +86,6 @@ static void get_core_registers (int);
>
> static void add_to_thread_list (bfd *, asection *, void *);
>
> -static int ignore (CORE_ADDR, bfd_byte *);
> -
> static int core_file_thread_alive (ptid_t tid);
>
> static void init_core_ops (void);
> @@ -603,7 +601,7 @@ core_xfer_partial (struct target_ops *op
> `gdb internal error' (since generic_mourn calls breakpoint_init_inferior). */
>
> static int
> -ignore (CORE_ADDR addr, bfd_byte *contents)
> +ignore (struct bp_target_info *bp_tgt)
> {
> return 0;
> }
> Index: cris-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/cris-tdep.c,v
> retrieving revision 1.135
> diff -u -p -r1.135 cris-tdep.c
> --- cris-tdep.c 5 Apr 2006 20:01:19 -0000 1.135
> +++ cris-tdep.c 17 Apr 2006 19:03:21 -0000
> @@ -558,15 +558,6 @@ struct instruction_environment
> int disable_interrupt;
> } inst_env_type;
>
> -/* Save old breakpoints in order to restore the state before a single_step.
> - At most, two breakpoints will have to be remembered. */
> -typedef
> -char binsn_quantum[BREAKPOINT_MAX];
> -static binsn_quantum break_mem[2];
> -static CORE_ADDR next_pc = 0;
> -static CORE_ADDR branch_target_address = 0;
> -static unsigned char branch_break_inserted = 0;
> -
> /* Machine-dependencies in CRIS for opcodes. */
>
> /* Instruction sizes. */
> @@ -2130,7 +2121,7 @@ static void
> cris_software_single_step (enum target_signal ignore, int insert_breakpoints)
> {
> inst_env_type inst_env;
> -
> +
> if (insert_breakpoints)
> {
> /* Analyse the present instruction environment and insert
> @@ -2146,28 +2137,19 @@ cris_software_single_step (enum target_s
> {
> /* Insert at most two breakpoints. One for the next PC content
> and possibly another one for a branch, jump, etc. */
> - next_pc = (CORE_ADDR) inst_env.reg[PC_REGNUM];
> - target_insert_breakpoint (next_pc, break_mem[0]);
> + CORE_ADDR next_pc = (CORE_ADDR) inst_env.reg[PC_REGNUM];
> + insert_single_step_breakpoint (next_pc);
> if (inst_env.branch_found
> && (CORE_ADDR) inst_env.branch_break_address != next_pc)
> {
> - branch_target_address =
> - (CORE_ADDR) inst_env.branch_break_address;
> - target_insert_breakpoint (branch_target_address, break_mem[1]);
> - branch_break_inserted = 1;
> + CORE_ADDR branch_target_address
> + = (CORE_ADDR) inst_env.branch_break_address;
> + insert_single_step_breakpoint (branch_target_address);
> }
> }
> }
> else
> - {
> - /* Remove breakpoints. */
> - target_remove_breakpoint (next_pc, break_mem[0]);
> - if (branch_break_inserted)
> - {
> - target_remove_breakpoint (branch_target_address, break_mem[1]);
> - branch_break_inserted = 0;
> - }
> - }
> + remove_single_step_breakpoints ();
> }
>
> /* Calculates the prefix value for quick offset addressing mode. */
> Index: exec.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/exec.c,v
> retrieving revision 1.60
> diff -u -p -r1.60 exec.c
> --- exec.c 25 Feb 2006 04:36:39 -0000 1.60
> +++ exec.c 17 Apr 2006 19:03:21 -0000
> @@ -59,8 +59,6 @@ static void set_section_command (char *,
>
> static void exec_files_info (struct target_ops *);
>
> -static int ignore (CORE_ADDR, bfd_byte *);
> -
> static void init_exec_ops (void);
>
> void _initialize_exec (void);
> @@ -691,7 +689,7 @@ exec_set_section_address (const char *fi
> breakpoint_init_inferior). */
>
> static int
> -ignore (CORE_ADDR addr, bfd_byte *contents)
> +ignore (struct bp_target_info *bp_tgt)
> {
> return 0;
> }
> Index: gdbarch.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbarch.c,v
> retrieving revision 1.328
> diff -u -p -r1.328 gdbarch.c
> --- gdbarch.c 17 Dec 2005 22:33:59 -0000 1.328
> +++ gdbarch.c 17 Apr 2006 19:03:21 -0000
> @@ -1250,8 +1250,8 @@ gdbarch_dump (struct gdbarch *current_gd
> #ifdef MEMORY_INSERT_BREAKPOINT
> fprintf_unfiltered (file,
> "gdbarch_dump: %s # %s\n",
> - "MEMORY_INSERT_BREAKPOINT(addr, contents_cache)",
> - XSTRING (MEMORY_INSERT_BREAKPOINT (addr, contents_cache)));
> + "MEMORY_INSERT_BREAKPOINT(bp_tgt)",
> + XSTRING (MEMORY_INSERT_BREAKPOINT (bp_tgt)));
> #endif
> fprintf_unfiltered (file,
> "gdbarch_dump: memory_insert_breakpoint = <0x%lx>\n",
> @@ -1259,8 +1259,8 @@ gdbarch_dump (struct gdbarch *current_gd
> #ifdef MEMORY_REMOVE_BREAKPOINT
> fprintf_unfiltered (file,
> "gdbarch_dump: %s # %s\n",
> - "MEMORY_REMOVE_BREAKPOINT(addr, contents_cache)",
> - XSTRING (MEMORY_REMOVE_BREAKPOINT (addr, contents_cache)));
> + "MEMORY_REMOVE_BREAKPOINT(bp_tgt)",
> + XSTRING (MEMORY_REMOVE_BREAKPOINT (bp_tgt)));
> #endif
> fprintf_unfiltered (file,
> "gdbarch_dump: memory_remove_breakpoint = <0x%lx>\n",
> @@ -2934,13 +2934,13 @@ set_gdbarch_adjust_breakpoint_address (s
> }
>
> int
> -gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, gdb_byte *contents_cache)
> +gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
> {
> gdb_assert (gdbarch != NULL);
> gdb_assert (gdbarch->memory_insert_breakpoint != NULL);
> if (gdbarch_debug >= 2)
> fprintf_unfiltered (gdb_stdlog, "gdbarch_memory_insert_breakpoint called\n");
> - return gdbarch->memory_insert_breakpoint (addr, contents_cache);
> + return gdbarch->memory_insert_breakpoint (bp_tgt);
> }
>
> void
> @@ -2951,13 +2951,13 @@ set_gdbarch_memory_insert_breakpoint (st
> }
>
> int
> -gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, gdb_byte *contents_cache)
> +gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
> {
> gdb_assert (gdbarch != NULL);
> gdb_assert (gdbarch->memory_remove_breakpoint != NULL);
> if (gdbarch_debug >= 2)
> fprintf_unfiltered (gdb_stdlog, "gdbarch_memory_remove_breakpoint called\n");
> - return gdbarch->memory_remove_breakpoint (addr, contents_cache);
> + return gdbarch->memory_remove_breakpoint (bp_tgt);
> }
>
> void
> Index: gdbarch.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbarch.h,v
> retrieving revision 1.284
> diff -u -p -r1.284 gdbarch.h
> --- gdbarch.h 17 Dec 2005 22:34:00 -0000 1.284
> +++ gdbarch.h 17 Apr 2006 19:03:21 -0000
> @@ -49,6 +49,7 @@ struct regset;
> struct disassemble_info;
> struct target_ops;
> struct obstack;
> +struct bp_target_info;
>
> extern struct gdbarch *current_gdbarch;
>
> @@ -899,24 +900,24 @@ typedef CORE_ADDR (gdbarch_adjust_breakp
> extern CORE_ADDR gdbarch_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr);
> extern void set_gdbarch_adjust_breakpoint_address (struct gdbarch *gdbarch, gdbarch_adjust_breakpoint_address_ftype *adjust_breakpoint_address);
>
> -typedef int (gdbarch_memory_insert_breakpoint_ftype) (CORE_ADDR addr, gdb_byte *contents_cache);
> -extern int gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, gdb_byte *contents_cache);
> +typedef int (gdbarch_memory_insert_breakpoint_ftype) (struct bp_target_info *bp_tgt);
> +extern int gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt);
> extern void set_gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, gdbarch_memory_insert_breakpoint_ftype *memory_insert_breakpoint);
> #if !defined (GDB_TM_FILE) && defined (MEMORY_INSERT_BREAKPOINT)
> #error "Non multi-arch definition of MEMORY_INSERT_BREAKPOINT"
> #endif
> #if !defined (MEMORY_INSERT_BREAKPOINT)
> -#define MEMORY_INSERT_BREAKPOINT(addr, contents_cache) (gdbarch_memory_insert_breakpoint (current_gdbarch, addr, contents_cache))
> +#define MEMORY_INSERT_BREAKPOINT(bp_tgt) (gdbarch_memory_insert_breakpoint (current_gdbarch, bp_tgt))
> #endif
>
> -typedef int (gdbarch_memory_remove_breakpoint_ftype) (CORE_ADDR addr, gdb_byte *contents_cache);
> -extern int gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, gdb_byte *contents_cache);
> +typedef int (gdbarch_memory_remove_breakpoint_ftype) (struct bp_target_info *bp_tgt);
> +extern int gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt);
> extern void set_gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, gdbarch_memory_remove_breakpoint_ftype *memory_remove_breakpoint);
> #if !defined (GDB_TM_FILE) && defined (MEMORY_REMOVE_BREAKPOINT)
> #error "Non multi-arch definition of MEMORY_REMOVE_BREAKPOINT"
> #endif
> #if !defined (MEMORY_REMOVE_BREAKPOINT)
> -#define MEMORY_REMOVE_BREAKPOINT(addr, contents_cache) (gdbarch_memory_remove_breakpoint (current_gdbarch, addr, contents_cache))
> +#define MEMORY_REMOVE_BREAKPOINT(bp_tgt) (gdbarch_memory_remove_breakpoint (current_gdbarch, bp_tgt))
> #endif
>
> extern CORE_ADDR gdbarch_decr_pc_after_break (struct gdbarch *gdbarch);
> Index: gdbarch.sh
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbarch.sh,v
> retrieving revision 1.363
> diff -u -p -r1.363 gdbarch.sh
> --- gdbarch.sh 17 Dec 2005 22:34:00 -0000 1.363
> +++ gdbarch.sh 17 Apr 2006 19:03:22 -0000
> @@ -549,8 +549,8 @@ f:=:CORE_ADDR:skip_prologue:CORE_ADDR ip
> f:=:int:inner_than:CORE_ADDR lhs, CORE_ADDR rhs:lhs, rhs:0:0
> f:=:const gdb_byte *:breakpoint_from_pc:CORE_ADDR *pcptr, int *lenptr:pcptr, lenptr::0:
> M::CORE_ADDR:adjust_breakpoint_address:CORE_ADDR bpaddr:bpaddr
> -f:=:int:memory_insert_breakpoint:CORE_ADDR addr, gdb_byte *contents_cache:addr, contents_cache:0:default_memory_insert_breakpoint::0
> -f:=:int:memory_remove_breakpoint:CORE_ADDR addr, gdb_byte *contents_cache:addr, contents_cache:0:default_memory_remove_breakpoint::0
> +f:=:int:memory_insert_breakpoint:struct bp_target_info *bp_tgt:bp_tgt:0:default_memory_insert_breakpoint::0
> +f:=:int:memory_remove_breakpoint:struct bp_target_info *bp_tgt:bp_tgt:0:default_memory_remove_breakpoint::0
> v:=:CORE_ADDR:decr_pc_after_break:::0:::0
>
> # A function can be addressed by either it's "pointer" (possibly a
> @@ -771,6 +771,7 @@ struct regset;
> struct disassemble_info;
> struct target_ops;
> struct obstack;
> +struct bp_target_info;
>
> extern struct gdbarch *current_gdbarch;
> EOF
> Index: i386-nat.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/i386-nat.c,v
> retrieving revision 1.13
> diff -u -p -r1.13 i386-nat.c
> --- i386-nat.c 17 Dec 2005 22:34:01 -0000 1.13
> +++ i386-nat.c 17 Apr 2006 19:03:22 -0000
> @@ -625,12 +625,13 @@ i386_stopped_by_hwbp (void)
> return 0;
> }
>
> -/* Insert a hardware-assisted breakpoint at address ADDR. SHADOW is
> - unused. Return 0 on success, EBUSY on failure. */
> +/* Insert a hardware-assisted breakpoint at BP_TGT->placed_address.
> + Return 0 on success, EBUSY on failure. */
> int
> -i386_insert_hw_breakpoint (CORE_ADDR addr, void *shadow)
> +i386_insert_hw_breakpoint (struct bp_target_info *bp_tgt)
> {
> unsigned len_rw = i386_length_and_rw_bits (1, hw_execute);
> + CORE_ADDR addr = bp_tgt->placed_address;
> int retval = i386_insert_aligned_watchpoint (addr, len_rw) ? EBUSY : 0;
>
> if (maint_show_dr)
> @@ -639,13 +640,14 @@ i386_insert_hw_breakpoint (CORE_ADDR add
> return retval;
> }
>
> -/* Remove a hardware-assisted breakpoint at address ADDR. SHADOW is
> - unused. Return 0 on success, -1 on failure. */
> +/* Remove a hardware-assisted breakpoint at BP_TGT->placed_address.
> + Return 0 on success, -1 on failure. */
>
> int
> -i386_remove_hw_breakpoint (CORE_ADDR addr, void *shadow)
> +i386_remove_hw_breakpoint (struct bp_target_info *bp_tgt)
> {
> unsigned len_rw = i386_length_and_rw_bits (1, hw_execute);
> + CORE_ADDR addr = bp_tgt->placed_address;
> int retval = i386_remove_aligned_watchpoint (addr, len_rw);
>
> if (maint_show_dr)
> Index: ia64-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/ia64-tdep.c,v
> retrieving revision 1.138
> diff -u -p -r1.138 ia64-tdep.c
> --- ia64-tdep.c 8 Mar 2006 15:28:17 -0000 1.138
> +++ ia64-tdep.c 17 Apr 2006 19:03:22 -0000
> @@ -550,8 +550,9 @@ fetch_instruction (CORE_ADDR addr, instr
> #define IA64_BREAKPOINT 0x00003333300LL
>
> static int
> -ia64_memory_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
> +ia64_memory_insert_breakpoint (struct bp_target_info *bp_tgt)
> {
> + CORE_ADDR addr = bp_tgt->placed_address;
> char bundle[BUNDLE_LEN];
> int slotnum = (int) (addr & 0x0f) / SLOT_MULTIPLIER;
> long long instr;
> @@ -574,7 +575,8 @@ ia64_memory_insert_breakpoint (CORE_ADDR
> }
>
> instr = slotN_contents (bundle, slotnum);
> - memcpy(contents_cache, &instr, sizeof(instr));
> + memcpy (bp_tgt->shadow_contents, &instr, sizeof (instr));
> + bp_tgt->placed_size = bp_tgt->shadow_len = sizeof (instr);
> replace_slotN_contents (bundle, IA64_BREAKPOINT, slotnum);
> if (val == 0)
> target_write_memory (addr, bundle, BUNDLE_LEN);
> @@ -583,8 +585,9 @@ ia64_memory_insert_breakpoint (CORE_ADDR
> }
>
> static int
> -ia64_memory_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
> +ia64_memory_remove_breakpoint (struct bp_target_info *bp_tgt)
> {
> + CORE_ADDR addr = bp_tgt->placed_address;
> char bundle[BUNDLE_LEN];
> int slotnum = (addr & 0x0f) / SLOT_MULTIPLIER;
> long long instr;
> @@ -603,7 +606,7 @@ ia64_memory_remove_breakpoint (CORE_ADDR
> slotnum = 2;
> }
>
> - memcpy (&instr, contents_cache, sizeof instr);
> + memcpy (&instr, bp_tgt->shadow_contents, sizeof instr);
> replace_slotN_contents (bundle, instr, slotnum);
> if (val == 0)
> target_write_memory (addr, bundle, BUNDLE_LEN);
> Index: m32r-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/m32r-tdep.c,v
> retrieving revision 1.40
> diff -u -p -r1.40 m32r-tdep.c
> --- m32r-tdep.c 17 Dec 2005 22:34:01 -0000 1.40
> +++ m32r-tdep.c 17 Apr 2006 19:03:22 -0000
> @@ -81,10 +81,12 @@ m32r_frame_align (struct gdbarch *gdbarc
> The following functions take care of this behavior. */
>
> static int
> -m32r_memory_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
> +m32r_memory_insert_breakpoint (struct bp_target_info *bp_tgt)
> {
> + CORE_ADDR addr = bp_tgt->placed_address;
> int val;
> gdb_byte buf[4];
> + gdb_byte *contents_cache = bp_tgt->shadow_contents;
> gdb_byte bp_entry[] = { 0x10, 0xf1 }; /* dpt */
>
> /* Save the memory contents. */
> @@ -92,6 +94,8 @@ m32r_memory_insert_breakpoint (CORE_ADDR
> if (val != 0)
> return val; /* return error */
>
> + bp_tgt->placed_size = bp_tgt->shadow_len = 4;
> +
> /* Determine appropriate breakpoint contents and size for this address. */
> if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
> {
> @@ -134,10 +138,12 @@ m32r_memory_insert_breakpoint (CORE_ADDR
> }
>
> static int
> -m32r_memory_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
> +m32r_memory_remove_breakpoint (struct bp_target_info *bp_tgt)
> {
> + CORE_ADDR addr = bp_tgt->placed_address;
> int val;
> gdb_byte buf[4];
> + gdb_byte *contents_cache = bp_tgt->shadow_contents;
>
> buf[0] = contents_cache[0];
> buf[1] = contents_cache[1];
> Index: mem-break.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/mem-break.c,v
> retrieving revision 1.11
> diff -u -p -r1.11 mem-break.c
> --- mem-break.c 17 Dec 2005 22:34:01 -0000 1.11
> +++ mem-break.c 17 Apr 2006 19:03:22 -0000
> @@ -33,60 +33,57 @@
> #include "target.h"
>
>
> -/* Insert a breakpoint on targets that don't have any better breakpoint
> - support. We read the contents of the target location and stash it,
> - then overwrite it with a breakpoint instruction. ADDR is the target
> - location in the target machine. CONTENTS_CACHE is a pointer to
> - memory allocated for saving the target contents. It is guaranteed
> - by the caller to be long enough to save BREAKPOINT_LEN bytes (this
> - is accomplished via BREAKPOINT_MAX). */
> +/* Insert a breakpoint on targets that don't have any better
> + breakpoint support. We read the contents of the target location
> + and stash it, then overwrite it with a breakpoint instruction.
> + BP_TGT->placed_address is the target location in the target
> + machine. BP_TGT->shadow_contents is some memory allocated for
> + saving the target contents. It is guaranteed by the caller to be
> + long enough to save BREAKPOINT_LEN bytes (this is accomplished via
> + BREAKPOINT_MAX). */
>
> int
> -default_memory_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
> +default_memory_insert_breakpoint (struct bp_target_info *bp_tgt)
> {
> int val;
> const unsigned char *bp;
> int bplen;
>
> /* Determine appropriate breakpoint contents and size for this address. */
> - bp = BREAKPOINT_FROM_PC (&addr, &bplen);
> + bp = BREAKPOINT_FROM_PC (&bp_tgt->placed_address, &bp_tgt->placed_size);
> if (bp == NULL)
> error (_("Software breakpoints not implemented for this target."));
>
> /* Save the memory contents. */
> - val = target_read_memory (addr, contents_cache, bplen);
> + bp_tgt->shadow_len = bp_tgt->placed_size;
> + val = target_read_memory (bp_tgt->placed_address, bp_tgt->shadow_contents,
> + bp_tgt->placed_size);
>
> /* Write the breakpoint. */
> if (val == 0)
> - val = target_write_memory (addr, bp, bplen);
> + val = target_write_memory (bp_tgt->placed_address, bp,
> + bp_tgt->placed_size);
>
> return val;
> }
>
>
> int
> -default_memory_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
> +default_memory_remove_breakpoint (struct bp_target_info *bp_tgt)
> {
> - const bfd_byte *bp;
> - int bplen;
> -
> - /* Determine appropriate breakpoint contents and size for this address. */
> - bp = BREAKPOINT_FROM_PC (&addr, &bplen);
> - if (bp == NULL)
> - error (_("Software breakpoints not implemented for this target."));
> -
> - return target_write_memory (addr, contents_cache, bplen);
> + return target_write_memory (bp_tgt->placed_address, bp_tgt->shadow_contents,
> + bp_tgt->placed_size);
> }
>
>
> int
> -memory_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
> +memory_insert_breakpoint (struct bp_target_info *bp_tgt)
> {
> - return MEMORY_INSERT_BREAKPOINT(addr, contents_cache);
> + return MEMORY_INSERT_BREAKPOINT (bp_tgt);
> }
>
> int
> -memory_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
> +memory_remove_breakpoint (struct bp_target_info *bp_tgt)
> {
> - return MEMORY_REMOVE_BREAKPOINT(addr, contents_cache);
> + return MEMORY_REMOVE_BREAKPOINT (bp_tgt);
> }
> Index: mips-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/mips-tdep.c,v
> retrieving revision 1.388
> diff -u -p -r1.388 mips-tdep.c
> --- mips-tdep.c 15 Mar 2006 16:59:54 -0000 1.388
> +++ mips-tdep.c 17 Apr 2006 19:03:23 -0000
> @@ -2188,20 +2188,17 @@ mips_addr_bits_remove (CORE_ADDR addr)
> void
> mips_software_single_step (enum target_signal sig, int insert_breakpoints_p)
> {
> - static CORE_ADDR next_pc;
> - typedef char binsn_quantum[BREAKPOINT_MAX];
> - static binsn_quantum break_mem;
> - CORE_ADDR pc;
> + CORE_ADDR pc, next_pc;
>
> if (insert_breakpoints_p)
> {
> pc = read_register (mips_regnum (current_gdbarch)->pc);
> next_pc = mips_next_pc (pc);
>
> - target_insert_breakpoint (next_pc, break_mem);
> + insert_single_step_breakpoint (next_pc);
> }
> else
> - target_remove_breakpoint (next_pc, break_mem);
> + remove_single_step_breakpoints ();
> }
>
> /* Test whether the PC points to the return instruction at the
> Index: monitor.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/monitor.c,v
> retrieving revision 1.63
> diff -u -p -r1.63 monitor.c
> --- monitor.c 24 Jan 2006 22:09:28 -0000 1.63
> +++ monitor.c 17 Apr 2006 19:03:23 -0000
> @@ -85,8 +85,6 @@ static int monitor_xfer_memory (CORE_ADD
> struct mem_attrib *attrib,
> struct target_ops *target);
> static void monitor_files_info (struct target_ops *ops);
> -static int monitor_insert_breakpoint (CORE_ADDR addr, gdb_byte *shadow);
> -static int monitor_remove_breakpoint (CORE_ADDR addr, gdb_byte *shadow);
> static void monitor_kill (void);
> static void monitor_load (char *file, int from_tty);
> static void monitor_mourn_inferior (void);
> @@ -2037,8 +2035,9 @@ monitor_mourn_inferior (void)
> /* Tell the monitor to add a breakpoint. */
>
> static int
> -monitor_insert_breakpoint (CORE_ADDR addr, gdb_byte *shadow)
> +monitor_insert_breakpoint (struct bp_target_info *bp_tgt)
> {
> + CORE_ADDR addr = bp_tgt->placed_address;
> int i;
> const unsigned char *bp;
> int bplen;
> @@ -2052,13 +2051,14 @@ monitor_insert_breakpoint (CORE_ADDR add
>
> /* Determine appropriate breakpoint size for this address. */
> bp = gdbarch_breakpoint_from_pc (current_gdbarch, &addr, &bplen);
> + bp_tgt->placed_address = addr;
> + bp_tgt->placed_size = bplen;
>
> for (i = 0; i < current_monitor->num_breakpoints; i++)
> {
> if (breakaddr[i] == 0)
> {
> breakaddr[i] = addr;
> - monitor_read_memory (addr, shadow, bplen);
> monitor_printf (current_monitor->set_break, addr);
> monitor_expect_prompt (NULL, 0);
> return 0;
> @@ -2071,17 +2071,15 @@ monitor_insert_breakpoint (CORE_ADDR add
> /* Tell the monitor to remove a breakpoint. */
>
> static int
> -monitor_remove_breakpoint (CORE_ADDR addr, gdb_byte *shadow)
> +monitor_remove_breakpoint (struct bp_target_info *bp_tgt)
> {
> + CORE_ADDR addr = bp_tgt->placed_address;
> int i;
>
> monitor_debug ("MON rmbkpt %s\n", paddr (addr));
> if (current_monitor->clr_break == NULL)
> error (_("No clr_break defined for this monitor"));
>
> - if (current_monitor->flags & MO_ADDR_BITS_REMOVE)
> - addr = ADDR_BITS_REMOVE (addr);
> -
> for (i = 0; i < current_monitor->num_breakpoints; i++)
> {
> if (breakaddr[i] == addr)
> Index: nto-procfs.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/nto-procfs.c,v
> retrieving revision 1.17
> diff -u -p -r1.17 nto-procfs.c
> --- nto-procfs.c 24 Jan 2006 22:09:28 -0000 1.17
> +++ nto-procfs.c 17 Apr 2006 19:03:23 -0000
> @@ -76,10 +76,6 @@ static ptid_t do_attach (ptid_t ptid);
>
> static int procfs_can_use_hw_breakpoint (int, int, int);
>
> -static int procfs_insert_hw_breakpoint (CORE_ADDR, char *);
> -
> -static int procfs_remove_hw_breakpoint (CORE_ADDR addr, char *);
> -
> static int procfs_insert_hw_watchpoint (CORE_ADDR addr, int len, int type);
>
> static int procfs_remove_hw_watchpoint (CORE_ADDR addr, int len, int type);
> @@ -812,27 +808,29 @@ procfs_breakpoint (CORE_ADDR addr, int t
> }
>
> static int
> -procfs_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
> +procfs_insert_breakpoint (struct bp_target_info *bp_tgt)
> {
> - return procfs_breakpoint (addr, _DEBUG_BREAK_EXEC, 0);
> + return procfs_breakpoint (bp_tgt->placed_address, _DEBUG_BREAK_EXEC, 0);
> }
>
> static int
> -procfs_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
> +procfs_remove_breakpoint (struct bp_target_info *bp_tgt)
> {
> - return procfs_breakpoint (addr, _DEBUG_BREAK_EXEC, -1);
> + return procfs_breakpoint (bp_tgt->placed_address, _DEBUG_BREAK_EXEC, -1);
> }
>
> static int
> -procfs_insert_hw_breakpoint (CORE_ADDR addr, char *contents_cache)
> +procfs_insert_hw_breakpoint (struct bp_target_info *bp_tgt)
> {
> - return procfs_breakpoint (addr, _DEBUG_BREAK_EXEC | _DEBUG_BREAK_HW, 0);
> + return procfs_breakpoint (bp_tgt->placed_address,
> + _DEBUG_BREAK_EXEC | _DEBUG_BREAK_HW, 0);
> }
>
> static int
> -procfs_remove_hw_breakpoint (CORE_ADDR addr, char *contents_cache)
> +procfs_remove_hw_breakpoint (struct bp_target_info *bp_tgt)
> {
> - return procfs_breakpoint (addr, _DEBUG_BREAK_EXEC | _DEBUG_BREAK_HW, -1);
> + return procfs_breakpoint (bp_tgt->placed_address,
> + _DEBUG_BREAK_EXEC | _DEBUG_BREAK_HW, -1);
> }
>
> static void
> Index: ocd.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/ocd.c,v
> retrieving revision 1.43
> diff -u -p -r1.43 ocd.c
> --- ocd.c 24 Jan 2006 22:09:28 -0000 1.43
> +++ ocd.c 17 Apr 2006 19:03:23 -0000
> @@ -1048,28 +1048,27 @@ ocd_load (char *args, int from_tty)
> /* BDM (at least on CPU32) uses a different breakpoint */
>
> int
> -ocd_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
> +ocd_insert_breakpoint (struct bp_target_info *bp_tgt)
> {
> static char break_insn[] = BDM_BREAKPOINT;
> int val;
>
> - val = target_read_memory (addr, contents_cache, sizeof (break_insn));
> + bp_tgt->placed_size = bp_tgt->shadow_len = sizeof (break_insn);
> + val = target_read_memory (bp_tgt->placed_address, bp_tgt->shadow_contents,
> + bp_tgt->placed_size);
>
> if (val == 0)
> - val = target_write_memory (addr, break_insn, sizeof (break_insn));
> + val = target_write_memory (bp_tgt->placed_address, break_insn,
> + bp_tgt->placed_size);
>
> return val;
> }
>
> int
> -ocd_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
> +ocd_remove_breakpoint (struct bp_target_info *bp_tgt)
> {
> - static char break_insn[] = BDM_BREAKPOINT;
> - int val;
> -
> - val = target_write_memory (addr, contents_cache, sizeof (break_insn));
> -
> - return val;
> + return target_write_memory (bp_tgt->placed_address, bp_tgt->shadow_contents,
> + bp_tgt->placed_size);
> }
>
> static void
> Index: ocd.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/ocd.h,v
> retrieving revision 1.8
> diff -u -p -r1.8 ocd.h
> --- ocd.h 17 Dec 2005 22:34:01 -0000 1.8
> +++ ocd.h 17 Apr 2006 19:03:23 -0000
> @@ -135,8 +135,8 @@ void ocd_write_bdm_register (int bdm_reg
>
> int ocd_wait (void);
>
> -int ocd_insert_breakpoint (CORE_ADDR addr, char *contents_cache);
> -int ocd_remove_breakpoint (CORE_ADDR addr, char *contents_cache);
> +int ocd_insert_breakpoint (struct bp_target_info *bp_tgt);
> +int ocd_remove_breakpoint (struct bp_target_info *bp_tgt);
>
> int ocd_write_bytes (CORE_ADDR memaddr, char *myaddr, int len);
>
> Index: ppc-linux-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/ppc-linux-tdep.c,v
> retrieving revision 1.77
> diff -u -p -r1.77 ppc-linux-tdep.c
> --- ppc-linux-tdep.c 15 Jan 2006 18:28:58 -0000 1.77
> +++ ppc-linux-tdep.c 17 Apr 2006 19:03:23 -0000
> @@ -457,9 +457,9 @@ ppc_linux_skip_trampoline_code (CORE_ADD
> regard to removing breakpoints in some potentially self modifying
> code. */
> int
> -ppc_linux_memory_remove_breakpoint (CORE_ADDR addr,
> - gdb_byte *contents_cache)
> +ppc_linux_memory_remove_breakpoint (struct bp_target_info *bp_tgt)
> {
> + CORE_ADDR addr = bp_tgt->placed_address;
> const unsigned char *bp;
> int val;
> int bplen;
> @@ -476,7 +476,7 @@ ppc_linux_memory_remove_breakpoint (CORE
> program modified the code on us, so it is wrong to put back the
> old value */
> if (val == 0 && memcmp (bp, old_contents, bplen) == 0)
> - val = target_write_memory (addr, contents_cache, bplen);
> + val = target_write_memory (addr, bp_tgt->shadow_contents, bplen);
>
> return val;
> }
> Index: ppc-tdep.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/ppc-tdep.h,v
> retrieving revision 1.50
> diff -u -p -r1.50 ppc-tdep.h
> --- ppc-tdep.h 17 Jan 2006 22:21:13 -0000 1.50
> +++ ppc-tdep.h 17 Apr 2006 19:03:24 -0000
> @@ -56,8 +56,7 @@ CORE_ADDR ppc64_sysv_abi_push_dummy_call
> CORE_ADDR struct_addr);
> CORE_ADDR ppc64_sysv_abi_adjust_breakpoint_address (struct gdbarch *gdbarch,
> CORE_ADDR bpaddr);
> -int ppc_linux_memory_remove_breakpoint (CORE_ADDR addr,
> - gdb_byte *contents_cache);
> +int ppc_linux_memory_remove_breakpoint (struct bp_target_info *bp_tgt);
> struct link_map_offsets *ppc_linux_svr4_fetch_link_map_offsets (void);
> void ppc_linux_supply_gregset (struct regcache *regcache,
> int regnum, const void *gregs, size_t size,
> Index: procfs.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/procfs.c,v
> retrieving revision 1.68
> diff -u -p -r1.68 procfs.c
> --- procfs.c 24 Jan 2006 22:09:28 -0000 1.68
> +++ procfs.c 17 Apr 2006 19:03:25 -0000
> @@ -3375,7 +3375,7 @@ static void remove_dbx_link_breakpoint (
> the address of the breakpoint, and the code that was replaced by
> a breakpoint. */
> static int dbx_link_bpt_addr = 0;
> -static char dbx_link_shadow_contents[BREAKPOINT_MAX];
> +static void *dbx_link_bpt;
>
> /*
> * Function: procfs_debug_inferior
> @@ -4777,6 +4777,14 @@ procfs_mourn_inferior (void)
> destroy_procinfo (pi);
> }
> unpush_target (&procfs_ops);
> +
> + if (dbx_link_bpt != NULL)
> + {
> + deprecated_remove_raw_breakpoint (dbx_link_bpt);
> + dbx_link_bpt_addr = 0;
> + dbx_link_bpt = NULL;
> + }
> +
> generic_mourn_inferior ();
> }
>
> @@ -4886,7 +4894,6 @@ procfs_init_inferior (int pid)
> has been inserted, the syssgi() notifications are no longer necessary,
> so they should be canceled. */
> proc_trace_syscalls_1 (pi, SYS_syssgi, PR_SYSEXIT, FLAG_SET, 0);
> - dbx_link_bpt_addr = 0;
> #endif
> }
>
> @@ -5571,11 +5578,11 @@ remove_dbx_link_breakpoint (void)
> if (dbx_link_bpt_addr == 0)
> return;
>
> - if (memory_remove_breakpoint (dbx_link_bpt_addr,
> - dbx_link_shadow_contents) != 0)
> + if (deprecated_remove_raw_breakpoint (dbx_link_bpt) != 0)
> warning (_("Unable to remove __dbx_link breakpoint."));
>
> dbx_link_bpt_addr = 0;
> + dbx_link_bpt = NULL;
> }
>
> /* Return the address of the __dbx_link() function in the file
> @@ -5643,7 +5650,8 @@ insert_dbx_link_bpt_in_file (int fd, COR
> {
> /* Insert the breakpoint. */
> dbx_link_bpt_addr = sym_addr;
> - if (target_insert_breakpoint (sym_addr, dbx_link_shadow_contents) != 0)
> + dbx_link_bpt = deprecated_insert_raw_breakpoint (sym_addr);
> + if (dbx_link_bpt == NULL)
> {
> warning (_("Failed to insert dbx_link breakpoint."));
> bfd_close (abfd);
> Index: remote-e7000.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/remote-e7000.c,v
> retrieving revision 1.57
> diff -u -p -r1.57 remote-e7000.c
> --- remote-e7000.c 24 Jan 2006 22:09:28 -0000 1.57
> +++ remote-e7000.c 17 Apr 2006 19:03:25 -0000
> @@ -1702,8 +1702,9 @@ static CORE_ADDR breakaddr[MAX_BREAKPOIN
> {0};
>
> static int
> -e7000_insert_breakpoint (CORE_ADDR addr, bfd_byte *shadow)
> +e7000_insert_breakpoint (struct bp_target_info *bp_tgt)
> {
> + CORE_ADDR addr = bp_tgt->placed_address;
> int i;
> char buf[200];
> #if 0
> @@ -1728,7 +1729,8 @@ e7000_insert_breakpoint (CORE_ADDR addr,
> }
> #else
> #if 0
> - e7000_read_inferior_memory (addr, shadow, 2);
> + bp_tgt->shadow_len = 2;
> + e7000_read_inferior_memory (addr, bp_tgt->shadow_contents, 2);
> e7000_write_inferior_memory (addr, nop, 2);
> #endif
>
> @@ -1745,8 +1747,9 @@ e7000_insert_breakpoint (CORE_ADDR addr,
> }
>
> static int
> -e7000_remove_breakpoint (CORE_ADDR addr, bfd_byte *shadow)
> +e7000_remove_breakpoint (struct bp_target_info *bp_tgt)
> {
> + CORE_ADDR addr = bp_tgt->placed_address;
> int i;
> char buf[200];
>
> @@ -1773,7 +1776,8 @@ e7000_remove_breakpoint (CORE_ADDR addr,
>
> #if 0
> /* Replace the insn under the break */
> - e7000_write_inferior_memory (addr, shadow, 2);
> + e7000_write_inferior_memory (addr, bp_tgt->shadow_contents,
> + bp_tgt->shadow_len);
> #endif
> #endif
>
> Index: remote-m32r-sdi.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/remote-m32r-sdi.c,v
> retrieving revision 1.17
> diff -u -p -r1.17 remote-m32r-sdi.c
> --- remote-m32r-sdi.c 24 Jan 2006 22:09:28 -0000 1.17
> +++ remote-m32r-sdi.c 17 Apr 2006 19:03:25 -0000
> @@ -1141,15 +1141,16 @@ m32r_mourn_inferior (void)
> }
>
> static int
> -m32r_insert_breakpoint (CORE_ADDR addr, bfd_byte *shadow)
> +m32r_insert_breakpoint (struct bp_target_info *bp_tgt)
> {
> + CORE_ADDR addr = bp_tgt->placed_address;
> int ib_breakpoints;
> unsigned char buf[13];
> int i, c;
>
> if (remote_debug)
> - fprintf_unfiltered (gdb_stdlog, "m32r_insert_breakpoint(%08lx,\"%s\")\n",
> - addr, shadow);
> + fprintf_unfiltered (gdb_stdlog, "m32r_insert_breakpoint(%08lx,...)\n",
> + addr);
>
> if (use_ib_breakpoints)
> ib_breakpoints = max_ib_breakpoints;
> @@ -1183,13 +1184,14 @@ m32r_insert_breakpoint (CORE_ADDR addr,
> }
>
> static int
> -m32r_remove_breakpoint (CORE_ADDR addr, bfd_byte *shadow)
> +m32r_remove_breakpoint (struct bp_target_info *bp_tgt)
> {
> + CORE_ADDR addr = bp_tgt->placed_address;
> int i;
>
> if (remote_debug)
> - fprintf_unfiltered (gdb_stdlog, "m32r_remove_breakpoint(%08lx,\"%s\")\n",
> - addr, shadow);
> + fprintf_unfiltered (gdb_stdlog, "m32r_remove_breakpoint(%08lx)\n",
> + addr);
>
> for (i = 0; i < MAX_BREAKPOINTS; i++)
> {
> Index: remote-mips.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/remote-mips.c,v
> retrieving revision 1.68
> diff -u -p -r1.68 remote-mips.c
> --- remote-mips.c 24 Jan 2006 22:09:28 -0000 1.68
> +++ remote-mips.c 17 Apr 2006 19:03:26 -0000
> @@ -2216,27 +2216,28 @@ mips_mourn_inferior (void)
> /* Insert a breakpoint. On targets that don't have built-in
> breakpoint support, we read the contents of the target location and
> stash it, then overwrite it with a breakpoint instruction. ADDR is
> - the target location in the target machine. CONTENTS_CACHE is a
> - pointer to memory allocated for saving the target contents. It is
> - guaranteed by the caller to be long enough to save the breakpoint
> - length returned by BREAKPOINT_FROM_PC. */
> + the target location in the target machine. BPT is the breakpoint
> + being inserted or removed, which contains memory for saving the
> + target contents. */
>
> static int
> -mips_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
> +mips_insert_breakpoint (struct bp_target_info *bp_tgt)
> {
> if (monitor_supports_breakpoints)
> - return set_breakpoint (addr, MIPS_INSN32_SIZE, BREAK_FETCH);
> + return set_breakpoint (bp_tgt->placed_address, MIPS_INSN32_SIZE,
> + BREAK_FETCH);
> else
> - return memory_insert_breakpoint (addr, contents_cache);
> + return memory_insert_breakpoint (bp_tgt);
> }
>
> static int
> -mips_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
> +mips_remove_breakpoint (struct bp_target_info *bp_tgt)
> {
> if (monitor_supports_breakpoints)
> - return clear_breakpoint (addr, MIPS_INSN32_SIZE, BREAK_FETCH);
> + return clear_breakpoint (bp_tgt->placed_address, MIPS_INSN32_SIZE,
> + BREAK_FETCH);
> else
> - return memory_remove_breakpoint (addr, contents_cache);
> + return memory_remove_breakpoint (bp_tgt);
> }
>
> /* Tell whether this target can support a hardware breakpoint. CNT
> Index: remote-rdp.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/remote-rdp.c,v
> retrieving revision 1.49
> diff -u -p -r1.49 remote-rdp.c
> --- remote-rdp.c 3 Mar 2006 23:08:12 -0000 1.49
> +++ remote-rdp.c 17 Apr 2006 19:03:26 -0000
> @@ -1050,8 +1050,10 @@ rdp_execute (void)
> }
>
> static int
> -remote_rdp_insert_breakpoint (CORE_ADDR addr, bfd_byte *save)
> +remote_rdp_insert_breakpoint (struct bp_target_info *bp_tgt)
> {
> + CORE_ADDR addr = bp_tgt->placed_address;
> +
> int res;
> if (ds.rdi_level > 0)
> {
> @@ -1059,7 +1061,7 @@ remote_rdp_insert_breakpoint (CORE_ADDR
> RDP_SET_BREAK,
> addr,
> RDP_SET_BREAK_TYPE_PC_EQUAL | RDP_SET_BREAK_TYPE_GET_HANDLE,
> - save,
> + bp_tgt->shadow_contents,
> &res);
> }
> else
> @@ -1074,14 +1076,15 @@ remote_rdp_insert_breakpoint (CORE_ADDR
> }
>
> static int
> -remote_rdp_remove_breakpoint (CORE_ADDR addr, bfd_byte *save)
> +remote_rdp_remove_breakpoint (struct bp_target_info *bp_tgt)
> {
> + CORE_ADDR addr = bp_tgt->placed_address;
> int res;
> if (ds.rdi_level > 0)
> {
> send_rdp ("b-p-S-B",
> RDP_CLEAR_BREAK,
> - save, 4,
> + bp_tgt->shadow_contents, 4,
> &res);
> }
> else
> @@ -1108,12 +1111,12 @@ rdp_step (void)
> }
> else
> {
> - char handle[4];
> + void *b;
> CORE_ADDR pc = read_register (ARM_PC_REGNUM);
> pc = arm_get_next_pc (pc);
> - remote_rdp_insert_breakpoint (pc, handle);
> + b = deprecated_insert_raw_breakpoint (pc);
> rdp_execute ();
> - remote_rdp_remove_breakpoint (pc, handle);
> + deprecated_remove_raw_breakpoint (b);
> }
> }
>
> Index: remote-sds.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/remote-sds.c,v
> retrieving revision 1.42
> diff -u -p -r1.42 remote-sds.c
> --- remote-sds.c 24 Jan 2006 22:09:28 -0000 1.42
> +++ remote-sds.c 17 Apr 2006 19:03:26 -0000
> @@ -99,10 +99,6 @@ static void interrupt_query (void);
>
> static int read_frame (char *);
>
> -static int sds_insert_breakpoint (CORE_ADDR, char *);
> -
> -static int sds_remove_breakpoint (CORE_ADDR, char *);
> -
> static void init_sds_ops (void);
>
> static void sds_command (char *args, int from_tty);
> @@ -1004,8 +1000,9 @@ sds_load (char *filename, int from_tty)
> replaced instruction back to the debugger. */
>
> static int
> -sds_insert_breakpoint (CORE_ADDR addr, char *contents_cache)
> +sds_insert_breakpoint (struct bp_target_info *bp_tgt)
> {
> + CORE_ADDR addr = bp_tgt->placed_address;
> int i, retlen;
> unsigned char *p, buf[PBUFSIZ];
>
> @@ -1020,14 +1017,15 @@ sds_insert_breakpoint (CORE_ADDR addr, c
> retlen = sds_send (buf, p - buf);
>
> for (i = 0; i < 4; ++i)
> - contents_cache[i] = buf[i + 2];
> + bp_tgt->shadow_contents[i] = buf[i + 2];
>
> return 0;
> }
>
> static int
> -sds_remove_breakpoint (CORE_ADDR addr, char *contents_cache)
> +sds_remove_breakpoint (struct bp_target_info *bp_tgt)
> {
> + CORE_ADDR addr = bp_tgt->placed_address;
> int i, retlen;
> unsigned char *p, buf[PBUFSIZ];
>
> @@ -1039,7 +1037,7 @@ sds_remove_breakpoint (CORE_ADDR addr, c
> *p++ = (int) (addr >> 8) & 0xff;
> *p++ = (int) (addr) & 0xff;
> for (i = 0; i < 4; ++i)
> - *p++ = contents_cache[i];
> + *p++ = bp_tgt->shadow_contents[i];
>
> retlen = sds_send (buf, p - buf);
>
> Index: remote-sim.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/remote-sim.c,v
> retrieving revision 1.53
> diff -u -p -r1.53 remote-sim.c
> --- remote-sim.c 21 Feb 2006 18:22:26 -0000 1.53
> +++ remote-sim.c 17 Apr 2006 19:03:26 -0000
> @@ -805,18 +805,6 @@ gdbsim_mourn_inferior (void)
> generic_mourn_inferior ();
> }
>
> -static int
> -gdbsim_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
> -{
> - return memory_insert_breakpoint (addr, contents_cache);
> -}
> -
> -static int
> -gdbsim_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
> -{
> - return memory_remove_breakpoint (addr, contents_cache);
> -}
> -
> /* Pass the command argument through to the simulator verbatim. The
> simulator must do any command interpretation work. */
>
> @@ -866,8 +854,8 @@ init_gdbsim_ops (void)
> gdbsim_ops.to_prepare_to_store = gdbsim_prepare_to_store;
> gdbsim_ops.deprecated_xfer_memory = gdbsim_xfer_inferior_memory;
> gdbsim_ops.to_files_info = gdbsim_files_info;
> - gdbsim_ops.to_insert_breakpoint = gdbsim_insert_breakpoint;
> - gdbsim_ops.to_remove_breakpoint = gdbsim_remove_breakpoint;
> + gdbsim_ops.to_insert_breakpoint = memory_insert_breakpoint;
> + gdbsim_ops.to_remove_breakpoint = memory_remove_breakpoint;
> gdbsim_ops.to_kill = gdbsim_kill;
> gdbsim_ops.to_load = gdbsim_load;
> gdbsim_ops.to_create_inferior = gdbsim_create_inferior;
> Index: remote-st.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/remote-st.c,v
> retrieving revision 1.30
> diff -u -p -r1.30 remote-st.c
> --- remote-st.c 10 Feb 2006 22:01:43 -0000 1.30
> +++ remote-st.c 17 Apr 2006 19:03:26 -0000
> @@ -599,20 +599,16 @@ static CORE_ADDR breakaddr[MAX_STDEBUG_B
> {0};
>
> static int
> -st2000_insert_breakpoint (CORE_ADDR addr, char *shadow)
> +st2000_insert_breakpoint (struct bp_target_info *bp_tgt)
> {
> + CORE_ADDR addr = bp_tgt->placed_address;
> int i;
> - CORE_ADDR bp_addr = addr;
> - int bp_size = 0;
> -
> - BREAKPOINT_FROM_PC (&bp_addr, &bp_size);
>
> for (i = 0; i <= MAX_STDEBUG_BREAKPOINTS; i++)
> if (breakaddr[i] == 0)
> {
> breakaddr[i] = addr;
>
> - st2000_read_inferior_memory (bp_addr, shadow, bp_size);
> printf_stdebug ("BR %x H\r", addr);
> expect_prompt (1);
> return 0;
> @@ -623,8 +619,9 @@ st2000_insert_breakpoint (CORE_ADDR addr
> }
>
> static int
> -st2000_remove_breakpoint (CORE_ADDR addr, char *shadow)
> +st2000_remove_breakpoint (struct bp_target_info *bp_tgt)
> {
> + CORE_ADDR addr = bp_tgt->placed_address;
> int i;
>
> for (i = 0; i < MAX_STDEBUG_BREAKPOINTS; i++)
> Index: remote.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/remote.c,v
> retrieving revision 1.207
> diff -u -p -r1.207 remote.c
> --- remote.c 12 Apr 2006 14:27:40 -0000 1.207
> +++ remote.c 17 Apr 2006 19:03:27 -0000
> @@ -136,10 +136,6 @@ static void skip_frame (void);
>
> static long read_frame (char **buf_p, long *sizeof_buf);
>
> -static int remote_insert_breakpoint (CORE_ADDR, bfd_byte *);
> -
> -static int remote_remove_breakpoint (CORE_ADDR, bfd_byte *);
> -
> static int hexnumlen (ULONGEST num);
>
> static void init_remote_ops (void);
> @@ -4356,22 +4352,18 @@ static unsigned char little_break_insn[]
>
> #endif /* DEPRECATED_REMOTE_BREAKPOINT */
>
> -/* Insert a breakpoint on targets that don't have any better
> - breakpoint support. We read the contents of the target location
> - and stash it, then overwrite it with a breakpoint instruction.
> - ADDR is the target location in the target machine. CONTENTS_CACHE
> - is a pointer to memory allocated for saving the target contents.
> - It is guaranteed by the caller to be long enough to save the number
> - of bytes returned by BREAKPOINT_FROM_PC. */
> +/* Insert a breakpoint. On targets that have software breakpoint
> + support, we ask the remote target to do the work; on targets
> + which don't, we insert a traditional memory breakpoint. */
>
> static int
> -remote_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
> +remote_insert_breakpoint (struct bp_target_info *bp_tgt)
> {
> + CORE_ADDR addr = bp_tgt->placed_address;
> struct remote_state *rs = get_remote_state ();
> #ifdef DEPRECATED_REMOTE_BREAKPOINT
> int val;
> #endif
> - int bp_size;
>
> /* Try the "Z" s/w breakpoint packet if it is not already disabled.
> If it succeeds, then set the support to PACKET_ENABLE. If it
> @@ -4382,13 +4374,13 @@ remote_insert_breakpoint (CORE_ADDR addr
> {
> char *p = rs->buf;
>
> - addr = remote_address_masked (addr);
> *(p++) = 'Z';
> *(p++) = '0';
> *(p++) = ',';
> - p += hexnumstr (p, (ULONGEST) addr);
> - BREAKPOINT_FROM_PC (&addr, &bp_size);
> - sprintf (p, ",%d", bp_size);
> + BREAKPOINT_FROM_PC (&bp_tgt->placed_address, &bp_tgt->placed_size);
> + addr = (ULONGEST) remote_address_masked (bp_tgt->placed_address);
> + p += hexnumstr (p, addr);
> + sprintf (p, ",%d", bp_tgt->placed_size);
>
> putpkt (rs->buf);
> getpkt (&rs->buf, &rs->buf_size, 0);
> @@ -4405,7 +4397,8 @@ remote_insert_breakpoint (CORE_ADDR addr
> }
>
> #ifdef DEPRECATED_REMOTE_BREAKPOINT
> - val = target_read_memory (addr, contents_cache, sizeof big_break_insn);
> + bp_tgt->placed_size = bp_tgt->shadow_len = sizeof big_break_insn;
> + val = target_read_memory (addr, bp_tgt->shadow_contents, bp_tgt->shadow_len);
>
> if (val == 0)
> {
> @@ -4419,13 +4412,14 @@ remote_insert_breakpoint (CORE_ADDR addr
>
> return val;
> #else
> - return memory_insert_breakpoint (addr, contents_cache);
> + return memory_insert_breakpoint (bp_tgt);
> #endif /* DEPRECATED_REMOTE_BREAKPOINT */
> }
>
> static int
> -remote_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
> +remote_remove_breakpoint (struct bp_target_info *bp_tgt)
> {
> + CORE_ADDR addr = bp_tgt->placed_address;
> struct remote_state *rs = get_remote_state ();
> int bp_size;
>
> @@ -4437,10 +4431,9 @@ remote_remove_breakpoint (CORE_ADDR addr
> *(p++) = '0';
> *(p++) = ',';
>
> - addr = remote_address_masked (addr);
> - p += hexnumstr (p, (ULONGEST) addr);
> - BREAKPOINT_FROM_PC (&addr, &bp_size);
> - sprintf (p, ",%d", bp_size);
> + addr = (ULONGEST) remote_address_masked (bp_tgt->placed_address);
> + p += hexnumstr (p, addr);
> + sprintf (p, ",%d", bp_tgt->placed_size);
>
> putpkt (rs->buf);
> getpkt (&rs->buf, &rs->buf_size, 0);
> @@ -4449,9 +4442,10 @@ remote_remove_breakpoint (CORE_ADDR addr
> }
>
> #ifdef DEPRECATED_REMOTE_BREAKPOINT
> - return target_write_memory (addr, contents_cache, sizeof big_break_insn);
> + return target_write_memory (bp_tgt->placed_address, bp_tgt->shadow_contents,
> + bp_tgt->shadow_len);
> #else
> - return memory_remove_breakpoint (addr, contents_cache);
> + return memory_remove_breakpoint (bp_tgt);
> #endif /* DEPRECATED_REMOTE_BREAKPOINT */
> }
>
> @@ -4595,16 +4589,16 @@ remote_stopped_data_address (struct targ
>
>
> static int
> -remote_insert_hw_breakpoint (CORE_ADDR addr, gdb_byte *shadow)
> +remote_insert_hw_breakpoint (struct bp_target_info *bp_tgt)
> {
> - int len = 0;
> + CORE_ADDR addr;
> struct remote_state *rs = get_remote_state ();
> char *p = rs->buf;
>
> /* The length field should be set to the size of a breakpoint
> - instruction. */
> + instruction, even though we aren't inserting one ourselves. */
>
> - BREAKPOINT_FROM_PC (&addr, &len);
> + BREAKPOINT_FROM_PC (&bp_tgt->placed_address, &bp_tgt->placed_size);
>
> if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE)
> error (_("Can't set hardware breakpoint without the '%s' (%s) packet."),
> @@ -4615,9 +4609,9 @@ remote_insert_hw_breakpoint (CORE_ADDR a
> *(p++) = '1';
> *(p++) = ',';
>
> - addr = remote_address_masked (addr);
> + addr = remote_address_masked (bp_tgt->placed_address);
> p += hexnumstr (p, (ULONGEST) addr);
> - sprintf (p, ",%x", len);
> + sprintf (p, ",%x", bp_tgt->placed_size);
>
> putpkt (rs->buf);
> getpkt (&rs->buf, &rs->buf_size, 0);
> @@ -4636,17 +4630,12 @@ remote_insert_hw_breakpoint (CORE_ADDR a
>
>
> static int
> -remote_remove_hw_breakpoint (CORE_ADDR addr, gdb_byte *shadow)
> +remote_remove_hw_breakpoint (struct bp_target_info *bp_tgt)
> {
> - int len;
> + CORE_ADDR addr;
> struct remote_state *rs = get_remote_state ();
> char *p = rs->buf;
>
> - /* The length field should be set to the size of a breakpoint
> - instruction. */
> -
> - BREAKPOINT_FROM_PC (&addr, &len);
> -
> if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE)
> error (_("Can't clear hardware breakpoint without the '%s' (%s) packet."),
> remote_protocol_packets[PACKET_Z1].name,
> @@ -4656,9 +4645,9 @@ remote_remove_hw_breakpoint (CORE_ADDR a
> *(p++) = '1';
> *(p++) = ',';
>
> - addr = remote_address_masked (addr);
> + addr = remote_address_masked (bp_tgt->placed_address);
> p += hexnumstr (p, (ULONGEST) addr);
> - sprintf (p, ",%x", len);
> + sprintf (p, ",%x", bp_tgt->placed_size);
>
> putpkt (rs->buf);
> getpkt (&rs->buf, &rs->buf_size, 0);
> Index: rs6000-nat.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/rs6000-nat.c,v
> retrieving revision 1.60
> diff -u -p -r1.60 rs6000-nat.c
> --- rs6000-nat.c 17 Dec 2005 22:34:02 -0000 1.60
> +++ rs6000-nat.c 17 Apr 2006 19:03:27 -0000
> @@ -527,15 +527,15 @@ exec_one_dummy_insn (void)
> {
> #define DUMMY_INSN_ADDR (TEXT_SEGMENT_BASE)+0x200
>
> - char shadow_contents[BREAKPOINT_MAX]; /* Stash old bkpt addr contents */
> int ret, status, pid;
> CORE_ADDR prev_pc;
> + void *bp;
>
> /* We plant one dummy breakpoint into DUMMY_INSN_ADDR address. We
> assume that this address will never be executed again by the real
> code. */
>
> - target_insert_breakpoint (DUMMY_INSN_ADDR, shadow_contents);
> + bp = deprecated_insert_raw_breakpoint (DUMMY_INSN_ADDR);
>
> /* You might think this could be done with a single ptrace call, and
> you'd be correct for just about every platform I've ever worked
> @@ -559,7 +559,7 @@ exec_one_dummy_insn (void)
> while (pid != PIDGET (inferior_ptid));
>
> write_pc (prev_pc);
> - target_remove_breakpoint (DUMMY_INSN_ADDR, shadow_contents);
> + deprecated_remove_raw_breakpoint (bp);
> }
>
> /* Fetch registers from the register section in core bfd. */
> Index: rs6000-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
> retrieving revision 1.256
> diff -u -p -r1.256 rs6000-tdep.c
> --- rs6000-tdep.c 10 Feb 2006 20:56:14 -0000 1.256
> +++ rs6000-tdep.c 17 Apr 2006 19:03:27 -0000
> @@ -110,17 +110,6 @@ struct reg
> register number. */
> };
>
> -/* Breakpoint shadows for the single step instructions will be kept here. */
> -
> -static struct sstep_breaks
> -{
> - /* Address, or 0 if this is not in use. */
> - CORE_ADDR address;
> - /* Shadow contents. */
> - gdb_byte data[4];
> -}
> -stepBreaks[2];
> -
> /* Hook for determining the TOC address when calling functions in the
> inferior under AIX. The initialization code in rs6000-nat.c sets
> this hook to point to find_toc_address. */
> @@ -730,7 +719,6 @@ rs6000_software_single_step (enum target
>
> if (insert_breakpoints_p)
> {
> -
> loc = read_pc ();
>
> insn = read_memory_integer (loc, 4);
> @@ -743,28 +731,17 @@ rs6000_software_single_step (enum target
> if (breaks[1] == breaks[0])
> breaks[1] = -1;
>
> - stepBreaks[1].address = 0;
> -
> for (ii = 0; ii < 2; ++ii)
> {
> -
> /* ignore invalid breakpoint. */
> if (breaks[ii] == -1)
> continue;
> - target_insert_breakpoint (breaks[ii], stepBreaks[ii].data);
> - stepBreaks[ii].address = breaks[ii];
> + insert_single_step_breakpoint (breaks[ii]);
> }
> -
> }
> else
> - {
> + remove_single_step_breakpoints ();
>
> - /* remove step breakpoints. */
> - for (ii = 0; ii < 2; ++ii)
> - if (stepBreaks[ii].address != 0)
> - target_remove_breakpoint (stepBreaks[ii].address,
> - stepBreaks[ii].data);
> - }
> errno = 0; /* FIXME, don't ignore errors! */
> /* What errors? {read,write}_memory call error(). */
> }
> Index: sol-thread.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/sol-thread.c,v
> retrieving revision 1.51
> diff -u -p -r1.51 sol-thread.c
> --- sol-thread.c 17 Dec 2005 22:34:02 -0000 1.51
> +++ sol-thread.c 17 Apr 2006 19:03:27 -0000
> @@ -1524,7 +1524,7 @@ sol_make_note_section (bfd *obfd, int *n
> }
>
> static int
> -ignore (CORE_ADDR addr, gdb_byte *contents)
> +ignore (struct bp_target_info *bp_tgt)
> {
> return 0;
> }
> Index: solib-irix.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/solib-irix.c,v
> retrieving revision 1.9
> diff -u -p -r1.9 solib-irix.c
> --- solib-irix.c 17 Dec 2005 22:34:02 -0000 1.9
> +++ solib-irix.c 17 Apr 2006 19:03:28 -0000
> @@ -227,10 +227,9 @@ fetch_lm_info (CORE_ADDR addr)
> /* The symbol which starts off the list of shared libraries. */
> #define DEBUG_BASE "__rld_obj_head"
>
> -char shadow_contents[BREAKPOINT_MAX]; /* Stash old bkpt addr contents */
> +static void *base_breakpoint;
>
> static CORE_ADDR debug_base; /* Base of dynamic linker structures */
> -static CORE_ADDR breakpoint_addr; /* Address where end bkpt is set */
>
> /*
>
> @@ -319,11 +318,13 @@ disable_break (void)
> /* Note that breakpoint address and original contents are in our address
> space, so we just need to write the original contents back. */
>
> - if (memory_remove_breakpoint (breakpoint_addr, shadow_contents) != 0)
> + if (deprecated_remove_raw_breakpoint (base_breakpoint) != 0)
> {
> status = 0;
> }
>
> + base_breakpoint = NULL;
> +
> /* Note that it is possible that we have stopped at a location that
> is different from the location where we inserted our breakpoint.
> On mips-irix, we can actually land in __dbx_init(), so we should
> @@ -352,12 +353,13 @@ disable_break (void)
> static int
> enable_break (void)
> {
> - if (symfile_objfile != NULL
> - && target_insert_breakpoint (entry_point_address (),
> - shadow_contents) == 0)
> + if (symfile_objfile != NULL)
> {
> - breakpoint_addr = entry_point_address ();
> - return 1;
> + base_breakpoint
> + = deprecated_insert_raw_breakpoint (entry_point_address ());
> +
> + if (base_breakpoint != NULL)
> + return 1;
> }
>
> return 0;
> Index: sparc-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/sparc-tdep.c,v
> retrieving revision 1.171
> diff -u -p -r1.171 sparc-tdep.c
> --- sparc-tdep.c 9 Apr 2006 08:22:43 -0000 1.171
> +++ sparc-tdep.c 17 Apr 2006 19:03:28 -0000
> @@ -1136,8 +1136,7 @@ sparc_software_single_step (enum target_
> {
> struct gdbarch *arch = current_gdbarch;
> struct gdbarch_tdep *tdep = gdbarch_tdep (arch);
> - static CORE_ADDR npc, nnpc;
> - static gdb_byte npc_save[4], nnpc_save[4];
> + CORE_ADDR npc, nnpc;
>
> if (insert_breakpoints_p)
> {
> @@ -1149,9 +1148,10 @@ sparc_software_single_step (enum target_
> /* Analyze the instruction at PC. */
> nnpc = sparc_analyze_control_transfer (arch, pc, &npc);
> if (npc != 0)
> - target_insert_breakpoint (npc, npc_save);
> + insert_single_step_breakpoint (npc);
> +
> if (nnpc != 0)
> - target_insert_breakpoint (nnpc, nnpc_save);
> + insert_single_step_breakpoint (nnpc);
>
> /* Assert that we have set at least one breakpoint, and that
> they're not set at the same spot - unless we're going
> @@ -1160,12 +1160,7 @@ sparc_software_single_step (enum target_
> gdb_assert (nnpc != npc || orig_npc == 0);
> }
> else
> - {
> - if (npc != 0)
> - target_remove_breakpoint (npc, npc_save);
> - if (nnpc != 0)
> - target_remove_breakpoint (nnpc, nnpc_save);
> - }
> + remove_single_step_breakpoints ();
> }
>
> static void
> Index: target.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/target.c,v
> retrieving revision 1.117
> diff -u -p -r1.117 target.c
> --- target.c 17 Mar 2006 00:30:34 -0000 1.117
> +++ target.c 17 Apr 2006 19:03:28 -0000
> @@ -111,15 +111,15 @@ static void debug_to_prepare_to_store (v
>
> static void debug_to_files_info (struct target_ops *);
>
> -static int debug_to_insert_breakpoint (CORE_ADDR, gdb_byte *);
> +static int debug_to_insert_breakpoint (struct bp_target_info *);
>
> -static int debug_to_remove_breakpoint (CORE_ADDR, gdb_byte *);
> +static int debug_to_remove_breakpoint (struct bp_target_info *);
>
> static int debug_to_can_use_hw_breakpoint (int, int, int);
>
> -static int debug_to_insert_hw_breakpoint (CORE_ADDR, gdb_byte *);
> +static int debug_to_insert_hw_breakpoint (struct bp_target_info *);
>
> -static int debug_to_remove_hw_breakpoint (CORE_ADDR, gdb_byte *);
> +static int debug_to_remove_hw_breakpoint (struct bp_target_info *);
>
> static int debug_to_insert_watchpoint (CORE_ADDR, int, int);
>
> @@ -515,10 +515,10 @@ update_current_target (void)
> (int (*) (int, int, int))
> return_zero);
> de_fault (to_insert_hw_breakpoint,
> - (int (*) (CORE_ADDR, gdb_byte *))
> + (int (*) (struct bp_target_info *))
> return_minus_one);
> de_fault (to_remove_hw_breakpoint,
> - (int (*) (CORE_ADDR, gdb_byte *))
> + (int (*) (struct bp_target_info *))
> return_minus_one);
> de_fault (to_insert_watchpoint,
> (int (*) (CORE_ADDR, int, int))
> @@ -2075,29 +2075,29 @@ debug_to_files_info (struct target_ops *
> }
>
> static int
> -debug_to_insert_breakpoint (CORE_ADDR addr, gdb_byte *save)
> +debug_to_insert_breakpoint (struct bp_target_info *bp_tgt)
> {
> int retval;
>
> - retval = debug_target.to_insert_breakpoint (addr, save);
> + retval = debug_target.to_insert_breakpoint (bp_tgt);
>
> fprintf_unfiltered (gdb_stdlog,
> "target_insert_breakpoint (0x%lx, xxx) = %ld\n",
> - (unsigned long) addr,
> + (unsigned long) bp_tgt->placed_address,
> (unsigned long) retval);
> return retval;
> }
>
> static int
> -debug_to_remove_breakpoint (CORE_ADDR addr, gdb_byte *save)
> +debug_to_remove_breakpoint (struct bp_target_info *bp_tgt)
> {
> int retval;
>
> - retval = debug_target.to_remove_breakpoint (addr, save);
> + retval = debug_target.to_remove_breakpoint (bp_tgt);
>
> fprintf_unfiltered (gdb_stdlog,
> "target_remove_breakpoint (0x%lx, xxx) = %ld\n",
> - (unsigned long) addr,
> + (unsigned long) bp_tgt->placed_address,
> (unsigned long) retval);
> return retval;
> }
> @@ -2161,29 +2161,29 @@ debug_to_stopped_data_address (struct ta
> }
>
> static int
> -debug_to_insert_hw_breakpoint (CORE_ADDR addr, gdb_byte *save)
> +debug_to_insert_hw_breakpoint (struct bp_target_info *bp_tgt)
> {
> int retval;
>
> - retval = debug_target.to_insert_hw_breakpoint (addr, save);
> + retval = debug_target.to_insert_hw_breakpoint (bp_tgt);
>
> fprintf_unfiltered (gdb_stdlog,
> "target_insert_hw_breakpoint (0x%lx, xxx) = %ld\n",
> - (unsigned long) addr,
> + (unsigned long) bp_tgt->placed_address,
> (unsigned long) retval);
> return retval;
> }
>
> static int
> -debug_to_remove_hw_breakpoint (CORE_ADDR addr, gdb_byte *save)
> +debug_to_remove_hw_breakpoint (struct bp_target_info *bp_tgt)
> {
> int retval;
>
> - retval = debug_target.to_remove_hw_breakpoint (addr, save);
> + retval = debug_target.to_remove_hw_breakpoint (bp_tgt);
>
> fprintf_unfiltered (gdb_stdlog,
> "target_remove_hw_breakpoint (0x%lx, xxx) = %ld\n",
> - (unsigned long) addr,
> + (unsigned long) bp_tgt->placed_address,
> (unsigned long) retval);
> return retval;
> }
> Index: target.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/target.h,v
> retrieving revision 1.81
> diff -u -p -r1.81 target.h
> --- target.h 21 Feb 2006 18:22:26 -0000 1.81
> +++ target.h 17 Apr 2006 19:03:28 -0000
> @@ -30,6 +30,7 @@ struct objfile;
> struct ui_file;
> struct mem_attrib;
> struct target_ops;
> +struct bp_target_info;
>
> /* This include file defines the interface between the main part
> of the debugger, and the part which is target-specific, or
> @@ -336,11 +337,11 @@ struct target_ops
> struct target_ops *target);
>
> void (*to_files_info) (struct target_ops *);
> - int (*to_insert_breakpoint) (CORE_ADDR, gdb_byte *);
> - int (*to_remove_breakpoint) (CORE_ADDR, gdb_byte *);
> + int (*to_insert_breakpoint) (struct bp_target_info *);
> + int (*to_remove_breakpoint) (struct bp_target_info *);
> int (*to_can_use_hw_breakpoint) (int, int, int);
> - int (*to_insert_hw_breakpoint) (CORE_ADDR, gdb_byte *);
> - int (*to_remove_hw_breakpoint) (CORE_ADDR, gdb_byte *);
> + int (*to_insert_hw_breakpoint) (struct bp_target_info *);
> + int (*to_remove_hw_breakpoint) (struct bp_target_info *);
> int (*to_remove_watchpoint) (CORE_ADDR, int, int);
> int (*to_insert_watchpoint) (CORE_ADDR, int, int);
> int (*to_stopped_by_watchpoint) (void);
> @@ -612,22 +613,17 @@ extern void print_section_info (struct t
> #define target_files_info() \
> (*current_target.to_files_info) (¤t_target)
>
> -/* Insert a breakpoint at address ADDR in the target machine. SAVE is
> - a pointer to memory allocated for saving the target contents. It
> - is guaranteed by the caller to be long enough to save the number of
> - breakpoint bytes indicated by BREAKPOINT_FROM_PC. Result is 0 for
> - success, or an errno value. */
> -
> -#define target_insert_breakpoint(addr, save) \
> - (*current_target.to_insert_breakpoint) (addr, save)
> -
> -/* Remove a breakpoint at address ADDR in the target machine.
> - SAVE is a pointer to the same save area
> - that was previously passed to target_insert_breakpoint.
> - Result is 0 for success, or an errno value. */
> +/* Insert a breakpoint at address BP_TGT->placed_address in the target
> + machine. Result is 0 for success, or an errno value. */
>
> -#define target_remove_breakpoint(addr, save) \
> - (*current_target.to_remove_breakpoint) (addr, save)
> +#define target_insert_breakpoint(bp_tgt) \
> + (*current_target.to_insert_breakpoint) (bp_tgt)
> +
> +/* Remove a breakpoint at address BP_TGT->placed_address in the target
> + machine. Result is 0 for success, or an errno value. */
> +
> +#define target_remove_breakpoint(bp_tgt) \
> + (*current_target.to_remove_breakpoint) (bp_tgt)
>
> /* Initialize the terminal settings we record for the inferior,
> before we actually run the inferior. */
> @@ -1057,11 +1053,11 @@ extern void (*deprecated_target_new_objf
> #endif
>
> #ifndef target_insert_hw_breakpoint
> -#define target_insert_hw_breakpoint(addr, save) \
> - (*current_target.to_insert_hw_breakpoint) (addr, save)
> +#define target_insert_hw_breakpoint(bp_tgt) \
> + (*current_target.to_insert_hw_breakpoint) (bp_tgt)
>
> -#define target_remove_hw_breakpoint(addr, save) \
> - (*current_target.to_remove_hw_breakpoint) (addr, save)
> +#define target_remove_hw_breakpoint(bp_tgt) \
> + (*current_target.to_remove_hw_breakpoint) (bp_tgt)
> #endif
>
> extern int target_stopped_data_address_p (struct target_ops *);
> @@ -1142,13 +1138,13 @@ struct section_table *target_section_by_
>
> /* From mem-break.c */
>
> -extern int memory_remove_breakpoint (CORE_ADDR, gdb_byte *);
> +extern int memory_remove_breakpoint (struct bp_target_info *);
>
> -extern int memory_insert_breakpoint (CORE_ADDR, gdb_byte *);
> +extern int memory_insert_breakpoint (struct bp_target_info *);
>
> -extern int default_memory_remove_breakpoint (CORE_ADDR, gdb_byte *);
> +extern int default_memory_remove_breakpoint (struct bp_target_info *);
>
> -extern int default_memory_insert_breakpoint (CORE_ADDR, gdb_byte *);
> +extern int default_memory_insert_breakpoint (struct bp_target_info *);
>
>
> /* From target.c */
> Index: wince.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/wince.c,v
> retrieving revision 1.44
> diff -u -p -r1.44 wince.c
> --- wince.c 24 Jan 2006 22:09:28 -0000 1.44
> +++ wince.c 17 Apr 2006 19:03:28 -0000
> @@ -146,7 +146,6 @@ typedef struct thread_info_struct
> int suspend_count;
> int stepped; /* True if stepped. */
> CORE_ADDR step_pc;
> - unsigned long step_prev;
> CONTEXT context;
> }
> thread_info;
> @@ -834,7 +833,7 @@ undoSStep (thread_info * th)
> {
> if (th->stepped)
> {
> - memory_remove_breakpoint (th->step_pc, (void *) &th->step_prev);
> + remove_single_step_breakpoints ();
> th->stepped = 0;
> }
> }
> @@ -857,8 +856,7 @@ wince_software_single_step (enum target_
> th->stepped = 1;
> pc = read_register (PC_REGNUM);
> th->step_pc = mips_next_pc (pc);
> - th->step_prev = 0;
> - memory_insert_breakpoint (th->step_pc, (void *) &th->step_prev);
> + insert_single_step_breakpoint (th->step_pc);
> return;
> }
> #elif SHx
> @@ -971,7 +969,7 @@ undoSStep (thread_info * th)
> {
> if (th->stepped)
> {
> - memory_remove_breakpoint (th->step_pc, (void *) &th->step_prev);
> + remove_single_step_breakpoints ();
> th->stepped = 0;
> }
> return;
> @@ -996,8 +994,7 @@ wince_software_single_step (enum target_
>
> th->stepped = 1;
> th->step_pc = sh_get_next_pc (&th->context);
> - th->step_prev = 0;
> - memory_insert_breakpoint (th->step_pc, (void *) &th->step_prev);
> + insert_single_step_breakpoint (th->step_pc);
> return;
> }
> #elif defined (ARM)
> @@ -1024,7 +1021,7 @@ undoSStep (thread_info * th)
> {
> if (th->stepped)
> {
> - memory_remove_breakpoint (th->step_pc, (void *) &th->step_prev);
> + remove_single_step_breakpoints ();
> th->stepped = 0;
> }
> }
> @@ -1047,8 +1044,7 @@ wince_software_single_step (enum target_
> th->stepped = 1;
> pc = read_register (PC_REGNUM);
> th->step_pc = arm_get_next_pc (pc);
> - th->step_prev = 0;
> - memory_insert_breakpoint (th->step_pc, (void *) &th->step_prev);
> + insert_single_step_breakpoint (th->step_pc);
> return;
> }
> #endif
> Index: config/i386/nm-i386.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/config/i386/nm-i386.h,v
> retrieving revision 1.7
> diff -u -p -r1.7 nm-i386.h
> --- config/i386/nm-i386.h 8 Oct 2004 17:30:48 -0000 1.7
> +++ config/i386/nm-i386.h 17 Apr 2006 19:03:28 -0000
> @@ -52,13 +52,14 @@ extern int i386_stopped_by_hwbp (void);
> true. Otherwise, return false. */
> extern int i386_stopped_data_address (CORE_ADDR *);
>
> -/* Insert a hardware-assisted breakpoint at address ADDR. SHADOW is
> - unused. Return 0 on success, EBUSY on failure. */
> -extern int i386_insert_hw_breakpoint (CORE_ADDR addr, void *shadow);
> -
> -/* Remove a hardware-assisted breakpoint at address ADDR. SHADOW is
> - unused. Return 0 on success, -1 on failure. */
> -extern int i386_remove_hw_breakpoint (CORE_ADDR addr, void *shadow);
> +/* Insert a hardware-assisted breakpoint at BP_TGT->placed_address.
> + Return 0 on success, EBUSY on failure. */
> +struct bp_target_info;
> +extern int i386_insert_hw_breakpoint (struct bp_target_info *bp_tgt);
> +
> +/* Remove a hardware-assisted breakpoint at BP_TGT->placed_address.
> + Return 0 on success, -1 on failure. */
> +extern int i386_remove_hw_breakpoint (struct bp_target_info *bp_tgt);
>
> /* Returns the number of hardware watchpoints of type TYPE that we can
> set. Value is positive if we can set CNT watchpoints, zero if
> @@ -105,11 +106,11 @@ extern int i386_stopped_by_watchpoint (v
> #define target_remove_watchpoint(addr, len, type) \
> i386_remove_watchpoint (addr, len, type)
>
> -#define target_insert_hw_breakpoint(addr, shadow) \
> - i386_insert_hw_breakpoint (addr, shadow)
> +#define target_insert_hw_breakpoint(bp_tgt) \
> + i386_insert_hw_breakpoint (bp_tgt)
>
> -#define target_remove_hw_breakpoint(addr, shadow) \
> - i386_remove_hw_breakpoint (addr, shadow)
> +#define target_remove_hw_breakpoint(bp_tgt) \
> + i386_remove_hw_breakpoint (bp_tgt)
>
> /* child_post_startup_inferior used to
> reset all debug registers by calling i386_cleanup_dregs (). */
> Index: doc/gdbint.texinfo
> ===================================================================
> RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v
> retrieving revision 1.240
> diff -u -p -r1.240 gdbint.texinfo
> --- doc/gdbint.texinfo 28 Mar 2006 19:19:16 -0000 1.240
> +++ doc/gdbint.texinfo 17 Apr 2006 19:03:30 -0000
> @@ -527,6 +527,44 @@ The basic definition of the software bre
> Basic breakpoint object handling is in @file{breakpoint.c}. However,
> much of the interesting breakpoint action is in @file{infrun.c}.
>
> +@table @code
> +@cindex insert or remove software breakpoint
> +@findex target_remove_breakpoint
> +@findex target_insert_breakpoint
> +@item target_remove_breakpoint (@var{bp_tgt})
> +@itemx target_insert_breakpoint (@var{bp_tgt})
> +Insert or remove a software breakpoint at address
> +@code{@var{bp_tgt}->placed_address}. Returns zero for success,
> +non-zero for failure. On input, @var{bp_tgt} contains the address of the
> +breakpoint, and is otherwise initialized to zero. @var{bp_tgt} is updated
> +to contain other information about the breakpoint on output:
> +@code{placed_address} may be updated if the breakpoint was placed at a
> +related address; @code{shadow_contents} is the real contents of the bytes
> +where the breakpoint has been inserted, if reading memory would return
> +the breakpoint instead of the underlying memory; @code{shadow_len} is the
> +length of memory cached in @code{shadow_contents}, if any; and
> +@code{placed_size} is optionally set and used by the target, if
> +it could differ from @code{shadow_len}.
> +
> +For example, the remote target @samp{Z0} packet does not require
> +shadowing memory, so @code{shadow_len} is left at zero. However,
> +the length reported by @code{BREAKPOINT_FROM_PC} is cached in
> +@code{placed_size}, so that a matching @samp{z0} packet can be
> +used to remove the breakpoint.
> +
> +@cindex insert or remove hardware breakpoint
> +@findex target_remove_hw_breakpoint
> +@findex target_insert_hw_breakpoint
> +@item target_remove_hw_breakpoint (@var{bp_tgt})
> +@itemx target_insert_hw_breakpoint (@var{bp_tgt})
> +Insert or remove a hardware-assisted breakpoint at address
> +@code{@var{bp_tgt}->placed_address}. Returns zero for success,
> +non-zero for failure. See @code{target_insert_breakpoint} for
> +a description of @var{bp_tgt}; the @code{shadow_contents} and
> +@code{shadow_len} members are not used for hardware breakpoints,
> +but @code{placed_size} may be.
> +@end table
> +
> @section Single Stepping
>
> @section Signal Handling
> @@ -657,18 +695,6 @@ defined by @file{breakpoint.h} as follow
> @noindent
> These two macros should return 0 for success, non-zero for failure.
>
> -@cindex insert or remove hardware breakpoint
> -@findex target_remove_hw_breakpoint
> -@findex target_insert_hw_breakpoint
> -@item target_remove_hw_breakpoint (@var{addr}, @var{shadow})
> -@itemx target_insert_hw_breakpoint (@var{addr}, @var{shadow})
> -Insert or remove a hardware-assisted breakpoint at address @var{addr}.
> -Returns zero for success, non-zero for failure. @var{shadow} is the
> -real contents of the byte where the breakpoint has been inserted; it
> -is generally not valid when hardware breakpoints are used, but since
> -no other code touches these values, the implementations of the above
> -two macros can use them for their internal purposes.
> -
> @findex target_stopped_data_address
> @item target_stopped_data_address (@var{addr_p})
> If the inferior has some watchpoint that triggered, place the address
> @@ -858,8 +884,8 @@ the count goes to zero.
>
> @findex i386_insert_hw_breakpoint
> @findex i386_remove_hw_breakpoint
> -@item i386_insert_hw_breakpoint (@var{addr}, @var{shadow}
> -@itemx i386_remove_hw_breakpoint (@var{addr}, @var{shadow})
> +@item i386_insert_hw_breakpoint (@var{bp_tgt})
> +@itemx i386_remove_hw_breakpoint (@var{bp_tgt})
> These functions insert and remove hardware-assisted breakpoints. The
> macros @code{target_insert_hw_breakpoint} and
> @code{target_remove_hw_breakpoint} are set to call these functions.
> @@ -3229,8 +3255,8 @@ instruction of the architecture.
>
> Replaces all the other @var{BREAKPOINT} macros.
>
> -@item MEMORY_INSERT_BREAKPOINT (@var{addr}, @var{contents_cache})
> -@itemx MEMORY_REMOVE_BREAKPOINT (@var{addr}, @var{contents_cache})
> +@item MEMORY_INSERT_BREAKPOINT (@var{bp_tgt})
> +@itemx MEMORY_REMOVE_BREAKPOINT (@var{bp_tgt})
> @findex MEMORY_REMOVE_BREAKPOINT
> @findex MEMORY_INSERT_BREAKPOINT
> Insert or remove memory based breakpoints. Reasonable defaults
>
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-17 20:25 ` Mark Kettenis
@ 2006-04-17 21:50 ` Daniel Jacobowitz
0 siblings, 0 replies; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-04-17 21:50 UTC (permalink / raw)
To: Mark Kettenis; +Cc: msnyder, gdb-patches
On Mon, Apr 17, 2006 at 10:24:06PM +0200, Mark Kettenis wrote:
> Hmm, if I understand things correctly, the only reason why you need
> placed_size, is because we want shadow_len to tell is whether we've
> actually saved the contents or not. This is eh, a wee bit ugly.
Correct (on both counts).
> Actually I think the z0 packet should not include the length of the
> breakpoint. The remote stub will have to keep track of the length of
> the inserted breakpoint anyway, exactly because it has get the the
> target memory correct.
Yes... and no. Two problems with that, which I'm sure you can see. One
is that, in practice, it's there; we can't remove it (protocol
incompatibilities), and because it's there, stub developers probably
use it. They may have to stash this information somewhere else, but
not use that copy when actually removing the breakpoint. Ugh!
[Actually I bet a lot of stubs DON'T get the underlying memory correct,
which makes their dependence on this even clearer. I bet a lot of
stubs would report the breakpoint. Most of the time, we read memory
with breakpoints removed, so a lot of stub authors may just not have
noticed this issue - and there's nothing about it in the manual. It
might be more pragmatic to always issue the read, but I'm reluctant
unless we find real problems with it; why double the number of packets
needlessly?]
And secondly, software breakpoints seem to be such a simple concept...
but the variety of ways people find to implement them is astounding.
For instance, you would not need to record the length if you could
"shadow" executing ROM pages using RAM; you could perform memory reads
from the ROM page, and insert breakpoints onto the RAM page.
> I'm still thinking about a more elegant solution. One would be to
> allocate the shadow contents dynamically and make it a NULL pointer if
> GDB didn't actually save any shadow contents. Meanwhile, I spropose
> you check this in. This issue has been on the table long enough now.
Thanks for your understanding. If you find a nicer way, I'll pitch in
to help clean up the result. In the mean time, we'll go with this
version.
I'm going to wait a little longer - I'd appreciate Eli's look over the
gdbint.texi bits, and I'm out of my GDB work environment at the moment
so I can't test it.
> P.S. Someone should really get rid of tm-sh.h and
> DEPRECATED_{BIG|LITTLE}_BREAKPOINT.
That's not all that someone should get rid of...
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-17 19:08 ` Daniel Jacobowitz
2006-04-17 20:25 ` Mark Kettenis
@ 2006-04-18 8:59 ` Eli Zaretskii
2006-04-18 19:21 ` Daniel Jacobowitz
1 sibling, 1 reply; 52+ messages in thread
From: Eli Zaretskii @ 2006-04-18 8:59 UTC (permalink / raw)
To: Mark Kettenis; +Cc: msnyder, gdb-patches
> Date: Mon, 17 Apr 2006 15:08:08 -0400
> From: Daniel Jacobowitz <drow@false.org>
> Cc: msnyder@redhat.com, gdb-patches@sourceware.org
>
> On the documentation front, I am quite mortified; I wrote this
> ChangeLog entry at least twice for earlier versions of the patch:
>
> * gdbint.texinfo (Watchpoints, Target Conditionals): Update insert
> and remove breakpoint prototypes.
>
> While they often use the underlying watchpoint registers, hardware
> breakpoints are breakpoints. I've moved these to the Breakpoints
> section, and added some more bits there. Eli, could you take a look
> at that?
Done, comments below.
> @var{bp_tgt} is updated
> +to contain other information about the breakpoint on output:
> +@code{placed_address} may be updated if the breakpoint was placed at a
> +related address; @code{shadow_contents} is the real contents of the bytes
> +where the breakpoint has been inserted, if reading memory would return
> +the breakpoint instead of the underlying memory; @code{shadow_len} is the
> +length of memory cached in @code{shadow_contents}, if any; and
> +@code{placed_size} is optionally set and used by the target, if
> +it could differ from @code{shadow_len}.
This paragraph uses names of fields of the bp_target_info struct, but
it doesn't mention the name of the struct, and doesn't say that those
are its fields. I suggest to modify the first sentence above like
this:
Fields of @code{struct bp_target_info} pointed to by @var{bp_tgt}
are updated to contain other information about the breakpoint on
output: @code{@var{bp_tgt}->placed_address} may be updated if the
breakpoint was placed ...
etc., you get the idea. Alternatively, something like "the field
@code{placed_address} may be updated ..." is also okay.
> +@item i386_insert_hw_breakpoint (@var{bp_tgt})
> +@itemx i386_remove_hw_breakpoint (@var{bp_tgt})
This should mention the type of the struct:
@item i386_insert_hw_breakpoint (struct bp_target_info *@var{bp_tgt})
Alternatively, mention the name of the struct in the text.
> +@item MEMORY_INSERT_BREAKPOINT (@var{bp_tgt})
> +@itemx MEMORY_REMOVE_BREAKPOINT (@var{bp_tgt})
Same here.
Otherwise, the patch is okay with me (including moving the description
of target_insert_hw_breakpoint and target_remove_hw_breakpoint.
Thanks!
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-18 8:59 ` Eli Zaretskii
@ 2006-04-18 19:21 ` Daniel Jacobowitz
2006-04-19 7:40 ` Eli Zaretskii
0 siblings, 1 reply; 52+ messages in thread
From: Daniel Jacobowitz @ 2006-04-18 19:21 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Mark Kettenis, msnyder, gdb-patches
On Tue, Apr 18, 2006 at 11:59:06AM +0300, Eli Zaretskii wrote:
> Done, comments below.
Thanks a lot. I've committed it with some changes along these lines;
I've attached the revised documentation patch (the code is unchanged).
Please let me know if you have any additional suggestions.
--
Daniel Jacobowitz
CodeSourcery
2006-04-18 Daniel Jacobowitz <dan@codesourcery.com>
* gdbint.texinfo (x86 Watchpoints, Target Conditionals): Update insert
and remove breakpoint prototypes.
(Watchpoints): Move description of target_insert_hw_breakpoint and
target_remove_hw_breakpoint ...
(Breakpoints): ... to here. Document target_insert_breakpoint and
target_remove_breakpoint.
Index: doc/gdbint.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v
retrieving revision 1.240
diff -u -p -r1.240 gdbint.texinfo
--- doc/gdbint.texinfo 28 Mar 2006 19:19:16 -0000 1.240
+++ doc/gdbint.texinfo 18 Apr 2006 16:06:16 -0000
@@ -527,6 +527,47 @@ The basic definition of the software bre
Basic breakpoint object handling is in @file{breakpoint.c}. However,
much of the interesting breakpoint action is in @file{infrun.c}.
+@table @code
+@cindex insert or remove software breakpoint
+@findex target_remove_breakpoint
+@findex target_insert_breakpoint
+@item target_remove_breakpoint (@var{bp_tgt})
+@itemx target_insert_breakpoint (@var{bp_tgt})
+Insert or remove a software breakpoint at address
+@code{@var{bp_tgt}->placed_address}. Returns zero for success,
+non-zero for failure. On input, @var{bp_tgt} contains the address of the
+breakpoint, and is otherwise initialized to zero. The fields of the
+@code{struct bp_target_info} pointed to by @var{bp_tgt} are updated
+to contain other information about the breakpoint on output. The field
+@code{placed_address} may be updated if the breakpoint was placed at a
+related address; the field @code{shadow_contents} contains the real
+contents of the bytes where the breakpoint has been inserted,
+if reading memory would return the breakpoint instead of the
+underlying memory; the field @code{shadow_len} is the length of
+memory cached in @code{shadow_contents}, if any; and the field
+@code{placed_size} is optionally set and used by the target, if
+it could differ from @code{shadow_len}.
+
+For example, the remote target @samp{Z0} packet does not require
+shadowing memory, so @code{shadow_len} is left at zero. However,
+the length reported by @code{BREAKPOINT_FROM_PC} is cached in
+@code{placed_size}, so that a matching @samp{z0} packet can be
+used to remove the breakpoint.
+
+@cindex insert or remove hardware breakpoint
+@findex target_remove_hw_breakpoint
+@findex target_insert_hw_breakpoint
+@item target_remove_hw_breakpoint (@var{bp_tgt})
+@itemx target_insert_hw_breakpoint (@var{bp_tgt})
+Insert or remove a hardware-assisted breakpoint at address
+@code{@var{bp_tgt}->placed_address}. Returns zero for success,
+non-zero for failure. See @code{target_insert_breakpoint} for
+a description of the @code{struct bp_target_info} pointed to by
+@var{bp_tgt}; the @code{shadow_contents} and
+@code{shadow_len} members are not used for hardware breakpoints,
+but @code{placed_size} may be.
+@end table
+
@section Single Stepping
@section Signal Handling
@@ -657,18 +698,6 @@ defined by @file{breakpoint.h} as follow
@noindent
These two macros should return 0 for success, non-zero for failure.
-@cindex insert or remove hardware breakpoint
-@findex target_remove_hw_breakpoint
-@findex target_insert_hw_breakpoint
-@item target_remove_hw_breakpoint (@var{addr}, @var{shadow})
-@itemx target_insert_hw_breakpoint (@var{addr}, @var{shadow})
-Insert or remove a hardware-assisted breakpoint at address @var{addr}.
-Returns zero for success, non-zero for failure. @var{shadow} is the
-real contents of the byte where the breakpoint has been inserted; it
-is generally not valid when hardware breakpoints are used, but since
-no other code touches these values, the implementations of the above
-two macros can use them for their internal purposes.
-
@findex target_stopped_data_address
@item target_stopped_data_address (@var{addr_p})
If the inferior has some watchpoint that triggered, place the address
@@ -858,11 +887,13 @@ the count goes to zero.
@findex i386_insert_hw_breakpoint
@findex i386_remove_hw_breakpoint
-@item i386_insert_hw_breakpoint (@var{addr}, @var{shadow}
-@itemx i386_remove_hw_breakpoint (@var{addr}, @var{shadow})
+@item i386_insert_hw_breakpoint (@var{bp_tgt})
+@itemx i386_remove_hw_breakpoint (@var{bp_tgt})
These functions insert and remove hardware-assisted breakpoints. The
macros @code{target_insert_hw_breakpoint} and
@code{target_remove_hw_breakpoint} are set to call these functions.
+The argument is a @code{struct bp_target_info *}, as described in
+the documentation for @code{target_insert_breakpoint}.
These functions work like @code{i386_insert_watchpoint} and
@code{i386_remove_watchpoint}, respectively, except that they set up
the debug registers to watch instruction execution, and each
@@ -3229,8 +3260,8 @@ instruction of the architecture.
Replaces all the other @var{BREAKPOINT} macros.
-@item MEMORY_INSERT_BREAKPOINT (@var{addr}, @var{contents_cache})
-@itemx MEMORY_REMOVE_BREAKPOINT (@var{addr}, @var{contents_cache})
+@item MEMORY_INSERT_BREAKPOINT (@var{bp_tgt})
+@itemx MEMORY_REMOVE_BREAKPOINT (@var{bp_tgt})
@findex MEMORY_REMOVE_BREAKPOINT
@findex MEMORY_INSERT_BREAKPOINT
Insert or remove memory based breakpoints. Reasonable defaults
^ permalink raw reply [flat|nested] 52+ messages in thread
* Re: Save the length of inserted breakpoints
2006-04-18 19:21 ` Daniel Jacobowitz
@ 2006-04-19 7:40 ` Eli Zaretskii
0 siblings, 0 replies; 52+ messages in thread
From: Eli Zaretskii @ 2006-04-19 7:40 UTC (permalink / raw)
To: gdb-patches
> Date: Tue, 18 Apr 2006 15:21:07 -0400
> From: Daniel Jacobowitz <drow@false.org>
> Cc: Mark Kettenis <mark.kettenis@xs4all.nl>, msnyder@redhat.com,
> gdb-patches@sourceware.org
>
> On Tue, Apr 18, 2006 at 11:59:06AM +0300, Eli Zaretskii wrote:
> > Done, comments below.
>
> Thanks a lot. I've committed it with some changes along these lines;
> I've attached the revised documentation patch (the code is unchanged).
> Please let me know if you have any additional suggestions.
The committed patch is fine; thanks.
^ permalink raw reply [flat|nested] 52+ messages in thread
end of thread, other threads:[~2006-04-19 7:40 UTC | newest]
Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-02 22:25 Save the length of inserted breakpoints Daniel Jacobowitz
2006-03-02 23:13 ` Mark Kettenis
2006-03-02 23:19 ` Daniel Jacobowitz
2006-03-03 0:08 ` Mark Kettenis
2006-03-03 1:21 ` Daniel Jacobowitz
2006-03-03 13:51 ` Eli Zaretskii
2006-03-03 15:03 ` Daniel Jacobowitz
2006-03-03 17:56 ` Eli Zaretskii
2006-03-03 18:04 ` Daniel Jacobowitz
2006-03-03 22:00 ` Eli Zaretskii
2006-03-03 22:10 ` Daniel Jacobowitz
2006-03-03 22:35 ` Eli Zaretskii
2006-03-03 23:01 ` Daniel Jacobowitz
2006-03-04 10:39 ` Eli Zaretskii
2006-03-04 14:58 ` Daniel Jacobowitz
2006-03-04 15:05 ` Eli Zaretskii
2006-03-04 15:11 ` Daniel Jacobowitz
2006-03-06 19:49 ` Eli Zaretskii
2006-03-07 5:31 ` Michael Snyder
2006-03-04 0:35 ` Steven Johnson
2006-03-04 10:18 ` Daniel Jacobowitz
2006-04-11 21:46 ` Daniel Jacobowitz
2006-04-11 22:32 ` David S. Miller
2006-04-12 7:30 ` Eli Zaretskii
2006-04-12 9:44 ` Mark Kettenis
2006-04-12 12:57 ` Daniel Jacobowitz
2006-04-12 18:38 ` Mark Kettenis
2006-04-12 18:47 ` Daniel Jacobowitz
2006-04-13 8:12 ` Eli Zaretskii
2006-04-13 22:13 ` Mark Kettenis
2006-04-13 22:59 ` Daniel Jacobowitz
2006-04-13 23:30 ` Daniel Jacobowitz
2006-04-14 8:10 ` Eli Zaretskii
2006-04-14 8:52 ` David S. Miller
2006-04-14 8:04 ` Eli Zaretskii
2006-04-14 8:51 ` David S. Miller
2006-04-16 23:58 ` Mark Kettenis
2006-04-17 7:07 ` Eli Zaretskii
2006-04-13 21:57 ` Michael Snyder
2006-04-13 22:59 ` Daniel Jacobowitz
2006-04-16 23:53 ` Mark Kettenis
2006-04-16 23:50 ` Mark Kettenis
2006-04-17 1:41 ` Daniel Jacobowitz
2006-04-17 13:09 ` Mark Kettenis
2006-04-17 13:37 ` Daniel Jacobowitz
2006-04-17 13:50 ` Mark Kettenis
2006-04-17 19:08 ` Daniel Jacobowitz
2006-04-17 20:25 ` Mark Kettenis
2006-04-17 21:50 ` Daniel Jacobowitz
2006-04-18 8:59 ` Eli Zaretskii
2006-04-18 19:21 ` Daniel Jacobowitz
2006-04-19 7:40 ` Eli Zaretskii
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox