* Inspecting environment variables from a core dump?
@ 2011-04-20 9:37 Ludovic Brenta
2011-04-20 9:56 ` Andreas Schwab
0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Brenta @ 2011-04-20 9:37 UTC (permalink / raw)
To: gdb
Hello,
After searching the GDB documentation, mailing list and bug database I
have not found an answer to my question, so as a last resort I post it
here.
Does a core dump contain the environment of the program that dumped core?
If so, how can I inspect the environment variables? "show environment"
shows the environment that GDB is running in, not the environment of the
debuggee.
(context: I am analyzing a core dump that was produced on another machine
and I supect the bug was caused by a bad environment variable).
Thanks for any help.
--
Ludovic Brenta.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Inspecting environment variables from a core dump?
2011-04-20 9:37 Inspecting environment variables from a core dump? Ludovic Brenta
@ 2011-04-20 9:56 ` Andreas Schwab
2011-04-20 12:28 ` Ludovic Brenta
0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2011-04-20 9:56 UTC (permalink / raw)
To: Ludovic Brenta; +Cc: gdb
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.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Inspecting environment variables from a core dump?
2011-04-20 9:56 ` Andreas Schwab
@ 2011-04-20 12:28 ` Ludovic Brenta
2011-05-08 8:05 ` Paul Pluzhnikov
0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Brenta @ 2011-04-20 12:28 UTC (permalink / raw)
To: gdb
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.
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?
--
Ludovic Brenta.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Inspecting environment variables from a core dump?
2011-04-20 12:28 ` Ludovic Brenta
@ 2011-05-08 8:05 ` Paul Pluzhnikov
0 siblings, 0 replies; 4+ messages in thread
From: Paul Pluzhnikov @ 2011-05-08 8:05 UTC (permalink / raw)
To: Ludovic Brenta; +Cc: gdb
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-05-08 8:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-20 9:37 Inspecting environment variables from a core dump? Ludovic Brenta
2011-04-20 9:56 ` Andreas Schwab
2011-04-20 12:28 ` Ludovic Brenta
2011-05-08 8:05 ` Paul Pluzhnikov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox