Noeud:Running the Executable, Noeud « Next »:, Noeud « Previous »:Attaching to an Already Running Program, Noeud « Up »:An example debugging session using gdb



Running the Executable

Since we are now at the gdb prompt with our program loaded, let's start it. For a program with no arguments, you can just type run, but for our program we need a word for it to work on, so we use run example. Note that gdb already knows the executable name, so you just give the run command the argument(s).

If you need to run a program many times in a debugging session, then it remembers the arguments you used last time, and passes them in again unless you specify others. The way to run it with no arguments again is to use set args. You can use show args to see what arguments will be used next time you type run.

So, let's run it:

     (gdb) run example
     Starting program: /home/paul/gnuprog2/src/debugging/ecount1 example
     
     Program exited with code 01.
     (gdb)
     

First problem - the program just ran right through to the end without stopping and finished.

So we need a way to stop it and take control.