4.3 Your Program’s Arguments

The arguments to your program can be specified by the arguments of the run command. They are passed to a shell, which expands wildcard characters and performs redirection of I/O, and thence to your program. Your SHELL environment variable (if it exists) specifies what shell ROCgdb uses. If you do not define SHELL, ROCgdb uses the default shell (/bin/sh on Unix).

On non-Unix systems, the program is usually invoked directly by ROCgdb, which emulates I/O redirection via the appropriate system calls, and the wildcard characters are expanded by the startup code of the program, not by the shell.

run with no arguments uses the same arguments used by the previous run, or those set by the set args command.

set args

Specify the arguments to be used the next time your program is run. If set args has no arguments, run executes your program with no arguments. Once you have run your program with arguments, using set args before the next run is the only way to run it again without arguments.

It is possible to set arguments containing a newline character. This can be done by enclosing an argument within a quotes. For example, start by entering:

(gdb) set args "ab

and then enter the newline, ROCgdb gives a secondary prompt > and allows you to continue entering the arguments:

(gdb) set args "ab
>cd"
(gdb) show args
Argument list to give program being debugged when it is started is ""ab
cd"".

On Unix systems both single or double quotes can be used around arguments containing a newline. On MS-Windows, only double quotes can be used.

show args

Show the arguments to give your program when it is started.