binutils-gdb/gdb/python
Andrew Burgess 0a481bb9a6 gdb/dap: add support for opening core files
This patch adds core file support to GDB's DAP interface.

Core files are supported as a GDB specific argument to 'attach', the
new argument is 'coreFile', the name of the core file to debug.

I think handling core files via attach makes the most sense; attach is
for connecting to existing processes, but these targets are (usually)
stopped as soon as GDB attaches, and that's what a core file looks
like, a target that was running, but is now stopped.  It just happens
that core file targets are special in that the target cannot be
resumed again, nor can the user modify the program state (e.g. write
to memory or registers).

Prior to starting this work I took a look at what lldb does.  The
documentation is not super clear, but this page seems to indicate that
lldb might also use the 'coreFile' argument to 'attach':

  https://lldb.llvm.org/use/lldbdap.html#configuration-settings-reference

Like I said, it's not very clear, but search for "coreFile" and you'll
see it mentioned, just once, under the "attach" header.  In order to
be compatible with lldb I used the same argument name with the same
capitalisation.

The new argument is added to the documentation and mentioned in NEWS.

I had to make some changes to testsuite/lib/dap-support.exp to support
this new feature.  There's a new dap_corefile proc to handle setting
up the initial connection.  This seemed cleaner that overloading
dap_attach, even though under the hood it is still an 'attach' request
that gets sent.

The new test tries to write to memory and registers with the core file
target in place, neither of these requests succeed, which is what we
want, but the exceptions are logged into the dap log file.  The
dap_shutdown proc calls dap_check_log_file to check the log for
exceptions, and these two exceptions are spotted and trigger a FAIL.
To avoid this I've added a new "expected_exception_count" argument
for dap_shutdown.  Now we check that we see the expected number of
exceptions.  We don't check for the specific exception types right
now, but as the test is already checking that the expected requests
fail, I think we're OK.

Approved-By: Tom Tromey <tom@tromey.com>
2026-04-23 09:58:02 +01:00
..
lib/gdb gdb/dap: add support for opening core files 2026-04-23 09:58:02 +01:00
py-all-events.def gdb/python: new events.corefile_changed event 2026-04-20 22:15:26 +01:00
py-arch.c gdb: add new helpers for retrieving a type's fully qualified name 2026-04-08 11:49:30 +01:00
py-auto-load.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-block.c gdb: add new helpers for retrieving a type's fully qualified name 2026-04-08 11:49:30 +01:00
py-bpevent.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-breakpoint.c gdb: add new helpers for retrieving a type's fully qualified name 2026-04-08 11:49:30 +01:00
py-cmd.c gdb: cast all Python extension objects passed to gdbpy_ref_policy to PyObject* 2026-01-29 16:46:14 +00:00
py-color.c gdb: introduce rgb_color type to simplify existing code 2026-03-10 11:22:28 +00:00
py-color.h Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-connection.c gdb: add new helpers for retrieving a type's fully qualified name 2026-04-08 11:49:30 +01:00
py-continueevent.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-corefile.c gdb/python: new events.corefile_changed event 2026-04-20 22:15:26 +01:00
py-dap.c Rewrite output redirection and logging 2026-02-09 08:15:44 -07:00
py-disasm.c gdb: add new helpers for retrieving a type's fully qualified name 2026-04-08 11:49:30 +01:00
py-event-types.def gdb/python: new events.corefile_changed event 2026-04-20 22:15:26 +01:00
py-event.c gdb/python: add accessor helpers for __dict__ in Python extension objects 2026-03-14 13:21:06 +00:00
py-event.h gdb: new setters and getters for __dict__, and attributes 2026-01-29 16:46:14 +00:00
py-events.h gdb: cast all Python extension objects passed to gdbpy_ref_policy to PyObject* 2026-01-29 16:46:14 +00:00
py-evtregistry.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-evts.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-exitedevent.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-finishbreakpoint.c gdb/python: fix gdb.FinishBreakpoint returning to a tail call frame 2026-03-05 17:45:29 +00:00
py-frame.c gdb: add new helpers for retrieving a type's fully qualified name 2026-04-08 11:49:30 +01:00
py-framefilter.c Return gdbpy_ref<> from frame_info_to_frame_object 2026-02-23 05:29:12 -07:00
py-function.c gdb: switch tuple object helpers to Python limited API equivalents 2026-03-04 15:38:11 +00:00
py-gdb-readline.c Python limited API: migrate Py_CompileStringExFlags and PyRun_SimpleString 2026-01-28 09:41:25 +00:00
py-inferior.c gdb: change new_objfile observer to take an objfile reference 2026-03-19 14:36:25 +00:00
py-infevents.c Return gdbpy_ref<> from frame_info_to_frame_object 2026-02-23 05:29:12 -07:00
py-infthread.c gdb: add new helpers for retrieving a type's fully qualified name 2026-04-08 11:49:30 +01:00
py-instruction.c gdb: make remaining Python extension objects inherit from PyObject 2026-01-29 16:46:14 +00:00
py-instruction.h Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-lazy-string.c gdb, gdbserver, gdbsupport: replace many uses of strcmp with streq 2026-03-16 13:24:00 -04:00
py-linetable.c Return gdbpy_ref<> from symtab_to_linetable_object 2026-02-23 05:29:12 -07:00
py-membuf.c gdb: cast all Python extension objects passed to gdbpy_ref_policy to PyObject* 2026-01-29 16:46:14 +00:00
py-mi.c gdb: add new helpers for retrieving a type's fully qualified name 2026-04-08 11:49:30 +01:00
py-micmd.c gdb: add new helpers for retrieving a type's fully qualified name 2026-04-08 11:49:30 +01:00
py-newobjfileevent.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-obj-type.c gdb: add new helpers for retrieving a type's fully qualified name 2026-04-08 11:49:30 +01:00
py-obj-type.h gdb: add new helpers for retrieving a type's fully qualified name 2026-04-08 11:49:30 +01:00
py-objfile.c gdb/python: add accessor helpers for __dict__ in Python extension objects 2026-03-14 13:21:06 +00:00
py-param.c gdb, gdbserver, gdbsupport: replace many uses of strcmp with streq 2026-03-16 13:24:00 -04:00
py-prettyprint.c gdb, gdbserver, gdbsupport: replace many uses of strcmp with streq 2026-03-16 13:24:00 -04:00
py-progspace.c gdb/python: add accessor helpers for __dict__ in Python extension objects 2026-03-14 13:21:06 +00:00
py-record-btrace.c Use the "O!" format more in the Python code 2026-02-27 12:01:56 -07:00
py-record-btrace.h Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-record-full.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-record-full.h Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-record.c gdb: make remaining Python extension objects inherit from PyObject 2026-01-29 16:46:14 +00:00
py-record.h gdb: make remaining Python extension objects inherit from PyObject 2026-01-29 16:46:14 +00:00
py-ref.h gdb/python: add accessor helpers for __dict__ in Python extension objects 2026-03-14 13:21:06 +00:00
py-registers.c Hold the GIL while clearing gdbpy_reggroup_object_map 2026-03-25 11:12:14 -06:00
py-signalevent.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-stopevent.c Return gdbpy_ref<> from value_to_value_object 2026-02-23 05:29:11 -07:00
py-stopevent.h Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-style.c gdb: add new helpers for retrieving a type's fully qualified name 2026-04-08 11:49:30 +01:00
py-symbol.c gdb: introduce iteration_status enum, use it for search callbacks 2026-04-17 15:30:29 -04:00
py-symtab.c gdb/python: introduce gdb.Symtab.source_lines method 2026-03-05 10:17:08 +00:00
py-threadevent.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-tui.c gdb: cast all Python extension objects passed to gdbpy_ref_policy to PyObject* 2026-01-29 16:46:14 +00:00
py-type.c gdb: add new helpers for retrieving a type's fully qualified name 2026-04-08 11:49:30 +01:00
py-uiout.h Remove m_applied_style from ui_file 2026-02-09 08:15:29 -07:00
py-unwind.c gdb: add new helpers for retrieving a type's fully qualified name 2026-04-08 11:49:30 +01:00
py-utils.c gdb: add new helpers for retrieving a type's fully qualified name 2026-04-08 11:49:30 +01:00
py-value.c Return gdbpy_ref<> from type_to_type_object 2026-02-23 05:29:12 -07:00
py-varobj.c Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00
py-xmethods.c gdb: switch tuple object helpers to Python limited API equivalents 2026-03-04 15:38:11 +00:00
python-config.py
python-internal.h gdb: add new helpers for retrieving a type's fully qualified name 2026-04-08 11:49:30 +01:00
python.c Add command styling to error messages 2026-04-08 19:12:44 -06:00
python.h Update copyright dates to include 2026 2026-01-05 13:16:46 -07:00