info args command
Displays information about the function arguments corresponding to the current stack frame.
Syntax
Remarks
The info args command displays the function argument values of the current frame. You can select frames using the frame, up and down commands.
Note that the info args command does not display the information about the local variables. Use the info locals command to list local variables.
Do not confuse the info args with the set args command. The set args command sets the command-line arguments for the debugged program, while the info args displays the arguments for the current function. The arguments provided via set args will be available via argv in the main() function.
Examples
To demonstrate the info args command we will debug a sample program listed below:
void func(int arg)
{
printf("func(%d)\n", arg);
}
int main(int argc, char *argv[])
{
int localVar1 = 1, localVar2 = 2;
func(localVar1 + localVar2);
return 0;
}
We will run the program, set a breakpoint in func() and use the info args command to display the argument values:
(gdb) b func
Breakpoint 1 at 0x80483ea: file test.cpp, line 5.
(gdb) run
Starting program: /home/testuser/test Hello
Breakpoint 1, func (arg=3) at test.cpp:5
5 printf("func(%d)arg);
(gdb) info args
arg = 3
(gdb) backtrace
#0 func (arg=3) at test.cpp:5
#1 0x0804842a in main (argc=2, argv=0xbffff774) at test.cpp:11
(gdb) up
#1 0x0804842a in main (argc=2, argv=0xbffff774) at test.cpp:11
11 func(localVar1 + localVar2);
(gdb) info args
argc = 2
argv = 0xbffff774
(gdb) print *argv@argc
$1 = {0xbffff89d "/home/testuser/test", 0xbffff8b1 "Hello"}
(gdb)
Compatibility with VisualGDB
You can execute the info args command manually using the GDB Session window in Visual Studio. However it is recommended to use the Call Stack window to see the information about the function arguments in a more user-friendly way.