Next: Symbol Tables In Python, Previous: Blocks In Python, Up: Python API
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. If omitted, the block for the current frame is used. 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.The result is a tuple of two elements. The first element is a
gdb.Symbolobject orNoneif the symbol is not found. If the symbol is found, the second element isTrueif the symbol is a field of a method's object (e.g.,thisin C++), otherwise it isFalse. If the symbol is not found, the second element isFalse.
This function searches for a global symbol by name. The search scope can be restricted to by the domain argument.
name is the name of the symbol. It must be a string. The optional domain argument restricts the search to the domain type. The domain argument must be a domain constant defined in the
gdbmodule and described later in this chapter.The result is a
gdb.Symbolobject orNoneif the symbol is not found.
A gdb.Symbol object has the following attributes:
The type of the symbol or
Noneif no type is recorded. This attribute is represented as agdb.Typeobject. See Types In Python. This attribute is not writable.
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 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.
A gdb.Symbol object has the following methods:
The available domain categories in gdb.Symbol are represented
as constants in the gdb module:
gdb.SYMBOL_UNDEF_DOMAINgdb.SYMBOL_VAR_DOMAINgdb.SYMBOL_STRUCT_DOMAINgdb.SYMBOL_LABEL_DOMAINgdb.SYMBOL_VARIABLES_DOMAINSYMBOLS_VAR_DOMAIN; it
contains everything minus functions and types.
gdb.SYMBOL_FUNCTION_DOMAINgdb.SYMBOL_TYPES_DOMAINThe available address class categories in gdb.Symbol are represented
as constants in the gdb module:
gdb.SYMBOL_LOC_UNDEFgdb.SYMBOL_LOC_CONSTgdb.SYMBOL_LOC_STATICgdb.SYMBOL_LOC_REGISTERgdb.SYMBOL_LOC_ARGgdb.SYMBOL_LOC_REF_ARGLOC_ARG except that the value's address is stored at the
offset, not the value itself.
gdb.SYMBOL_LOC_REGPARM_ADDRLOC_REGISTER except
the register holds the address of the argument instead of the argument
itself.
gdb.SYMBOL_LOC_LOCALgdb.SYMBOL_LOC_TYPEDEFSYMBOL_STRUCT_DOMAIN all
have this class.
gdb.SYMBOL_LOC_BLOCKgdb.SYMBOL_LOC_CONST_BYTESgdb.SYMBOL_LOC_UNRESOLVEDgdb.SYMBOL_LOC_OPTIMIZED_OUTgdb.SYMBOL_LOC_COMPUTED