aboutsummaryrefslogtreecommitdiff
path: root/gdb/ax-gdb.c
diff options
context:
space:
mode:
authorStan Shebs <shebs@codesourcery.com>2011-11-02 23:44:21 +0000
committerStan Shebs <shebs@codesourcery.com>2011-11-02 23:44:21 +0000
commit3065dfb6b4e2e605b3601c5f71fa25de5dd4970e (patch)
treeac641720c021164a841a9c669e88e599134191e6 /gdb/ax-gdb.c
parent39f4f51d8bf1d516a5cca652a1d9efe8f3ef9863 (diff)
downloadgdb-3065dfb6b4e2e605b3601c5f71fa25de5dd4970e.zip
gdb-3065dfb6b4e2e605b3601c5f71fa25de5dd4970e.tar.gz
gdb-3065dfb6b4e2e605b3601c5f71fa25de5dd4970e.tar.bz2
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/ax-gdb.c')
-rw-r--r--gdb/ax-gdb.c50
1 files changed, 47 insertions, 3 deletions
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index bd8800c..e59c735 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -42,6 +42,9 @@
#include "cp-support.h"
#include "arch-utils.h"
+#include "valprint.h"
+#include "c-lang.h"
+
/* To make sense of this file, you should read doc/agentexpr.texi.
Then look at the types and enums in ax-gdb.h. For the code itself,
look at gen_expr, towards the bottom; that's the main function that
@@ -335,6 +338,11 @@ maybe_const_expr (union exp_element **pc)
emits the trace bytecodes at the appropriate points. */
int trace_kludge;
+/* Inspired by trace_kludge, this indicates that pointers to chars
+ should get an added tracenz bytecode to record nonzero bytes, up to
+ a length that is the value of trace_string_kludge. */
+int trace_string_kludge;
+
/* Scan for all static fields in the given class, including any base
classes, and generate tracing bytecodes for each. */
@@ -393,19 +401,35 @@ static void
gen_traced_pop (struct gdbarch *gdbarch,
struct agent_expr *ax, struct axs_value *value)
{
+ int string_trace = 0;
+ if (trace_string_kludge
+ && TYPE_CODE (value->type) == TYPE_CODE_PTR
+ && c_textual_element_type (check_typedef (TYPE_TARGET_TYPE (value->type)),
+ 's'))
+ string_trace = 1;
+
if (trace_kludge)
switch (value->kind)
{
case axs_rvalue:
- /* We don't trace rvalues, just the lvalues necessary to
- produce them. So just dispose of this value. */
- ax_simple (ax, aop_pop);
+ if (string_trace)
+ {
+ ax_const_l (ax, trace_string_kludge);
+ ax_simple (ax, aop_tracenz);
+ }
+ else
+ /* We don't trace rvalues, just the lvalues necessary to
+ produce them. So just dispose of this value. */
+ ax_simple (ax, aop_pop);
break;
case axs_lvalue_memory:
{
int length = TYPE_LENGTH (check_typedef (value->type));
+ if (string_trace)
+ ax_simple (ax, aop_dup);
+
/* There's no point in trying to use a trace_quick bytecode
here, since "trace_quick SIZE pop" is three bytes, whereas
"const8 SIZE trace" is also three bytes, does the same
@@ -413,6 +437,13 @@ gen_traced_pop (struct gdbarch *gdbarch,
work correctly for objects with large sizes. */
ax_const_l (ax, length);
ax_simple (ax, aop_trace);
+
+ if (string_trace)
+ {
+ ax_simple (ax, aop_ref32);
+ ax_const_l (ax, trace_string_kludge);
+ ax_simple (ax, aop_tracenz);
+ }
}
break;
@@ -422,6 +453,15 @@ gen_traced_pop (struct gdbarch *gdbarch,
larger than will fit in a stack, so just mark it for
collection and be done with it. */
ax_reg_mask (ax, value->u.reg);
+
+ /* But if the register points to a string, assume the value
+ will fit on the stack and push it anyway. */
+ if (string_trace)
+ {
+ ax_reg (ax, value->u.reg);
+ ax_const_l (ax, trace_string_kludge);
+ ax_simple (ax, aop_tracenz);
+ }
break;
}
else
@@ -2489,6 +2529,10 @@ agent_command (char *exp, int from_tty)
if (exp == 0)
error_no_arg (_("expression to translate"));
+ trace_string_kludge = 0;
+ if (*exp == '/')
+ exp = decode_agent_options (exp);
+
/* Recognize the return address collection directive specially. Note
that it is not really an expression of any sort. */
if (strcmp (exp, "$_ret") == 0)