Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/dap: add support for opening core files
Date: Tue, 21 Apr 2026 15:35:27 +0100	[thread overview]
Message-ID: <87a4uw2xg0.fsf@redhat.com> (raw)
In-Reply-To: <de78016b74c2e883ab6c6929283d708e37152767.1776725506.git.aburgess@redhat.com>

Andrew Burgess <aburgess@redhat.com> writes:

> 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.

I had a follow up thought relating to this patch -- I wonder if we
should add a custom capability, something like:

  @capability("supportsGDBAttachWithCoreFile")

then a DAP user will know if they can load a core file in this way or
not.  Obviously, this would need some doc changes too...

I'm not sure if we have any custom capabilities yet, I couldn't see
anything documented, so I guess not.

Thanks,
Andrew


  reply	other threads:[~2026-04-21 14:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-20 22:52 Andrew Burgess
2026-04-21 14:35 ` Andrew Burgess [this message]
2026-04-22 17:20   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a4uw2xg0.fsf@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox