This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v2 00/25] Towards great frontend GDB consoles


Here's an update of the series I first posted here:
  https://sourceware.org/ml/gdb-patches/2016-02/msg00067.html

New in v2:

- The "Command line input handling TLC" patch [1] has since been split
  into a series of its own [2], and pushed in.

  [1] https://sourceware.org/ml/gdb-patches/2016-02/msg00070.html
  [2] https://sourceware.org/ml/gdb-patches/2016-02/msg00557.html

- Currently, if GDB's (main) stdin closes, GDB exits.  That logic
  carried over to secondary UIs as well, by mistake, so v1, if a
  secondary UI's terminal was closed, GDB would just exit as well...
  In v2, that's now detected, and GDB just discards the UI.

- I noticed that if you typed something in a secondary UI, and then
  Ctrl-C'd the main UI, GDB would internal error.  The problem was
  that nothing was making use async signal handlers (in this case,
  async_request_quit) always run on the main UI.

- Added a convenience "info uis" command to list UIs.

- Some cleanups here and there

Force-pushed to users/palves/console at sourceware.org.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Series intro:

This series provides a way to for frontends's GDB console to be on par
with gdb's native console running on a terminal.

The current support for implementing a GDB console that MI frontends
have available, based on "-interpreter-exec console", leaves readline,
history, completion, when to show/hide/print the prompt (sync vs async
execution), pagination, etc. all up to the frontend.

The end result is that all frontends have a real bad GDB console
experience, if they provide one at all.

GDB already has to handle all that for the native CLI, when GDB is
started without MI.  This series leverages that.  Instead, have
Eclipse create a pty and wrap it in a window widget -- the same as
Eclipse's shell console -- and start GDB in that pty.  Then, create a
second pty for MI communication, and tell GDB to start a MI
interpreter there, with a new "new-ui mi /dev/pts/N" command.

GDB then creates/manages a CLI on its terminal, with readline,
history, etc., support all done by GDB.

It's also possible to start extra CLI consoles, with "new-ui console
/dev/pts/N".  The current limitation is that these extra consoles
don't have readline active (work as if "set editing off"), because
there can only be one instance of readline in a process, currently.
(I have a readline patch that addresses it, but it'll need API and
implementation discussion and it may or not be accepted.)

It should be possible to start gdb in MI mode, and then start an extra
console, and support readline on that console (since there's still
just one readline user), though it'll need a little bit more work to
get there.  I just didn't try it yet, but it's definitely possible.

My original prototype did start out by doing things the other way
around -- start GDB in MI mode, and then start an extra CLI console on
a separate tty.  I handed over that (functional) prototype to Marc
Khouzam @ Eclipse CDT a while ago, and after experimentation and
discussion, we ended up concluding that starting GDB in CLI mode
instead was both easier and actually also makes it possible to support
an interesting use case -- connect an Eclipse frontend to a GDB that
is already running outside Eclipse.  Say, you're debugging on a
terminal, and then suddendly decide to start Eclipse's Standalone
Debugger _reusing_ your existing GDB, without having to start the
debug session from scratch.  Magic.

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 an 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

More details in patch 24, which actually adds the new-ui command.

This still misses ChangeLog entries, some comments, and documentation
changes.  And I haven't thought about tests yet.

In case I messed up something on this update, you can still find v1 on
my github:
  https://github.com/palves/gdb/commits/palves/console-v1

Pedro Alves (25):
  Introduce "struct ui"
  Make gdb_stdout&co be per UI
  Make the interpreters be per UI
  Introduce interpreter factories
  Make the intepreters output to all UIs
  Always run async signal handlers in the main UI
  Make instream and serial_stdin be per UI
  Make input_fd be per UI
  Make outstream be per UI
  Delete def_uiout
  Make current_ui_out be per UI
  Make command line editing (use of readline) be per UI
  Always process target events in the main UI
  Make target_terminal_inferior/ours almost nops on non-main UIs
  Introduce display_mi_prompt
  Simplify starting the command event loop
  Make gdb_in_secondary_prompt_p() be per UI
  Replace the sync_execution global with a new enum prompt_state
    tristate
  New function should_print_stop_to_console
  Push thread->control.command_interp to the struct thread_fsm
  Only send sync execution command output to the UI that ran the command
  Make main_ui be heap allocated
  Handle UI terminal closed
  Add new command to create extra console/mi UI channels
  Add command to list UIs

 gdb/annotate.c                     |  15 +-
 gdb/breakpoint.c                   |  21 +-
 gdb/cli/cli-interp.c               | 248 +++++++---
 gdb/cli/cli-interp.h               |  32 ++
 gdb/cli/cli-script.c               |  27 +-
 gdb/compile/compile.c              |  14 +-
 gdb/event-loop.c                   |   5 +
 gdb/event-top.c                    | 322 +++++++------
 gdb/event-top.h                    |  13 +-
 gdb/exceptions.c                   |   4 +-
 gdb/gdbthread.h                    |   5 -
 gdb/guile/guile.c                  |  14 +-
 gdb/guile/scm-ports.c              |   6 +-
 gdb/inf-loop.c                     |   2 +-
 gdb/infcall.c                      |  43 +-
 gdb/infcmd.c                       | 102 ++--
 gdb/inflow.c                       |  23 +-
 gdb/infrun.c                       | 137 ++++--
 gdb/infrun.h                       |  10 +-
 gdb/interps.c                      | 262 +++++++---
 gdb/interps.h                      |  49 +-
 gdb/linux-nat.c                    |   2 -
 gdb/main.c                         |  53 +--
 gdb/mi/mi-interp.c                 | 946 ++++++++++++++++++++++---------------
 gdb/mi/mi-main.c                   |   2 +-
 gdb/python/python.c                |  15 +-
 gdb/remote.c                       |   2 -
 gdb/target.c                       |  27 +-
 gdb/terminal.h                     |   6 +-
 gdb/testsuite/gdb.gdb/selftest.exp |   4 +
 gdb/thread-fsm.c                   |  12 +-
 gdb/thread-fsm.h                   |  23 +-
 gdb/thread.c                       |   2 +-
 gdb/top.c                          | 344 ++++++++++++--
 gdb/top.h                          | 154 +++++-
 gdb/tui/tui-interp.c               | 168 +++++--
 gdb/tui/tui-io.c                   |   4 +-
 gdb/ui-file.c                      |   4 +-
 gdb/ui-file.h                      |   4 +-
 gdb/ui-out.c                       | 184 --------
 gdb/ui-out.h                       |   3 +-
 gdb/utils.c                        |   4 +-
 gdb/utils.h                        |  19 +-
 43 files changed, 2146 insertions(+), 1190 deletions(-)
 create mode 100644 gdb/cli/cli-interp.h

-- 
2.5.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]