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¶
- head_name = 'list'¶
- nodelists_name = None¶
- percpu_cache = None¶
- percpu_name = None¶
- slub_debug_compiled = True¶
- exception crash.types.slab.KmemCacheNotFound[source]¶
Bases:
RuntimeErrorThe specified kmem_cache could not be found.
- class crash.types.slab.KmemCacheSLAB(name: str, gdb_obj: Value)[source]¶
Bases:
KmemCache- buffer_size: int¶
- get_slabs_of_type(node: Value, slabtype: int, reverse: bool = False, exact_cycles: bool = False) Iterable[SlabSLAB][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- process_all(flags: ProcessingFlags) None[source]¶
- class crash.types.slab.Slab(gdb_obj: Value, kmem_cache: KmemCache)[source]¶
Bases:
ABCA 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 slaborstruct page.kmem_cache – The kmem_cache instance the slab belongs to.
- gdb_obj¶
The structure being wrapped. The value is of type
struct slaborstruct page.- Type:
- address¶
Address of the structure being wrapped.
- Type:
int
- 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 objectrange.
- 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.
- address (
- 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.Valueobject ofstruct list_headtype.
- abstract classmethod from_page(page: Page) Slab[source]¶
Create Slab object wrapper from a
Pagestruct 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 cacheof free objects (e.g. per-cpu), a short description of such cache.
- 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¶
- 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 objectrange.
- 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.
- address (
- 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.Valueobject ofstruct list_headtype.
- classmethod from_page(page: Page) SlabSLAB[source]¶
Create Slab object wrapper from a
Pagestruct page wrapper.
- get_allocated_objects() Iterable[int][source]¶
Generates object addresses for all allocated objects in the slab.
- kmem_cache: KmemCacheSLAB¶
- 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 cacheof free objects (e.g. per-cpu), a short description of such cache.
- page_slab: bool = False¶
- 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 objectrange.
- 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.
- address (
- 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.Valueobject ofstruct list_headtype.
- classmethod from_page(page: Page) SlabSLUB[source]¶
Create Slab object wrapper from a
Pagestruct page wrapper.
- get_allocated_objects() Iterable[int][source]¶
Generates object addresses for all allocated objects in the slab.
- kmem_cache: KmemCacheSLUB¶
- 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 cacheof free objects (e.g. per-cpu), a short description of such cache.