started implementing dumping --debug-dump=frames
diff --git a/scripts/readelf.py b/scripts/readelf.py
index 335d5ee..01c4d1f 100755
--- a/scripts/readelf.py
+++ b/scripts/readelf.py
@@ -36,9 +36,10 @@
)
from elftools.dwarf.dwarfinfo import DWARFInfo
from elftools.dwarf.descriptions import (
- describe_attr_value, set_global_machine_arch)
+ describe_attr_value, set_global_machine_arch, describe_CFI_instruction)
from elftools.dwarf.constants import (
DW_LNS_copy, DW_LNS_set_file, DW_LNE_define_file)
+from elftools.dwarf.callframe import CIE, FDE
class ReadElf(object):
@@ -432,6 +433,8 @@
self._dump_debug_info()
elif dump_what == 'decodedline':
self._dump_debug_line_programs()
+ elif dump_what == 'frames':
+ self._dump_debug_frames()
else:
self._emitline('debug dump not yet supported for "%s"' % dump_what)
@@ -598,6 +601,34 @@
# Another readelf oddity...
self._emitline()
+ def _dump_debug_frames(self):
+ """ Dump the raw frame information from .debug_frame
+ """
+ self._emitline('Contents of the .debug_frame section:')
+
+ for entry in self._dwarfinfo.CFI_entries():
+ if isinstance(entry, CIE):
+ self._emitline('\n%08x %08x %08x CIE' % (
+ entry.offset, entry['length'], entry['CIE_id']))
+ self._emitline(' Version: %d' % entry['version'])
+ self._emitline(' Augmentation: "%s"' % entry['augmentation'])
+ self._emitline(' Code alignment factor: %u' % entry['code_alignment_factor'])
+ self._emitline(' Data alignment factor: %d' % entry['data_alignment_factor'])
+ self._emitline(' Return address column: %d' % entry['return_address_register'])
+ else: # FDE
+ self._emitline('\n%08x %08x %08x FDE cie=%08x pc=%08x..%08x' % (
+ entry.offset,
+ entry['length'],
+ entry['CIE_pointer'],
+ entry.cie.offset,
+ entry['initial_location'],
+ entry['initial_location'] + entry['address_range']))
+
+ if len(entry.instructions) > 0:
+ self._emitline('')
+ for instr in entry.instructions:
+ self._emitline(describe_CFI_instruction(instr, entry))
+
def _emit(self, s=''):
""" Emit an object to output
"""