diff options
author | Pedro Alves <palves@redhat.com> | 2016-06-21 01:11:55 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2016-06-21 01:11:55 +0100 |
commit | 60eb5395fa7a7b8e3cd1841e38b6d1a0c16be0d0 (patch) | |
tree | 0b522219c0efc6982e6f93d2c5b451f6eedac060 /gdb/interps.h | |
parent | 268a799a454ce862f516ff2215290fae08eca7fa (diff) | |
download | binutils-gdb-60eb5395fa7a7b8e3cd1841e38b6d1a0c16be0d0.tar.gz |
Add new command to create extra console/mi UIs
With all the previous plumbing in place, it's now easy to add a
command that actually creates a new console/mi UI.
The intended use case is to make it possible and easy for MI frontends
to provide a fully featured GDB console to users, with readline
support, command line editing, history, etc., just like if gdb was
started on the command line. Currently MI frontends have to try to
implement all of that theirselves and make use of "-interpreter-exec
console ...", which is far from perfect. If you ever tried Eclipse's
gdb console window, you'll know what I mean...
Instead of trying to multiplex console through MI, this command let's
just leverage all the built in readline/editing support already inside
gdb.
The plan is for the MI frontend to start GDB in regular console mode,
running inside a terminal emulator widget embedded in Eclipse (which
already exists, for supporting the shell widget; other frontends have
similar widgets), and then tell GDB to run a full MI interpreter on an
specified input/output device, independent of the console.
My original prototype planned to do things the other way around --
start GDB in MI mode, and then start an extra CLI console on separate
tty. I handed over that prototype to Marc Khouzam @ Eclipse CDT, and
after experimentation and discussion, we ended up concluding that
starting GDB in CLI mode instead was both easier and actually also
supported an interesting use case -- connect an Eclipse frontend to a
GDB that is already running outside Eclipse.
The current usage is "new-ui <interpreter> <tty>".
E.g., on a terminal run this scriplet:
$ cat gdb-client
#!/bin/bash
reset
tty
tail -f /dev/null
$ gdb-client
/dev/pts/15
Now run gdb on another terminal, and tell it to start a MI interpreter
on the tty of the other terminal:
...
(gdb) new-ui mi /dev/pts/15
New UI allocated
Now back to the the gdb-client terminal, we'll get an MI prompt, ready
for MI input:
/dev/pts/15
=thread-group-added,id="i1"
(gdb)
You can also start a new UI running a CLI, with:
(gdb) new-ui console /dev/pts/15
Though note that this console won't support readline command editing.
It works as if "set editing off" was entered.
gdb/ChangeLog:
2016-06-21 Pedro Alves <palves@redhat.com>
* interps.c (set_top_level_interpreter): New function, factored
out from captured_main.
(interpreter_completer): Make extern.
* interps.h (set_top_level_interpreter, interpreter_completer):
New declarations.
(captured_main): Use set_top_level_interpreter.
* top.c [!O_NOCTTY] (O_NOCTTY): Define as 0.
(open_terminal_stream, new_ui_command): New functions.
(init_main): Install the "new-ui" command.
Diffstat (limited to 'gdb/interps.h')
-rw-r--r-- | gdb/interps.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gdb/interps.h b/gdb/interps.h index 4ac08453357..97d510ff9c0 100644 --- a/gdb/interps.h +++ b/gdb/interps.h @@ -95,6 +95,11 @@ extern int interp_set (struct interp *interp, int top_level); the interpreter. */ extern struct interp *interp_lookup (struct ui *ui, const char *name); +/* Set the current UI's top level interpreter to the interpreter named + NAME. Throws an error if NAME is not a known interpreter or the + interpreter fails to initialize. */ +extern void set_top_level_interpreter (const char *name); + extern struct ui_out *interp_ui_out (struct interp *interp); extern void *interp_data (struct interp *interp); extern const char *interp_name (struct interp *interp); @@ -131,6 +136,12 @@ extern int interp_supports_command_editing (struct interp *interp); chance to e.g., print a prompt. */ extern void interp_pre_command_loop (struct interp *interp); +/* List the possible interpreters which could complete the given + text. */ +extern VEC (char_ptr) *interpreter_completer (struct cmd_list_element *ignore, + const char *text, + const char *word); + /* well-known interpreters */ #define INTERP_CONSOLE "console" #define INTERP_MI1 "mi1" |