crash.types.percpu module

exception crash.types.percpu.PerCPUError(var: Union[gdb.Value, gdb.Symbol])[source]

Bases: TypeError

The passed object does not respond to a percpu pointer.

class crash.types.percpu.PerCPUState[source]

Bases: object

Per-cpus come in a few forms: - “Array” of objects - “Array” of pointers to objects - Pointers to either of those

If we want to get the typing right, we need to recognize each one and figure out what type to pass back. We do want to dereference pointer to a percpu but we don’t want to dereference a percpu pointer.

classmethod dump_ranges() → None[source]

Dump all percpu ranges to stdout

get_percpu_var(var: Union[gdb.Value, gdb.Symbol], cpu: int) → gdb.Value[source]

Retrieve a per-cpu variable for one or all CPUs

Parameters:
  • var – The symbol or value to use to resolve the percpu location
  • cpu – The cpu for which to return the per-cpu value.
Returns:

The value corresponding to the specified CPU. The value is of the same type passed via var.

Return type:

gdb.Value

Raises:
get_percpu_vars(var: Union[gdb.Value, gdb.Symbol], nr_cpus: int = None) → Dict[int, gdb.Value][source]

Retrieve a per-cpu variable for all CPUs

Parameters:
  • var – The symbol or value to use to resolve the percpu location
  • nr_cpus (optional) – The number of CPUs for which to return results None (or unspecified) will use the highest possible CPU count.
Returns:

The values corresponding to every CPU in a dictionary indexed by CPU number. The type of the gdb.Value used as the dict value is the same type as the gdb.Value or gdb.Symbol passed as var.

Return type:

dict`(:obj:`int, gdb.Value)

Raises:
is_module_percpu_var(addr: int) → bool[source]

Returns whether the provided value or symbol falls within any of the percpu ranges for modules

Parameters:addr – The address to query
Returns:Whether this address belongs to a module range
Return type:bool
is_percpu_var(var: Union[gdb.Value, gdb.Symbol]) → bool[source]

Returns whether the provided value or symbol falls within any of the percpu ranges

Parameters:var – The symbol or value to query
Returns:Whether the value belongs to any percpu range
Return type:bool
is_static_percpu_var(addr: int) → bool[source]

Returns whether the provided address is within the bounds of the percpu static ranges

Parameters:addr – The address to query
Returns:Whether this address belongs to a static range
Return type:bool
classmethod setup_module_ranges(unused: gdb.Symbol) → None[source]
classmethod setup_nr_cpus(unused: gdb.Symbol) → None[source]
classmethod setup_per_cpu_size(unused: gdb.Symbol) → None[source]
crash.types.percpu.get_percpu_var(var: Union[gdb.Value, gdb.Symbol], cpu: int) → gdb.Value[source]

Retrieve a per-cpu variable for a single CPU

Parameters:
  • var – The symbol or value to use to resolve the percpu location
  • cpu – The cpu for which to return the per-cpu value.
Returns:

The value corresponding to the specified CPU. The value is of the same type passed via var.

Return type:

gdb.Value

Raises:
crash.types.percpu.get_percpu_vars(var: Union[gdb.Value, gdb.Symbol], nr_cpus: int = None) → Dict[int, gdb.Value][source]

Retrieve a per-cpu variable for all CPUs

Parameters:
  • var – The symbol or value to use to resolve the percpu location.
  • nr_cpus (optional) – The number of CPUs for which to return results. None (or unspecified) will use the highest possible CPU count.
Returns:

The values corresponding to every CPU in a dictionary indexed by CPU number. The type of the gdb.Value used as the dict value is the same type as the gdb.Value or gdb.Symbol passed as var.

Return type:

dict`(:obj:`int, gdb.Value)

Raises:
crash.types.percpu.is_percpu_var(var: Union[gdb.Value, gdb.Symbol]) → bool[source]

Returns whether the provided value or symbol falls within any of the percpu ranges

Parameters:var – The symbol or value to query
Returns:Whether the value belongs to any percpu range
Return type:bool
crash.types.percpu.percpu_counter_sum(var: Union[gdb.Value, gdb.Symbol]) → int[source]

Returns the sum of a percpu counter

Parameters:var – The percpu counter to sum. The value must be of type struct percpu_counter.
Returns:the sum of all components of the percpu counter
Return type:int