diff options
author | Stan Shebs <shebs@codesourcery.com> | 2010-01-06 04:20:27 +0000 |
---|---|---|
committer | Stan Shebs <shebs@codesourcery.com> | 2010-01-06 04:20:27 +0000 |
commit | 7a697b8dd7ac3c14e35ae3026d955aeae3ecc054 (patch) | |
tree | 62009f9b707ae6f18c12be8956f7b1e5fc586a7a /gdb/i386-tdep.c | |
parent | 737a160ed9bb7bbe1ac8ebea1cdc27438213c247 (diff) | |
download | gdb-7a697b8dd7ac3c14e35ae3026d955aeae3ecc054.zip gdb-7a697b8dd7ac3c14e35ae3026d955aeae3ecc054.tar.gz gdb-7a697b8dd7ac3c14e35ae3026d955aeae3ecc054.tar.bz2 |
Add fast tracepoints.
* arch-utils.h (default_fast_tracepoint_valid_at): Declare.
* arch-utils.c (default_fast_tracepoint_valid_at): New function.
* breakpoint.h (enum bptype): Add bp_fast_tracepoint.
* breakpoint.c (tracepoint_type): New function.
(ALL_TRACEPOINTS): Use it.
(should_be_inserted): Ditto.
(bpstat_check_location): Ditto.
(print_one_breakpoint_location): Ditto.
(user_settable_breakpoint): Ditto.
(set_breakpoint_location_function): Ditto.
(disable_breakpoints_in_shlibs): Ditto.
(delete_trace_command): Ditto.
(print_it_typical): Add bp_fast_tracepoint case.
(bpstat_what): Ditto.
(print_one_breakpoint_location): Ditto.
(allocate_bp_location): Ditto.
(mention): Ditto.
(breakpoint_re_set_one): Ditto.
(disable_command): Ditto.
(enable_command): Ditto.
(check_fast_tracepoint_sals): New function.
(break_command_really): Call it.
(ftrace_command): New function.
(_initialize_breakpoint): Add ftrace command.
* gdbarch.sh (fast_tracepoint_valid_at): New.
* gdbarch.h, gdbarch.c: Regenerate.
* i386-tdep.c (i386_fast_tracepoint_valid_at): New function.
(i386_gdbarch_init): Use it.
* remote.c (struct remote_state): New field fast_tracepoints.
(PACKET_FastTracepoints): New packet config type.
(remote_fast_tracepoint_feature): New function.
(remote_protocol_features): Add FastTracepoints.
(remote_supports_fast_tracepoints): New function.
(_initialize_remote): Add FastTracepoints.
* tracepoint.c (download_tracepoint): Add fast tracepoint option.
* NEWS: Mention fast tracepoints.
* gdb.texinfo (Create and Delete Tracepoints): Describe fast
tracepoints.
(Tracepoint Packets): Describe remote protocol for fast
tracepoints.
* gdb.trace/tracecmd.exp: Test ftrace.
Diffstat (limited to 'gdb/i386-tdep.c')
-rw-r--r-- | gdb/i386-tdep.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index f4d037c..eea4ff4 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -43,6 +43,7 @@ #include "target.h" #include "value.h" #include "dis-asm.h" +#include "disasm.h" #include "gdb_assert.h" #include "gdb_string.h" @@ -5567,6 +5568,49 @@ static const int i386_record_regmap[] = I386_DS_REGNUM, I386_ES_REGNUM, I386_FS_REGNUM, I386_GS_REGNUM }; +/* Check that the given address appears suitable for a fast + tracepoint, which on x86 means that we need an instruction of at + least 5 bytes, so that we can overwrite it with a 4-byte-offset + jump and not have to worry about program jumps to an address in the + middle of the tracepoint jump. Returns 1 if OK, and writes a size + of instruction to replace, and 0 if not, plus an explanatory + string. */ + +static int +i386_fast_tracepoint_valid_at (struct gdbarch *gdbarch, + CORE_ADDR addr, int *isize, char **msg) +{ + int len, jumplen; + static struct ui_file *gdb_null = NULL; + + /* This is based on the target agent using a 4-byte relative jump. + Alternate future possibilities include 8-byte offset for x86-84, + or 3-byte jumps if the program has trampoline space close by. */ + jumplen = 5; + + /* Dummy file descriptor for the disassembler. */ + if (!gdb_null) + gdb_null = ui_file_new (); + + /* Check for fit. */ + len = gdb_print_insn (gdbarch, addr, gdb_null, NULL); + if (len < jumplen) + { + /* Return a bit of target-specific detail to add to the caller's + generic failure message. */ + if (msg) + *msg = xstrprintf (_("; instruction is only %d bytes long, need at least %d bytes for the jump"), + len, jumplen); + return 0; + } + + if (isize) + *isize = len; + if (msg) + *msg = NULL; + return 1; +} + static struct gdbarch * i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) @@ -5769,6 +5813,9 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_skip_permanent_breakpoint (gdbarch, i386_skip_permanent_breakpoint); + set_gdbarch_fast_tracepoint_valid_at (gdbarch, + i386_fast_tracepoint_valid_at); + return gdbarch; } |