From a1dcb23a280b453738e569f0f7674dbd8ca39933 Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Mon, 1 Feb 2010 16:09:22 +0000 Subject: [PATCH] * arch-utils.c (default_remote_breakpoint_from_pc): New function. * arch-utils.h (default_remote_breakpoint_from_pc): Declare. * gdbarch.c, gdbarch.h: Regenerated. * gdbarch.sh (remote_breakpoint_from_pc): New architecture method. * remote.c (remote_insert_breakpoint, remote_insert_hw_breakpoint): Use gdbarch_remote_breakpoint_from_pc. doc/ * gdb.texinfo (Architecture-Specific Protocol Details): New section. Document ARM breakpoint types. (Register Packet Format): Move into the new section. (Packets): Describe the KIND argument for Z0, z0, Z1, and z1 packets. --- gdb/ChangeLog | 9 +++++ gdb/arch-utils.c | 7 ++++ gdb/arch-utils.h | 3 ++ gdb/doc/ChangeLog | 7 ++++ gdb/doc/gdb.texinfo | 84 +++++++++++++++++++++++++++++++-------------- gdb/gdbarch.c | 25 ++++++++++++++ gdb/gdbarch.h | 8 +++++ gdb/gdbarch.sh | 4 +++ gdb/remote.c | 4 +-- 9 files changed, 123 insertions(+), 28 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 45d1e619740..ee0a8f3f458 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2010-02-01 Daniel Jacobowitz + + * arch-utils.c (default_remote_breakpoint_from_pc): New function. + * arch-utils.h (default_remote_breakpoint_from_pc): Declare. + * gdbarch.c, gdbarch.h: Regenerated. + * gdbarch.sh (remote_breakpoint_from_pc): New architecture method. + * remote.c (remote_insert_breakpoint, remote_insert_hw_breakpoint): Use + gdbarch_remote_breakpoint_from_pc. + 2010-01-29 Daniel Jacobowitz * infrun.c (prepare_to_proceed): Handle other signals which might diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 55011754bcd..765312d8c45 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -776,6 +776,13 @@ default_fast_tracepoint_valid_at (struct gdbarch *gdbarch, return 1; } +void +default_remote_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, + int *kindptr) +{ + gdbarch_breakpoint_from_pc (gdbarch, pcptr, kindptr); +} + /* */ extern initialize_file_ftype _initialize_gdbarch_utils; /* -Wmissing-prototypes */ diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h index 6fee1e57faa..d5d7f1db54f 100644 --- a/gdb/arch-utils.h +++ b/gdb/arch-utils.h @@ -159,4 +159,7 @@ extern int default_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr, int *isize, char **msg); +extern void default_remote_breakpoint_from_pc (struct gdbarch *, + CORE_ADDR *pcptr, int *kindptr); + #endif diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 300ac23e3fb..adeed1adac0 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,10 @@ +2010-02-01 Daniel Jacobowitz + + * gdb.texinfo (Architecture-Specific Protocol Details): New section. + Document ARM breakpoint types. + (Register Packet Format): Move into the new section. + (Packets): Describe the KIND argument for Z0, z0, Z1, and z1 packets. + 2010-01-21 Joel Brobecker * gdb.texinfo (File Options): Adjust the documentation of this diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index fc11609122f..2145f2b7ef2 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -28422,7 +28422,7 @@ Show the current setting of the target wait timeout. * Packets:: * Stop Reply Packets:: * General Query Packets:: -* Register Packet Format:: +* Architecture-Specific Protocol Details:: * Tracepoint Packets:: * Host I/O Packets:: * Interrupts:: @@ -29169,14 +29169,13 @@ for success for an error @end table -@item z @var{type},@var{addr},@var{length} -@itemx Z @var{type},@var{addr},@var{length} +@item z @var{type},@var{addr},@var{kind} +@itemx Z @var{type},@var{addr},@var{kind} @anchor{insert breakpoint or watchpoint packet} @cindex @samp{z} packet @cindex @samp{Z} packets Insert (@samp{Z}) or remove (@samp{z}) a @var{type} breakpoint or -watchpoint starting at address @var{address} and covering the next -@var{length} bytes. +watchpoint starting at address @var{address} of kind @var{kind}. Each breakpoint and watchpoint packet @var{type} is documented separately. @@ -29188,18 +29187,20 @@ remote target shall support either both or neither of a given avoid potential problems with duplicate packets, the operations should be implemented in an idempotent way.} -@item z0,@var{addr},@var{length} -@itemx Z0,@var{addr},@var{length} +@item z0,@var{addr},@var{kind} +@itemx Z0,@var{addr},@var{kind} @cindex @samp{z0} packet @cindex @samp{Z0} packet Insert (@samp{Z0}) or remove (@samp{z0}) a memory breakpoint at address -@var{addr} of size @var{length}. +@var{addr} of type @var{kind}. A memory breakpoint is implemented by replacing the instruction at @var{addr} with a software breakpoint or trap instruction. The -@var{length} is used by targets that indicates the size of the -breakpoint (in bytes) that should be inserted (e.g., the @sc{arm} and -@sc{mips} can insert either a 2 or 4 byte breakpoint). +@var{kind} is target-specific and typically indicates the size of +the breakpoint in bytes that should be inserted. E.g., the @sc{arm} +and @sc{mips} can insert either a 2 or 4 byte breakpoint. Some +architectures have additional meanings for @var{kind}; +see @ref{Architecture-Specific Protocol Details}. @emph{Implementation note: It is possible for a target to copy or move code that contains memory breakpoints (e.g., when implementing @@ -29216,15 +29217,16 @@ not supported for an error @end table -@item z1,@var{addr},@var{length} -@itemx Z1,@var{addr},@var{length} +@item z1,@var{addr},@var{kind} +@itemx Z1,@var{addr},@var{kind} @cindex @samp{z1} packet @cindex @samp{Z1} packet Insert (@samp{Z1}) or remove (@samp{z1}) a hardware breakpoint at -address @var{addr} of size @var{length}. +address @var{addr}. A hardware breakpoint is implemented using a mechanism that is not -dependant on being able to modify the target's memory. +dependant on being able to modify the target's memory. @var{kind} +has the same meaning as in @samp{Z0} packets. @emph{Implementation note: A hardware breakpoint is not affected by code movement.} @@ -29239,11 +29241,12 @@ not supported for an error @end table -@item z2,@var{addr},@var{length} -@itemx Z2,@var{addr},@var{length} +@item z2,@var{addr},@var{kind} +@itemx Z2,@var{addr},@var{kind} @cindex @samp{z2} packet @cindex @samp{Z2} packet -Insert (@samp{Z2}) or remove (@samp{z2}) a write watchpoint. +Insert (@samp{Z2}) or remove (@samp{z2}) a write watchpoint at @var{addr}. +@var{kind} is interpreted as the number of bytes to watch. Reply: @table @samp @@ -29255,11 +29258,12 @@ not supported for an error @end table -@item z3,@var{addr},@var{length} -@itemx Z3,@var{addr},@var{length} +@item z3,@var{addr},@var{kind} +@itemx Z3,@var{addr},@var{kind} @cindex @samp{z3} packet @cindex @samp{Z3} packet -Insert (@samp{Z3}) or remove (@samp{z3}) a read watchpoint. +Insert (@samp{Z3}) or remove (@samp{z3}) a read watchpoint at @var{addr}. +@var{kind} is interpreted as the number of bytes to watch. Reply: @table @samp @@ -29271,11 +29275,12 @@ not supported for an error @end table -@item z4,@var{addr},@var{length} -@itemx Z4,@var{addr},@var{length} +@item z4,@var{addr},@var{kind} +@itemx Z4,@var{addr},@var{kind} @cindex @samp{z4} packet @cindex @samp{Z4} packet -Insert (@samp{Z4}) or remove (@samp{z4}) an access watchpoint. +Insert (@samp{Z4}) or remove (@samp{z4}) an access watchpoint at @var{addr}. +@var{kind} is interpreted as the number of bytes to watch. Reply: @table @samp @@ -30338,8 +30343,35 @@ A badly formed request or an error was encountered. @end table -@node Register Packet Format -@section Register Packet Format +@node Architecture-Specific Protocol Details +@section Architecture-Specific Protocol Details + +This section describes how the remote protocol is applied to specific +target architectures. Also see @ref{Standard Target Features}, for +details of XML target descriptions for each architecture. + +@subsection ARM + +@subsubsection Breakpoint Kinds + +These breakpoint kinds are defined for the @samp{Z0} and @samp{Z1} packets. + +@table @r + +@item 2 +16-bit Thumb mode breakpoint. + +@item 3 +32-bit Thumb mode (Thumb-2) breakpoint. + +@item 4 +32-bit ARM mode breakpoint. + +@end table + +@subsection MIPS + +@subsubsection Register Packet Format The following @code{g}/@code{G} packets have previously been defined. In the below, some thirty-two bit registers are transferred as diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 9d7702758f4..e0736761891 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -188,6 +188,7 @@ struct gdbarch gdbarch_skip_main_prologue_ftype *skip_main_prologue; gdbarch_inner_than_ftype *inner_than; gdbarch_breakpoint_from_pc_ftype *breakpoint_from_pc; + 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; gdbarch_memory_remove_breakpoint_ftype *memory_remove_breakpoint; @@ -330,6 +331,7 @@ struct gdbarch startup_gdbarch = 0, /* skip_main_prologue */ 0, /* inner_than */ 0, /* breakpoint_from_pc */ + default_remote_breakpoint_from_pc, /* remote_breakpoint_from_pc */ 0, /* adjust_breakpoint_address */ default_memory_insert_breakpoint, /* memory_insert_breakpoint */ default_memory_remove_breakpoint, /* memory_remove_breakpoint */ @@ -456,6 +458,7 @@ gdbarch_alloc (const struct gdbarch_info *info, gdbarch->value_from_register = default_value_from_register; gdbarch->pointer_to_address = unsigned_pointer_to_address; gdbarch->address_to_pointer = unsigned_address_to_pointer; + 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; gdbarch->remote_register_number = default_remote_register_number; @@ -593,6 +596,8 @@ 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->remote_breakpoint_from_pc == default_remote_breakpoint_from_pc) + fprintf_unfiltered (log, "\n\tremote_breakpoint_from_pc"); /* Skip verify of adjust_breakpoint_address, has predicate */ /* Skip verify of memory_insert_breakpoint, invalid_p == 0 */ /* Skip verify of memory_remove_breakpoint, invalid_p == 0 */ @@ -1066,6 +1071,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) fprintf_unfiltered (file, "gdbarch_dump: regset_from_core_section = <%s>\n", host_address_to_string (gdbarch->regset_from_core_section)); + fprintf_unfiltered (file, + "gdbarch_dump: remote_breakpoint_from_pc = <%s>\n", + host_address_to_string (gdbarch->remote_breakpoint_from_pc)); fprintf_unfiltered (file, "gdbarch_dump: remote_register_number = <%s>\n", host_address_to_string (gdbarch->remote_register_number)); @@ -2284,6 +2292,23 @@ set_gdbarch_breakpoint_from_pc (struct gdbarch *gdbarch, gdbarch->breakpoint_from_pc = breakpoint_from_pc; } +void +gdbarch_remote_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *kindptr) +{ + gdb_assert (gdbarch != NULL); + gdb_assert (gdbarch->remote_breakpoint_from_pc != NULL); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_remote_breakpoint_from_pc called\n"); + gdbarch->remote_breakpoint_from_pc (gdbarch, pcptr, kindptr); +} + +void +set_gdbarch_remote_breakpoint_from_pc (struct gdbarch *gdbarch, + gdbarch_remote_breakpoint_from_pc_ftype remote_breakpoint_from_pc) +{ + gdbarch->remote_breakpoint_from_pc = remote_breakpoint_from_pc; +} + int gdbarch_adjust_breakpoint_address_p (struct gdbarch *gdbarch) { diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 18267c9c5fe..661d34bc2a0 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -407,6 +407,14 @@ typedef const gdb_byte * (gdbarch_breakpoint_from_pc_ftype) (struct gdbarch *gdb extern const gdb_byte * gdbarch_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr); extern void set_gdbarch_breakpoint_from_pc (struct gdbarch *gdbarch, gdbarch_breakpoint_from_pc_ftype *breakpoint_from_pc); +/* Return the adjusted address and kind to use for Z0/Z1 packets. + KIND is usually the memory length of the breakpoint, but may have a + different target-specific meaning. */ + +typedef void (gdbarch_remote_breakpoint_from_pc_ftype) (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *kindptr); +extern void gdbarch_remote_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *kindptr); +extern void set_gdbarch_remote_breakpoint_from_pc (struct gdbarch *gdbarch, gdbarch_remote_breakpoint_from_pc_ftype *remote_breakpoint_from_pc); + extern int gdbarch_adjust_breakpoint_address_p (struct gdbarch *gdbarch); typedef CORE_ADDR (gdbarch_adjust_breakpoint_address_ftype) (struct gdbarch *gdbarch, CORE_ADDR bpaddr); diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 9474addc5c5..6bcf473e130 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -486,6 +486,10 @@ m:CORE_ADDR:skip_prologue:CORE_ADDR ip:ip:0:0 M:CORE_ADDR:skip_main_prologue:CORE_ADDR ip:ip 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: +# Return the adjusted address and kind to use for Z0/Z1 packets. +# KIND is usually the memory length of the breakpoint, but may have a +# different target-specific meaning. +m:void:remote_breakpoint_from_pc:CORE_ADDR *pcptr, int *kindptr:pcptr, kindptr::default_remote_breakpoint_from_pc: M:CORE_ADDR:adjust_breakpoint_address:CORE_ADDR bpaddr:bpaddr 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 diff --git a/gdb/remote.c b/gdb/remote.c index 2cee1b0c3a0..bf7568cb4d5 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -7245,7 +7245,7 @@ remote_insert_breakpoint (struct gdbarch *gdbarch, char *p; int bpsize; - gdbarch_breakpoint_from_pc (gdbarch, &addr, &bpsize); + gdbarch_remote_breakpoint_from_pc (gdbarch, &addr, &bpsize); rs = get_remote_state (); p = rs->buf; @@ -7447,7 +7447,7 @@ remote_insert_hw_breakpoint (struct gdbarch *gdbarch, /* The length field should be set to the size of a breakpoint instruction, even though we aren't inserting one ourselves. */ - gdbarch_breakpoint_from_pc + gdbarch_remote_breakpoint_from_pc (gdbarch, &bp_tgt->placed_address, &bp_tgt->placed_size); if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE) -- 2.30.2