binutils-gdb/gdb/python
Andrew Burgess b080fe54fb gdb: add inferior-specific breakpoints
This commit extends the breakpoint mechanism to allow for inferior
specific breakpoints (but not watchpoints in this commit).

As GDB gains better support for multiple connections, and so for
running multiple (possibly unrelated) inferiors, then it is not hard
to imagine that a user might wish to create breakpoints that apply to
any thread in a single inferior.  To achieve this currently, the user
would need to create a condition possibly making use of the $_inferior
convenience variable, which, though functional, isn't the most user
friendly.

This commit adds a new 'inferior' keyword that allows for the creation
of inferior specific breakpoints.

Inferior specific breakpoints are automatically deleted when the
associated inferior is removed from GDB, this is similar to how
thread-specific breakpoints are deleted when the associated thread is
deleted.

Watchpoints are already per-program-space, which in most cases mean
watchpoints are already inferior specific.  There is a small window
where inferior-specific watchpoints might make sense, which is after a
vfork, when two processes are sharing the same address space.
However, I'm leaving that as an exercise for another day.  For now,
attempting to use the inferior keyword with a watchpoint will give an
error, like this:

  (gdb) watch a8 inferior 1
  Cannot use 'inferior' keyword with watchpoints

A final note on the implementation: currently, inferior specific
breakpoints, like thread-specific breakpoints, are inserted into every
inferior, GDB then checks once the inferior stops if we are in the
correct thread or inferior, and resumes automatically if we stopped in
the wrong thread/inferior.

An obvious optimisation here is to only insert breakpoint locations
into the specific program space (which mostly means inferior) that
contains either the inferior or thread we are interested in.  This
would reduce the number times GDB has to stop and then resume again in
a multi-inferior setup.

I have a series on the mailing list[1] that implements this
optimisation for thread-specific breakpoints.  Once this series has
landed I'll update that series to also handle inferior specific
breakpoints in the same way.  For now, inferior specific breakpoints
are just slightly less optimal, but this is no different to
thread-specific breakpoints in a multi-inferior debug session, so I
don't see this as a huge problem.

[1] https://inbox.sourceware.org/gdb-patches/cover.1685479504.git.aburgess@redhat.com/
2023-08-17 16:42:39 +01:00
..
lib/gdb Implement DAP module-removed event 2023-08-16 09:55:10 -06:00
py-all-events.def gdb/Python: Added ThreadExitedEvent 2023-06-19 16:17:21 +02:00
py-arch.c gdb: add __repr__() implementation to a few Python types 2023-07-04 12:07:16 +01:00
py-auto-load.c gdb/python: add mechanism to manage Python initialization functions 2023-05-05 18:24:42 +01:00
py-block.c gdb: add __repr__() implementation to a few Python types 2023-07-04 12:07:16 +01:00
py-bpevent.c
py-breakpoint.c gdb: add inferior-specific breakpoints 2023-08-17 16:42:39 +01:00
py-cmd.c gdb/python: add mechanism to manage Python initialization functions 2023-05-05 18:24:42 +01:00
py-connection.c gdb/python: add mechanism to manage Python initialization functions 2023-05-05 18:24:42 +01:00
py-continueevent.c
py-dap.c [gdb/dap] Disable DAP for python <= 3.5 2023-08-02 23:14:58 +02:00
py-disasm.c Fix two Python calls that don't check for errors 2023-07-03 11:35:18 -06:00
py-event-types.def gdb/Python: Added ThreadExitedEvent 2023-06-19 16:17:21 +02:00
py-event.c gdb/python: add mechanism to manage Python initialization functions 2023-05-05 18:24:42 +01:00
py-event.h gdb/Python: Added ThreadExitedEvent 2023-06-19 16:17:21 +02:00
py-events.h
py-evtregistry.c gdb/python: add mechanism to manage Python initialization functions 2023-05-05 18:24:42 +01:00
py-evts.c
py-exitedevent.c
py-finishbreakpoint.c gdb: add inferior-specific breakpoints 2023-08-17 16:42:39 +01:00
py-frame.c gdb/python: add mechanism to manage Python initialization functions 2023-05-05 18:24:42 +01:00
py-framefilter.c Don't treat references to compound values as "simple". 2023-05-04 08:58:18 -06:00
py-function.c gdb/python: add mechanism to manage Python initialization functions 2023-05-05 18:24:42 +01:00
py-gdb-readline.c gdb/python: add mechanism to manage Python initialization functions 2023-05-05 18:24:42 +01:00
py-inferior.c Fix gdb.Inferior.read_memory without execution (PR dap/30644) 2023-07-19 14:10:19 +01:00
py-infevents.c
py-infthread.c gdb/python: add mechanism to manage Python initialization functions 2023-05-05 18:24:42 +01:00
py-instruction.c gdb/python: add mechanism to manage Python initialization functions 2023-05-05 18:24:42 +01:00
py-instruction.h
py-lazy-string.c gdb/python: add mechanism to manage Python initialization functions 2023-05-05 18:24:42 +01:00
py-linetable.c gdb/python: add mechanism to manage Python initialization functions 2023-05-05 18:24:42 +01:00
py-membuf.c gdb/python: add mechanism to manage Python initialization functions 2023-05-05 18:24:42 +01:00
py-mi.c Implement gdb.execute_mi 2023-05-23 10:09:28 -06:00
py-micmd.c Use unique_xmalloc_ptr for mi_parse::command 2023-06-20 06:23:30 -06:00
py-newobjfileevent.c
py-objfile.c gdb/python: add mechanism to manage Python initialization functions 2023-05-05 18:24:42 +01:00
py-param.c [gdb/build] Fix enum param_types odr violation 2023-08-14 18:32:29 +02:00
py-prettyprint.c Fix value chain use-after-free 2023-02-27 15:46:31 -07:00
py-progspace.c Add Progspace.objfile_for_address 2023-07-21 12:05:30 -06:00
py-record-btrace.c python, btrace: Fix some small formatting issues. 2023-05-31 09:27:17 +02:00
py-record-btrace.h
py-record-full.c
py-record-full.h
py-record.c python, btrace: Fix some small formatting issues. 2023-05-31 09:27:17 +02:00
py-record.h
py-ref.h
py-registers.c gdb/python: add mechanism to manage Python initialization functions 2023-05-05 18:24:42 +01:00
py-signalevent.c
py-stopevent.c
py-stopevent.h
py-symbol.c gdb: add __repr__() implementation to a few Python types 2023-07-04 12:07:16 +01:00
py-symtab.c gdb/python: add mechanism to manage Python initialization functions 2023-05-05 18:24:42 +01:00
py-threadevent.c gdb/Python: Added ThreadExitedEvent 2023-06-19 16:17:21 +02:00
py-tui.c [gdb/tui] Fix assert in ~gdbpy_tui_window_maker 2023-07-26 12:29:28 +02:00
py-type.c Fix typo in py-type.c docstring 2023-07-21 10:33:07 -06:00
py-unwind.c gdb/python: add mechanism to manage Python initialization functions 2023-05-05 18:24:42 +01:00
py-utils.c Python QUIT processing updates 2023-02-27 16:20:39 -07:00
py-value.c Add gdb.Value.assign method 2023-06-12 12:09:39 -06:00
py-varobj.c
py-xmethods.c gdb/python: add mechanism to manage Python initialization functions 2023-05-05 18:24:42 +01:00
python-config.py
python-internal.h Implement gdb.execute_mi 2023-05-23 10:09:28 -06:00
python.c Re-acquire GIL earlier in gdbpy_parse_and_eval 2023-07-28 06:15:30 -06:00
python.h