[PATCH v2] tracepoint: add new trace command "printf" and agent expression "printf" [2] gdbserver
Hui Zhu
teawater@gmail.com
Thu Aug 11 06:55:00 GMT 2011
This patches are for 7.3 and trunk.
Best,
Hui
-------------- next part --------------
---
gdbserver/tracepoint.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
--- a/gdbserver/tracepoint.c
+++ b/gdbserver/tracepoint.c
@@ -4284,6 +4284,16 @@ gdb_agent_op_name (int op)
return gdb_agent_op_names[op];
}
+int
+tp_printf (const char *format, ...)
+{
+ va_list ap;
+ va_start (ap, format);
+ vprintf (format, ap);
+ va_end (ap);
+ return 0;
+}
+
/* The agent expression evaluator, as specified by the GDB docs. It
returns 0 if everything went OK, and a nonzero error code
otherwise. */
@@ -4643,6 +4653,40 @@ eval_agent_expr (struct tracepoint_hit_c
agent_tsv_read (tframe, arg);
break;
+ case gdb_agent_op_printf:
+ {
+ void *argv;
+ arg = aexpr->bytes[pc++];
+ argv = (void *) (unsigned long) top;
+ if (--sp >= 0)
+ top = stack[sp];
+
+ if (arg)
+ {
+ if (strstr ((char *) (aexpr->bytes + pc), "%s"))
+ {
+ int i;
+ unsigned char buf[100];
+
+ for (i = 0; i < 100; i++)
+ {
+ agent_mem_read (tframe, buf + i,
+ (CORE_ADDR) ((unsigned long)argv + i),
+ 1);
+ if (!buf[i])
+ break;
+ }
+ tp_printf ((char *) (aexpr->bytes + pc), buf);
+ }
+ else
+ tp_printf ((char *) (aexpr->bytes + pc), argv);
+ }
+ else
+ tp_printf ((char *) (aexpr->bytes + pc));
+ pc += strlen ((char *) aexpr->bytes + pc) + 1;
+ }
+ break;
+
/* GDB never (currently) generates any of these ops. */
case gdb_agent_op_float:
case gdb_agent_op_ref_float:
-------------- next part --------------
---
gdbserver/tracepoint.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
--- a/gdbserver/tracepoint.c
+++ b/gdbserver/tracepoint.c
@@ -4215,6 +4215,16 @@ gdb_agent_op_name (int op)
return gdb_agent_op_names[op];
}
+int
+tp_printf (const char *format, ...)
+{
+ va_list ap;
+ va_start (ap, format);
+ vprintf (format, ap);
+ va_end (ap);
+ return 0;
+}
+
/* The agent expression evaluator, as specified by the GDB docs. It
returns 0 if everything went OK, and a nonzero error code
otherwise. */
@@ -4574,6 +4584,40 @@ eval_agent_expr (struct tracepoint_hit_c
agent_tsv_read (tframe, arg);
break;
+ case gdb_agent_op_printf:
+ {
+ void *argv;
+ arg = aexpr->bytes[pc++];
+ argv = (void *) (unsigned long) top;
+ if (--sp >= 0)
+ top = stack[sp];
+
+ if (arg)
+ {
+ if (strstr ((char *) (aexpr->bytes + pc), "%s"))
+ {
+ int i;
+ unsigned char buf[100];
+
+ for (i = 0; i < 100; i++)
+ {
+ agent_mem_read (tframe, buf + i,
+ (CORE_ADDR) ((unsigned long)argv + i),
+ 1);
+ if (!buf[i])
+ break;
+ }
+ tp_printf ((char *) (aexpr->bytes + pc), buf);
+ }
+ else
+ tp_printf ((char *) (aexpr->bytes + pc), argv);
+ }
+ else
+ tp_printf ((char *) (aexpr->bytes + pc));
+ pc += strlen ((char *) aexpr->bytes + pc) + 1;
+ }
+ break;
+
/* GDB never (currently) generates any of these ops. */
case gdb_agent_op_float:
case gdb_agent_op_ref_float:
More information about the Gdb-patches
mailing list