From 54ff260e99e42183830de2415cd93cc1d6e044b9 Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Tue, 27 Dec 2011 06:51:20 +0200 Subject: [PATCH] a bit progress on locationlists --- elftools/dwarf/locationlists.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/elftools/dwarf/locationlists.py b/elftools/dwarf/locationlists.py index 4ea8877..afe12e3 100644 --- a/elftools/dwarf/locationlists.py +++ b/elftools/dwarf/locationlists.py @@ -11,8 +11,34 @@ from collections import namedtuple from ..common.utils import struct_parse +LocationEntry = namedtuple('LocationEntry', 'begin_offset end_offset loc_expr') +BaseAddressEntry = namedtuple('BaseAddressEntry', 'base_address') + + class LocationLists(object): def __init__(self, stream, structs): + self._max_addr = 2 ** (self.structs.address_size * 8) - 1 + + def get_location_list_at_offset(self, offset): pass + + def iter_location_lists(self): + pass + + def _parse_location_list_from_stream(self): + lst = [] + while True: + begin_offset = struct_parse( + self.structs.Dwarf_target_addr(''), self.stream) + end_offset = struct_parse( + self.structs.Dwarf_target_addr(''), self.stream) + if begin_offset == 0 and end_offset == 0: + # End of list - we're done. + break + elif begin_offset == self._max_addr: + # base + else: + # entry... + -- 2.30.2