aboutsummaryrefslogtreecommitdiff
path: root/gdb/ax-gdb.c
diff options
context:
space:
mode:
authorHui Zhu <teawater@gmail.com>2011-02-21 08:38:14 +0000
committerHui Zhu <teawater@gmail.com>2011-02-21 08:38:14 +0000
commitd0e92d82d87a287847fcd66da278836f7136a3ef (patch)
tree432a9056a4ff0e356ff223fbe228aedef40ba131 /gdb/ax-gdb.c
parentc0c8b2f268cd3a8735abed708e08aedd2edd26be (diff)
downloadgdb-d0e92d82d87a287847fcd66da278836f7136a3ef.zip
gdb-d0e92d82d87a287847fcd66da278836f7136a3ef.tar.gz
gdb-d0e92d82d87a287847fcd66da278836f7136a3ef.tar.bz2
2011-02-21 Hui Zhu <teawater@gmail.com>
* Makefile.in (HFILES_NO_SRCDIR): Add printcmd.h. * ax-gdb.c (gen_printf_expr_callback): New function. * ax-gdb.h (gen_printf_expr_callback): Forward declare. * ax-general.c (ax_memcpy): New function. (ax_print): Handle "printf". (ax_reqs): Ditto. * ax.h (ax_memcpy): Forward declare. * common/ax.def (invalid2): Removed. (printf): New entry. * printcmd.c (printcmd.h): New include. (string_printf): New function. (ui_printf): Removed. (printf_command): Remove static. Call string_printf. (eval_command): Call string_printf. * printcmd.h: New file. * tracepoint.c (validate_actionline, encode_actions_1): handle printf_command.
Diffstat (limited to 'gdb/ax-gdb.c')
-rw-r--r--gdb/ax-gdb.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index d1736e1..d995d87 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -2445,6 +2445,65 @@ gen_eval_for_expr (CORE_ADDR scope, struct expression *expr)
return ax;
}
+void
+gen_printf_expr_callback (char *fbuf, char **expp, void *loc_v, void *aexpr_v)
+{
+ struct bp_location *loc = loc_v;
+ struct agent_expr *aexpr = aexpr_v;
+
+ if (expp)
+ {
+ struct cleanup *old_chain = NULL;
+ struct expression *expr = NULL;
+ union exp_element *pc;
+ struct axs_value value;
+
+ expr = parse_exp_1 (expp, block_for_pc (loc->address), 1);
+ old_chain = make_cleanup (free_current_contents, &expr);
+
+ pc = expr->elts;
+ trace_kludge = 0;
+ value.optimized_out = 0;
+ gen_expr (expr, &pc, aexpr, &value);
+
+ if (value.optimized_out)
+ error (_("value has been optimized out"));
+ switch (value.kind)
+ {
+ case axs_lvalue_memory:
+ if (TYPE_CODE (value.type) != TYPE_CODE_ARRAY)
+ {
+ int length = TYPE_LENGTH (check_typedef (value.type));
+ switch (length)
+ {
+ case 4:
+ ax_simple (aexpr, aop_ref32);
+ break;
+ case 8:
+ ax_simple (aexpr, aop_ref64);
+ break;
+ default:
+ error (_("Size of value is not OK."));
+ break;
+ }
+ }
+ break;
+ case axs_lvalue_register:
+ ax_reg (aexpr, value.u.reg);
+ break;
+ }
+
+ do_cleanups (old_chain);
+ }
+
+ ax_simple (aexpr, aop_printf);
+ if (expp)
+ ax_simple (aexpr, 1);
+ else
+ ax_simple (aexpr, 0);
+ ax_memcpy (aexpr, fbuf, strlen (fbuf) + 1);
+}
+
static void
agent_command (char *exp, int from_tty)
{