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?

thanx

Recommended Answers

All 2 Replies

run abc.dat
IIRC

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.
(gdb)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.