How to portably print out Env of a Process

Daniel Jacobowitz drow@false.org
Wed Jul 12 16:56:00 GMT 2006


On Wed, May 24, 2006 at 10:13:16AM +0530, Arijit Das wrote:
> Thanks...
> 
> (gdb) p ((char * (*)()) getenv) ("HOME")
> 
> seems to be working fine so far. But couldn't make sense of the cast
> logically. As you said, ideally, it should have been something like
> 
> (gdb) p ((char * (*)(const char *)) getenv) ("HOME")
> 
> which doesn't work!

I haven't got the time it's going to take to fix this right now, but I
do see what's wrong.  It's a combination of two things.  One is
the "const"; push_type and follow_types don't have any scoping in them,
so a call to follow_types always eats everything on the stack.  Which
eats the bit making this a pointer to a function instead of a function.

The other is that the func_mod rule in c-exp.y just discards the
arguments.  We never look at them.

This is all somewhat lame, but will be tricky to improve without
breaking something that already works.

Thanks for reporting this!

-- 
Daniel Jacobowitz
CodeSourcery



More information about the Gdb mailing list