diff options
author | Yao Qi <yao.qi@linaro.org> | 2016-11-03 14:35:13 +0000 |
---|---|---|
committer | Yao Qi <yao.qi@linaro.org> | 2016-11-03 14:35:13 +0000 |
commit | cd6c3b4ffc4ea6f56f12581419e2eed885441beb (patch) | |
tree | dd525fa7db9d4373ab5d66189a123e8cb899c28e /gdb/gdbarch.c | |
parent | d19280adb5b2d1470dc39756ccac8a8fa2af8321 (diff) | |
download | binutils-gdb-cd6c3b4ffc4ea6f56f12581419e2eed885441beb.tar.gz |
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.
Diffstat (limited to 'gdb/gdbarch.c')
-rw-r--r-- | gdb/gdbarch.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 4d8ef183cde..0377b4d906c 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -230,6 +230,8 @@ struct gdbarch gdbarch_skip_entrypoint_ftype *skip_entrypoint; gdbarch_inner_than_ftype *inner_than; gdbarch_breakpoint_from_pc_ftype *breakpoint_from_pc; + gdbarch_breakpoint_kind_from_pc_ftype *breakpoint_kind_from_pc; + gdbarch_sw_breakpoint_from_kind_ftype *sw_breakpoint_from_kind; gdbarch_remote_breakpoint_from_pc_ftype *remote_breakpoint_from_pc; gdbarch_adjust_breakpoint_address_ftype *adjust_breakpoint_address; gdbarch_memory_insert_breakpoint_ftype *memory_insert_breakpoint; @@ -403,6 +405,7 @@ gdbarch_alloc (const struct gdbarch_info *info, gdbarch->pointer_to_address = unsigned_pointer_to_address; gdbarch->address_to_pointer = unsigned_address_to_pointer; gdbarch->return_in_first_hidden_param_p = default_return_in_first_hidden_param_p; + gdbarch->sw_breakpoint_from_kind = NULL; gdbarch->remote_breakpoint_from_pc = default_remote_breakpoint_from_pc; gdbarch->memory_insert_breakpoint = default_memory_insert_breakpoint; gdbarch->memory_remove_breakpoint = default_memory_remove_breakpoint; @@ -583,6 +586,9 @@ verify_gdbarch (struct gdbarch *gdbarch) fprintf_unfiltered (log, "\n\tinner_than"); if (gdbarch->breakpoint_from_pc == 0) fprintf_unfiltered (log, "\n\tbreakpoint_from_pc"); + if (gdbarch->breakpoint_kind_from_pc == 0) + fprintf_unfiltered (log, "\n\tbreakpoint_kind_from_pc"); + /* Skip verify of sw_breakpoint_from_kind, invalid_p == 0 */ /* Skip verify of remote_breakpoint_from_pc, invalid_p == 0 */ /* Skip verify of adjust_breakpoint_address, has predicate. */ /* Skip verify of memory_insert_breakpoint, invalid_p == 0 */ @@ -793,6 +799,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) "gdbarch_dump: breakpoint_from_pc = <%s>\n", host_address_to_string (gdbarch->breakpoint_from_pc)); fprintf_unfiltered (file, + "gdbarch_dump: breakpoint_kind_from_pc = <%s>\n", + host_address_to_string (gdbarch->breakpoint_kind_from_pc)); + fprintf_unfiltered (file, "gdbarch_dump: byte_order = %s\n", plongest (gdbarch->byte_order)); fprintf_unfiltered (file, @@ -1399,6 +1408,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) "gdbarch_dump: static_transform_name = <%s>\n", host_address_to_string (gdbarch->static_transform_name)); fprintf_unfiltered (file, + "gdbarch_dump: sw_breakpoint_from_kind = <%s>\n", + host_address_to_string (gdbarch->sw_breakpoint_from_kind)); + fprintf_unfiltered (file, "gdbarch_dump: syscalls_info = %s\n", host_address_to_string (gdbarch->syscalls_info)); fprintf_unfiltered (file, @@ -2782,6 +2794,40 @@ set_gdbarch_breakpoint_from_pc (struct gdbarch *gdbarch, gdbarch->breakpoint_from_pc = breakpoint_from_pc; } +int +gdbarch_breakpoint_kind_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr) +{ + gdb_assert (gdbarch != NULL); + gdb_assert (gdbarch->breakpoint_kind_from_pc != NULL); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_breakpoint_kind_from_pc called\n"); + return gdbarch->breakpoint_kind_from_pc (gdbarch, pcptr); +} + +void +set_gdbarch_breakpoint_kind_from_pc (struct gdbarch *gdbarch, + gdbarch_breakpoint_kind_from_pc_ftype breakpoint_kind_from_pc) +{ + gdbarch->breakpoint_kind_from_pc = breakpoint_kind_from_pc; +} + +const gdb_byte * +gdbarch_sw_breakpoint_from_kind (struct gdbarch *gdbarch, int kind, int *size) +{ + gdb_assert (gdbarch != NULL); + gdb_assert (gdbarch->sw_breakpoint_from_kind != NULL); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_sw_breakpoint_from_kind called\n"); + return gdbarch->sw_breakpoint_from_kind (gdbarch, kind, size); +} + +void +set_gdbarch_sw_breakpoint_from_kind (struct gdbarch *gdbarch, + gdbarch_sw_breakpoint_from_kind_ftype sw_breakpoint_from_kind) +{ + gdbarch->sw_breakpoint_from_kind = sw_breakpoint_from_kind; +} + void gdbarch_remote_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *kindptr) { |