I have installed gdb and added -g option to my compilation command, but when I try (gdb) s or (gdb) n it says:

The program is not being run.

It only works when I try (gdb) r and goes and stops where my program stops because of it's error(that I could see this without gdb in command line).

How should I trace line-by-line my code?

closed as off-topic by muru, Romeo Ninov, Stephen Kitt, Anthony Geoghegan, shirish May 15 '18 at 1:54

  • This question does not appear to be about Unix or Linux within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    Add a breakpoint at some suitable location. – muru May 12 '18 at 6:12

You need to define a breakpoint, for example

break main



and gdb will start your program and stop when it enters main.

Not the answer you're looking for? Browse other questions tagged or ask your own question.