This is the mail archive of the
mailing list for the GDB project.
Re: Debugging variable arguments functions (stdarg)
On 15 July 2010 17:47, G <firstname.lastname@example.org> wrote:
> How can I look at the values of "..." in a function which can
> take a variable number of arguments (i.e. uses va_start(),
> va_end() etc.) in gdb?
There is no nice way to do that. GCC does not record the actual types
used in a call site of a variadic function, e.g. what is on the
call-site of WriteLog(int,int,char*,...) in MysqlWrapper.
Alter source code of the caller to:
const char * msg = mysql_error(sql_handle)
WriteLog(stuff1,stuff1,stuff3, query, msg);
and hope the compiler does not optimize the local variable.
Get value of stack pointer (RSP?) of frame MysqlWrapper() and dump raw
memory around the address. You should see these values somewhere
0x00000000004041e2 (return address in MysqlWrapper)
0x406bf0 (the third argument to WriteLog)
Between these two values should be the values of 3rd and 4th argument.
(You have to cast them to char*.)