Fix Container's __pretty_str__ to use str instead of repr. This provides more consist...
[pyelftools.git] / scripts / readelf.py
index a7296f52feee3bff039b83ed2a06da7b0ef9fdb8..6ecac7bd8a68f4db92cf5ac976ceeced8f70eda5 100755 (executable)
@@ -12,10 +12,8 @@ from optparse import OptionParser
 from itertools import ifilter
 import string
 
-
 # If elftools is not installed, maybe we're running from the root or scripts
 # dir of the source distribution
-#
 try:
     import elftools
 except ImportError:
@@ -543,9 +541,13 @@ class ReadElf(object):
                     die.tag))
                 
                 for attr in die.attributes.itervalues():
+                    name = attr.name
+                    # Unknown attribute values are passed-through as integers
+                    if isinstance(name, int):
+                        name = 'Unknown AT value: %x' % name
                     self._emitline('    <%2x>   %-18s: %s' % (
                         attr.offset,
-                        attr.name,
+                        name,
                         describe_attr_value(
                             attr, die, section_offset)))
                 
@@ -752,8 +754,10 @@ def main(stream=None):
             action='store', dest='show_string_dump', metavar='<number|name>',
             help='Dump the contents of section <number|name> as strings')
     optparser.add_option('--debug-dump',
-            action='store', dest='debug_dump_what', metavar='<section>',
-            help='Display the contents of DWARF debug sections')
+            action='store', dest='debug_dump_what', metavar='<what>',
+            help=(
+                'Display the contents of DWARF debug sections. <what> can ' +
+                'one of {info,decodedline,frames,frames-interp}'))
 
     options, args = optparser.parse_args()