aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/mi/ChangeLog11
-rw-r--r--gdb/mi/mi-cmds.c264
-rw-r--r--gdb/mi/mi-cmds.h30
-rw-r--r--gdb/mi/mi-main.c23
-rw-r--r--gdb/mi/mi-parse.c2
5 files changed, 176 insertions, 154 deletions
diff --git a/gdb/mi/ChangeLog b/gdb/mi/ChangeLog
index 5af17c3..a9a09d1 100644
--- a/gdb/mi/ChangeLog
+++ b/gdb/mi/ChangeLog
@@ -1,3 +1,14 @@
+2003-08-04 Andrew Cagney <cagney@redhat.com>
+
+ * mi-cmds.h (struct mi_cli): Define.
+ (struct mi_cmd): Change type of "cli" to "struct mi_cli".
+ * mi-cmds.c (mi_cmds): Update table.
+ * mi-parse.c (mi_parse): Update.
+ * mi-main.c (mi_execute_cli_command): Add "args_p" parameter, make
+ others constant.
+ (mi_cmd_execute): Update call.
+ (captured_mi_execute_command): Ditto.
+
2003-08-04 David Carlton <carlton@kealia.com>
* mi-main.c (mi_error_last_message): Add "%s" second argument to
diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c
index 9182402..0dfc217 100644
--- a/gdb/mi/mi-cmds.c
+++ b/gdb/mi/mi-cmds.c
@@ -34,138 +34,138 @@ static void build_table (struct mi_cmd *commands);
struct mi_cmd mi_cmds[] =
{
- {"break-after", "ignore %s", 0},
- {"break-catch", 0, 0},
- {"break-commands", 0, 0},
- {"break-condition", "cond %s", 0},
- {"break-delete", "delete breakpoint %s", 0},
- {"break-disable", "disable breakpoint %s", 0},
- {"break-enable", "enable breakpoint %s", 0},
- {"break-info", "info break %s", 0},
- {"break-insert", 0, 0, mi_cmd_break_insert},
- {"break-list", "info break", 0},
- {"break-watch", 0, 0, mi_cmd_break_watch},
- {"data-disassemble", 0, 0, mi_cmd_disassemble},
- {"data-evaluate-expression", 0, 0, mi_cmd_data_evaluate_expression},
- {"data-list-changed-registers", 0, 0, mi_cmd_data_list_changed_registers},
- {"data-list-register-names", 0, 0, mi_cmd_data_list_register_names},
- {"data-list-register-values", 0, 0, mi_cmd_data_list_register_values},
- {"data-read-memory", 0, 0, mi_cmd_data_read_memory},
- {"data-write-memory", 0, 0, mi_cmd_data_write_memory},
- {"data-write-register-values", 0, 0, mi_cmd_data_write_register_values},
- {"display-delete", 0, 0},
- {"display-disable", 0, 0},
- {"display-enable", 0, 0},
- {"display-insert", 0, 0},
- {"display-list", 0, 0},
- {"environment-cd", 0, 0, mi_cmd_env_cd},
- {"environment-directory", 0, 0, mi_cmd_env_dir},
- {"environment-path", 0, 0, mi_cmd_env_path},
- {"environment-pwd", 0, 0, mi_cmd_env_pwd},
- {"exec-abort", 0, 0},
- {"exec-arguments", "set args %s", 0},
- {"exec-continue", 0, mi_cmd_exec_continue},
- {"exec-finish", 0, mi_cmd_exec_finish},
- {"exec-interrupt", 0, mi_cmd_exec_interrupt},
- {"exec-next", 0, mi_cmd_exec_next},
- {"exec-next-instruction", 0, mi_cmd_exec_next_instruction},
- {"exec-return", 0, mi_cmd_exec_return},
- {"exec-run", 0, mi_cmd_exec_run},
- {"exec-show-arguments", 0, 0},
- {"exec-signal", 0, 0},
- {"exec-step", 0, mi_cmd_exec_step},
- {"exec-step-instruction", 0, mi_cmd_exec_step_instruction},
- {"exec-until", 0, mi_cmd_exec_until},
- {"file-clear", 0, 0},
- {"file-exec-and-symbols", "file %s", 0},
- {"file-exec-file", "exec-file %s", 0},
- {"file-list-exec-sections", 0, 0},
- {"file-list-exec-source-file", 0, 0, mi_cmd_file_list_exec_source_file},
- {"file-list-exec-source-files", 0, 0},
- {"file-list-shared-libraries", 0, 0},
- {"file-list-symbol-files", 0, 0},
- {"file-symbol-file", "symbol-file %s", 0},
- {"gdb-complete", 0, 0},
- {"gdb-exit", 0, 0, mi_cmd_gdb_exit},
- {"gdb-set", "set %s", 0},
- {"gdb-show", "show %s", 0},
- {"gdb-source", 0, 0},
- {"gdb-version", "show version", 0},
- {"interpreter-exec", 0, 0, mi_cmd_interpreter_exec},
- {"kod-info", 0, 0},
- {"kod-list", 0, 0},
- {"kod-list-object-types", 0, 0},
- {"kod-show", 0, 0},
- {"overlay-auto", 0, 0},
- {"overlay-list-mapping-state", 0, 0},
- {"overlay-list-overlays", 0, 0},
- {"overlay-map", 0, 0},
- {"overlay-off", 0, 0},
- {"overlay-on", 0, 0},
- {"overlay-unmap", 0, 0},
- {"signal-handle", 0, 0},
- {"signal-list-handle-actions", 0, 0},
- {"signal-list-signal-types", 0, 0},
- {"stack-info-depth", 0, 0, mi_cmd_stack_info_depth},
- {"stack-info-frame", 0, 0},
- {"stack-list-arguments", 0, 0, mi_cmd_stack_list_args},
- {"stack-list-exception-handlers", 0, 0},
- {"stack-list-frames", 0, 0, mi_cmd_stack_list_frames},
- {"stack-list-locals", 0, 0, mi_cmd_stack_list_locals},
- {"stack-select-frame", 0, 0, mi_cmd_stack_select_frame},
- {"symbol-info-address", 0, 0},
- {"symbol-info-file", 0, 0},
- {"symbol-info-function", 0, 0},
- {"symbol-info-line", 0, 0},
- {"symbol-info-symbol", 0, 0},
- {"symbol-list-functions", 0, 0},
- {"symbol-list-lines", 0, 0, mi_cmd_symbol_list_lines},
- {"symbol-list-types", 0, 0},
- {"symbol-list-variables", 0, 0},
- {"symbol-locate", 0, 0},
- {"symbol-type", 0, 0},
- {"target-attach", 0, 0},
- {"target-compare-sections", 0, 0},
- {"target-detach", "detach", 0},
- {"target-disconnect", "disconnect", 0},
- {"target-download", 0, mi_cmd_target_download},
- {"target-exec-status", 0, 0},
- {"target-list-available-targets", 0, 0},
- {"target-list-current-targets", 0, 0},
- {"target-list-parameters", 0, 0},
- {"target-select", 0, mi_cmd_target_select},
- {"thread-info", 0, 0},
- {"thread-list-all-threads", 0, 0},
- {"thread-list-ids", 0, 0, mi_cmd_thread_list_ids},
- {"thread-select", 0, 0, mi_cmd_thread_select},
- {"trace-actions", 0, 0},
- {"trace-delete", 0, 0},
- {"trace-disable", 0, 0},
- {"trace-dump", 0, 0},
- {"trace-enable", 0, 0},
- {"trace-exists", 0, 0},
- {"trace-find", 0, 0},
- {"trace-frame-number", 0, 0},
- {"trace-info", 0, 0},
- {"trace-insert", 0, 0},
- {"trace-list", 0, 0},
- {"trace-pass-count", 0, 0},
- {"trace-save", 0, 0},
- {"trace-start", 0, 0},
- {"trace-stop", 0, 0},
- {"var-assign", 0, 0, mi_cmd_var_assign},
- {"var-create", 0, 0, mi_cmd_var_create},
- {"var-delete", 0, 0, mi_cmd_var_delete},
- {"var-evaluate-expression", 0, 0, mi_cmd_var_evaluate_expression},
- {"var-info-expression", 0, 0, mi_cmd_var_info_expression},
- {"var-info-num-children", 0, 0, mi_cmd_var_info_num_children},
- {"var-info-type", 0, 0, mi_cmd_var_info_type},
- {"var-list-children", 0, 0, mi_cmd_var_list_children},
- {"var-set-format", 0, 0, mi_cmd_var_set_format},
- {"var-show-attributes", 0, 0, mi_cmd_var_show_attributes},
- {"var-show-format", 0, 0, mi_cmd_var_show_format},
- {"var-update", 0, 0, mi_cmd_var_update},
- {0,}
+ { "break-after", { "ignore", 1 }, NULL, NULL },
+ { "break-catch", { NULL, 0 }, NULL, NULL },
+ { "break-commands", { NULL, 0 }, NULL, NULL },
+ { "break-condition", { "cond", 1 }, NULL, NULL },
+ { "break-delete", { "delete breakpoint", 1 }, NULL, NULL },
+ { "break-disable", { "disable breakpoint", 1 }, NULL, NULL },
+ { "break-enable", { "enable breakpoint", 1 }, NULL, NULL },
+ { "break-info", { "info break", 1 }, NULL, NULL },
+ { "break-insert", { NULL, 0 }, 0, mi_cmd_break_insert},
+ { "break-list", { "info break", }, NULL, NULL },
+ { "break-watch", { NULL, 0 }, 0, mi_cmd_break_watch},
+ { "data-disassemble", { NULL, 0 }, 0, mi_cmd_disassemble},
+ { "data-evaluate-expression", { NULL, 0 }, 0, mi_cmd_data_evaluate_expression},
+ { "data-list-changed-registers", { NULL, 0 }, 0, mi_cmd_data_list_changed_registers},
+ { "data-list-register-names", { NULL, 0 }, 0, mi_cmd_data_list_register_names},
+ { "data-list-register-values", { NULL, 0 }, 0, mi_cmd_data_list_register_values},
+ { "data-read-memory", { NULL, 0 }, 0, mi_cmd_data_read_memory},
+ { "data-write-memory", { NULL, 0 }, 0, mi_cmd_data_write_memory},
+ { "data-write-register-values", { NULL, 0 }, 0, mi_cmd_data_write_register_values},
+ { "display-delete", { NULL, 0 }, NULL, NULL },
+ { "display-disable", { NULL, 0 }, NULL, NULL },
+ { "display-enable", { NULL, 0 }, NULL, NULL },
+ { "display-insert", { NULL, 0 }, NULL, NULL },
+ { "display-list", { NULL, 0 }, NULL, NULL },
+ { "environment-cd", { NULL, 0 }, 0, mi_cmd_env_cd},
+ { "environment-directory", { NULL, 0 }, 0, mi_cmd_env_dir},
+ { "environment-path", { NULL, 0 }, 0, mi_cmd_env_path},
+ { "environment-pwd", { NULL, 0 }, 0, mi_cmd_env_pwd},
+ { "exec-abort", { NULL, 0 }, NULL, NULL },
+ { "exec-arguments", { "set args", 1 }, NULL, NULL },
+ { "exec-continue", { NULL, 0 }, mi_cmd_exec_continue},
+ { "exec-finish", { NULL, 0 }, mi_cmd_exec_finish},
+ { "exec-interrupt", { NULL, 0 }, mi_cmd_exec_interrupt},
+ { "exec-next", { NULL, 0 }, mi_cmd_exec_next},
+ { "exec-next-instruction", { NULL, 0 }, mi_cmd_exec_next_instruction},
+ { "exec-return", { NULL, 0 }, mi_cmd_exec_return},
+ { "exec-run", { NULL, 0 }, mi_cmd_exec_run},
+ { "exec-show-arguments", { NULL, 0 }, NULL, NULL },
+ { "exec-signal", { NULL, 0 }, NULL, NULL },
+ { "exec-step", { NULL, 0 }, mi_cmd_exec_step},
+ { "exec-step-instruction", { NULL, 0 }, mi_cmd_exec_step_instruction},
+ { "exec-until", { NULL, 0 }, mi_cmd_exec_until},
+ { "file-clear", { NULL, 0 }, NULL, NULL },
+ { "file-exec-and-symbols", { "file", 1 }, NULL, NULL },
+ { "file-exec-file", { "exec-file", 1 }, NULL, NULL },
+ { "file-list-exec-sections", { NULL, 0 }, NULL, NULL },
+ { "file-list-exec-source-file", { NULL, 0 }, 0, mi_cmd_file_list_exec_source_file},
+ { "file-list-exec-source-files", { NULL, 0 }, NULL, NULL },
+ { "file-list-shared-libraries", { NULL, 0 }, NULL, NULL },
+ { "file-list-symbol-files", { NULL, 0 }, NULL, NULL },
+ { "file-symbol-file", { "symbol-file", 1 }, NULL, NULL },
+ { "gdb-complete", { NULL, 0 }, NULL, NULL },
+ { "gdb-exit", { NULL, 0 }, 0, mi_cmd_gdb_exit},
+ { "gdb-set", { "set", 1 }, NULL, NULL },
+ { "gdb-show", { "show", 1 }, NULL, NULL },
+ { "gdb-source", { NULL, 0 }, NULL, NULL },
+ { "gdb-version", { "show version", 0 }, 0 },
+ { "interpreter-exec", { NULL, 0 }, 0, mi_cmd_interpreter_exec},
+ { "kod-info", { NULL, 0 }, NULL, NULL },
+ { "kod-list", { NULL, 0 }, NULL, NULL },
+ { "kod-list-object-types", { NULL, 0 }, NULL, NULL },
+ { "kod-show", { NULL, 0 }, NULL, NULL },
+ { "overlay-auto", { NULL, 0 }, NULL, NULL },
+ { "overlay-list-mapping-state", { NULL, 0 }, NULL, NULL },
+ { "overlay-list-overlays", { NULL, 0 }, NULL, NULL },
+ { "overlay-map", { NULL, 0 }, NULL, NULL },
+ { "overlay-off", { NULL, 0 }, NULL, NULL },
+ { "overlay-on", { NULL, 0 }, NULL, NULL },
+ { "overlay-unmap", { NULL, 0 }, NULL, NULL },
+ { "signal-handle", { NULL, 0 }, NULL, NULL },
+ { "signal-list-handle-actions", { NULL, 0 }, NULL, NULL },
+ { "signal-list-signal-types", { NULL, 0 }, NULL, NULL },
+ { "stack-info-depth", { NULL, 0 }, 0, mi_cmd_stack_info_depth},
+ { "stack-info-frame", { NULL, 0 }, NULL, NULL },
+ { "stack-list-arguments", { NULL, 0 }, 0, mi_cmd_stack_list_args},
+ { "stack-list-exception-handlers", { NULL, 0 }, NULL, NULL },
+ { "stack-list-frames", { NULL, 0 }, 0, mi_cmd_stack_list_frames},
+ { "stack-list-locals", { NULL, 0 }, 0, mi_cmd_stack_list_locals},
+ { "stack-select-frame", { NULL, 0 }, 0, mi_cmd_stack_select_frame},
+ { "symbol-info-address", { NULL, 0 }, NULL, NULL },
+ { "symbol-info-file", { NULL, 0 }, NULL, NULL },
+ { "symbol-info-function", { NULL, 0 }, NULL, NULL },
+ { "symbol-info-line", { NULL, 0 }, NULL, NULL },
+ { "symbol-info-symbol", { NULL, 0 }, NULL, NULL },
+ { "symbol-list-functions", { NULL, 0 }, NULL, NULL },
+ { "symbol-list-lines", { NULL, 0 }, 0, mi_cmd_symbol_list_lines},
+ { "symbol-list-types", { NULL, 0 }, NULL, NULL },
+ { "symbol-list-variables", { NULL, 0 }, NULL, NULL },
+ { "symbol-locate", { NULL, 0 }, NULL, NULL },
+ { "symbol-type", { NULL, 0 }, NULL, NULL },
+ { "target-attach", { NULL, 0 }, NULL, NULL },
+ { "target-compare-sections", { NULL, 0 }, NULL, NULL },
+ { "target-detach", { "detach", 0 }, 0 },
+ { "target-disconnect", { "disconnect", 0 }, 0 },
+ { "target-download", { NULL, 0 }, mi_cmd_target_download},
+ { "target-exec-status", { NULL, 0 }, NULL, NULL },
+ { "target-list-available-targets", { NULL, 0 }, NULL, NULL },
+ { "target-list-current-targets", { NULL, 0 }, NULL, NULL },
+ { "target-list-parameters", { NULL, 0 }, NULL, NULL },
+ { "target-select", { NULL, 0 }, mi_cmd_target_select},
+ { "thread-info", { NULL, 0 }, NULL, NULL },
+ { "thread-list-all-threads", { NULL, 0 }, NULL, NULL },
+ { "thread-list-ids", { NULL, 0 }, 0, mi_cmd_thread_list_ids},
+ { "thread-select", { NULL, 0 }, 0, mi_cmd_thread_select},
+ { "trace-actions", { NULL, 0 }, NULL, NULL },
+ { "trace-delete", { NULL, 0 }, NULL, NULL },
+ { "trace-disable", { NULL, 0 }, NULL, NULL },
+ { "trace-dump", { NULL, 0 }, NULL, NULL },
+ { "trace-enable", { NULL, 0 }, NULL, NULL },
+ { "trace-exists", { NULL, 0 }, NULL, NULL },
+ { "trace-find", { NULL, 0 }, NULL, NULL },
+ { "trace-frame-number", { NULL, 0 }, NULL, NULL },
+ { "trace-info", { NULL, 0 }, NULL, NULL },
+ { "trace-insert", { NULL, 0 }, NULL, NULL },
+ { "trace-list", { NULL, 0 }, NULL, NULL },
+ { "trace-pass-count", { NULL, 0 }, NULL, NULL },
+ { "trace-save", { NULL, 0 }, NULL, NULL },
+ { "trace-start", { NULL, 0 }, NULL, NULL },
+ { "trace-stop", { NULL, 0 }, NULL, NULL },
+ { "var-assign", { NULL, 0 }, 0, mi_cmd_var_assign},
+ { "var-create", { NULL, 0 }, 0, mi_cmd_var_create},
+ { "var-delete", { NULL, 0 }, 0, mi_cmd_var_delete},
+ { "var-evaluate-expression", { NULL, 0 }, 0, mi_cmd_var_evaluate_expression},
+ { "var-info-expression", { NULL, 0 }, 0, mi_cmd_var_info_expression},
+ { "var-info-num-children", { NULL, 0 }, 0, mi_cmd_var_info_num_children},
+ { "var-info-type", { NULL, 0 }, 0, mi_cmd_var_info_type},
+ { "var-list-children", { NULL, 0 }, 0, mi_cmd_var_list_children},
+ { "var-set-format", { NULL, 0 }, 0, mi_cmd_var_set_format},
+ { "var-show-attributes", { NULL, 0 }, 0, mi_cmd_var_show_attributes},
+ { "var-show-format", { NULL, 0 }, 0, mi_cmd_var_show_format},
+ { "var-update", { NULL, 0 }, 0, mi_cmd_var_update},
+ { NULL, }
};
/* Pointer to the mi command table (built at run time) */
diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h
index b0c8cb8..efcf0b5 100644
--- a/gdb/mi/mi-cmds.h
+++ b/gdb/mi/mi-cmds.h
@@ -108,18 +108,26 @@ extern mi_cmd_argv_ftype mi_cmd_var_update;
/* Description of a single command. */
+struct mi_cli
+{
+ /* Corresponding CLI command. If ARGS_P is non-zero, the MI
+ command's argument list is appended to the CLI command. */
+ const char *cmd;
+ int args_p;
+};
+
struct mi_cmd
- {
- /* official name of the command */
- const char *name;
- /* If non-null, the corresponding CLI command that can be used to
- implement this MI command */
- const char *cli;
- /* If non-null, the function implementing the MI command */
- mi_cmd_args_ftype *args_func;
- /* If non-null, the function implementing the MI command */
- mi_cmd_argv_ftype *argv_func;
- };
+{
+ /* official name of the command. */
+ const char *name;
+ /* The corresponding CLI command that can be used to implement this
+ MI command (if cli.lhs is non NULL). */
+ struct mi_cli cli;
+ /* If non-null, the function implementing the MI command. */
+ mi_cmd_args_ftype *args_func;
+ /* If non-null, the function implementing the MI command. */
+ mi_cmd_argv_ftype *argv_func;
+};
/* Lookup a command in the mi comand table */
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 64a28fd..29eccac 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -87,7 +87,8 @@ static char *old_regs;
extern void _initialize_mi_main (void);
static enum mi_cmd_result mi_cmd_execute (struct mi_parse *parse);
-static void mi_execute_cli_command (const char *cli, char *args);
+static void mi_execute_cli_command (const char *cmd, int args_p,
+ const char *args);
static enum mi_cmd_result mi_execute_async_cli_command (char *mi, char *args, int from_tty);
static void mi_exec_async_cli_cmd_continuation (struct continuation_arg *arg);
@@ -1156,9 +1157,7 @@ captured_mi_execute_command (struct ui_out *uiout, void *data)
mi commands */
/* echo the command on the console. */
fprintf_unfiltered (gdb_stdlog, "%s\n", context->command);
- /* FIXME: If the command string has something that looks like
- a format spec (e.g. %s) we will get a core dump */
- mi_execute_cli_command ("%s", context->command);
+ mi_execute_cli_command (context->command, 0, NULL);
/* If we changed interpreters, DON'T print out anything. */
if (current_interp_named_p (INTERP_MI)
@@ -1275,12 +1274,13 @@ mi_cmd_execute (struct mi_parse *parse)
return parse->cmd->args_func (parse->args, 0 /*from_tty */ );
return parse->cmd->argv_func (parse->command, parse->argv, parse->argc);
}
- else if (parse->cmd->cli != 0)
+ else if (parse->cmd->cli.cmd != 0)
{
/* FIXME: DELETE THIS. */
/* The operation is still implemented by a cli command */
/* Must be a synchronous one */
- mi_execute_cli_command (parse->cmd->cli, parse->args);
+ mi_execute_cli_command (parse->cmd->cli.cmd, parse->cmd->cli.args_p,
+ parse->args);
return MI_CMD_DONE;
}
else
@@ -1301,17 +1301,20 @@ mi_cmd_execute (struct mi_parse *parse)
/* Use only for synchronous commands */
void
-mi_execute_cli_command (const char *cli, char *args)
+mi_execute_cli_command (const char *cmd, int args_p, const char *args)
{
- if (cli != 0)
+ if (cmd != 0)
{
struct cleanup *old_cleanups;
char *run;
- xasprintf (&run, cli, args);
+ if (args_p)
+ xasprintf (&run, "%s %s", cmd, args);
+ else
+ run = xstrdup (cmd);
if (mi_debug_p)
/* FIXME: gdb_???? */
fprintf_unfiltered (gdb_stdout, "cli=%s run=%s\n",
- cli, run);
+ cmd, run);
old_cleanups = make_cleanup (xfree, run);
execute_command ( /*ui */ run, 0 /*from_tty */ );
do_cleanups (old_cleanups);
diff --git a/gdb/mi/mi-parse.c b/gdb/mi/mi-parse.c
index ebfddc7..a0ff889 100644
--- a/gdb/mi/mi-parse.c
+++ b/gdb/mi/mi-parse.c
@@ -222,7 +222,7 @@ mi_parse (char *cmd)
/* For CLI and old ARGS commands, also return the remainder of the
command line as a single string. */
if (parse->cmd->args_func != NULL
- || parse->cmd->cli != NULL)
+ || parse->cmd->cli.cmd != NULL)
{
parse->args = xstrdup (chp);
}