How to debug a macro in GDB?
c, gdb, macros
Solution
You could convert the macro into a `static inline` function, e.g. from
#define max(a, b) (a) > (b) ? (a) : (b)
to
static inline max(int a, int b)
{
return a > b ? a : b;
}
This lets the compiler create debugging information for the macro (now function).
Problem
I am debugging a huge C source code, and it has many macro definition. currently there is a segmentation fault is occurring at a macro. I want to be able to debug macro, step in macro definition just like as a function. I tried that ``` ./configure debugflags="-gdwarf-2 -g3" make ``` but this is not working, make is failing. Without above option it compile correctly, but could not debug macro. How can I debug macro?