Randomblue
Randomblue

Reputation: 116373

Is this possible to let GDB recognise preprocessor symbols?

I have lots and lots of C preprocessor #define statements, which make my C programming much easier. However, when debugging with GDB, the preprocessor "labels" are not accounted for in the symbols list.

Is there are way to have GDB recognise the #defined labels?

Upvotes: 6

Views: 484

Answers (2)

Fred Larson
Fred Larson

Reputation: 62093

#define symbols are not usually included as part of the debug information. const variables (or inline functions for function-like macros) are usually a better idea, and for more reasons than this (e.g., scoping, type safety, multiple evaluations, etc.). I recommend using them in favor of preprocessor symbols whenever you can.

Upvotes: 3

cnicutar
cnicutar

Reputation: 182684

You can try compiling with g3, as described here.

gcc -gdwarf-2 -g3

We pass the -gdwarf-2 and -g3 flags to ensure the compiler includes information about preprocessor macros in the debugging information.

Or you can try -ggdb.

Upvotes: 9

Related Questions