binutils-gdb/gdb/python
Tom de Vries 032d23a6db [gdb/dap] Fix stray KeyboardInterrupt after cancel
When running test-case gdb.dap/pause.exp 100 times in a loop, it passes
100/100.

But if we remove the two "sleep 0.2" from the test-case, we run into
(copied from dap.log and edited for readability):
...
Traceback (most recent call last):
  File "startup.py", line 251, in message
    def message():

KeyboardInterrupt
Quit
...

This happens as follows.

CancellationHandler.cancel calls gdb.interrupt to cancel a request in flight.

The idea is that this interrupt triggers while in fn here in message (a nested
function of send_gdb_with_response):
...
    def message():
        try:
            val = fn()
            result_q.put(val)
        except (Exception, KeyboardInterrupt) as e:
            result_q.put(e)
...
but instead it triggers outside the try/except.

Fix this by:
- in CancellationHandler, renaming variable in_flight to in_flight_dap_thread,
  and adding a variable in_flight_gdb_thread to be able to distinguish when
  a request is in flight in the dap thread or the gdb thread.
- adding a wrapper Cancellable to to deal with cancelling the wrapped
  event
- using Cancellable in send_gdb and send_gdb_with_response to wrap the posted
  event
- in CancellationHandler.cancel, only call gdb.interrupt if
  req == self.in_flight_gdb_thread.

This makes the test-case pass 100/100, also when adding the extra stressor of
"taskset -c 0", which makes the fail more likely without the patch.

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>

PR dap/31275
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31275
2024-02-29 21:29:34 +01:00
..
lib/gdb [gdb/dap] Fix stray KeyboardInterrupt after cancel 2024-02-29 21:29:34 +01:00
py-all-events.def Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-arch.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-auto-load.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-block.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-bpevent.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-breakpoint.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-cmd.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-connection.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-continueevent.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-dap.c Fix gdb.interrupt race 2024-02-28 09:08:16 -07:00
py-disasm.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-event-types.def Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-event.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-event.h gdb: pass frames as const frame_info_ptr & 2024-02-20 10:42:25 -05:00
py-events.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-evtregistry.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-evts.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-exitedevent.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-finishbreakpoint.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-frame.c gdb: pass frames as const frame_info_ptr & 2024-02-20 10:42:25 -05:00
py-framefilter.c gdb: pass frames as const frame_info_ptr & 2024-02-20 10:42:25 -05:00
py-function.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-gdb-readline.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-inferior.c gdb: pass frames as const frame_info_ptr & 2024-02-20 10:42:25 -05:00
py-infevents.c gdb: pass frames as const frame_info_ptr & 2024-02-20 10:42:25 -05:00
py-infthread.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-instruction.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-instruction.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-lazy-string.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-linetable.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-membuf.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-mi.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-micmd.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-newobjfileevent.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-objfile.c Use domain_search_flags in lookup_symbol et al 2024-01-28 10:58:16 -07:00
py-param.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-prettyprint.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-progspace.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-record-btrace.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-record-btrace.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-record-full.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-record-full.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-record.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-record.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-ref.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-registers.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-signalevent.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-stopevent.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-stopevent.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-symbol.c Rename SEARCH_ALL 2024-02-01 07:10:57 -07:00
py-symtab.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-threadevent.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-tui.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-type.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-uiout.h gdb: Buffer output streams during events that might download debuginfo 2024-01-19 00:18:00 -05:00
py-unwind.c gdb: pass frames as const frame_info_ptr & 2024-02-20 10:42:25 -05:00
py-utils.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-value.c Allow calling of C++ methods from python 2024-02-08 20:09:56 +01:00
py-varobj.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
py-xmethods.c Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
python-config.py gdb/python-config: replace deprecated distutils.sysconfig 2022-09-01 04:51:33 -04:00
python-internal.h gdb: pass frames as const frame_info_ptr & 2024-02-20 10:42:25 -05:00
python.c Add extension_language_ops::shutdown 2024-02-27 10:30:29 -07:00
python.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00