Make dwarf_pubnames_types example a bit more general
authorEli Bendersky <eliben@gmail.com>
Tue, 27 Oct 2020 12:59:56 +0000 (05:59 -0700)
committerEli Bendersky <eliben@gmail.com>
Tue, 27 Oct 2020 12:59:56 +0000 (05:59 -0700)
examples/dwarf_pubnames_types.py

index 292c68ef4c38f649e47ebd466cb742ce0e9a8cf3..a747874d93cc48c1c95c057ea51702dbdbcc552e 100644 (file)
@@ -39,19 +39,13 @@ def process_file(filename):
         else:
             print('%d entries found in .debug_pubnames' % len(pubnames))
 
-            # try getting information on a global symbol.
             print('Trying pubnames example ...')
-            sym_name = 'main'
-            try:
-                entry = pubnames[sym_name]
-            except KeyError:
-                print('ERROR: No pubname entry found for ' + sym_name)
-            else:
+            for name, entry in pubnames.items():
                 print('%s: cu_ofs = %d, die_ofs = %d' %
-                        (sym_name, entry.cu_ofs, entry.die_ofs))
+                        (name, entry.cu_ofs, entry.die_ofs))
 
                 # get the actual CU/DIE that has this information.
-                print('Fetching the actual die for %s ...' % sym_name)
+                print('Fetching the actual die for %s ...' % name)
                 for cu in dwarfinfo.iter_CUs():
                     if cu.cu_offset == entry.cu_ofs:
                         for die in cu.iter_DIEs():