Reputation: 2035
When debugging C code with gdb, I often have to find where things are first declared, whether a type (structure) or a variable. According to this answer ( GDB: break if variable equal value ) it might not be possible in gdb. Is this true?
If it's not possible in gdb, are there other strategies? I have often used grep
, but this fails if there are too many results.
Upvotes: 2
Views: 1928
Reputation:
I often have to find where things are first declared, whether a type (structure) or a variable.
Declared or defined (What is the difference between a definition and a declaration?)? If defined then these commands are available:
Examining the Symbol Table (https://sourceware.org/gdb/onlinedocs/gdb/Symbols.html#Symbols) (if compiled with -g):
info types regexp
lists all source files where a type is defined.
info variables regexp
- prints the names and data types of all variables (except for local variables) whose names contain a match for regular expression regexp.
Upvotes: 3