aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2007-01-27 12:30:46 +0000
committerEli Zaretskii <eliz@gnu.org>2007-01-27 12:30:46 +0000
commit40c03ae8b35379347d3afea7bd4ddcb6cc7425c7 (patch)
tree91fffe4e6addc2906fb9ef9c921df0e089f4dbbf /gdb/breakpoint.c
parent474d0ad39b9380f2ce83648a145e6ad77cf2520f (diff)
downloadgdb-40c03ae8b35379347d3afea7bd4ddcb6cc7425c7.zip
gdb-40c03ae8b35379347d3afea7bd4ddcb6cc7425c7.tar.gz
gdb-40c03ae8b35379347d3afea7bd4ddcb6cc7425c7.tar.bz2
* cli/cli-script.c: Include breakpoint.h.
(build_command_line): Require arguments only for if and while commands. (get_command_line, execute_user_command, execute_control_command): Fix wording of warning messages. (print_command_lines): Print breakpoint commands. (execute_control_command): Call commands_from_control_command to handle the `commands' command inside a body of a flow-control command. (read_next_line): Recognize the `commands' command and build a command line structure for it. (recurse_read_control_structure, read_command_lines): Handle `commands' similarly to `if' and `while'. * breakpoint.c (get_number_trailer): Document the special meaning of NULL as the first argument PP. (commands_from_control_command): New function. * breakpoint.h (commands_from_control_command): Add prototype. * defs.h (commands_control): New enumerated value for enum command_control_type.
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r--gdb/breakpoint.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 2a5e81f..e50c99a 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -403,6 +403,8 @@ int default_breakpoint_line;
Currently the string can either be a number or "$" followed by the name
of a convenience variable. Making it an expression wouldn't work well
for map_breakpoint_numbers (e.g. "4 + 5 + 6").
+
+ If the string is a NULL pointer, that denotes the last breakpoint.
TRAILER is a character which can be found after the number; most
commonly this is `-'. If you don't want a trailer, use \0. */
@@ -647,6 +649,52 @@ commands_command (char *arg, int from_tty)
}
error (_("No breakpoint number %d."), bnum);
}
+
+/* Like commands_command, but instead of reading the commands from
+ input stream, takes them from an already parsed command structure.
+
+ This is used by cli-script.c to DTRT with breakpoint commands
+ that are part of if and while bodies. */
+enum command_control_type
+commands_from_control_command (char *arg, struct command_line *cmd)
+{
+ struct breakpoint *b;
+ char *p;
+ int bnum;
+
+ /* If we allowed this, we would have problems with when to
+ free the storage, if we change the commands currently
+ being read from. */
+
+ if (executing_breakpoint_commands)
+ error (_("Can't use the \"commands\" command among a breakpoint's commands."));
+
+ /* An empty string for the breakpoint number means the last
+ breakpoint, but get_number expects a NULL pointer. */
+ if (arg && !*arg)
+ p = NULL;
+ else
+ p = arg;
+ bnum = get_number (&p);
+
+ if (p && *p)
+ error (_("Unexpected extra arguments following breakpoint number."));
+
+ ALL_BREAKPOINTS (b)
+ if (b->number == bnum)
+ {
+ free_command_lines (&b->commands);
+ if (cmd->body_count != 1)
+ error (_("Invalid \"commands\" block structure."));
+ /* We need to copy the commands because if/while will free the
+ list after it finishes execution. */
+ b->commands = copy_command_lines (cmd->body_list[0]);
+ breakpoints_changed ();
+ breakpoint_modify_event (b->number);
+ return simple_control;
+ }
+ error (_("No breakpoint number %d."), bnum);
+}
/* Like target_read_memory() but if breakpoints are inserted, return
the shadow contents instead of the breakpoints themselves.