Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "Paul Pluzhnikov" <ppluzhnikov@google.com>
To: "Jean-Marc Saffroy" <saffroy@gmail.com>
Cc: gdb@sourceware.org
Subject: Re: how could gdb handle truncated core files?
Date: Fri, 29 Aug 2008 16:30:00 -0000	[thread overview]
Message-ID: <8ac60eac0808270946l284eb94awf97be09b8b3a4aa@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0808261803230.5290@erda.mds>

On Wed, Aug 27, 2008 at 8:21 AM, Jean-Marc Saffroy <saffroy@gmail.com> wrote:

> For now, gdb does not seem to be able to do anything useful with a truncated
> core file on Linux (ie. what you get when your process dies and the core
> size limit is not 0 but less than the size of the process).
>
> In a number of cases, I think it would be nice to be able to at least get a
> stack trace, and examine local variables. This could require a limited
> amount of data to be dumped by the kernel.
...
> In search of a solution, I patched my Linux kernel so that dumping a core
> would start with the segments that hold a stack (assuming user stack
> pointers are valid): thus these segments have a chance of being dumped
> before the core limit is reached.

You may also want to look at Google user-space coredumper:
  http://code.google.com/p/google-coredumper/

It is often easier to play with than to boot custom kernels,
and it already has support for prioritisation of what is dumped,
as well as compression of the core (core files are often *extremely*
compressible).

> This approach gives interesting results with a (very simple) single threaded
> process. However, my attempts with a multithreaded process failed, like
> this:
>
> $ gdb <binary> <core>
> GNU gdb 6.8
> <snip>
> This GDB was configured as "x86_64-unknown-linux-gnu"...
> Cannot access memory at address 0x2aaaaabc29c8
> (gdb) bt
> #0  0x00002aaaaabc9345 in ?? ()
> #1  0x00000000400179f0 in ?? ()
> #2  0x0000000000000000 in ?? ()
>
> That is:
>  - gdb does not load symbols from binaries

The problem here most likely is that _r_debug.r_map was not found
in the (truncated) core. Without it, GDB can't know which libraries
were loaded, hence can't load unwind info for libpthread, hence
can't produce correct stack trace.

> So, I have the following questions to the community:
>  - what can I do (eg. in my kernel patch) to have gdb load symbols from
> binaries?

You might get better mileage if you dump at least the beginning of
the initial data segment.

>  - do you have any comment on my approach? (eg. I *think* I've seen AIX
> produce small dumps, but I have no idea how they do it, if it's a special
> file format, etc.)

I don't believe AIX has "small" dumps.

AFAIK, they have "regular" dumps (similar to Linux) and "full" dumps,
where full dump includes all the shared libraries, and thus allows
one to examine the core on a developer machine (which may not have
the same version of shared libs as the one used at runtime).

Cheers,
-- 
Paul Pluzhnikov


  parent reply	other threads:[~2008-08-27 16:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-28 13:55 Jean-Marc Saffroy
2008-08-29  1:55 ` Paul Koning
2008-08-29 16:30 ` Paul Pluzhnikov [this message]
2008-08-29 17:46   ` Jean-Marc Saffroy

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=8ac60eac0808270946l284eb94awf97be09b8b3a4aa@mail.gmail.com \
    --to=ppluzhnikov@google.com \
    --cc=gdb@sourceware.org \
    --cc=saffroy@gmail.com \
    /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