This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
Re: RFA: new gdbarch methods for inserting/removing breakpoints
On Oct 14, 9:47am, Andrew Cagney wrote:
> > Is there something else I needed to do?
>
> Ah, yes. That handles the non multi-arch case. A multi-arch target
> (eg d10v) would likely dump core. The ``init'' field in that script
> should do it.
>
> default_arch is there simply to stop GDB crashing during
> initialization. Some code unfortunatly assumes that an architecture has
> already been selected by the time _initialize has been called (see
> gdbtypes.c). It is never used as a real architecture.
I see. Without closely reading the code I was assuming that
default_arch was memcpy'd over to the newly allocated structure
created in gdbarch_alloc().
I've appended my revised patches below. All that's really changed from
the first patches I sent are that I changed the following on the
two lines that I added to gdbarch.sh
a) changed the ``default'' field to be 0
b) put default_memory_{insert,remove}_breakpoint in the ``init'' field
c) added a 0 ``init_p'' field
I then reran gdbarch.sh to generate a new gdbarch.c. (gdbarch.h didn't
change at all.)
BTW, the whole process of adding new arch methods turned out being a
lot less painful than I expected. Nice job on the gdbarch.sh
facility.
Kevin
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/14 00:14:41
@@ -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;
@@ -300,6 +302,8 @@
0,
0,
0,
+ 0,
+ 0,
/* default_gdbarch() */
};
struct gdbarch *current_gdbarch = &default_gdbarch;
@@ -336,6 +340,8 @@
gdbarch->call_dummy_length = -1;
gdbarch->call_dummy_p = -1;
gdbarch->call_dummy_stack_adjust_p = -1;
+ gdbarch->memory_insert_breakpoint = default_memory_insert_breakpoint;
+ gdbarch->memory_remove_breakpoint = default_memory_remove_breakpoint;
gdbarch->decr_pc_after_break = -1;
gdbarch->function_start_offset = -1;
gdbarch->frame_args_skip = -1;
@@ -549,6 +555,12 @@
&& (gdbarch->breakpoint_from_pc == 0))
internal_error ("gdbarch: verify_gdbarch: breakpoint_from_pc invalid");
if ((GDB_MULTI_ARCH >= 2)
+ && (0))
+ internal_error ("gdbarch: verify_gdbarch: memory_insert_breakpoint invalid");
+ if ((GDB_MULTI_ARCH >= 2)
+ && (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 +857,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 +2135,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/14 00:14:42
@@ -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/14 00:14:43
@@ -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::0:default_memory_insert_breakpoint:0
+f:2:MEMORY_REMOVE_BREAKPOINT:int:memory_remove_breakpoint:CORE_ADDR addr, char *contents_cache:addr, contents_cache::0: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/14 00:14:44
@@ -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/14 00:14:47
@@ -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)