crash.infra.lookup module

class crash.infra.lookup.DelayedMinimalSymbol(name: str, wait_for_target: bool = True)[source]

Bases: DelayedValue

A DelayedValue that handles minimal symbols.

Parameters:

name – The name of the minimal symbol

class crash.infra.lookup.DelayedMinimalSymval(name: str, wait_for_target: bool = True)[source]

Bases: DelayedMinimalSymbol

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

Parameters:

name – The name of the minimal symbol.

callback(value: MinSymbol) None[source]
class crash.infra.lookup.DelayedSymbol(name: str, wait_for_target: bool = True)[source]

Bases: DelayedValue

A DelayedValue that handles symbols.

Parameters:

name – The name of the symbol

class crash.infra.lookup.DelayedSymval(name: str, wait_for_target: bool = True)[source]

Bases: DelayedSymbol

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

Parameters:

name – The name of the symbol.

callback(value: Symbol) None[source]
class crash.infra.lookup.DelayedType(name: str, wait_for_target: bool = True, block: Block = None)[source]

Bases: DelayedValue

A DelayedValue for types.

Parameters:

name – The name of the type.

callback(value: Type) None[source]
class crash.infra.lookup.DelayedValue(name: str, wait_for_target: bool = True, **kwargs: Any)[source]

Bases: object

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

attach_callback(cbcls: Type[NamedCallback], **kwargs: Any) None[source]
callback(value: Any) None[source]
get() Any[source]
class crash.infra.lookup.MinimalSymbolCallback(name: str, callback: Callable[[Any], bool | None], wait_for_target: bool = True, symbol_file: str = None)[source]

Bases: 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() MinSymbol | None[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], bool | None], wait_for_target: bool = True, **kwargs: Any)[source]

Bases: 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) 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

class crash.infra.lookup.SymbolCallback(name: str, callback: Callable[[Any], bool | None], wait_for_target: bool = True, domain: int = 0)[source]

Bases: 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() Symbol | None[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], bool | None], wait_for_target: bool = True, domain: int = 0)[source]

Bases: 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() Value | None[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], bool | None], wait_for_target: bool = True, block: Block = None, **kwargs: Any)[source]

Bases: 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() Type | None[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)