diff options
Diffstat (limited to 'gdb/cli/cli-script.c')
-rw-r--r-- | gdb/cli/cli-script.c | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index a27e971c017..ad64a4a65b1 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -30,6 +30,7 @@ #include "gdb_string.h" #include "exceptions.h" #include "top.h" +#include "breakpoint.h" #include "cli/cli-cmds.h" #include "cli/cli-decode.h" #include "cli/cli-script.h" @@ -82,7 +83,7 @@ build_command_line (enum command_control_type type, char *args) { struct command_line *cmd; - if (args == NULL) + if (args == NULL && (type == if_control || type == while_control)) error (_("if/while commands require arguments.")); cmd = (struct command_line *) xmalloc (sizeof (struct command_line)); @@ -115,7 +116,7 @@ get_command_line (enum command_control_type type, char *arg) /* Read in the body of this command. */ if (recurse_read_control_structure (cmd) == invalid_control) { - warning (_("Error reading in control structure.")); + warning (_("Error reading in canned sequence of commands.")); do_cleanups (old_chain); return NULL; } @@ -207,6 +208,23 @@ print_command_lines (struct ui_out *uiout, struct command_line *cmd, continue; } + /* A commands command. Print the breakpoint commands and continue. */ + if (list->control_type == commands_control) + { + if (*(list->line)) + ui_out_field_fmt (uiout, NULL, "commands %s", list->line); + else + ui_out_field_string (uiout, NULL, "commands"); + ui_out_text (uiout, "\n"); + print_command_lines (uiout, *list->body_list, depth + 1); + if (depth) + ui_out_spaces (uiout, 2 * depth); + ui_out_field_string (uiout, NULL, "end"); + ui_out_text (uiout, "\n"); + list = list->next; + continue; + } + /* ignore illegal command type and try next */ list = list->next; } /* while (list) */ @@ -292,7 +310,7 @@ execute_user_command (struct cmd_list_element *c, char *args) ret = execute_control_command (cmdlines); if (ret != simple_control && ret != break_control) { - warning (_("Error in control structure.")); + warning (_("Error executing canned sequence of commands.")); break; } cmdlines = cmdlines->next; @@ -498,9 +516,20 @@ execute_control_command (struct command_line *cmd) break; } + case commands_control: + { + /* Breakpoint commands list, record the commands in the breakpoint's + command list and return. */ + new_line = insert_args (cmd->line); + if (!new_line) + break; + make_cleanup (free_current_contents, &new_line); + ret = commands_from_control_command (new_line, cmd); + break; + } default: - warning (_("Invalid control type in command structure.")); + warning (_("Invalid control type in canned commands structure.")); break; } @@ -849,6 +878,14 @@ read_next_line (struct command_line **command) first_arg++; *command = build_command_line (if_control, first_arg); } + else if (p1 - p >= 8 && !strncmp (p, "commands", 8)) + { + char *first_arg; + first_arg = p + 8; + while (first_arg < p1 && isspace (*first_arg)) + first_arg++; + *command = build_command_line (commands_control, first_arg); + } else if (p1 - p == 10 && !strncmp (p, "loop_break", 10)) { *command = (struct command_line *) @@ -924,9 +961,10 @@ recurse_read_control_structure (struct command_line *current_cmd) if (val == end_command) { if (current_cmd->control_type == while_control - || current_cmd->control_type == if_control) + || current_cmd->control_type == if_control + || current_cmd->control_type == commands_control) { - /* Success reading an entire control structure. */ + /* Success reading an entire canned sequence of commands. */ ret = simple_control; break; } @@ -974,7 +1012,8 @@ recurse_read_control_structure (struct command_line *current_cmd) /* If the latest line is another control structure, then recurse on it. */ if (next->control_type == while_control - || next->control_type == if_control) + || next->control_type == if_control + || next->control_type == commands_control) { control_level++; ret = recurse_read_control_structure (next); @@ -1045,7 +1084,8 @@ read_command_lines (char *prompt_arg, int from_tty) } if (next->control_type == while_control - || next->control_type == if_control) + || next->control_type == if_control + || next->control_type == commands_control) { control_level++; ret = recurse_read_control_structure (next); |