gdb represents every variable, function and type as an
entry in a symbol table. See Examining the Symbol Table.
Similarly, Python represents these symbols in gdb with the
gdb.Symbol object.
The following symbol-related functions are available in the gdb
module:
This function searches for a symbol by name. The search scope can be restricted to the parameters defined in the optional domain and block arguments.
name is the name of the symbol. It must be a string. The optional block argument restricts the search to symbols visible in that block. The block argument must be a
gdb.Blockobject. The optional domain argument restricts the search to the domain type. The domain argument must be a domain constant defined in thegdbmodule and described later in this chapter.
A gdb.Symbol object has the following attributes:
The symbol table in which the symbol appears. This attribute is represented as a
gdb.Symtabobject. See Symbol Tables In Python. This attribute is not writable.
The name of the symbol as a string. This attribute is not writable.
The name of the symbol, as used by the linker (i.e., may be mangled). This attribute is not writable.
The name of the symbol in a form suitable for output. This is either
nameorlinkage_name, depending on whether the user asked gdb to display demangled or mangled names.
The available domain categories in gdb.Symbol are represented
as constants in the gdb module:
SYMBOL_UNDEF_DOMAINSYMBOL_VAR_DOMAINSYMBOL_STRUCT_DOMAINSYMBOL_LABEL_DOMAINSYMBOL_VARIABLES_DOMAINSYMBOLS_VAR_DOMAIN; it
contains everything minus functions and types.
SYMBOL_FUNCTION_DOMAINSYMBOL_TYPES_DOMAINThe available address class categories in gdb.Symbol are represented
as constants in the gdb module:
SYMBOL_LOC_UNDEFSYMBOL_LOC_CONSTSYMBOL_LOC_STATICSYMBOL_LOC_REGISTERSYMBOL_LOC_ARGSYMBOL_LOC_REF_ARGLOC_ARG except that the value's address is stored at the
offset, not the value itself.
SYMBOL_LOC_REGPARM_ADDRLOC_REGISTER except
the register holds the address of the argument instead of the argument
itself.
SYMBOL_LOC_LOCALSYMBOL_LOC_TYPEDEFSYMBOL_STRUCT_DOMAIN all
have this class.
SYMBOL_LOC_BLOCKSYMBOL_LOC_CONST_BYTESSYMBOL_LOC_UNRESOLVEDSYMBOL_LOC_OPTIMIZED_OUTSYMBOL_LOC_COMPUTED