[PATCHv2,0/3] Improve debug output support in gdbserver

Message ID cover.1701369189.git.aburgess@redhat.com
Headers
Series Improve debug output support in gdbserver |

Message

Andrew Burgess Nov. 30, 2023, 6:44 p.m. UTC
  Changes since v1:

  - I've now dropped the --remote-debug and --event-loop-debug command
    line options,

  - I've now dropped the 'monitor set remote-debug' and 'monitor set
    event-loop-debug' monitor commands,

  - I've fixed some of Eli's doc feedback.  We still have the
    duplication between the man page and info manual content.  I'm not
    sure if that can easily be fixed as part of this commit, or if
    that should be a separate piece of work,

  - Now accept on/off instead of 1/0 in the monitor commands,

  - Now allow 'all' as a component in the monitor commands.
    Preventing this before was pretty arbitrary, and on reflection
    seemed pointless,

  - Fixed a bug where the 'all' component would only actually enable
    the 'threads' component,

  - The first patch of the prevoius series has been pushed.  But I
    have a new first patch which fixes another gdbserver debug related
    issue.

---

For another patch I'm working on I wanted to add some additional debug
output to gdbserver.

Right now there appears to be two broad approaches I could take, these are:

  1. Just use threads_debug_printf.  The comments in debug.h even
  claim that this is really the "general" gdbserver debug output and
  that the "threads" here is just historic, but that feels like a bit
  of a cop out, we do have separate remote and event-loop debug
  control.  I think what really happened is folk just started reusing
  the threads_debug_printf rather than adding a new debug category,
  and over time we just resigned ourselves to threads actually being
  general output...  I think we can do better than that, so

  2. We can add a whole new debug category, with a new *_debug_printf
  function.  That I think would be better, but to control this new
  debug flag we then need to add a new command line flag (we already
  have --debug, --remote-debug, and --event-loop-debug), and then we
  need to add new monitor commands to control this new debug
  setting... this begins to feel not very scalable.

So, in this series I try to reimagine debug control in gdbserver.

The gdbserver command line flag now takes an optional list of
components, so we can do:

  gdbserver --debug=remote,threads

to enable 'remote' and 'threads' debug.  The default if no components
are listed is 'threads', which retains backwards compatibility with
the current behaviour, thought we might want to change this in the
future.

I've also removed the two existing flags '--remote-debug' and
'--event-loop-debug', instead we should now do '--debug=remote',
'--debug=event-loop', or '--debug=remote,event-loop' as needed.

And on the monitor command side, we now support:

  (gdb) monitor set debug COMPONENT on
  (gdb) monitor set debug COMPONENT off

to enable and disable debug for COMPONENT.  Where COMPONENT is again,
'all', 'threads', 'remote', and 'event-loop'.  Again, I've retained:

  (gdb) monitor set debug on

As a synonym for 'monitor set debug threads on', but I have changed:

  (gdb) monitor set debug off

Which now disables all debugging output from gdbserver.  Notice also
that I'm not using 'on' and 'off' in the monitor commands rather than
'1' and '0'.  The old 1/0 still works, but on/off is what the docs now
suggest; this seemed to better match GDB's internal settings.

I have removed the monitor command:

  (gdb) monitor set remote-debug 0|1
  (gdb) monitor set event-loop-debug 0|1

These commands are replaces by using the 'remote' or 'event-loop'
components as needed.

---

Andrew Burgess (3):
  gdb: fix GDB_DEBUG and GDBSERVER_DEBUG Makefile variables
  gdbserver: allow the --debug command line option to take a value
  gdbserver: allow for general 'monitor set debug COMPONENT VALUE' use

 gdb/Makefile.in                         |   5 +-
 gdb/NEWS                                |  18 ++
 gdb/doc/gdb.texinfo                     |  98 ++++++--
 gdb/testsuite/gdb.server/server-mon.exp |  25 +-
 gdbserver/server.cc                     | 315 +++++++++++++++++++++---
 5 files changed, 397 insertions(+), 64 deletions(-)


base-commit: a393b155174d20d3d120b5012b87c5438ab9e3d4
  

Comments

Tom Tromey Dec. 1, 2023, 6:02 p.m. UTC | #1
>>>>> Andrew Burgess <aburgess@redhat.com> writes:

> Changes since v1:
>   - I've now dropped the --remote-debug and --event-loop-debug command
>     line options,
[...]

Thank you.  This looks good to me.
Approved-By: Tom Tromey <tom@tromey.com>

Tom
  
Andrew Burgess Dec. 8, 2023, 6:03 p.m. UTC | #2
Tom Tromey <tom@tromey.com> writes:

>>>>>> Andrew Burgess <aburgess@redhat.com> writes:
>
>> Changes since v1:
>>   - I've now dropped the --remote-debug and --event-loop-debug command
>>     line options,
> [...]
>
> Thank you.  This looks good to me.
> Approved-By: Tom Tromey <tom@tromey.com>

Pushed.

Thanks,
Andrew