diff options
author | Stan Shebs <shebs@codesourcery.com> | 2009-12-30 16:11:08 +0000 |
---|---|---|
committer | Stan Shebs <shebs@codesourcery.com> | 2009-12-30 16:11:08 +0000 |
commit | 236f1d4defb2070d3e43ce406604da7659860b38 (patch) | |
tree | 52a055eebedde94394340cff1c0be1a648d388f6 /gdb/tracepoint.c | |
parent | 176fe33f0d2b5c96ea89acba35b684757bdf6e52 (diff) | |
download | gdb-236f1d4defb2070d3e43ce406604da7659860b38.zip gdb-236f1d4defb2070d3e43ce406604da7659860b38.tar.gz gdb-236f1d4defb2070d3e43ce406604da7659860b38.tar.bz2 |
Add default-collect variable.
* tracepoint.c (default_collect): New global.
(encode_actions): Use it.
(download_tracepoint): Test it, for otherwise
action-less tracepoints.
(_initialize_tracepoint): Add set/show.
* NEWS: Mention default-collect.
* gdb.texinfo (Tracepoint Actions): Describe default-collect.
* gdb.trace/actions.exp: Test default-collect.
Diffstat (limited to 'gdb/tracepoint.c')
-rw-r--r-- | gdb/tracepoint.c | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 702d348..2e3e2e8 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -140,9 +140,12 @@ static struct symtab_and_line traceframe_sal; /* Tracing command lists */ static struct cmd_list_element *tfindlist; +/* List of expressions to collect by default at each tracepoint hit. */ +static char *default_collect = ""; + static char *target_buf; static long target_buf_size; - + /* ======= Important command functions: ======= */ static void trace_actions_command (char *, int); static void trace_start_command (char *, int); @@ -1285,7 +1288,8 @@ encode_actions (struct breakpoint *t, char ***tdp_actions, struct agent_expr *aexpr; int frame_reg; LONGEST frame_offset; - + char *default_collect_line = NULL; + struct action_line *default_collect_action = NULL; clear_collection_list (&tracepoint_list); clear_collection_list (&stepping_list); @@ -1297,7 +1301,32 @@ encode_actions (struct breakpoint *t, char ***tdp_actions, gdbarch_virtual_frame_pointer (t->gdbarch, t->loc->address, &frame_reg, &frame_offset); - for (action = t->actions; action; action = action->next) + action = t->actions; + + /* If there are default expressions to collect, make up a collect + action and prepend to the action list to encode. Note that since + validation is per-tracepoint (local var "xyz" might be valid for + one tracepoint and not another, etc), we make up the action on + the fly, and don't cache it. */ + if (*default_collect) + { + char *line; + enum actionline_type linetype; + + default_collect_line = xmalloc (12 + strlen (default_collect)); + sprintf (default_collect_line, "collect %s", default_collect); + line = default_collect_line; + linetype = validate_actionline (&line, t); + if (linetype != BADLINE) + { + default_collect_action = xmalloc (sizeof (struct action_line)); + default_collect_action->next = t->actions; + default_collect_action->action = line; + action = default_collect_action; + } + } + + for (; action; action = action->next) { QUIT; /* allow user to bail out with ^C */ action_exp = action->action; @@ -1454,6 +1483,9 @@ encode_actions (struct breakpoint *t, char ***tdp_actions, tdp_buff); *stepping_actions = stringify_collection_list (&stepping_list, step_buff); + + xfree (default_collect_line); + xfree (default_collect_action); } static void @@ -1616,14 +1648,14 @@ download_tracepoint (struct breakpoint *t) warning (_("Target does not support conditional tracepoints, ignoring tp %d cond"), t->number); } - if (t->actions) + if (t->actions || *default_collect) strcat (buf, "-"); putpkt (buf); remote_get_noisy_reply (&target_buf, &target_buf_size); if (strcmp (target_buf, "OK")) error (_("Target does not support tracepoints.")); - if (!t->actions) + if (!t->actions && !*default_collect) return; encode_actions (t, &tdp_actions, &stepping_actions); @@ -2568,6 +2600,14 @@ Tracepoint actions may include collecting of specified data, \n\ single-stepping, or enabling/disabling other tracepoints, \n\ depending on target's capabilities.")); + default_collect = xstrdup (""); + add_setshow_string_cmd ("default-collect", class_trace, + &default_collect, _("\ +Set the list of expressions to collect by default"), _("\ +Show the list of expressions to collect by default"), NULL, + NULL, NULL, + &setlist, &showlist); + target_buf_size = 2048; target_buf = xmalloc (target_buf_size); } |