dwarflang.ast module¶
The DWARF expression language AST.
Just a list of DwarfInstr.
- class dwarflang.ast.DwarfInstr(opcode, args)¶
Bases:
tuple- Parameters
opcode (dwarflang.enums.DW_OP) –
args (List[Any]) –
- args: List[Any]¶
Alias for field number 1
- opcode: dwarflang.enums.DW_OP¶
Alias for field number 0
- dwarflang.ast.check(instr: dwarflang.ast.DwarfInstr) None¶
- Parameters
instr (dwarflang.ast.DwarfInstr) –
- Return type
None
- dwarflang.ast.const_to_int(instr: dwarflang.ast.DwarfInstr) Optional[int]¶
- Parameters
instr (dwarflang.ast.DwarfInstr) –
- Return type
Optional[int]
- dwarflang.ast.instr_to_json(instr: dwarflang.ast.DwarfInstr) List[Any]¶
- Parameters
instr (dwarflang.ast.DwarfInstr) –
- Return type
List[Any]
- dwarflang.ast.offset_as_lit(reg_instr: dwarflang.ast.DwarfInstr) dwarflang.ast.DwarfInstr¶
Create a
DW_OP_lit*instruction from the offset inreg_instr- Parameters
reg_instr (dwarflang.ast.DwarfInstr) –
- Return type
- dwarflang.ast.offset_to_int(reg_instr: dwarflang.ast.DwarfInstr) int¶
Get the offset in a
DW_OP_bregorDW_OP_fbreg- Parameters
reg_instr (dwarflang.ast.DwarfInstr) –
- Return type
int
- dwarflang.ast.replace_instructions(instructions: List[dwarflang.ast.DwarfInstr], pred: Callable[[dwarflang.ast.DwarfInstr], bool], replacement: Callable[[dwarflang.ast.DwarfInstr], List[dwarflang.ast.DwarfInstr]]) List[dwarflang.ast.DwarfInstr]¶
Find and replace all instructions matching a predicate.
- Parameters
instructions (List[dwarflang.ast.DwarfInstr]) –
pred (Callable[[dwarflang.ast.DwarfInstr], bool]) –
replacement (Callable[[dwarflang.ast.DwarfInstr], List[dwarflang.ast.DwarfInstr]]) –
- Return type
List[dwarflang.ast.DwarfInstr]
- dwarflang.ast.set_fbreg(instructions: List[dwarflang.ast.DwarfInstr], replacement: Callable[[dwarflang.ast.DwarfInstr], List[dwarflang.ast.DwarfInstr]]) List[dwarflang.ast.DwarfInstr]¶
Replace
DW_OP_fbregwith another expression.Function parameters and local variables often have location expressions referring to
DW_OP_fbreg, which has a value known from their parent DIE. This function can be used to replace instances ofDW_OP_fbregwith that known value.- Parameters
instructions (List[dwarflang.ast.DwarfInstr]) –
replacement (Callable[[dwarflang.ast.DwarfInstr], List[dwarflang.ast.DwarfInstr]]) –
- Return type
List[dwarflang.ast.DwarfInstr]
- dwarflang.ast.to_json(instructions: List[dwarflang.ast.DwarfInstr]) List[Any]¶
- Parameters
instructions (List[dwarflang.ast.DwarfInstr]) –
- Return type
List[Any]