diff options
author | Hui Zhu <teawater@gmail.com> | 2011-02-21 08:38:14 +0000 |
---|---|---|
committer | Hui Zhu <teawater@gmail.com> | 2011-02-21 08:38:14 +0000 |
commit | d0e92d82d87a287847fcd66da278836f7136a3ef (patch) | |
tree | 432a9056a4ff0e356ff223fbe228aedef40ba131 /gdb/tracepoint.c | |
parent | c0c8b2f268cd3a8735abed708e08aedd2edd26be (diff) | |
download | gdb-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/tracepoint.c')
-rw-r--r-- | gdb/tracepoint.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 2d675ce..987edcc 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -51,6 +51,7 @@ #include "ax.h" #include "ax-gdb.h" #include "memrange.h" +#include "printcmd.h" /* readline include files */ #include "readline/readline.h" @@ -763,6 +764,28 @@ validate_actionline (char **line, struct breakpoint *t) error (_("while-stepping step count `%s' is malformed."), *line); } + else if (cmd_cfunc_eq (c, printf_command)) + { + char fbuf[101]; + + for (loc = t->loc; loc; loc = loc->next) + { + int nargs; + aexpr = new_agent_expr (loc->gdbarch, loc->address); + old_chain = make_cleanup_free_agent_expr (aexpr); + string_printf (p, NULL, gen_printf_expr_callback, + loc, aexpr); + ax_simple (aexpr, aop_end); + /* The agent expr include expr for arguments, format string, 1 byte + for aop_printf, 1 byte for the number of arguments, 1 byte for + size of format string, 1 byte for blank after format string + and 1 byte for aop_end. */ + if (aexpr->len > MAX_AGENT_EXPR_LEN) + error (_("Expression is too complicated.")); + do_cleanups (old_chain); + } + } + else if (cmd_cfunc_eq (c, end_actions_pseudocommand)) ; @@ -1474,6 +1497,22 @@ encode_actions_1 (struct command_line *action, encode_actions_1 (action->body_list[0], t, tloc, frame_reg, frame_offset, stepping_list, NULL); } + else if (cmd_cfunc_eq (cmd, printf_command)) + { + char fbuf[101]; + struct cleanup *old_chain = NULL; + + aexpr = new_agent_expr (tloc->gdbarch, tloc->address); + old_chain = make_cleanup_free_agent_expr (aexpr); + string_printf (action_exp, NULL, gen_printf_expr_callback, + tloc, aexpr); + ax_simple (aexpr, aop_end); + + ax_reqs (aexpr); + report_agent_reqs_errors (aexpr); + discard_cleanups (old_chain); + add_aexpr (collect, aexpr); + } else error (_("Invalid tracepoint command '%s'"), action->line); } /* for */ |