Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get environment variable from a core dump

Tags:

gdb

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

like image 285
Parthiban Manoharan Avatar asked Jun 21 '17 21:06

Parthiban Manoharan


1 Answers

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.

like image 97
Employed Russian Avatar answered Nov 04 '22 02:11

Employed Russian