From afd02f27b0ece4542cdd921572ab8ea2c9f021ba Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 2 Apr 2010 01:39:53 +0000 Subject: [PATCH] * tracepoint.c (trace_dump_actions): New, factored out from trace_dump_command, and adjusted to recurse into while-stepping's action list. (trace_dump_command): Use it. --- gdb/ChangeLog | 7 ++++ gdb/tracepoint.c | 109 +++++++++++++++++++++++++++++++------------------------ 2 files changed, 68 insertions(+), 48 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 18eb942..2adaa18 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2010-04-02 Pedro Alves + * tracepoint.c (trace_dump_actions): New, factored out from + trace_dump_command, and adjusted to recurse into while-stepping's + action list. + (trace_dump_command): Use it. + +2010-04-02 Pedro Alves + * breakpoint.h (struct counted_command_line): Moved definition to breakpoint.c, and forward declare. (breakpoint_commands): Declare. diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index ac10997..1b41806 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -2370,54 +2370,21 @@ replace_comma (void *data) *comma = ','; } -/* tdump command */ + +/* Helper for trace_dump_command. Dump the action list starting at + ACTION. STEPPING_ACTIONS is true if we're iterating over the + actions of the body of a while-stepping action. STEPPING_FRAME is + set if the current traceframe was determined to be a while-stepping + traceframe. */ + static void -trace_dump_command (char *args, int from_tty) +trace_dump_actions (struct command_line *action, + int stepping_actions, int stepping_frame, + int from_tty) { - struct regcache *regcache; - struct gdbarch *gdbarch; - struct breakpoint *t; - struct command_line *action; char *action_exp, *next_comma; - struct cleanup *old_cleanups; - int stepping_actions = 0; - int stepping_frame = 0; - struct bp_location *loc; - - if (tracepoint_number == -1) - { - warning (_("No current trace frame.")); - return; - } - - t = get_tracepoint (tracepoint_number); - - if (t == NULL) - error (_("No known tracepoint matches 'current' tracepoint #%d."), - tracepoint_number); - - old_cleanups = make_cleanup (null_cleanup, NULL); - printf_filtered ("Data collected at tracepoint %d, trace frame %d:\n", - tracepoint_number, traceframe_number); - - /* The current frame is a trap frame if the frame PC is equal - to the tracepoint PC. If not, then the current frame was - collected during single-stepping. */ - - regcache = get_current_regcache (); - gdbarch = get_regcache_arch (regcache); - - /* If the traceframe's address matches any of the tracepoint's - locations, assume it is a direct hit rather than a while-stepping - frame. (FIXME this is not reliable, should record each frame's - type.) */ - stepping_frame = 1; - for (loc = t->loc; loc; loc = loc->next) - if (loc->address == regcache_read_pc (regcache)) - stepping_frame = 0; - - for (action = breakpoint_commands (t); action; action = action->next) + for (; action != NULL; action = action->next) { struct cmd_list_element *cmd; @@ -2437,9 +2404,13 @@ trace_dump_command (char *args, int from_tty) error (_("Bad action list item: %s"), action_exp); if (cmd_cfunc_eq (cmd, while_stepping_pseudocommand)) - stepping_actions = 1; - else if (cmd_cfunc_eq (cmd, end_actions_pseudocommand)) - stepping_actions = 0; + { + int i; + + for (i = 0; i < action->body_count; ++i) + trace_dump_actions (action->body_list[i], + 1, stepping_frame, from_tty); + } else if (cmd_cfunc_eq (cmd, collect_pseudocommand)) { /* Display the collected data. @@ -2485,7 +2456,49 @@ trace_dump_command (char *args, int from_tty) } } } - discard_cleanups (old_cleanups); +} + +/* The tdump command. */ + +static void +trace_dump_command (char *args, int from_tty) +{ + struct regcache *regcache; + struct breakpoint *t; + int stepping_frame = 0; + struct bp_location *loc; + + if (tracepoint_number == -1) + { + warning (_("No current trace frame.")); + return; + } + + t = get_tracepoint (tracepoint_number); + + if (t == NULL) + error (_("No known tracepoint matches 'current' tracepoint #%d."), + tracepoint_number); + + printf_filtered ("Data collected at tracepoint %d, trace frame %d:\n", + tracepoint_number, traceframe_number); + + /* The current frame is a trap frame if the frame PC is equal + to the tracepoint PC. If not, then the current frame was + collected during single-stepping. */ + + regcache = get_current_regcache (); + + /* If the traceframe's address matches any of the tracepoint's + locations, assume it is a direct hit rather than a while-stepping + frame. (FIXME this is not reliable, should record each frame's + type.) */ + stepping_frame = 1; + for (loc = t->loc; loc; loc = loc->next) + if (loc->address == regcache_read_pc (regcache)) + stepping_frame = 0; + + trace_dump_actions (breakpoint_commands (t), 0, stepping_frame, from_tty); } /* Encode a piece of a tracepoint's source-level definition in a form -- 2.7.4