crash.types.slab module

class crash.types.slab.KmemCache(name: str, gdb_obj: Value)[source]

Bases: ABC

SLUB = False
SlabFlags = {'ACCOUNT': 67108864, 'CACHE_DMA': 16384, 'CONSISTENCY_CHECKS': 256, 'DEBUG_OBJECTS': 4194304, 'FAILSLAB': 33554432, 'HWCACHE_ALIGN': 8192, 'MEM_SPREAD': 1048576, 'NOLEAKTRACE': 8388608, 'NOTRACK': 16777216, 'PANIC': 262144, 'POISON': 2048, 'RECLAIM_ACCOUNT': 131072, 'RED_ZONE': 1024, 'STORE_USER': 65536, 'TRACE': 2097152, 'TYPESAFE_BY_RCU': 524288}
alien_cache_type_exists = False
buffer_size_name = None
abstract check_all() None[source]
classmethod check_kmem_cache_node_type(gdbtype: Type) None[source]
classmethod check_kmem_cache_type(gdbtype: Type) None[source]
classmethod create(name: str, gdb_obj: Value) KmemCache[source]
abstract get_allocated_objects() Iterable[int][source]
has_flag(flag_name: str) bool[source]
head_name = 'list'
abstract list_all(verbosity: int) None[source]
nodelists_name = None
percpu_cache = None
percpu_name = None
slub_debug_compiled = True
tracks_full_slabs() bool[source]
exception crash.types.slab.KmemCacheNotFound[source]

Bases: RuntimeError

The specified kmem_cache could not be found.

class crash.types.slab.KmemCacheSLAB(name: str, gdb_obj: Value)[source]

Bases: KmemCache

buffer_size: int
check_all() None[source]
check_array_caches() None[source]
get_allocated_objects() Iterable[int][source]
get_array_caches() Dict[int, Dict[str, int | str]][source]
get_slabs_of_type(node: Value, slabtype: int, reverse: bool = False, exact_cycles: bool = False) Iterable[SlabSLAB][source]
list_all(verbosity: int) None[source]
classmethod setup_alien_cache_type(gdbtype: Type) None[source]
slab_list_fullname = {0: 'slabs_partial', 1: 'slabs_full', 2: 'slabs_free'}
slab_list_name = {0: 'partial', 1: 'full', 2: 'free'}
class crash.types.slab.KmemCacheSLUB(name: str, gdb_obj: Value)[source]

Bases: KmemCache

check_all() None[source]
get_allocated_objects() Iterable[int][source]
list_all(verbosity: int) None[source]
process_all(flags: ProcessingFlags) None[source]
red_left_pad() int[source]
slub_process_once() None[source]
class crash.types.slab.ProcessingFlags(print_level: int = 0)[source]

Bases: object

class crash.types.slab.Slab(gdb_obj: Value, kmem_cache: KmemCache)[source]

Bases: ABC

A common superclass representing a slab, i.e. a collection of objects on a single (possibly high-order) page.

Parameters:
  • gdb_obj – The structure to wrap, of type struct slab or struct page.

  • kmem_cache – The kmem_cache instance the slab belongs to.

gdb_obj

The structure being wrapped. The value is of type struct slab or struct page.

Type:

gdb.Value

address

Address of the structure being wrapped.

Type:

int

kmem_cache

The cache the slab belongs to.

Type:

KmemCache

free

Set of addresses of free objects in the slab.

Type:

Set[int]

nr_objects (

obj:`int): Total number of objects in the slab.

nr_inuse (

obj:`int): Number of allocated objects in the slab.

nr_free (

obj:`int): Number of free objects in the slab.

abstract contains_obj(addr: int) Tuple[bool, int, str | None][source]

Returns whether the slab contains an object at given address.

Parameters:

addr – Address of object to check.

Returns:

A tuple with object information. contains (bool): Whether addr points inside valid object

range.

address (int): Starting address of the object. Might be

returned even if contains is False, when addr falls e.g. into a red zone or padding of an object.

description (str): Optional description of where addr points

to in case it’s not a valid object.

Return type:

(contains, address, description)

abstract find_obj(addr: int) int | None[source]

Returns starting address of object in slab.

Parameters:

addr – Address of the object to find.

Returns:

Starting address of the object, or None if the address

does not fall into the slab’s range. Note that while object address might be returned, addr might still be outside of valid range. Use contains_obj() to verify.

Return type:

int

abstract classmethod from_list_head(list_head: Value, kmem_cache: KmemCache) Slab[source]

Create Slab oject wrapper from a gdb.Value object of struct list_head type.

abstract classmethod from_page(page: Page) Slab[source]

Create Slab object wrapper from a Page struct page wrapper.

abstract get_allocated_objects() Iterable[int][source]

Generates object addresses for all allocated objects in the slab.

abstract long_header() str[source]

Return a long header consisting of slab’s address, role and stats.

abstract obj_in_use(addr: int) Tuple[bool, str | None][source]

Returns information about whether object is allocated (in use) or free.

Arg:

addr: Base address of object to check, obtained e.g. by find.obj()

Returns:

obj:(in_use, free_details): A tuple with information. in_use (:obj:`bool): Whether object is currently in use. free_details (str): If an object is in some special cache

of free objects (e.g. per-cpu), a short description of such cache.

populate_free() None[source]

Make sure the set of free objects is populated

abstract print_objects() None[source]

Print all objects in slab, indicating if they are free or allocated.

abstract short_header() str[source]

Return a short header consisting of slab’s address and role.

class crash.types.slab.SlabSLAB(gdb_obj: Value, kmem_cache: KmemCacheSLAB, error: bool = False)[source]

Bases: Slab

AC_ALIEN = 'alien'
AC_PERCPU = 'percpu'
AC_SHARED = 'shared'
BUFCTL_END = 4294967295
bufctl_type: Type
check(slabtype: int, nid: int) int[source]
classmethod check_bufctl_type(gdbtype: Type) None[source]
classmethod check_page_type(gdbtype: Type) None[source]
classmethod check_slab_type(gdbtype: Type) None[source]
contains_obj(addr: int) Tuple[bool, int, str | None][source]

Returns whether the slab contains an object at given address.

Parameters:

addr – Address of object to check.

Returns:

A tuple with object information. contains (bool): Whether addr points inside valid object

range.

address (int): Starting address of the object. Might be

returned even if contains is False, when addr falls e.g. into a red zone or padding of an object.

description (str): Optional description of where addr points

to in case it’s not a valid object.

Return type:

(contains, address, description)

find_obj(addr: int) int | None[source]

Returns starting address of object in slab.

Parameters:

addr – Address of the object to find.

Returns:

Starting address of the object, or None if the address

does not fall into the slab’s range. Note that while object address might be returned, addr might still be outside of valid range. Use contains_obj() to verify.

Return type:

int

classmethod from_addr(slab_addr: int, kmem_cache: int | KmemCacheSLAB) SlabSLAB[source]
classmethod from_list_head(list_head: Value, kmem_cache: KmemCache) SlabSLAB[source]

Create Slab oject wrapper from a gdb.Value object of struct list_head type.

classmethod from_page(page: Page) SlabSLAB[source]

Create Slab object wrapper from a Page struct page wrapper.

get_allocated_objects() Iterable[int][source]

Generates object addresses for all allocated objects in the slab.

get_objects() Iterable[int][source]
kmem_cache: KmemCacheSLAB
long_header() str[source]

Return a long header consisting of slab’s address, role and stats.

obj_in_use(addr: int) Tuple[bool, str | None][source]

Returns information about whether object is allocated (in use) or free.

Arg:

addr: Base address of object to check, obtained e.g. by find.obj()

Returns:

obj:(in_use, free_details): A tuple with information. in_use (:obj:`bool): Whether object is currently in use. free_details (str): If an object is in some special cache

of free objects (e.g. per-cpu), a short description of such cache.

page_slab: bool = False
print_objects() None[source]

Print all objects in slab, indicating if they are free or allocated.

real_slab_type: Type
short_header() str[source]

Return a short header consisting of slab’s address and role.

slab_free = 2
slab_full = 1
slab_list_head: str = 'list'
slab_partial = 0
class crash.types.slab.SlabSLUB(gdb_obj: Value, kmem_cache: KmemCacheSLUB)[source]

Bases: Slab

contains_obj(addr: int) Tuple[bool, int, str | None][source]

Returns whether the slab contains an object at given address.

Parameters:

addr – Address of object to check.

Returns:

A tuple with object information. contains (bool): Whether addr points inside valid object

range.

address (int): Starting address of the object. Might be

returned even if contains is False, when addr falls e.g. into a red zone or padding of an object.

description (str): Optional description of where addr points

to in case it’s not a valid object.

Return type:

(contains, address, description)

find_obj(addr: int) int | None[source]

Returns starting address of object in slab.

Parameters:

addr – Address of the object to find.

Returns:

Starting address of the object, or None if the address

does not fall into the slab’s range. Note that while object address might be returned, addr might still be outside of valid range. Use contains_obj() to verify.

Return type:

int

classmethod from_list_head(list_head: Value, kmem_cache: KmemCache) SlabSLUB[source]

Create Slab oject wrapper from a gdb.Value object of struct list_head type.

classmethod from_page(page: Page) SlabSLUB[source]

Create Slab object wrapper from a Page struct page wrapper.

classmethod from_page_obj(page: Value) SlabSLUB[source]
get_allocated_objects() Iterable[int][source]

Generates object addresses for all allocated objects in the slab.

get_objects() Iterable[int][source]
kmem_cache: KmemCacheSLUB
long_header() str[source]

Return a long header consisting of slab’s address, role and stats.

obj_in_use(addr: int) Tuple[bool, str | None][source]

Returns information about whether object is allocated (in use) or free.

Arg:

addr: Base address of object to check, obtained e.g. by find.obj()

Returns:

obj:(in_use, free_details): A tuple with information. in_use (:obj:`bool): Whether object is currently in use. free_details (str): If an object is in some special cache

of free objects (e.g. per-cpu), a short description of such cache.

print_objects() None[source]

Print all objects in slab, indicating if they are free or allocated.

short_header() str[source]

Return a short header consisting of slab’s address and role.

slab_role() str[source]
warn_frozen(expected: int, header: str) None[source]
crash.types.slab.atomic_long_read(val: Value) int[source]
crash.types.slab.col_bold(msg: str) str[source]
crash.types.slab.col_error(msg: str) str[source]
crash.types.slab.kmem_cache_from_addr(addr: int) KmemCache[source]
crash.types.slab.kmem_cache_from_name(name: str) KmemCache[source]
crash.types.slab.kmem_cache_get_all() ValuesView[KmemCache][source]
crash.types.slab.print_flags(val: int, names: Dict[str, int]) str[source]
crash.types.slab.slab_from_obj_addr(addr: int) Slab | None[source]
crash.types.slab.slab_from_page(page: Page) Slab[source]