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 #define
d labels?
Normally, when GDB looks up symbols, it matches their names with case sensitivity determined by the current source language. Occasionally, you may wish to control that. The command set case-sensitive lets you do that by specifying on for case-sensitive matches or off for case-insensitive ones.
A debugging symbol table is information included in the binary file that maps the compiled instructions to the corresponding line, function, and/or variable in the original source code. This is not something you would want to do with your final builds of any code, as it makes the final executable larger and slower.
A Debugging Symbol Table maps instructions in the compiled binary program to their corresponding variable, function, or line in the source code. This mapping could be something like: Program instruction ⇒ item name, item type, original file, line number defined.
A debug symbol is a special kind of symbol that attaches additional information to the symbol table of an object file, such as a shared library or an executable.
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
.
#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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With