Reputation: 711
Now I have a c language project which include three directories /bin, /inc and /src. All of header files (.h) are included in /inc and all of source(.c) files are stored in /src, i.e. a.c, b.c, c.c..., the final generated executable file will locate in /bin.
after compling with makefile, all of obj files will be generated in /src/obj like a.o, b.o, c.o, d....! Moreover an final.exe executable file will be generated in the /bin directory.
Now if I want to debug it with GDB, how can I do it???
To debug those obj files in /src/obj? or somewhat else?
Many thanks for the kind help!
Upvotes: 3
Views: 8796
Reputation: 28267
You can either debug an application by starting it with GDB
%> gdb <your_executable>
or what is usually easier is to start your application and then attach the debugger to the process using the PID.
%> gdb -p <pid>
For command line options, just type gdb -h
and while running inside of gdb
help is always available by typing "help" on the gdb command line.
Here is a quick cheat sheet and a tutorial site on some common commands.
As Arkaitz mentioned, be sure to compile your code so that it has the necessary debug information included in the executable.
If debugging from the command line is a bit daunting, there are some UIs available that use GDB. I do a lot of my debugging in Eclipse using gdb.
Once you get started down the gdb path, I'm sure you'll have more questions and I encourage you to ask those more specific questions on SO.
Good luck.
Upvotes: 4
Reputation: 23198
What is the problem with gdb bin/binary.exe
? If you compiled correctly and placed -g -ggdb
in the compile flags GDB should have enough info to display inlined code
Upvotes: 1