This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How to portably print out Env of a Process


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]