dwarflang.eval.base module

An implementation of the DWARFv4 stack machine.

Incomplete parts of the code are marked with TODO, other NotImplementedError instances are from methods that must be overridden.

See:
class dwarflang.eval.base.Evaluator

Bases: object

An (unfinished) implementation of the DWARFv4 stack machine.

To evaluate a DWARFv4 expression, subclass this and override the following methods: - _fbreg - _breg - _bregx - _deref - _deref_size - _xderef - _xderef_size - _form_tls_address - _call_frame_cfa - _reg - _regx

The above specify the operating environment of the evaluator, whose behavior is specified in terms of values in the CPU of a machine running the program to which this debug info is attached.

Many other methods have names that are suffices of the various DWARFv4 opcodes (e.g. DW_OP_add becomes _add), the behavior of the evaluator may be changed as necessary by subclasses by overriding them. For even more control, override _dispatch.

TODO: say which methods access the stack through operations other than _push and _pop!

NB: This is not standards compliant, the arithmetic operations are all supposed to happen mod some number depending on the largest representable address on the machine that the binary is compiled for.

Incomplete parts of the code are marked with TODO, other NotImplementedError instances are from methods that must be overridden.

Return type

None

eval(instructions: Sequence[dwarflang.ast.DwarfInstr]) None
Parameters

instructions (Sequence[dwarflang.ast.DwarfInstr]) –

Return type

None

pop() int
Return type

int

was_stack_value() bool
Return type

bool