my program is written in c and compiled and linked with gcc. In normal way; i execute it by giving an argument after writing executable.

./my_executable abc.dat

and it works.

i need to execute it in gdb debugger. how will i give this abc.dat argument to the gdb debugger? could u plz give a little sample?


9 Years
Discussion Span
Last Post by dwks

You can also set the arguments to your program without actually running the program, such as right at the beginning before you forget, with "set args parameters". This is also the easiest way to start your program with no arguments after you ran it with some.

(gdb) help run
Start debugged program.  You may specify arguments to give it.
Args may include "*", or "[...]"; they are expanded using "sh".
Input and output redirection with ">", "<", or ">>" are also allowed.

With no arguments, uses arguments last specified (with "run" or "set args").
To cancel previous arguments and run with no arguments,
use "set args" without arguments.
(gdb) help set args
Set argument list to give program being debugged when it is started.
Follow this command with any number of args, to be passed to the program.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.