aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Shebs <shebs@codesourcery.com>2009-12-30 16:11:08 +0000
committerStan Shebs <shebs@codesourcery.com>2009-12-30 16:11:08 +0000
commit236f1d4defb2070d3e43ce406604da7659860b38 (patch)
tree52a055eebedde94394340cff1c0be1a648d388f6
parent176fe33f0d2b5c96ea89acba35b684757bdf6e52 (diff)
downloadgdb-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.
-rw-r--r--gdb/ChangeLog10
-rw-r--r--gdb/NEWS6
-rw-r--r--gdb/doc/ChangeLog4
-rw-r--r--gdb/doc/gdb.texinfo16
-rw-r--r--gdb/testsuite/ChangeLog4
-rw-r--r--gdb/testsuite/gdb.trace/actions.exp9
-rw-r--r--gdb/tracepoint.c50
7 files changed, 94 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 64b9e17..5c9586b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
+2009-12-30 Stan Shebs <stan@codesourcery.com>
+
+ 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.
+
2009-12-29 Stan Shebs <stan@codesourcery.com>
* language.c (pointer_type): Un-comment out.
diff --git a/gdb/NEWS b/gdb/NEWS
index b680d9b..eb84ee7 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -105,6 +105,12 @@ show follow-exec-mode
creates a new one. This is useful to be able to restart the old
executable after the inferior having done an exec call.
+set default-collect EXPR, ...
+show default-collect
+ Define a list of expressions to be collected at each tracepoint.
+ This is a useful way to ensure essential items are not overlooked,
+ such as registers or a critical global variable.
+
* New remote packets
QTDV
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index d02f7ec..7171423 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,7 @@
+2009-12-29 Stan Shebs <stan@codesourcery.com>
+
+ * gdb.texinfo (Tracepoint Actions): Describe default-collect.
+
2009-12-28 Stan Shebs <stan@codesourcery.com>
* gdb.texinfo (Trace State Variables): New section.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 7d3a35c..39f0d67 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -9643,6 +9643,22 @@ its own @code{end} command):
@noindent
You may abbreviate @code{while-stepping} as @code{ws} or
@code{stepping}.
+
+@item set default-collect @var{expr1}, @var{expr2}, @dots{}
+@kindex set default-collect
+@cindex default collection action
+This variable is a list of expressions to collect at each tracepoint
+hit. It is effectively an additional @code{collect} action prepended
+to every tracepoint action list. The expressions are parsed
+individually for each tracepoint, so for instance a variable named
+@code{xyz} may be interpreted as a global for one tracepoint, and a
+local for another, as appropriate to the tracepoint's location.
+
+@item show default-collect
+@kindex show default-collect
+Show the list of expressions that are collected by default at each
+tracepoint hit.
+
@end table
@node Listing Tracepoints
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index a170dcf..13da3d3 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2009-12-29 Stan Shebs <stan@codesourcery.com>
+
+ * gdb.trace/actions.exp: Test default-collect.
+
2009-12-28 Stan Shebs <stan@codesourcery.com>
* gdb.trace/tsv.exp: New file.
diff --git a/gdb/testsuite/gdb.trace/actions.exp b/gdb/testsuite/gdb.trace/actions.exp
index b22b210..bb7277f 100644
--- a/gdb/testsuite/gdb.trace/actions.exp
+++ b/gdb/testsuite/gdb.trace/actions.exp
@@ -203,3 +203,12 @@ gdb_test "help while-stepping" \
gdb_test "help end" "Ends a list of commands or actions.*" \
"5.8d: help end"
+# 5.9 default-collect
+
+gdb_test "set default-collect gdb_char_test, gdb_long_test - 100" \
+ "" \
+ "5.9a: set default-collect"
+
+gdb_test "show default-collect" \
+ "The list of expressions to collect by default is \"gdb_char_test, gdb_long_test - 100\"..*" \
+ "5.9b: show default-collect"
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);
}