added description for location_expr
authoreliben <devnull@localhost>
Sun, 6 Nov 2011 13:49:37 +0000 (15:49 +0200)
committereliben <devnull@localhost>
Sun, 6 Nov 2011 13:49:37 +0000 (15:49 +0200)
kinda works vs. readelf!

elftools/dwarf/descriptions.py
elftools/dwarf/location_expr.py
tests/test_dwarf_location_expr.py

index 9cef354d8197b8fed700083037a5097aae4c59dc..950ff43e049201c57b8ad2cbfc2d1e52aa7fcd7b 100644 (file)
@@ -9,6 +9,7 @@
 from collections import defaultdict
 
 from .constants import *
+from .location_expr import LocationExpressionDumper
 
 
 def describe_attr_value(attr, die, section_offset):
@@ -218,7 +219,9 @@ def _location_list_extra(attr, die, section_offset):
     if attr.form in ('DW_FORM_data4', 'DW_FORM_data8'):
         return '(location list)'
     else:
-        return '<<ZZZ>> %s %s' % (attr.value, type(attr.value))
+        location_expr_dumper = LocationExpressionDumper(die.cu.structs)
+        location_expr_dumper.process_expr(attr.value)
+        return '(' + location_expr_dumper.get_str() + ')'
 
 
 _EXTRA_INFO_DESCRIPTION_MAP = defaultdict(
index 0040559c9392d9c2961e3ea79c87fb5d0e8bccb5..09445d7582986957ddb81e64a5c340db757f58b7 100644 (file)
@@ -223,6 +223,8 @@ class GenericLocationExprVisitor(object):
             add('DW_OP_breg%s' % n, 
                 self._make_visitor_arg_struct(self.structs.Dwarf_sleb128('')))
 
+        add('DW_OP_fbreg',
+            self._make_visitor_arg_struct(self.structs.Dwarf_sleb128('')))
         add('DW_OP_regx',
             self._make_visitor_arg_struct(self.structs.Dwarf_uleb128('')))
         add('DW_OP_bregx',
@@ -262,7 +264,7 @@ class LocationExpressionDumper(GenericLocationExprVisitor):
             'DW_OP_const4u', 'DW_OP_const4s', 'DW_OP_constu', 'DW_OP_consts',
             'DW_OP_pick', 'DW_OP_plus_uconst', 'DW_OP_bra', 'DW_OP_skip',
             'DW_OP_fbreg', 'DW_OP_piece', 'DW_OP_deref_size',
-            'DW_OP_xderef_size', 'DW_OP_regx', 'DW_OP_fbreg', ])
+            'DW_OP_xderef_size', 'DW_OP_regx',])
         
         for n in range(0, 32):
             self._ops_with_decimal_arg.add('DW_OP_breg%s' % n)
index b6c219815f003abe7e7201d692ee9c978855499c..d0d6ab0f1edffb348e60f3db3d017f90f6bf0c10 100644 (file)
@@ -24,6 +24,11 @@ class TestLocationExpressionDumper(unittest.TestCase):
         self.visitor.process_expr([0x74, 0x82, 0x01])
         self.assertEqual(self.visitor.get_str(),
             'DW_OP_breg4: 130')
+        
+        self.setUp()
+        self.visitor.process_expr([0x91, 0x82, 0x01])
+        self.assertEqual(self.visitor.get_str(),
+            'DW_OP_fbreg: 130')
 
         self.setUp()
         self.visitor.process_expr([0x9d, 0x8f, 0x0A, 0x90, 0x01])