""" Get a LocationLists object representing the .debug_loc section of
the DWARF data, or None if this section doesn't exist.
"""
- return LocationLists(self.debug_loc_sec.stream, self.structs)
+ if self.debug_loc_sec:
+ return LocationLists(self.debug_loc_sec.stream, self.structs)
+ else:
+ return None
def range_lists(self):
""" Get a RangeLists object representing the .debug_ranges section of
the DWARF data, or None if this section doesn't exist.
"""
- # ".debug_ranges" section is optional
- if self.debug_ranges_sec == None:
- return None
- else:
+ if self.debug_ranges_sec:
return RangeLists(self.debug_ranges_sec.stream, self.structs)
+ else:
+ return None
#------ PRIVATE ------#
# The range lists are extracted by DWARFInfo from the .debug_ranges
# section, and returned here as a RangeLists object.
range_lists = dwarfinfo.range_lists()
- if range_lists == None:
+ if range_lists is None:
print(' file has no .debug_ranges section')
return
'arm_with_form_indirect.elf'), 'rb') as f:
elffile = ELFFile(f)
self.assertTrue(elffile.has_dwarf_info())
-
- dwarfinfo = elffile.get_dwarf_info()
- self.assertEqual(dwarfinfo.range_lists(), None)
+ self.assertIsNone(elffile.get_dwarf_info().range_lists())
# Test the presence of .debug_ranges section
def test_range_list_presence(self):
'sample_exe64.elf'), 'rb') as f:
elffile = ELFFile(f)
self.assertTrue(elffile.has_dwarf_info())
-
- dwarfinfo = elffile.get_dwarf_info()
- self.assertTrue(dwarfinfo.range_lists() != None)
+ self.assertIsNotNone(elffile.get_dwarf_info().range_lists())
if __name__ == '__main__':
unittest.main()