From: Paul Pluzhnikov <ppluzhnikov@google.com>
To: Ludovic Brenta <ludovic@ludovic-brenta.org>
Cc: gdb@sourceware.org
Subject: Re: Inspecting environment variables from a core dump?
Date: Sun, 08 May 2011 08:05:00 -0000 [thread overview]
Message-ID: <BANLkTimgiYF7gKXr+pQStp+j-9Dp3iJtmA@mail.gmail.com> (raw)
In-Reply-To: <102a959df9a18135271bc2ddd5ae9eb1@localhost>
On Wed, Apr 20, 2011 at 5:24 AM, Ludovic Brenta
<ludovic@ludovic-brenta.org> wrote:
>
> Andreas Schwab wrote:
>> Ludovic Brenta <ludovic@ludovic-brenta.org> writes:
>>
>>> Does a core dump contain the environment of the program that dumped
> core?
>>
>> A core dump contains the whole used address space of the program, and
>> the environment is of course part of it.
>>
>>> If so, how can I inspect the environment variables?
>>
>> The environment is always stored in the variable environ.
There are possibly two environments: "the environment passed from the
kernel at execve(2) time", and "the environment as it was possibly
modified by putenv/setenv etc. at crash point". The latter is pointed
at by the 'environ' variable.
> Thanks but:
>
> (gdb) p environ
> $13 = 0
> (gdb) whatis environ
> type = <data variable, no debug info>
>
> Am I simply out of luck or doing something wrong?
You aren't doing anything wrong, but you lack debug info needed to
make it work. GDB has no special knowledge about the 'environ', but
you *do*. Use it!
(gdb) print (char ***) &environ
$1 = (char ***) 0x7ffff7ffe9a0
(gdb) print $1[0][0]@100 # should print the first 100 env variables.
HTH,
--
Paul Pluzhnikov
prev parent reply other threads:[~2011-05-08 8:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-20 9:37 Ludovic Brenta
2011-04-20 9:56 ` Andreas Schwab
2011-04-20 12:28 ` Ludovic Brenta
2011-05-08 8:05 ` Paul Pluzhnikov [this message]
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=BANLkTimgiYF7gKXr+pQStp+j-9Dp3iJtmA@mail.gmail.com \
--to=ppluzhnikov@google.com \
--cc=gdb@sourceware.org \
--cc=ludovic@ludovic-brenta.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