aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi/mi-main.c
diff options
context:
space:
mode:
authorJan Vrany <jan.vrany@labware.com>2020-06-23 14:45:38 +0100
committerAndrew Burgess <aburgess@redhat.com>2021-12-14 11:28:00 +0000
commit1f6c8c3317e5692e9994c18f427b45093863d572 (patch)
treebec5656e39509e778ead182d9fff1388945b4ef9 /gdb/mi/mi-main.c
parent3be0fed62e0dfb36d674944fe85eaebbf70b9029 (diff)
downloadgdb-1f6c8c3317e5692e9994c18f427b45093863d572.zip
gdb-1f6c8c3317e5692e9994c18f427b45093863d572.tar.gz
gdb-1f6c8c3317e5692e9994c18f427b45093863d572.tar.bz2
gdb/mi: use separate classes for different types of MI command
This commit changes the infrastructure in mi-cmds.{c,h} to add new sub-classes for the different types of MI command. Instances of these sub-classes are then created and added into mi_cmd_table. The existing mi_cmd class becomes the abstract base class, this has an invoke method and takes care of the suppress notifications handling, before calling a do_invoke virtual method which is implemented by all of the sub-classes. There's currently two different sub-classes, one of pure MI commands, and a second for MI commands that delegate to CLI commands. There should be no user visible changes after this commit.
Diffstat (limited to 'gdb/mi/mi-main.c')
-rw-r--r--gdb/mi/mi-main.c37
1 files changed, 3 insertions, 34 deletions
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 269c01d..710eef7 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -90,8 +90,6 @@ int mi_proceeded;
static void mi_cmd_execute (struct mi_parse *parse);
-static void mi_execute_cli_command (const char *cmd, bool args_p,
- const char *args);
static void mi_execute_async_cli_command (const char *cli_command,
char **argv, int argc);
static bool register_changed_p (int regnum, readonly_detached_regcache *,
@@ -1936,11 +1934,6 @@ mi_execute_command (const char *cmd, int from_tty)
{
ptid_t previous_ptid = inferior_ptid;
- gdb::optional<scoped_restore_tmpl<int>> restore_suppress;
-
- if (command->cmd != NULL && command->cmd->suppress_notification != NULL)
- restore_suppress.emplace (command->cmd->suppress_notification, 1);
-
command->token = token;
if (do_timings)
@@ -2079,35 +2072,11 @@ mi_cmd_execute (struct mi_parse *parse)
current_context = parse;
- if (parse->cmd->argv_func != NULL)
- {
- parse->cmd->argv_func (parse->command, parse->argv, parse->argc);
- }
- else if (parse->cmd->cli.cmd != 0)
- {
- /* FIXME: DELETE THIS. */
- /* The operation is still implemented by a cli command. */
- /* Must be a synchronous one. */
- bool args_p = parse->cmd->cli.args_p != 0;
- const char *args = args_p ? parse->args : nullptr;
- mi_execute_cli_command (parse->cmd->cli.cmd, args_p, args);
- }
- else
- {
- /* FIXME: DELETE THIS. */
- string_file stb;
-
- stb.puts ("Undefined mi command: ");
- stb.putstr (parse->command, '"');
- stb.puts (" (missing implementation)");
-
- error_stream (stb);
- }
+ gdb_assert (parse->cmd != nullptr);
+ parse->cmd->invoke (parse);
}
-/* FIXME: This is just a hack so we can get some extra commands going.
- We don't want to channel things through the CLI, but call libgdb directly.
- Use only for synchronous commands. */
+/* See mi-main.h. */
void
mi_execute_cli_command (const char *cmd, bool args_p, const char *args)