Reputation: 838
So lets say I have my main file: main.c, linked with file1.c and file2.c where file1 and file2 include their header files: file1.h, file2.h
I compiled them together like so:
gcc main.c file1.c file2.c
which creates the ./a.out
executable to be run.
In GDB how do I set a break point in my main.c? I've tried
b main.c
which gave me this output:
Make break-point pending on future shared library load? yes or no
to which I responded yes
but it never sets a break-point anywhere even after I say b 232
: the line number, I even tried b main 232
and b main.c 232
but non of these work either..
Upvotes: 2
Views: 1765
Reputation: 41017
As an alternative to @MarcoBonelli's answer you can use
break main.c:main
or since there cannot be more than one main
function in a project you can simply use
break main
this has the advantage of not having to search for the line number.
Upvotes: 4
Reputation: 69346
What you want is the following (see GDB doc):
break main.c:232
And don't forget to compile with -g
, otherwise line number information will not be present in the generated program.
Upvotes: 4