This is the mail archive of the
mailing list for the GDB project.
Re: How to portably print out Env of a Process
- From: Daniel Jacobowitz <drow at false dot org>
- To: Arijit Das <arijit79 at gmail dot com>
- Cc: Bob Rossi <bob_rossi at cox dot net>, gdb at sourceware dot org
- Date: Wed, 12 Jul 2006 12:56:30 -0400
- Subject: Re: How to portably print out Env of a Process
- References: <firstname.lastname@example.org> <20060523125622.GA15393@brasko.net> <20060523130544.GA21177@nevyn.them.org> <email@example.com>
On Wed, May 24, 2006 at 10:13:16AM +0530, Arijit Das wrote:
> (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!