mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-27 01:28:46 +00:00
New gdbarch methods breakpoint_kind_from_pc and sw_breakpoint_from_kind
This patch adds two gdbarch methods breakpoint_kind_from_pc and
sw_breakpoint_from_kind, and uses target_info.placed_size as "kind"
of the breakpoint. This patch updates the usages of
target_info.placed_size.
The "kind" of a breakpoint is determined by gdbarch rather than
target, so we have gdbarch method breakpoint_kind_from_pc, and we
should set target_info.placed_size out of each implementation of
target to_insert_breakpoint. In this way, each target doesn't have
to set target_info.placed_size any more.
This patch also sets target_info.placed_address before
target_insert_breakpoint too, so that target to_insert_breakpoint
can use it, see record_full_insert_breakpoint.
Before we call target_insert_breakpoint, we set
target_info.placed_address and target_info.placed_size like this,
CORE_ADDR addr = bl->target_info.reqstd_address;
bl->target_info.placed_size = gdbarch_breakpoint_kind_from_pc (bl->gdbarch, &addr);
bl->target_info.placed_address = addr;
return target_insert_breakpoint (bl->gdbarch, &bl->target_info);
target_insert_breakpoint may fail, but it doesn't matter to the "kind"
and "placed_address" of a breakpoint. They should be determined by
gdbarch.
gdb:
2016-11-03 Yao Qi <yao.qi@linaro.org>
* arch-utils.h (GDBARCH_BREAKPOINT_MANIPULATION): Define
breakpoint_kind_from_pc and sw_breakpoint_from_kind.
(GDBARCH_BREAKPOINT_MANIPULATION_ENDIAN): Likewise.
(SET_GDBARCH_BREAKPOINT_MANIPULATION): Call
set_gdbarch_breakpoint_kind_from_pc and
set_gdbarch_sw_breakpoint_from_kind.
* arm-tdep.c: Add comments.
* bfin-tdep.c: Likewise.
* breakpoint.c (breakpoint_kind): New function.
(insert_bp_location): Set target_info.placed_size and
target_info.placed_address.
(bkpt_insert_location): Likewise.
* cris-tdep.c: Add comments.
* gdbarch.sh (breakpoint_kind_from_pc): New.
(sw_breakpoint_from_kind): New.
* gdbarch.c, gdbarch.h: Regenerated.
* ia64-tdep.c (ia64_memory_insert_breakpoint): Don't set
bp_tgt->placed_size.
(ia64_memory_remove_breakpoint): Don't assert
bp_tgt->placed_size.
(ia64_breakpoint_kind_from_pc): New function.
(ia64_gdbarch_init): Install ia64_breakpoint_kind_from_pc.
* m32r-tdep.c (m32r_memory_insert_breakpoint): Don't set
bp_tgt->placed_size.
* mem-break.c (default_memory_insert_breakpoint): Don't set
bp_tgt->placed_size. Call gdbarch_sw_breakpoint_from_kind.
(default_memory_remove_breakpoint): Call
gdbarch_sw_breakpoint_from_kind.
(memory_validate_breakpoint): Don't check bp_tgt->placed_size.
* mips-tdep.c: Add comments.
* mt-tdep.c: Likewise.
* nios2-tdep.c: Likewise.
* record-full.c (record_full_insert_breakpoint): Don't call
gdbarch_breakpoint_from_pc. Don't set bp_tgt->placed_address
and bp_tgt->placed_size.
* remote.c (remote_insert_breakpoint): Don't call
gdbarch_remote_breakpoint_from_pc. Use bp_tgt->placed_size.
Don't set bp_tgt->placed_address and bp_tgt->placed_size.
(remote_insert_hw_breakpoint): Likewise.
* score-tdep.c: Likewise.
* sh-tdep.c: Likewise.
* tic6x-tdep.c: Likewise.
* v850-tdep.c: Likewise.
* xtensa-tdep.c: Likewise.
This commit is contained in:
@@ -38,34 +38,50 @@ struct gdbarch_info;
|
||||
}
|
||||
|
||||
#define GDBARCH_BREAKPOINT_MANIPULATION(ARCH,BREAK_INSN) \
|
||||
static const gdb_byte * \
|
||||
ARCH##_breakpoint_from_pc (struct gdbarch *gdbarch, \
|
||||
CORE_ADDR *pcptr, \
|
||||
int *lenptr) \
|
||||
static int \
|
||||
ARCH##_breakpoint_kind_from_pc (struct gdbarch *gdbarch, \
|
||||
CORE_ADDR *pcptr) \
|
||||
{ \
|
||||
*lenptr = sizeof (BREAK_INSN); \
|
||||
return sizeof (BREAK_INSN); \
|
||||
} \
|
||||
static const gdb_byte * \
|
||||
ARCH##_sw_breakpoint_from_kind (struct gdbarch *gdbarch, \
|
||||
int kind, int *size) \
|
||||
{ \
|
||||
*size = kind; \
|
||||
return BREAK_INSN; \
|
||||
}
|
||||
} \
|
||||
GDBARCH_BREAKPOINT_FROM_PC (ARCH)
|
||||
|
||||
#define SET_GDBARCH_BREAKPOINT_MANIPULATION(ARCH) \
|
||||
set_gdbarch_breakpoint_from_pc (gdbarch, ARCH##_breakpoint_from_pc)
|
||||
#define SET_GDBARCH_BREAKPOINT_MANIPULATION(ARCH) \
|
||||
set_gdbarch_breakpoint_from_pc (gdbarch, ARCH##_breakpoint_from_pc); \
|
||||
set_gdbarch_breakpoint_kind_from_pc (gdbarch, \
|
||||
ARCH##_breakpoint_kind_from_pc); \
|
||||
set_gdbarch_sw_breakpoint_from_kind (gdbarch, \
|
||||
ARCH##_sw_breakpoint_from_kind)
|
||||
|
||||
#define GDBARCH_BREAKPOINT_MANIPULATION_ENDIAN(ARCH, \
|
||||
LITTLE_BREAK_INSN, \
|
||||
BIG_BREAK_INSN) \
|
||||
static const gdb_byte * \
|
||||
ARCH##_breakpoint_from_pc (struct gdbarch *gdbarch, \
|
||||
CORE_ADDR *pcptr, \
|
||||
int *lenptr) \
|
||||
static int \
|
||||
ARCH##_breakpoint_kind_from_pc (struct gdbarch *gdbarch, \
|
||||
CORE_ADDR *pcptr) \
|
||||
{ \
|
||||
gdb_static_assert (ARRAY_SIZE (LITTLE_BREAK_INSN) \
|
||||
== ARRAY_SIZE (BIG_BREAK_INSN)); \
|
||||
*lenptr = sizeof (LITTLE_BREAK_INSN); \
|
||||
if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) \
|
||||
return BIG_BREAK_INSN; \
|
||||
else \
|
||||
return LITTLE_BREAK_INSN; \
|
||||
}
|
||||
return sizeof (BIG_BREAK_INSN); \
|
||||
} \
|
||||
static const gdb_byte * \
|
||||
ARCH##_sw_breakpoint_from_kind (struct gdbarch *gdbarch, \
|
||||
int kind, int *size) \
|
||||
{ \
|
||||
*size = kind; \
|
||||
if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) \
|
||||
return BIG_BREAK_INSN; \
|
||||
else \
|
||||
return LITTLE_BREAK_INSN; \
|
||||
} \
|
||||
GDBARCH_BREAKPOINT_FROM_PC (ARCH)
|
||||
|
||||
/* An implementation of gdbarch_displaced_step_copy_insn for
|
||||
processors that don't need to modify the instruction before
|
||||
|
||||
Reference in New Issue
Block a user