From: Eli Bendersky Date: Tue, 27 Oct 2020 12:59:56 +0000 (-0700) Subject: Make dwarf_pubnames_types example a bit more general X-Git-Tag: v0.27~3 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ee723a374fe4ea5c30a533144aa4573412ca7fa1;p=pyelftools.git Make dwarf_pubnames_types example a bit more general --- diff --git a/examples/dwarf_pubnames_types.py b/examples/dwarf_pubnames_types.py index 292c68e..a747874 100644 --- a/examples/dwarf_pubnames_types.py +++ b/examples/dwarf_pubnames_types.py @@ -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():