From: Eli Bendersky Date: Thu, 27 Oct 2011 12:28:12 +0000 (+0200) Subject: added name field to AttributeValue X-Git-Tag: v0.10~82 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5be3be82cc3f0faf84dba6fa35339c11fe5e56f7;p=pyelftools.git added name field to AttributeValue --- diff --git a/elftools/dwarf/descriptions.py b/elftools/dwarf/descriptions.py index 55995ff..50c7273 100644 --- a/elftools/dwarf/descriptions.py +++ b/elftools/dwarf/descriptions.py @@ -11,10 +11,9 @@ from collections import defaultdict from .constants import * -def describe_attr_value(attrname, attr, die, section_offset): - """ Given an attribute (attrname is the name, attr is the AttributeValue), - return the textual representation of its value, suitable for tools like - readelf. +def describe_attr_value(attr, die, section_offset): + """ Given an attribute attr, return the textual representation of its + value, suitable for tools like readelf. To cover all cases, this function needs some extra arguments: @@ -25,7 +24,7 @@ def describe_attr_value(attrname, attr, die, section_offset): val_description = descr_func(attr, die, section_offset) # For some attributes we can display further information - extra_info_func = _EXTRA_INFO_DESCRIPTION_MAP[attrname] + extra_info_func = _EXTRA_INFO_DESCRIPTION_MAP[attr.name] extra_info = extra_info_func(attr, die, section_offset) return str(val_description) + '\t' + extra_info @@ -211,6 +210,9 @@ def _make_extra_string(s=''): return s return extra + +def location_list_extra(attr, die, section_offset): + pass _location_list_extra = _make_extra_string('(location list)') diff --git a/elftools/dwarf/die.py b/elftools/dwarf/die.py index f4f422e..0836aa0 100644 --- a/elftools/dwarf/die.py +++ b/elftools/dwarf/die.py @@ -14,6 +14,9 @@ from ..common.utils import struct_parse, preserve_stream_pos # AttributeValue - describes an attribute value in the DIE: # +# name: +# The name (DW_AT_*) of this attribute +# # form: # The DW_FORM_* name of this attribute # @@ -29,7 +32,7 @@ from ..common.utils import struct_parse, preserve_stream_pos # Offset of this attribute's value in the stream # AttributeValue = namedtuple( - 'AttributeValue', 'form value raw_value offset') + 'AttributeValue', 'name form value raw_value offset') class DIE(object): @@ -164,6 +167,7 @@ class DIE(object): raw_value = struct_parse(structs.Dwarf_dw_form[form], self.stream) value = self._translate_attr_value(form, raw_value) self.attributes[name] = AttributeValue( + name=name, form=form, value=value, raw_value=raw_value, diff --git a/scripts/readelf.py b/scripts/readelf.py index 0688f40..283ad92 100755 --- a/scripts/readelf.py +++ b/scripts/readelf.py @@ -524,7 +524,7 @@ class ReadElf(object): attr.offset - section_offset, attrname, describe_attr_value( - attrname, attr, die, section_offset))) + attr, die, section_offset))) if die.has_children: die_depth += 1