crash.infra.lookup module

class crash.infra.lookup.DelayedMinimalSymbol(name: str)[source]

Bases: crash.infra.lookup.DelayedValue

A DelayedValue that handles minimal symbols.

Parameters:name – The name of the minimal symbol
class crash.infra.lookup.DelayedMinimalSymval(name: str)[source]

Bases: crash.infra.lookup.DelayedMinimalSymbol

A DelayedMinimalSymbol that returns the address of the minimal symbol as an int.

Parameters:name – The name of the minimal symbol.
callback(value: gdb.MinSymbol) → None[source]
class crash.infra.lookup.DelayedSymbol(name: str)[source]

Bases: crash.infra.lookup.DelayedValue

A DelayedValue that handles symbols.

Parameters:name – The name of the symbol
class crash.infra.lookup.DelayedSymval(name: str)[source]

Bases: crash.infra.lookup.DelayedSymbol

A DelayedSymbol that returns the gdb.Value associated with the symbol.

Parameters:name – The name of the symbol.
callback(value: gdb.Symbol) → None[source]
class crash.infra.lookup.DelayedType(name: str)[source]

Bases: crash.infra.lookup.DelayedValue

A DelayedValue for types.

Parameters:name – The name of the type.
callback(value: gdb.Type) → None[source]
class crash.infra.lookup.DelayedValue(name: str, attrname: str = None)[source]

Bases: object

A generic class for making class attributes available that describe to-be-loaded symbols, minimal symbols, and types.

callback(value: Any) → None[source]
get() → Any[source]
class crash.infra.lookup.MinimalSymbolCallback(name: str, callback: Callable[[Any], Optional[bool]], symbol_file: str = None)[source]

Bases: crash.infra.lookup.NamedCallback

A callback that executes when the named minimal symbol is discovered in the objfile and returns the gdb.MinSymbol.

The callback must accept a gdb.MinSymbol and return bool or None.

Parameters:
  • name – The name of the minimal symbol to discover
  • callback – The callback to execute when the minimal symbol is discovered
  • symbol_file (optional) – Name of the symbol file to use
check_ready() → Optional[gdb.MinSymbol][source]

Returns the result of looking up the minimal symbol when a new object file is loaded.

Returns:The requested minimal symbol
Return type:gdb.MinSymbol
class crash.infra.lookup.NamedCallback(name: str, callback: Callable[[Any], Optional[bool]], attrname: str = None)[source]

Bases: crash.infra.callback.ObjfileEventCallback

A base class for Callbacks with names

This cannot be used directly since it does not provide a method for ObjfileEventCallback.callback().

Parameters:
  • name – The name of the symbol or type to be resolved.
  • callback – A function to call with the result of the derived class’s ObjfileEventCallback.check_ready() method.
  • attrname (optional) – A name safe for use as an attribute name. If unspecified, defaults to the same string as name.
name

The name of the symbol or type being resolved.

Type:str
attrname

The name of symbol or type being resolved translated for use as an attribute name.

Type:str
callback(result: Any) → Union[None, bool][source]

The callback for handling the sucessful result of check_ready().

It indirectly calls the callback specified in the constructor.

Parameters:result – The result returned from check_ready()
Returns:If None or True, the callback succeeded and will be completed and removed. Otherwise, the callback will stay connected for future completion.
Return type:None or bool
check_ready() → Any[source]

The method that derived classes implement for detecting when the conditions required to call the callback have been met.

Returns:This method can return an arbitrary object. It will be passed untouched to callback() if the result is anything other than None or False.
Return type:object
class crash.infra.lookup.SymbolCallback(name: str, callback: Callable[[Any], Optional[bool]], domain: int = 0)[source]

Bases: crash.infra.lookup.NamedCallback

A callback that executes when the named symbol is discovered in the objfile and returns the gdb.Symbol.

The callback must accept a gdb.Symbol and return bool or None.

Parameters:
  • name – The name of the symbol to discover
  • callback – The callback to execute when the symbol is discovered
  • domain (optional) – The domain to search for the symbol. The value is assumed to be one of the value associated with gdb.Symbol constant, i.e. SYMBOL_*_DOMAIN.
check_ready() → Optional[gdb.Symbol][source]

Returns the result of looking up the symbol when a new object file is loaded.

Returns:The requested symbol
Return type:gdb.Symbol
class crash.infra.lookup.SymvalCallback(name: str, callback: Callable[[Any], Optional[bool]], domain: int = 0)[source]

Bases: crash.infra.lookup.SymbolCallback

A callback that executes when the named symbol is discovered in the objfile and returns the gdb.Value associated with the gdb.Symbol.

The callback must accept a gdb.Value and return bool or None.

See SymbolCallback for arguments.

check_ready() → Optional[gdb.Value][source]

After successfully looking up the gdb.Symbol, returns the gdb.Value associated with it.

Returns:The value associated with the requested symbol
Return type:gdb.Value
class crash.infra.lookup.TypeCallback(name: str, callback: Callable[[Any], Optional[bool]], block: gdb.Block = None)[source]

Bases: crash.infra.lookup.NamedCallback

A callback that executes when the named type is discovered in the objfile and returns the gdb.Type associated with it.

The callback must accept a gdb.Type and return bool or None.

Parameters:
  • name – The name of the type to discover
  • callback – The callback to execute when the type is discovered
  • block (optional) – The gdb.Block to search for the symbol
check_ready() → Optional[gdb.Type][source]

The method that derived classes implement for detecting when the conditions required to call the callback have been met.

Returns:This method can return an arbitrary object. It will be passed untouched to callback() if the result is anything other than None or False.
Return type:object
static resolve_type(name: str) → Tuple[str, str, bool][source]

This function takes a C type name and translates it into a 3-tuple that contains the basic type name, the type name translated to a form suitable for an attribute name, and whether the type corresponds to a pointer.

The basic type name has all leading and trailing whitespace stripped, and any * removed.

The attribute type name takes that base, removes the leading struct for structure types, removes any leading or trailing whitespace, replaces internal spaces with underscores, and appends a _type or _p_type suffix, depending on whether the type is a pointer type.

Some examples:

  • struct foofoo_type
  • struct foo *foo_p_type
  • unsigned longunsigned_long_type
Notes:
  • Multiple levels of pointers are not handled properly. In
    practice this means that struct foo * and struct foo ** can’t be used simultaneously. This is typically not a problem.
  • Unions are not handled as a special case as structs are. A
    union type would use an attribute name of union_foo_type.
Returns:A 3-tuple consisting of the basic type name, the name formatted for use as an attribute name, and whether the type is a pointer type.
Return type:(str, str, bool)