crash.subsystem.storage.decoders module¶
-
class
crash.subsystem.storage.decoders.
BadBHDecoder
(bh: gdb.Value)[source]¶ Bases:
crash.subsystem.storage.decoders.Decoder
Placeholder decoder for bad buffer_head pointers
Rather than raise a
gdb.NotAvailableError
during decoding, we use aBadBHDecoder
decoder to annotate where in the chain there was an invalid buffer_head.Parameters: bh – The struct buffer_head
to be decoded. The value must be of typestruct buffer_head
.
-
class
crash.subsystem.storage.decoders.
BadBioDecoder
(bio: gdb.Value)[source]¶ Bases:
crash.subsystem.storage.decoders.Decoder
Placeholder decoder for bad bio pointers
Rather than raise a
NotAvailableError
during decoding, we use aBadBioDecoder
decoder to annotate where in the chain there was an invalid bio.Parameters: bio – The bio to decode. The value must be of type struct bio
.
-
class
crash.subsystem.storage.decoders.
Decoder
(value: gdb.Value = None)[source]¶ Bases:
object
Decoder objects are used to unwind the storage stack
They are relatively lightweight at runtime, meaning that the object is initialized but not decoded until it’s needed. The string will be formatted each time, but each
Decoder
’sinterpret()
method will be called once.-
interpret
() → None[source]¶ Interpret the
Decoder
objectRather than populate all the fields when they may not be used, we delay interpreting the object until the fields are needed.
This method will examine the object passed to the derived class’s constructor and produce the attributes required for each object.
-
-
class
crash.subsystem.storage.decoders.
GenericBHDecoder
(bh: gdb.Value)[source]¶ Bases:
crash.subsystem.storage.decoders.Decoder
Decodes a bio that references a
struct buffer_head
This method decodes a generic
struct buffer_head
, when no implementation-specific decoder is availableParameters: bh – The struct buffer_head
to be decoded. The value must be of typestruct buffer_head
.-
bh
¶ The
struct buffer head
that was referenced from the bio. The value is of typestruct buffer_head
.Type: gdb.Value
-
interpret
() → None[source]¶ Interpret the
Decoder
objectRather than populate all the fields when they may not be used, we delay interpreting the object until the fields are needed.
This method will examine the object passed to the derived class’s constructor and produce the attributes required for each object.
-
-
class
crash.subsystem.storage.decoders.
GenericBioDecoder
(bio: gdb.Value)[source]¶ Bases:
crash.subsystem.storage.decoders.Decoder
Placeholder decoder for when we have a valid bio but nothing to decode it
Parameters: bio – The bio to decode. The value must be of type struct bio
.
-
crash.subsystem.storage.decoders.
decode_bh
(bh: gdb.Value) → crash.subsystem.storage.decoders.Decoder[source]¶ Decodes a single buffer_head, if possible
This method will return a
Decoder
object describing a singlestruct buffer_head
after decoding it using a registered decoder, if available.If no decoder is registered, a generic decoder will be used.
If an invalid object is encountered, a handler decoder will be used.
Parameters: bh – The buffer_head to decode. The value must be of type struct buffer_head
.Returns: The decoder appropriate for this buffer_head type Return type: Decoder
-
crash.subsystem.storage.decoders.
decode_bio
(bio: gdb.Value) → crash.subsystem.storage.decoders.Decoder[source]¶ Decodes a single bio, if possible
This method will return a
Decoder
object describing a single bio after decoding it using a registered decoder, if available.If no decoder is registered, a generic decoder will be used.
If an invalid object is encountered, a handler decoder will be used.
Parameters: bio – The bio to decode. The value must be of type struct bio
.Returns: The decoder appropriate for this bio type. Return type: Decoder
-
crash.subsystem.storage.decoders.
for_each_bio_in_stack
(bio: gdb.Value) → Iterable[crash.subsystem.storage.decoders.Decoder][source]¶ Iterates and decodes each bio involved in a stacked storage environment
This method will yield a Decoder object describing each level in the storage stack, starting with the provided bio, as processed by each level’s decoder. The stack will be interrupted if an encountered object doesn’t have a decoder specified.
Parameters: bio – The initial struct bio to start decoding. The value must be of type struct bio
.Yields: Decoder
– The nextDecoder
in the stack, if any remain.
-
crash.subsystem.storage.decoders.
register_decoder
(endio: Union[int, str, List[str], gdb.Value, gdb.Symbol], decoder: Type[crash.subsystem.storage.decoders.Decoder]) → None[source]¶ Registers a bio/buffer_head decoder with the storage subsystem.
A decoder is a class that accepts a bio, buffer_head, or other object, potentially interprets the private members of the object, and returns a
Decoder
object that describes it.The only mandatory part of a
Decoder
is the__str__()
method to format the description.If the bio is part of a stack, the
__next__()
method will contain the nextDecoder
object in the stack. It does not necessarily need to be a bio. TheDecoder
does not need to be registered unless it will be a top-level decoder.Other attributes can be added as-needed to allow informed callers to obtain direct information.
Parameters: - endio –
The function(s) used as endio callback(s).
The
str
orlist
ofstr
arguments are used to register a callback such that theDecoder
is registered when the symbol is available.The
gdb.Symbol
,gdb.Value
, andint
versions are to be used once the symbol is available for resolution.If in doubt, use the names instead of the
gdb.Symbol
objects. - decoder – The decoder class used to handle this object.
- endio –