From 3f18aa2334ea18f69ee3bd20cd3add45714be668 Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Tue, 27 Dec 2011 05:25:35 +0200 Subject: [PATCH] basic preparations for parsing location lists --- elftools/dwarf/dwarfinfo.py | 6 +++++- elftools/dwarf/locationlists.py | 18 ++++++++++++++++++ elftools/elf/elffile.py | 5 +++-- 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 elftools/dwarf/locationlists.py diff --git a/elftools/dwarf/dwarfinfo.py b/elftools/dwarf/dwarfinfo.py index c530b43..cc2a7b9 100644 --- a/elftools/dwarf/dwarfinfo.py +++ b/elftools/dwarf/dwarfinfo.py @@ -58,18 +58,22 @@ class DWARFInfo(object): debug_abbrev_sec, debug_frame_sec, debug_str_sec, + debug_loc_sec, debug_line_sec): """ config: A DwarfConfig object debug_*_sec: - DebugSectionDescriptor for a section + DebugSectionDescriptor for a section. Pass None for sections + that don't exist. These arguments are best given with + keyword syntax. """ self.config = config self.debug_info_sec = debug_info_sec self.debug_abbrev_sec = debug_abbrev_sec self.debug_frame_sec = debug_frame_sec self.debug_str_sec = debug_str_sec + self.debug_loc_sec = debug_loc_sec self.debug_line_sec = debug_line_sec # This is the DWARFStructs the context uses, so it doesn't depend on diff --git a/elftools/dwarf/locationlists.py b/elftools/dwarf/locationlists.py new file mode 100644 index 0000000..4ea8877 --- /dev/null +++ b/elftools/dwarf/locationlists.py @@ -0,0 +1,18 @@ +#------------------------------------------------------------------------------- +# elftools: dwarf/locationlists.py +# +# DWARF location lists section decoding +# +# Eli Bendersky (eliben@gmail.com) +# This code is in the public domain +#------------------------------------------------------------------------------- +from collections import namedtuple + +from ..common.utils import struct_parse + + +class LocationLists(object): + def __init__(self, stream, structs): + pass + + diff --git a/elftools/elf/elffile.py b/elftools/elf/elffile.py index 0f642da..57b213b 100644 --- a/elftools/elf/elffile.py +++ b/elftools/elf/elffile.py @@ -118,12 +118,12 @@ class ELFFile(object): are looked up and applied. """ # Expect that has_dwarf_info was called, so at least .debug_info is - # present. Check also the presence of other must-have debug sections. + # present. # Sections that aren't found will be passed as None to DWARFInfo. # debug_sections = {} for secname in ('.debug_info', '.debug_abbrev', '.debug_str', - '.debug_line', '.debug_frame'): + '.debug_line', '.debug_frame', '.debug_loc'): section = self.get_section_by_name(secname) if section is None: debug_sections[secname] = None @@ -141,6 +141,7 @@ class ELFFile(object): debug_abbrev_sec=debug_sections['.debug_abbrev'], debug_frame_sec=debug_sections['.debug_frame'], debug_str_sec=debug_sections['.debug_str'], + debug_loc_sec=debug_sections['.debug_loc'], debug_line_sec=debug_sections['.debug_line']) def get_machine_arch(self): -- 2.30.2