]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb: Buffer output streams during events that might download debuginfo
authorAaron Merey <amerey@redhat.com>
Fri, 12 Jan 2024 19:38:45 +0000 (14:38 -0500)
committerAaron Merey <amerey@redhat.com>
Fri, 19 Jan 2024 05:18:00 +0000 (00:18 -0500)
commit519d634396592c5698add4a327468e6e6920576e
tree695c241945e77efdfae59af2a33922425cb8f290
parent64db3e4d881d347704139c89d90048082774c9cc
gdb: Buffer output streams during events that might download debuginfo

Introduce new ui_file buffering_file to temporarily collect output
written to gdb_std* output streams during print_thread, print_frame_info
and print_stop_event.

This ensures that output during these functions is not interrupted
by debuginfod progress messages.

With the addition of deferred debuginfo downloading it is possible
for download progress messages to print during these events.
Without any intervention we can end up with poorly formatted output:

    (gdb) backtrace
    [...]
    #8  0x00007fbe8af7d7cf in pygi_invoke_c_callable (Downloading separate debug info for /lib64/libpython3.11.so.1.0
    function_cache=0x561221b224d0, state=<optimized out>...

To fix this we buffer writes to gdb_std* output streams while allowing
debuginfod progress messages to skip the buffers and print to the
underlying output streams immediately.  Buffered output is then written
to the output streams.  This ensures that progress messages print first,
followed by uninterrupted frame/thread/stop info:

    (gdb) backtrace
    [...]
    Downloading separate debug info for /lib64/libpython3.11.so.1.0
    #8  0x00007fbe8af7d7cf in pygi_invoke_c_callable (function_cache=0x561221b224d0, state=<optimized out>...

Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
Approved-By: Andrew Burgess <aburgess@redhat.com>
gdb/cli-out.c
gdb/cli-out.h
gdb/debuginfod-support.c
gdb/infrun.c
gdb/mi/mi-out.h
gdb/python/py-uiout.h
gdb/stack.c
gdb/thread.c
gdb/ui-out.c
gdb/ui-out.h