aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-03-16 10:57:32 -0600
committerTom Tromey <tromey@adacore.com>2023-05-23 10:09:28 -0600
commitc97d123d6701fbf462e96db001cea07ed32e4efa (patch)
tree7442dc14459bc1e8874998d219dda702371f380e /gdb/mi
parente7a2797eb00dbbceb6796f1baa120055d174a229 (diff)
downloadgdb-c97d123d6701fbf462e96db001cea07ed32e4efa.zip
gdb-c97d123d6701fbf462e96db001cea07ed32e4efa.tar.gz
gdb-c97d123d6701fbf462e96db001cea07ed32e4efa.tar.bz2
Implement gdb.execute_mi
This adds a new Python function, gdb.execute_mi, that can be used to invoke an MI command but get the output as a Python object, rather than a string. This is done by implementing a new ui_out subclass that builds a Python object. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=11688 Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Diffstat (limited to 'gdb/mi')
-rw-r--r--gdb/mi/mi-cmds.h5
-rw-r--r--gdb/mi/mi-main.c15
2 files changed, 20 insertions, 0 deletions
diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h
index d867c29..c62b134 100644
--- a/gdb/mi/mi-cmds.h
+++ b/gdb/mi/mi-cmds.h
@@ -206,6 +206,11 @@ extern mi_command *mi_cmd_lookup (const char *command);
extern void mi_execute_command (const char *cmd, int from_tty);
+/* Execute an MI command given an already-constructed parse
+ object. */
+
+extern void mi_execute_command (mi_parse *context);
+
/* Insert COMMAND into the global mi_cmd_table. Return false if
COMMAND->name already exists in mi_cmd_table, in which case COMMAND will
not have been added to mi_cmd_table. Otherwise, return true, and
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index b430115..f3b7490 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1965,6 +1965,21 @@ mi_execute_command (const char *cmd, int from_tty)
}
}
+/* See mi-cmds.h. */
+
+void
+mi_execute_command (mi_parse *context)
+{
+ if (context->op != MI_COMMAND)
+ error (_("Command is not an MI command"));
+
+ scoped_restore save_token = make_scoped_restore (&current_token,
+ context->token);
+ scoped_restore save_debug = make_scoped_restore (&mi_debug_p, 0);
+
+ mi_cmd_execute (context);
+}
+
/* Captures the current user selected context state, that is the current
thread and frame. Later we can then check if the user selected context
has changed at all. */