"""
return self._parent
- def get_filename(self):
- """Return the filename for the DIE.
- The filename, which is the join of 'DW_AT_comp_dir' and 'DW_AT_name',
- either of which may be missing in practice. Note that its value
- is usually a string taken from the .debug_string section and the
- returned value will be a string.
+ def get_full_path(self):
+ """ Return the full path filename for the DIE.
+
+ The filename is the join of 'DW_AT_comp_dir' and 'DW_AT_name',
+ either of which may be missing in practice. Note that its value is
+ usually a string taken from the .debug_string section and the
+ returned value will be a string.
"""
- comp_dir = ''
- try:
- comp_dir_attr = self.attributes['DW_AT_comp_dir']
- comp_dir = bytes2str(comp_dir_attr.value)
- except KeyError:
- pass
-
- fname = ''
- try:
- fname_attr = self.attributes['DW_AT_name']
- fname = bytes2str(fname_attr.value)
- except KeyError:
- pass
+ comp_dir_attr = self.attributes.get('DW_AT_comp_dir', None)
+ comp_dir = bytes2str(comp_dir_attr.value) if comp_dir_attr else ''
+ fname_attr = self.attributes.get('DW_AT_name', None)
+ fname = bytes2str(fname_attr.value) if fname_attr else ''
return os.path.join(comp_dir, fname)
def iter_children(self):
print(' Top DIE with tag=%s' % top_DIE.tag)
# We're interested in the filename...
- print(' name=%s' % top_DIE.get_filename())
+ print(' name=%s' % top_DIE.get_full_path())
# Display DIEs recursively starting with top_DIE
die_info_rec(top_DIE)
print(' Top DIE with tag=%s' % top_DIE.tag)
# We're interested in the filename...
- print(' name=%s' % top_DIE.get_filename())
+ print(' name=%s' % top_DIE.get_full_path())
if __name__ == '__main__':
for filename in sys.argv[1:]:
Processing file: ./examples/sample_exe64.elf
Found a compile unit at offset 0, length 115
Top DIE with tag=DW_TAG_compile_unit
- name=../sysdeps/x86_64/elf/start.S
+ name=/usr/src/packages/BUILD/glibc-2.11.1/csu/../sysdeps/x86_64/elf/start.S
DIE tag=DW_TAG_compile_unit
Found a compile unit at offset 119, length 135
Top DIE with tag=DW_TAG_compile_unit
- name=init.c
+ name=/usr/src/packages/BUILD/glibc-2.11.1/csu/init.c
DIE tag=DW_TAG_compile_unit
DIE tag=DW_TAG_base_type
DIE tag=DW_TAG_base_type
DIE tag=DW_TAG_const_type
Found a compile unit at offset 258, length 156
Top DIE with tag=DW_TAG_compile_unit
- name=z.c
+ name=/tmp/ebenders/z.c
DIE tag=DW_TAG_compile_unit
DIE tag=DW_TAG_subprogram
DIE tag=DW_TAG_formal_parameter
DIE tag=DW_TAG_variable
Found a compile unit at offset 418, length 300
Top DIE with tag=DW_TAG_compile_unit
- name=elf-init.c
+ name=/usr/src/packages/BUILD/glibc-2.11.1/csu/elf-init.c
DIE tag=DW_TAG_compile_unit
DIE tag=DW_TAG_base_type
DIE tag=DW_TAG_typedef
Processing file: ./examples/sample_exe64.elf
Found a compile unit at offset 0, length 115
Top DIE with tag=DW_TAG_compile_unit
- name=../sysdeps/x86_64/elf/start.S
+ name=/usr/src/packages/BUILD/glibc-2.11.1/csu/../sysdeps/x86_64/elf/start.S
Found a compile unit at offset 119, length 135
Top DIE with tag=DW_TAG_compile_unit
- name=init.c
+ name=/usr/src/packages/BUILD/glibc-2.11.1/csu/init.c
Found a compile unit at offset 258, length 156
Top DIE with tag=DW_TAG_compile_unit
- name=z.c
+ name=/tmp/ebenders/z.c
Found a compile unit at offset 418, length 300
Top DIE with tag=DW_TAG_compile_unit
- name=elf-init.c
+ name=/usr/src/packages/BUILD/glibc-2.11.1/csu/elf-init.c