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.Block
object. The optional domain argument restricts the search to the domain type. The domain argument must be a domain constant defined in thegdb
module 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.Symtab
object. 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
name
orlinkage_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_DOMAIN
SYMBOL_VAR_DOMAIN
SYMBOL_STRUCT_DOMAIN
SYMBOL_LABEL_DOMAIN
SYMBOL_VARIABLES_DOMAIN
SYMBOLS_VAR_DOMAIN
; it
contains everything minus functions and types.
SYMBOL_FUNCTION_DOMAIN
SYMBOL_TYPES_DOMAIN
The available address class categories in gdb.Symbol
are represented
as constants in the gdb
module:
SYMBOL_LOC_UNDEF
SYMBOL_LOC_CONST
SYMBOL_LOC_STATIC
SYMBOL_LOC_REGISTER
SYMBOL_LOC_ARG
SYMBOL_LOC_REF_ARG
LOC_ARG
except that the value's address is stored at the
offset, not the value itself.
SYMBOL_LOC_REGPARM_ADDR
LOC_REGISTER
except
the register holds the address of the argument instead of the argument
itself.
SYMBOL_LOC_LOCAL
SYMBOL_LOC_TYPEDEF
SYMBOL_STRUCT_DOMAIN
all
have this class.
SYMBOL_LOC_BLOCK
SYMBOL_LOC_CONST_BYTES
SYMBOL_LOC_UNRESOLVED
SYMBOL_LOC_OPTIMIZED_OUT
SYMBOL_LOC_COMPUTED