aboutsummaryrefslogtreecommitdiff
path: root/gdb/tracepoint.c
diff options
context:
space:
mode:
authorStan Shebs <shebs@codesourcery.com>2009-07-14 21:40:34 +0000
committerStan Shebs <shebs@codesourcery.com>2009-07-14 21:40:34 +0000
commit782b2b07842dcec0cbd9c4248b155d7acf8c8dbe (patch)
treeac5c0fb0117ac15be913c0fa20a659ec90ef1028 /gdb/tracepoint.c
parentf662c3bce4df8aa5361122ea49dec9ee0e14dfad (diff)
downloadgdb-782b2b07842dcec0cbd9c4248b155d7acf8c8dbe.zip
gdb-782b2b07842dcec0cbd9c4248b155d7acf8c8dbe.tar.gz
gdb-782b2b07842dcec0cbd9c4248b155d7acf8c8dbe.tar.bz2
gdb/
Conditional tracepoints. * ax-gdb.h (gen_eval_for_expr): Declare. * ax-gdb.c (gen_expr): Generate bytecodes for BINOP_EQUAL and other comparisons. (gen_eval_for_expr): New function. (agent_eval_command): New maintenance command. (_initialize_ax_gdb): Define the command. * remote.c (struct remote_state): New field cond_tracepoints. (PACKET_ConditionalTracepoints): New packet config type. (remote_cond_tracepoint_feature): New function. (remote_protocol_features): Add ConditionalTracepoints. (remote_supports_cond_tracepoints): New function. (_initialize_remote): Add ConditionalTracepoints. * tracepoint.c (download_tracepoint): Add conditional. * NEWS: Mention conditional tracepoints. gdb/doc/ * gdb.texinfo (Tracepoint Conditions): New section. (General Query Packets): Describe ConditionalTracepoints. (Tracepoint Packets): Describe condition field. (Maintenance Commands): Describe maint agent-eval. * agentexpr.texi (Using Agent Expressions): Mention eval usage. gdb/testsuite/ * gdb.trace/tracecmd.exp: Add basic test of tracepoint conditions.
Diffstat (limited to 'gdb/tracepoint.c')
-rw-r--r--gdb/tracepoint.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 232c9e9..0d439ef 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -33,6 +33,7 @@
#include "breakpoint.h"
#include "tracepoint.h"
#include "remote.h"
+extern int remote_supports_cond_tracepoints (void);
#include "linespec.h"
#include "regcache.h"
#include "completer.h"
@@ -1311,12 +1312,31 @@ download_tracepoint (struct breakpoint *t)
char **stepping_actions;
int ndx;
struct cleanup *old_chain = NULL;
+ struct agent_expr *aexpr;
+ struct cleanup *aexpr_chain = NULL;
sprintf_vma (tmp, (t->loc ? t->loc->address : 0));
sprintf (buf, "QTDP:%x:%s:%c:%lx:%x", t->number,
tmp, /* address */
(t->enable_state == bp_enabled ? 'E' : 'D'),
t->step_count, t->pass_count);
+ /* If the tracepoint has a conditional, make it into an agent
+ expression and append to the definition. */
+ if (t->loc->cond)
+ {
+ /* Only test support at download time, we may not know target
+ capabilities at definition time. */
+ if (remote_supports_cond_tracepoints ())
+ {
+ aexpr = gen_eval_for_expr (t->loc->address, t->loc->cond);
+ aexpr_chain = make_cleanup_free_agent_expr (aexpr);
+ sprintf (buf + strlen (buf), ":X%x,", aexpr->len);
+ mem2hex (aexpr->buf, buf + strlen (buf), aexpr->len);
+ do_cleanups (aexpr_chain);
+ }
+ else
+ warning (_("Target does not support conditional tracepoints, ignoring tp %d cond"), t->number);
+ }
if (t->actions)
strcat (buf, "-");