Debugging variable arguments functions (stdarg)

Petr Hluzín petr.hluzin@gmail.com
Sun Jul 18 19:28:00 GMT 2010


On 16 July 2010 21:12, Jan Kratochvil <jan.kratochvil@redhat.com> wrote:
> On Fri, 16 Jul 2010 20:57:57 +0200, Petr Hluzín wrote:
>> Workaround B:
>> Get value of stack pointer (RSP?) of frame MysqlWrapper() and dump raw
>> memory around the address. You should see these values somewhere
>> around:
>> 0x00000000004041e2 (return address in MysqlWrapper)
>> 0x406bf0 (the third argument to WriteLog)
>> Between these two values should be the values of 3rd and 4th argument.
>
> This is not so simple on x86_64, it passes even (first few) stdarg parameters
> in registers.
>        http://www.x86-64.org/documentation/abi.pdf

Nice reading.
I suppose it is documented section "3.5.7 Variable Argument Lists".
Unfortunately I was not able to find any specific wording.
But it makes sense. You are probably right.

It should be possible by reading the document to determine if the two
arguments go to stack or remained in registers. I failed to figure
that out.

Ok, this means that G has to examine stack memory of all frames - infeasible.

-- 
Petr Hluzin



More information about the Gdb mailing list