This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
RFA: new gdbarch methods for inserting/removing breakpoints
- To: Andrew Cagney <cagney at cygnus dot com>, gdb-patches at sourceware dot cygnus dot com
- Subject: RFA: new gdbarch methods for inserting/removing breakpoints
- From: Kevin Buettner <kevinb at cygnus dot com>
- Date: Wed, 13 Oct 1999 14:54:36 -0700
Andrew, et.al,
I would like to check in the changes below. These changes will allow
us to write architecture specific versions of
memory_insert_breakpoint() and memory_remove_breakpoint(). Custom
versions of these functions are needed on architectures where an
instruction is a strange size and/or does not fall neatly on a
byte-aligned boundary. (E.g, ia64.)
I'll add some documentation to doc/gdbint.texinfo after approval.
Kevin
* mem-break.c (default_memory_insert_breakpoint): Renamed from
memory_insert_breakpoint.
(default_memory_remove_breakpoint): Renamed from
memory_remove_breakpoint.
(memory_insert_breakpoint, memory_remove_breakpoint,
MEMORY_INSERT_BREAKPOINT, MEMORY_REMOVE_BREAKPOINT): New
wrappers.
* target.h (default_memory_remove_breakpoint,
default_memory_insert_breakpoint): Added declarations.
* gdbarch.sh (MEMORY_INSERT_BREAKPOINT, MEMORY_REMOVE_BREAKPOINT):
New methods.
* gdbarch.h, gdbarch.c (MEMORY_INSERT_BREAKPOINT,
MEMORY_REMOVE_BREAKPOINT, gdbarch_memory_insert_breakpoint,
gdbarch_memory_remove_breakpoint, set_gdbarch_memory_insert_breakpoint,
set_gdbarch_memory_remove_breakpoint) : Generated from gdbarch.sh.
Index: gdbarch.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/gdbarch.c,v
retrieving revision 2.56
diff -u -r2.56 gdbarch.c
--- gdbarch.c 1999/08/24 04:56:58 2.56
+++ gdbarch.c 1999/10/13 21:13:20
@@ -192,6 +192,8 @@
gdbarch_skip_prologue_ftype *skip_prologue;
gdbarch_inner_than_ftype *inner_than;
gdbarch_breakpoint_from_pc_ftype *breakpoint_from_pc;
+ gdbarch_memory_insert_breakpoint_ftype *memory_insert_breakpoint;
+ gdbarch_memory_remove_breakpoint_ftype *memory_remove_breakpoint;
CORE_ADDR decr_pc_after_break;
CORE_ADDR function_start_offset;
gdbarch_remote_translate_xfer_address_ftype *remote_translate_xfer_address;
@@ -288,6 +290,8 @@
0,
0,
0,
+ default_memory_insert_breakpoint,
+ default_memory_remove_breakpoint,
0,
0,
0,
@@ -549,6 +553,12 @@
&& (gdbarch->breakpoint_from_pc == 0))
internal_error ("gdbarch: verify_gdbarch: breakpoint_from_pc invalid");
if ((GDB_MULTI_ARCH >= 2)
+ && (gdbarch->memory_insert_breakpoint == 0))
+ internal_error ("gdbarch: verify_gdbarch: memory_insert_breakpoint invalid");
+ if ((GDB_MULTI_ARCH >= 2)
+ && (gdbarch->memory_remove_breakpoint == 0))
+ internal_error ("gdbarch: verify_gdbarch: memory_remove_breakpoint invalid");
+ if ((GDB_MULTI_ARCH >= 2)
&& (gdbarch->decr_pc_after_break == -1))
internal_error ("gdbarch: verify_gdbarch: decr_pc_after_break invalid");
if ((GDB_MULTI_ARCH >= 2)
@@ -845,6 +855,14 @@
(long) current_gdbarch->breakpoint_from_pc
/*BREAKPOINT_FROM_PC ()*/);
fprintf_unfiltered (gdb_stdlog,
+ "gdbarch_update: MEMORY_INSERT_BREAKPOINT = 0x%08lx\n",
+ (long) current_gdbarch->memory_insert_breakpoint
+ /*MEMORY_INSERT_BREAKPOINT ()*/);
+ fprintf_unfiltered (gdb_stdlog,
+ "gdbarch_update: MEMORY_REMOVE_BREAKPOINT = 0x%08lx\n",
+ (long) current_gdbarch->memory_remove_breakpoint
+ /*MEMORY_REMOVE_BREAKPOINT ()*/);
+ fprintf_unfiltered (gdb_stdlog,
"gdbarch_update: DECR_PC_AFTER_BREAK = %ld\n",
(long) DECR_PC_AFTER_BREAK);
fprintf_unfiltered (gdb_stdlog,
@@ -2115,6 +2133,42 @@
gdbarch_breakpoint_from_pc_ftype breakpoint_from_pc)
{
gdbarch->breakpoint_from_pc = breakpoint_from_pc;
+}
+
+int
+gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, char *contents_cache)
+{
+ if (gdbarch->memory_insert_breakpoint == 0)
+ internal_error ("gdbarch: gdbarch_memory_insert_breakpoint invalid");
+ if (gdbarch_debug >= 2)
+ /* FIXME: gdb_std??? */
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_memory_insert_breakpoint called\n");
+ return gdbarch->memory_insert_breakpoint (addr, contents_cache);
+}
+
+void
+set_gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch,
+ gdbarch_memory_insert_breakpoint_ftype memory_insert_breakpoint)
+{
+ gdbarch->memory_insert_breakpoint = memory_insert_breakpoint;
+}
+
+int
+gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, char *contents_cache)
+{
+ if (gdbarch->memory_remove_breakpoint == 0)
+ internal_error ("gdbarch: gdbarch_memory_remove_breakpoint invalid");
+ if (gdbarch_debug >= 2)
+ /* FIXME: gdb_std??? */
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_memory_remove_breakpoint called\n");
+ return gdbarch->memory_remove_breakpoint (addr, contents_cache);
+}
+
+void
+set_gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch,
+ gdbarch_memory_remove_breakpoint_ftype memory_remove_breakpoint)
+{
+ gdbarch->memory_remove_breakpoint = memory_remove_breakpoint;
}
CORE_ADDR
Index: gdbarch.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/gdbarch.h,v
retrieving revision 2.58
diff -u -r2.58 gdbarch.h
--- gdbarch.h 1999/08/24 04:56:58 2.58
+++ gdbarch.h 1999/10/13 21:13:21
@@ -673,6 +673,24 @@
#endif
#endif
+typedef int (gdbarch_memory_insert_breakpoint_ftype) (CORE_ADDR addr, char *contents_cache);
+extern int gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, char *contents_cache);
+extern void set_gdbarch_memory_insert_breakpoint (struct gdbarch *gdbarch, gdbarch_memory_insert_breakpoint_ftype *memory_insert_breakpoint);
+#if GDB_MULTI_ARCH
+#if (GDB_MULTI_ARCH > 1) || !defined (MEMORY_INSERT_BREAKPOINT)
+#define MEMORY_INSERT_BREAKPOINT(addr, contents_cache) (gdbarch_memory_insert_breakpoint (current_gdbarch, addr, contents_cache))
+#endif
+#endif
+
+typedef int (gdbarch_memory_remove_breakpoint_ftype) (CORE_ADDR addr, char *contents_cache);
+extern int gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, CORE_ADDR addr, char *contents_cache);
+extern void set_gdbarch_memory_remove_breakpoint (struct gdbarch *gdbarch, gdbarch_memory_remove_breakpoint_ftype *memory_remove_breakpoint);
+#if GDB_MULTI_ARCH
+#if (GDB_MULTI_ARCH > 1) || !defined (MEMORY_REMOVE_BREAKPOINT)
+#define MEMORY_REMOVE_BREAKPOINT(addr, contents_cache) (gdbarch_memory_remove_breakpoint (current_gdbarch, addr, contents_cache))
+#endif
+#endif
+
extern CORE_ADDR gdbarch_decr_pc_after_break (struct gdbarch *gdbarch);
extern void set_gdbarch_decr_pc_after_break (struct gdbarch *gdbarch, CORE_ADDR decr_pc_after_break);
#if GDB_MULTI_ARCH
Index: gdbarch.sh
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/gdbarch.sh,v
retrieving revision 2.40
diff -u -r2.40 gdbarch.sh
--- gdbarch.sh 1999/09/13 08:55:36 2.40
+++ gdbarch.sh 1999/10/13 21:13:23
@@ -208,6 +208,8 @@
f:2:SKIP_PROLOGUE:CORE_ADDR:skip_prologue:CORE_ADDR ip:ip::0:0
f:2:INNER_THAN:int:inner_than:CORE_ADDR lhs, CORE_ADDR rhs:lhs, rhs::0:0
f:2:BREAKPOINT_FROM_PC:unsigned char *:breakpoint_from_pc:CORE_ADDR *pcptr, int *lenptr:pcptr, lenptr::0:0
+f:2:MEMORY_INSERT_BREAKPOINT:int:memory_insert_breakpoint:CORE_ADDR addr, char *contents_cache:addr, contents_cache::default_memory_insert_breakpoint:0
+f:2:MEMORY_REMOVE_BREAKPOINT:int:memory_remove_breakpoint:CORE_ADDR addr, char *contents_cache:addr, contents_cache::default_memory_remove_breakpoint:0
v:2:DECR_PC_AFTER_BREAK:CORE_ADDR:decr_pc_after_break::::0:-1
v:2:FUNCTION_START_OFFSET:CORE_ADDR:function_start_offset::::0:-1
#
Index: mem-break.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/mem-break.c,v
retrieving revision 1.20
diff -u -r1.20 mem-break.c
--- mem-break.c 1999/07/07 23:51:39 1.20
+++ mem-break.c 1999/10/13 21:13:23
@@ -84,7 +84,7 @@
is accomplished via BREAKPOINT_MAX). */
int
-memory_insert_breakpoint (addr, contents_cache)
+default_memory_insert_breakpoint (addr, contents_cache)
CORE_ADDR addr;
char *contents_cache;
{
@@ -109,7 +109,7 @@
int
-memory_remove_breakpoint (addr, contents_cache)
+default_memory_remove_breakpoint (addr, contents_cache)
CORE_ADDR addr;
char *contents_cache;
{
@@ -122,4 +122,29 @@
error ("Software breakpoints not implemented for this target.");
return target_write_memory (addr, contents_cache, bplen);
+}
+
+
+#if !defined(MEMORY_INSERT_BREAKPOINT)
+#define MEMORY_INSERT_BREAKPOINT(addr, contents_cache) \
+ default_memory_insert_breakpoint(addr, contents_cache)
+#endif
+int
+memory_insert_breakpoint (addr, contents_cache)
+ CORE_ADDR addr;
+ char *contents_cache;
+{
+ MEMORY_INSERT_BREAKPOINT(addr, contents_cache);
+}
+
+#if !defined(MEMORY_REMOVE_BREAKPOINT)
+#define MEMORY_REMOVE_BREAKPOINT(addr, contents_cache) \
+ default_memory_remove_breakpoint(addr, contents_cache)
+#endif
+int
+memory_remove_breakpoint (addr, contents_cache)
+ CORE_ADDR addr;
+ char *contents_cache;
+{
+ MEMORY_REMOVE_BREAKPOINT(addr, contents_cache);
}
Index: target.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/target.h,v
retrieving revision 1.86
diff -u -r1.86 target.h
--- target.h 1999/10/01 22:56:40 1.86
+++ target.h 1999/10/13 21:13:27
@@ -1258,6 +1258,10 @@
extern int memory_insert_breakpoint PARAMS ((CORE_ADDR, char *));
+extern int default_memory_remove_breakpoint PARAMS ((CORE_ADDR, char *));
+
+extern int default_memory_insert_breakpoint PARAMS ((CORE_ADDR, char *));
+
extern breakpoint_from_pc_fn memory_breakpoint_from_pc;
#ifndef BREAKPOINT_FROM_PC
#define BREAKPOINT_FROM_PC(pcptr, lenptr) memory_breakpoint_from_pc (pcptr, lenptr)