diff options
Diffstat (limited to 'gdb/gdbserver/tracepoint.c')
-rw-r--r-- | gdb/gdbserver/tracepoint.c | 94 |
1 files changed, 87 insertions, 7 deletions
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: " |