summaryrefslogtreecommitdiff
path: root/gdb/tracepoint.c
diff options
context:
space:
mode:
authorStan Shebs <shebs@apple.com>2011-11-02 23:44:18 +0000
committerStan Shebs <shebs@apple.com>2011-11-02 23:44:18 +0000
commite59629c2737c21734e111d92acde94cbb9d981fd (patch)
tree774d83d13930da4c766aa171cfb8590bb8df84d9 /gdb/tracepoint.c
parent9d6a6f8cbd2e67e8e4b999356a8820f82496da1c (diff)
downloadgdb-e59629c2737c21734e111d92acde94cbb9d981fd.tar.gz
2011-11-02 Stan Shebs <stan@codesourcery.com>
String collection for tracepoints. * NEWS: Mention string collection. * common/ax.def (tracenz): New bytecode. * ax-gdb.h (trace_string_kludge): Declare. * ax-gdb.c: Include valprint.h and c-lang.h. (trace_string_kludge): New global. (gen_traced_pop): Add string case. (agent_command): Add string case. * tracepoint.h (decode_agent_options): Declare. * tracepoint.c: Include cli-utils.h. (decode_agent_options): New function. (validate_actionline): Call it. (encode_actions_1): Ditto. * target.h (struct target_ops): New method to_supports_string_tracing. (target_supports_string_tracing): New macro. * target.c (update_current_target): Add to_supports_string_tracing. * remote.c (struct remote_state): New field string_tracing. (remote_string_tracing_feature): New function. (remote_protocol_features): New feature tracenz. (remote_supports_string_tracing): New function. (init_remote_ops): Set to_supports_string_tracing. * tracepoint.c (agent_mem_read_string): New function. (eval_agent_expr): Call it for tracenz. * server.c (handle_query): Report support for tracenz. * gdb.texinfo (Tracepoint Action Lists): Document collect/s. (General Query Packets): Describe tracenz feature. * agentexpr.texi (Bytecode Descriptions): Describe tracenz. * gdb.trace/collection.c: Add code using strings. * gdb.trace/collection.exp: Add tests of string collection.
Diffstat (limited to 'gdb/tracepoint.c')
-rw-r--r--gdb/tracepoint.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index d88fcd7c995..4ca4ec2a1d5 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -52,6 +52,7 @@
#include "ax-gdb.h"
#include "memrange.h"
#include "exceptions.h"
+#include "cli/cli-utils.h"
/* readline include files */
#include "readline/readline.h"
@@ -574,6 +575,46 @@ teval_pseudocommand (char *args, int from_tty)
error (_("This command can only be used in a tracepoint actions list."));
}
+/* Parse any collection options, such as /s for strings. */
+
+char *
+decode_agent_options (char *exp)
+{
+ struct value_print_options opts;
+
+ if (*exp != '/')
+ return exp;
+
+ /* Call this to borrow the print elements default for collection
+ size. */
+ get_user_print_options (&opts);
+
+ exp++;
+ if (*exp == 's')
+ {
+ if (target_supports_string_tracing ())
+ {
+ /* Allow an optional decimal number giving an explicit maximum
+ string length, defaulting it to the "print elements" value;
+ so "collect/s80 mystr" gets at most 80 bytes of string. */
+ trace_string_kludge = opts.print_max;
+ exp++;
+ if (*exp >= '0' && *exp <= '9')
+ trace_string_kludge = atoi (exp);
+ while (*exp >= '0' && *exp <= '9')
+ exp++;
+ }
+ else
+ error (_("Target does not support \"/s\" option for string tracing."));
+ }
+ else
+ error (_("Undefined collection format \"%c\"."), *exp);
+
+ exp = skip_spaces (exp);
+
+ return exp;
+}
+
/* Enter a list of actions for a tracepoint. */
static void
trace_actions_command (char *args, int from_tty)
@@ -656,6 +697,10 @@ validate_actionline (char **line, struct breakpoint *b)
if (cmd_cfunc_eq (c, collect_pseudocommand))
{
+ trace_string_kludge = 0;
+ if (*p == '/')
+ p = decode_agent_options (p);
+
do
{ /* Repeat over a comma-separated list. */
QUIT; /* Allow user to bail out with ^C. */
@@ -1313,6 +1358,10 @@ encode_actions_1 (struct command_line *action,
if (cmd_cfunc_eq (cmd, collect_pseudocommand))
{
+ trace_string_kludge = 0;
+ if (*action_exp == '/')
+ action_exp = decode_agent_options (action_exp);
+
do
{ /* Repeat over a comma-separated list. */
QUIT; /* Allow user to bail out with ^C. */
@@ -2581,6 +2630,9 @@ trace_dump_actions (struct command_line *action,
STEPPING_ACTIONS should be equal. */
if (stepping_frame == stepping_actions)
{
+ if (*action_exp == '/')
+ action_exp = decode_agent_options (action_exp);
+
do
{ /* Repeat over a comma-separated list. */
QUIT; /* Allow user to bail out with ^C. */