How to portably print out Env of a Process

Arijit Das arijit79@gmail.com
Tue May 23 13:05:00 GMT 2006


Hi,

Is it possible to print out the env of a process portably with the
same cmdline/script in different os/arch combinations?

Here is how I tried to do it for i686 - RH3.0:

(gdb) p (char *) getenv("HOME")
[Switching to Thread 1024 (LWP 17639)]
$1 = 0xdffff781 "/remote/vtghome7/arijit"
(gdb)

It worked fine.

But when I tried executing this command in x86_64, I got strange results:

(gdb) p (char *) getenv("HOME")
[Switching to Thread 182901576896 (LWP 26427)]
$1 = 0xffffffffbfffc790 <Address 0xffffffffbfffc790 out of bounds>
(gdb)

I guess some kind of 32/64 bits conversion might be messing things up
here....but am not sure exactly what? Any help here?

Thanks,
Arijit



More information about the Gdb mailing list