diff options
author | Kwok Yeung <kcy@sourceware.org> | 2011-05-12 12:09:17 +0000 |
---|---|---|
committer | Kwok Yeung <kcy@sourceware.org> | 2011-05-12 12:09:17 +0000 |
commit | d248b706a328fbba18c4320880b36df5488b1e91 (patch) | |
tree | 4147e6bb3093b75c1a62833173b0213b060505bf /gdb/gdbserver | |
parent | de1491f042ec18741bc7427aeb69d9c5ffa1cbd7 (diff) | |
download | gdb-d248b706a328fbba18c4320880b36df5488b1e91.zip gdb-d248b706a328fbba18c4320880b36df5488b1e91.tar.gz gdb-d248b706a328fbba18c4320880b36df5488b1e91.tar.bz2 |
Add support for enabling and disabling tracepoints while a trace
experiment is still running.
gdb/
* breakpoint.c (disable_breakpoint): Disable all locations
associated with a tracepoint on target if a trace experiment is
running.
(disable_command): Disable a specific tracepoint location on target if
a trace experiment is running.
(do_enable_breakpoint): Enable all locations associated with a
tracepoint on target if a trace experiment is running.
(enable_command) Enable a specific tracepoint location on target if a
trace experiment is running.
* target.c (update_current_target): Add INHERIT and de_fault clauses for
to_supports_enable_disable_tracepoint, to_enable_tracepoint and
to_disable_tracepoint.
* target.h: Add declaration of struct bp_location.
(struct target_ops): Add new functions
to_supports_enable_disable_tracepoint, to_enable_tracepoint and
to_disable_tracepoint to target operations.
(target_supports_enable_disable_tracepoint): New macro.
(target_enable_tracepoint): New macro.
(target_disable_tracepoint): New macro.
* remote.c (struct remote_state): Add new field.
(remote_enable_disable_tracepoint_feature): New.
(remote_protocol_features): Add new entry.
(remote_supports_enable_disable_tracepoint): New.
(remote_enable_tracepoint): New.
(remote_disable_tracepoint): New.
(init_remote_ops): Add remote_enable_tracepoint,
remote_disable_tracepoint and remote_supports_enable_disable_tracepoint
to remote operations.
* tracepoint.c (start_tracing): Allow tracing to start without any
tracepoints enabled with just a warning if they can be re-enabled
later.
* NEWS: Add news item for the new behaviour of the enable and disable
GDB commands when applied to tracepoints.
Add news items for the new remote packets QTEnable and QTDisable.
gdb/doc/
* gdb.texinfo: Document change in the behaviour of the enable and
disable GDB commands when applied to tracepoints.
Document the EnableDisableTracepoints remote stub feature.
Document QTEnable and QTDisable in the list of tracepoint packets.
gdb/gdbserver/
* server.c (handle_query): Add EnableDisableTracepoints to the list
of supported features.
* tracepoint.c (clear_installed_tracepoints): Uninstall disabled
tracepoints.
(cmd_qtenable_disable): New.
(cmd_qtstart): Install tracepoints even if disabled.
(handle_tracepoint_general_set): Add call to cmd_qtenable_disable on
receiving a QTEnable or QTDisable packet.
(gdb_collect): Skip data collection if fast tracepoint is disabled.
(ust_marker_to_static_tracepoint): Do not ignore disabled static
tracepoints.
(gdb_probe): Skip data collection if static tracepoint is disabled.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 15 | ||||
-rw-r--r-- | gdb/gdbserver/server.c | 1 | ||||
-rw-r--r-- | gdb/gdbserver/tracepoint.c | 94 |
3 files changed, 103 insertions, 7 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index bea804d..c5ae99f 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,18 @@ +2011-05-12 Kwok Cheung Yeung <kcy@codesourcery.com> + + * server.c (handle_query): Add EnableDisableTracepoints to the list + of supported features. + * tracepoint.c (clear_installed_tracepoints): Uninstall disabled + tracepoints. + (cmd_qtenable_disable): New. + (cmd_qtstart): Install tracepoints even if disabled. + (handle_tracepoint_general_set): Add call to cmd_qtenable_disable on + receiving a QTEnable or QTDisable packet. + (gdb_collect): Skip data collection if fast tracepoint is disabled. + (ust_marker_to_static_tracepoint): Do not ignore disabled static + tracepoints. + (gdb_probe): Skip data collection if static tracepoint is disabled. + 2011-05-10 Doug Evans <dje@google.com> * thread-db.c (thread_db_handle_monitor_command): Handle elided path. diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 6bf6eaa..fd06c8f 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -1540,6 +1540,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p) strcat (own_buf, ";StaticTracepoints+"); strcat (own_buf, ";qXfer:statictrace:read+"); strcat (own_buf, ";qXfer:traceframe-info:read+"); + strcat (own_buf, ";EnableDisableTracepoints+"); } return; diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c index 0916835..dc1050e 100644 --- a/gdb/gdbserver/tracepoint.c +++ b/gdb/gdbserver/tracepoint.c @@ -2214,9 +2214,6 @@ clear_installed_tracepoints (void) /* Restore any bytes overwritten by tracepoints. */ for (tpoint = tracepoints; tpoint; tpoint = tpoint->next) { - if (!tpoint->enabled) - continue; - /* Catch the case where we might try to remove a tracepoint that was never actually installed. */ if (tpoint->handle == NULL) @@ -2455,6 +2452,73 @@ cmd_qtdv (char *own_buf) } static void +cmd_qtenable_disable (char *own_buf, int enable) +{ + char *packet = own_buf; + ULONGEST num, addr; + struct tracepoint *tp; + + packet += strlen (enable ? "QTEnable:" : "QTDisable:"); + packet = unpack_varlen_hex (packet, &num); + ++packet; /* skip a colon */ + packet = unpack_varlen_hex (packet, &addr); + + tp = find_tracepoint (num, addr); + + if (tp) + { + if ((enable && tp->enabled) || (!enable && !tp->enabled)) + { + trace_debug ("Tracepoint %d at 0x%s is already %s", + (int) num, paddress (addr), + enable ? "enabled" : "disabled"); + write_ok (own_buf); + return; + } + + trace_debug ("%s tracepoint %d at 0x%s", + enable ? "Enabling" : "Disabling", + (int) num, paddress (addr)); + + tp->enabled = enable; + + if (tp->type == fast_tracepoint || tp->type == static_tracepoint) + { + int ret; + int offset = offsetof (struct tracepoint, enabled); + CORE_ADDR obj_addr = tp->obj_addr_on_target + offset; + + ret = prepare_to_access_memory (); + if (ret) + { + trace_debug ("Failed to temporarily stop inferior threads"); + write_enn (own_buf); + return; + } + + ret = write_inferior_integer (obj_addr, enable); + done_accessing_memory (); + + if (ret) + { + trace_debug ("Cannot write enabled flag into " + "inferior process memory"); + write_enn (own_buf); + return; + } + } + + write_ok (own_buf); + } + else + { + trace_debug ("Tracepoint %d at 0x%s not found", + (int) num, paddress (addr)); + write_enn (own_buf); + } +} + +static void cmd_qtv (char *own_buf) { ULONGEST num; @@ -2719,9 +2783,6 @@ cmd_qtstart (char *packet) /* Ensure all the hit counts start at zero. */ tpoint->hit_count = 0; - if (!tpoint->enabled) - continue; - if (tpoint->type == trap_tracepoint) { ++slow_tracepoint_count; @@ -3461,6 +3522,16 @@ handle_tracepoint_general_set (char *packet) cmd_qtdpsrc (packet); return 1; } + else if (strncmp ("QTEnable:", packet, strlen ("QTEnable:")) == 0) + { + cmd_qtenable_disable (packet, 1); + return 1; + } + else if (strncmp ("QTDisable:", packet, strlen ("QTDisable:")) == 0) + { + cmd_qtenable_disable (packet, 0); + return 1; + } else if (strncmp ("QTDV:", packet, strlen ("QTDV:")) == 0) { cmd_qtdv (packet); @@ -5340,6 +5411,9 @@ gdb_collect (struct tracepoint *tpoint, unsigned char *regs) if (!tracing) return; + if (!tpoint->enabled) + return; + ctx.base.type = fast_tracepoint; ctx.regs = regs; ctx.regcache_initted = 0; @@ -6598,7 +6672,7 @@ ust_marker_to_static_tracepoint (const struct marker *mdata) for (tpoint = tracepoints; tpoint; tpoint = tpoint->next) { - if (!tpoint->enabled || tpoint->type != static_tracepoint) + if (tpoint->type != static_tracepoint) continue; if (tpoint->address == (uintptr_t) mdata->location) @@ -6653,6 +6727,12 @@ gdb_probe (const struct marker *mdata, void *probe_private, return; } + if (!tpoint->enabled) + { + trace_debug ("gdb_probe: tracepoint disabled"); + return; + } + ctx.tpoint = tpoint; trace_debug ("gdb_probe: collecting marker: " |