Search code examples
gdb

How to get environment variable from a core dump


In UNIX environment(linux/solaris/AIX) my application crashing. Please help to me get environment variable from the core dump


Solution

  • Running strings -a core should produce an obvious-looking block of strings like HOME=..., HOSTNAME=..., etc.

    You can also examine initial environment by looking at the 3rd argument to main, which is a envp[] -- a NULL-terminated array of pointers to the environment strings.

    Finally, current environment block is pointed at by __environ or similar variable.