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]

Re: gdb / dbx / pstack question - getting function argument addresses from stack


On Thu, 2008-06-26 at 14:50 -0400, Joel Brobecker wrote:
> > As you've mentioned previously, this only works on Solaris. Am I
> > totally out of luck on Linux?
> 
> The Operating System is actually not the most important factor in
> this case. The reason why this "works" on Sparc is because the Sparc
> ABI says that the first few parameters should be passed through the
> output/input registers. There can be up to 6 registers passed this
> way.  So when dbx prints the "parameters" when there is no debugging
> info, it is actually printing the contents of these registers.
> 
> You didn't say which CPU your Linux was running on, but I'll guess
> it's x86. I don't know x86 all that well, but I remember that the
> arguments are passed through the stack at an offset to the function
> frame base. So the idea that works on Sparc doesn't work for x86,
> and I don't see another simple scheme that would work on x86 either.

Worse, they're sometimes passed on the stack, and 
sometimes in registers, and sometimes both.  Only
the compiler knows for sure (in the absence of 
debug info).




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