When stepping through functions one can end up in a function with a definition like handle_error (const char *fmt, ...)
.
How can I access the varargs for constructing a message to be seen in the GDB console?
Note: I do know from the implementation that it does
va_list ap;
va_start (ap, fmt);
vfprintf (stderr, fmt, ap);
va_end (ap);
So the first though was to just call
those functions - which isn't possible as va_start
is a compiler builtin:
(gdb) call (void)va_start (ap, fmt)
No symbol "__builtin_va_start" in current context.
(gdb) call (int)vfprintf (stderr, fmt, ap)
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff6c0ada1 in vfprintf () from target:/usr/lib64/libc.so.6
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To put that into the GDB console I guess I'd have to vsprintf to a temporary variable and then use that for output - but as all varargs functions need an initialized va_list...
The GDB is python enabled, but I didn't found any reasonable python handling for C varargs either...