Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Debug a C code that is compiled using a Makefile

Tags:

c

debugging

I am asked to debug a C code containing a number of .c files and is complied using a Makefile on a Redhat Linux system. I want to debug that whole code. How to go about it? What changes do i need to make in the Makefile?

I am using gcc as the compiler.

like image 401
rushi Avatar asked Aug 13 '26 18:08

rushi


1 Answers

If you're using GCC as compiler add to the CFLAGS variable the -g option. Then you'll be able to debug the resulting executable using the gdb command.

like image 132
f00l Avatar answered Aug 16 '26 13:08

f00l