public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Simon Sobisch <simonsobisch@gnu.org>
To: Christian Biesinger <cbiesinger@google.com>
Cc: Pedro Alves <pedro@palves.net>, gdb@sourceware.org
Subject: Re: Is corefile support for missing on Win32?
Date: Tue, 7 Feb 2023 11:35:57 +0100	[thread overview]
Message-ID: <299ca968-412e-5e43-32d6-f0d136cec7bb@gnu.org> (raw)
In-Reply-To: <87eba601-e753-02ac-0645-45c09377cac6@palves.net>

This is especially a call to Christian Biesinger to ask if there was any 
more work on "supporting minidump with GDB"; but there's more content 
"inline" in the text, too.


Am 09.06.2022 um 18:20 schrieb Pedro Alves:
> On 2022-06-07 20:30, Simon Sobisch via Gdb wrote:
>> Testing with MSYS2 generated mingw64 gcc 12.1 + gdb 12.1 resulted in "everything working" ...until I needed to create a core file.
>>
>> (gdb) show arch
>> The target architecture is set to "auto" (currently "i386:x86-64").
>> (gdb) gcore test.core
>> warning: cannot close "test.core": invalid operation
>> Can't create a corefile
>>
>> (with gnutarget auto, pei-x86-64 and pe-x86-64)
>>
>> I see that the first error message comes from
>>    gdb/gdb_bfd.c (gdb_bfd_close_warning)
>> and the second from the default implementation
>>    gdb/exec.c (make_corefile_notes)
>>
>>
>> This issue seems to exists for longer as some SO question [1] asked about this over 5 years ago.
>>
>> Further testing showed the same issue with same tools in MinGW x86 and with "good old MinGW" using GDB 7.6.1 / GCC 9.2.
>>
>> Testing with cygwin-x64 (GDB 11.2) shows the same result.
>>
> 
> Native Windows GDB was never able to generate cores.  Basically because cores are ELF objects,
> while Windows is PE, so it's kind of a foreign thing.

I see. That's a real pitty, but maybe this improves some day.

> However, Cygwin comes with a separate utility that is able to dump cores in ELF format, and
> Windows GDB is actually able to read those.  This utility is called "dumper".  See here:
> 
>    https://www.cygwin.com/cygwin-ug-net/dumper.html
> 
> Sources are here:
> 
>    https://cygwin.com/git/?p=newlib-cygwin.git;a=blob;f=winsup/utils/dumper.cc
> 
> If someone wanted to work on it, I don't see any obstacle to GDB's gcore command
> itself generating an ELF core in the exact same format.

That would be an interesting point I'll check with its contributors later.

In the meantime I did test the dumper on cygwin, it works there but only 
in specific cases (I did not get it to work in mot cases "while the 
process runs", as it often generates a file that contains only threads 
in the Windows API where no debugging symbols are available and 
therefore all threads have broken backtraces with not a single one in 
the program space one is interested in.
This _may_ worked around if the generation could be postponed until the 
code reaches "program space", but I don't know enough about that (and it 
won't work on a "real abort".
Note: the part where it _did_ work was when "dumper" is hooked into 
cygwin's internal abort handling, then reaching a SIGSEGV.
The corefile was not usable when, for example, the user code did `raise(6)`.

>> I guess the system's minidump format cannot be processed with GDB, can it?
> 
> Unfortunately not.  Christian Biesinger did write a patch to add support for it while ago, though:
> 
>    https://sourceware.org/git/?p=binutils-gdb.git;a=shortlog;h=refs/heads/users/cbiesinger/minidump
> 
> AFAIK, this was never finished/contributed for proper inclusion, and I don't know how far
> that is to being complete.

We'll see if/how Christian (or others that now about that approach from 
2020) answers.

Thanks for any hints,
Simon

  reply	other threads:[~2023-02-07 10:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-07 19:30 Simon Sobisch
2022-06-09 16:20 ` Pedro Alves
2023-02-07 10:35   ` Simon Sobisch [this message]
2023-02-07 20:18     ` Christian Biesinger
2023-02-08 16:28       ` Hannes Domani

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=299ca968-412e-5e43-32d6-f0d136cec7bb@gnu.org \
    --to=simonsobisch@gnu.org \
    --cc=cbiesinger@google.com \
    --cc=gdb@sourceware.org \
    --cc=pedro@palves.net \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).