[rfc] Add gdbarch to memory_{insert,remove}_breakpoint

Markus Deuling
2008-02-19T18:00:08Z

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

Hi,

this patch adds gdbarch as parameter to memory_{insert,remove}_breakpoint to get rid of some
current_gdbarch. Tested by gdb_buildall.sh.

Ok ?

ChangeLog:

* gdbarch.sh (memory_insert_breakpoint, memory_remove_breakpoint): Add
gdbarch as parameter.

* gdbarch.{c,h}: Regenerate.

* ppc-tdep.h (ppc_linux_memory_remove_breakpoint): Add gdbarch as
parameter.
* mem-break.c (default_memory_insert_breakpoint)
(default_memory_remove_breakpoint): Likewise.
* target.h (default_memory_remove_breakpoint)
(default_memory_insert_breakpoint): Likewise.

* ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Add gdbarch as
parameter. Replace current_gdbarch by gdbarch.
* m32r-tdep.c (m32r_memory_insert_breakpoint)
(m32r_memory_remove_breakpoint): Likewise.

--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com

[-- Attachment #2: diff-insert-remove-bp --]
[-- Type: text/plain, Size: 9575 bytes --]

diff -urpN src/gdb/gdbarch.c dev/gdb/gdbarch.c
--- src/gdb/gdbarch.c 2008-01-18 18:06:41.000000000 +0100
+++ dev/gdb/gdbarch.c 2008-02-19 18:19:32.000000000 +0100
@@ -309,8 +309,8 @@ struct gdbarch startup_gdbarch =
0, /* inner_than */
0, /* breakpoint_from_pc */
0, /* adjust_breakpoint_address */
- 0, /* memory_insert_breakpoint */
- 0, /* memory_remove_breakpoint */
+ default_memory_insert_breakpoint, /* memory_insert_breakpoint */
+ default_memory_remove_breakpoint, /* memory_remove_breakpoint */
0, /* decr_pc_after_break */
0, /* deprecated_function_start_offset */
default_remote_register_number, /* remote_register_number */
@@ -2139,7 +2139,7 @@ gdbarch_memory_insert_breakpoint (struct
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 (bp_tgt);
+ return gdbarch->memory_insert_breakpoint (gdbarch, bp_tgt);
}

void
@@ -2156,7 +2156,7 @@ gdbarch_memory_remove_breakpoint (struct
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 (bp_tgt);
+ return gdbarch->memory_remove_breakpoint (gdbarch, bp_tgt);
}

void
diff -urpN src/gdb/gdbarch.h dev/gdb/gdbarch.h
--- src/gdb/gdbarch.h 2008-01-18 18:06:42.000000000 +0100
+++ dev/gdb/gdbarch.h 2008-02-19 18:19:23.000000000 +0100
@@ -388,11 +388,11 @@ 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) (struct bp_target_info *bp_tgt);
+typedef int (gdbarch_memory_insert_breakpoint_ftype) (struct gdbarch *gdbarch, 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);

-typedef int (gdbarch_memory_remove_breakpoint_ftype) (struct bp_target_info *bp_tgt);
+typedef int (gdbarch_memory_remove_breakpoint_ftype) (struct gdbarch *gdbarch, 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);

diff -urpN src/gdb/gdbarch.sh dev/gdb/gdbarch.sh
--- src/gdb/gdbarch.sh 2008-01-18 18:06:42.000000000 +0100
+++ dev/gdb/gdbarch.sh 2008-02-19 18:19:13.000000000 +0100
@@ -480,8 +480,8 @@ m:CORE_ADDR:skip_prologue:CORE_ADDR ip:i
f:int:inner_than:CORE_ADDR lhs, CORE_ADDR rhs:lhs, rhs:0:0
m: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: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
+m:int:memory_insert_breakpoint:struct bp_target_info *bp_tgt:bp_tgt:0:default_memory_insert_breakpoint::0
+m: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
diff -urpN src/gdb/ia64-tdep.c dev/gdb/ia64-tdep.c
--- src/gdb/ia64-tdep.c 2008-01-11 14:20:52.000000000 +0100
+++ dev/gdb/ia64-tdep.c 2008-02-19 18:27:00.000000000 +0100
@@ -553,7 +553,8 @@ fetch_instruction (CORE_ADDR addr, instr
#define IA64_BREAKPOINT 0x00003333300LL

static int
-ia64_memory_insert_breakpoint (struct bp_target_info *bp_tgt)
+ia64_memory_insert_breakpoint (struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt)
{
CORE_ADDR addr = bp_tgt->placed_address;
char bundle[BUNDLE_LEN];
@@ -588,7 +589,8 @@ ia64_memory_insert_breakpoint (struct bp
}

static int
-ia64_memory_remove_breakpoint (struct bp_target_info *bp_tgt)
+ia64_memory_remove_breakpoint (struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt)
{
CORE_ADDR addr = bp_tgt->placed_address;
char bundle[BUNDLE_LEN];
diff -urpN src/gdb/m32r-tdep.c dev/gdb/m32r-tdep.c
--- src/gdb/m32r-tdep.c 2008-01-11 14:20:52.000000000 +0100
+++ dev/gdb/m32r-tdep.c 2008-02-19 18:24:52.000000000 +0100
@@ -79,7 +79,8 @@ m32r_frame_align (struct gdbarch *gdbarc
The following functions take care of this behavior. */

static int
-m32r_memory_insert_breakpoint (struct bp_target_info *bp_tgt)
+m32r_memory_insert_breakpoint (struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt)
{
CORE_ADDR addr = bp_tgt->placed_address;
int val;
@@ -95,7 +96,7 @@ m32r_memory_insert_breakpoint (struct bp
bp_tgt->placed_size = bp_tgt->shadow_len = 4;

/* Determine appropriate breakpoint contents and size for this address. */
- if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
{
if ((addr & 3) == 0)
{
@@ -136,7 +137,8 @@ m32r_memory_insert_breakpoint (struct bp
}

static int
-m32r_memory_remove_breakpoint (struct bp_target_info *bp_tgt)
+m32r_memory_remove_breakpoint (struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt)
{
CORE_ADDR addr = bp_tgt->placed_address;
int val;
@@ -149,7 +151,7 @@ m32r_memory_remove_breakpoint (struct bp
buf[3] = contents_cache[3];

/* Remove parallel bit. */
- if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+ if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
{
if ((buf[0] & 0x80) == 0 && (buf[2] & 0x80) != 0)
buf[2] &= 0x7f;
diff -urpN src/gdb/mem-break.c dev/gdb/mem-break.c
--- src/gdb/mem-break.c 2008-01-01 23:53:12.000000000 +0100
+++ dev/gdb/mem-break.c 2008-02-19 18:51:53.000000000 +0100
@@ -41,7 +41,8 @@
BREAKPOINT_MAX). */

int
-default_memory_insert_breakpoint (struct bp_target_info *bp_tgt)
+default_memory_insert_breakpoint (struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt)
{
int val;
const unsigned char *bp;
@@ -49,7 +50,7 @@ default_memory_insert_breakpoint (struct

/* Determine appropriate breakpoint contents and size for this address. */
bp = gdbarch_breakpoint_from_pc
- (current_gdbarch, &bp_tgt->placed_address, &bp_tgt->placed_size);
+ (gdbarch, &bp_tgt->placed_address, &bp_tgt->placed_size);
if (bp == NULL)
error (_("Software breakpoints not implemented for this target."));

@@ -68,7 +69,8 @@ default_memory_insert_breakpoint (struct

int
-default_memory_remove_breakpoint (struct bp_target_info *bp_tgt)
+default_memory_remove_breakpoint (struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt)
{
return target_write_memory (bp_tgt->placed_address, bp_tgt->shadow_contents,
bp_tgt->placed_size);
diff -urpN src/gdb/ppc-linux-tdep.c dev/gdb/ppc-linux-tdep.c
--- src/gdb/ppc-linux-tdep.c 2008-01-01 23:53:12.000000000 +0100
+++ dev/gdb/ppc-linux-tdep.c 2008-02-19 18:22:33.000000000 +0100
@@ -273,7 +273,8 @@ ppc_linux_skip_trampoline_code (struct f
regard to removing breakpoints in some potentially self modifying
code. */
int
-ppc_linux_memory_remove_breakpoint (struct bp_target_info *bp_tgt)
+ppc_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt)
{
CORE_ADDR addr = bp_tgt->placed_address;
const unsigned char *bp;
@@ -282,7 +283,7 @@ ppc_linux_memory_remove_breakpoint (stru
gdb_byte old_contents[BREAKPOINT_MAX];

/* Determine appropriate breakpoint contents and size for this address. */
- bp = gdbarch_breakpoint_from_pc (current_gdbarch, &addr, &bplen);
+ bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen);
if (bp == NULL)
error (_("Software breakpoints not implemented for this target."));

diff -urpN src/gdb/ppc-tdep.h dev/gdb/ppc-tdep.h
--- src/gdb/ppc-tdep.h 2008-02-11 05:48:37.000000000 +0100
+++ dev/gdb/ppc-tdep.h 2008-02-19 18:25:29.000000000 +0100
@@ -54,7 +54,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 (struct bp_target_info *bp_tgt);
+int ppc_linux_memory_remove_breakpoint (struct gdbarch *, struct bp_target_info *);
struct link_map_offsets *ppc_linux_svr4_fetch_link_map_offsets (void);
const struct regset *ppc_linux_gregset (int);
const struct regset *ppc_linux_fpregset (void);
diff -urpN src/gdb/target.h dev/gdb/target.h
--- src/gdb/target.h 2008-01-01 23:53:13.000000000 +0100
+++ dev/gdb/target.h 2008-02-19 18:43:21.000000000 +0100
@@ -1177,9 +1177,9 @@ extern int memory_remove_breakpoint (str

extern int memory_insert_breakpoint (struct bp_target_info *);

-extern int default_memory_remove_breakpoint (struct bp_target_info *);
+extern int default_memory_remove_breakpoint (struct gdbarch *, struct bp_target_info *);

-extern int default_memory_insert_breakpoint (struct bp_target_info *);
+extern int default_memory_insert_breakpoint (struct gdbarch *, struct bp_target_info *);

/* From target.c */