From 4a98d471c954f4a56fbe9f7907acf27e7a726cea Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Fri, 13 Mar 2020 06:31:41 -0700 Subject: [PATCH] DWARF expr: clean up more old code and add some comments --- elftools/dwarf/descriptions.py | 3 --- elftools/dwarf/dwarf_expr.py | 6 +++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/elftools/dwarf/descriptions.py b/elftools/dwarf/descriptions.py index 5007a80..08bfccc 100644 --- a/elftools/dwarf/descriptions.py +++ b/elftools/dwarf/descriptions.py @@ -574,9 +574,6 @@ class ExprDumper(object): self._ops_with_hex_arg = set( ['DW_OP_addr', 'DW_OP_call2', 'DW_OP_call4', 'DW_OP_call_ref']) - def _after_visit(self, opcode, opcode_name, args): - self._str_parts.append(self._dump_to_string(opcode, opcode_name, args)) - def _dump_to_string(self, opcode, opcode_name, args): if len(args) == 0: if opcode_name.startswith('DW_OP_reg'): diff --git a/elftools/dwarf/dwarf_expr.py b/elftools/dwarf/dwarf_expr.py index 4e47934..f92d597 100644 --- a/elftools/dwarf/dwarf_expr.py +++ b/elftools/dwarf/dwarf_expr.py @@ -104,11 +104,15 @@ _generate_dynamic_values(DW_OP_name2opcode, 'DW_OP_breg', 0, 31, 0x70) DW_OP_opcode2name = dict((v, k) for k, v in iteritems(DW_OP_name2opcode)) +# Each parsed DWARF expression is returned as this type with its numeric opcode, +# op name (as a string) and a list of arguments. DwarfExprOp = namedtuple('DwarfExprOp', 'op op_name args') def parse_expr(expr, structs): - """TODO + """ Parses expr (a list of integers) into a list of DwarfExprOp. + + The list can potentially be nested. """ dispatch_table = _init_dispatch_table(structs) -- 2.30.2