Vector35 / dwarf_import

This loads DWARF info from an open binary and propagates function names, arguments, and type info
MIT License
24 stars 7 forks source link

AttributeError trying to apply on latest dev #28

Closed CouleeApps closed 1 year ago

CouleeApps commented 1 year ago

Dev 3.5.4286, stock Ubuntu 20.04 and installed from plugin manager

Trying to use DWARF Import > Load DWARF Symbols on a simple C Linux ELF file throws a bunch of errors in the python console and fails to work. Binary available upon request

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/home/vector35/binaryninja/plugins/../python/binaryninja/plugin.py", line 928, in run
    self.task.run()
  File "/home/vector35/.binaryninja/repositories/official/plugins/Vector35_dwarf_import/__init__.py", line 41, in run
    analysis_session = AnalysisSession(binary_view = self.view, debug_file = self.debug_file)
  File "/home/vector35/.binaryninja/repositories/official/plugins/Vector35_dwarf_import/mapped_model.py", line 67, in __init__
    m = AnalysisModel.from_dwarf(debug_source, self.debug_root, name=binary_name, logger=logger)
  File "/home/vector35/.binaryninja/repositories/official/plugins/Vector35_dwarf_import/model/analysis_model.py", line 297, in from_dwarf
    import_ELF_DWARF_into_model(elf_file, model, debug_root=debug_root, logger=logger)
  File "/home/vector35/.binaryninja/repositories/official/plugins/Vector35_dwarf_import/io/dwarf_import.py", line 1466, in import_ELF_DWARF_into_model
    dwarf_db = DWARFDB(elf_file, debug_root)
  File "/home/vector35/.binaryninja/repositories/official/plugins/Vector35_dwarf_import/io/dwarf_import.py", line 263, in __init__
    self._pri = DWARFData(elf_file, debug_root)
  File "/home/vector35/.binaryninja/repositories/official/plugins/Vector35_dwarf_import/io/dwarf_import.py", line 182, in __init__
    self._index()
  File "/home/vector35/.binaryninja/repositories/official/plugins/Vector35_dwarf_import/io/dwarf_import.py", line 185, in _index
    for cu in self._dwarf_info.iter_CUs():
  File "/home/vector35/.binaryninja/python38/site-packages/elftools/dwarf/dwarfinfo.py", line 353, in _parse_CUs_iter
    cu = self._cached_CU_at_offset(offset)
  File "/home/vector35/.binaryninja/python38/site-packages/elftools/dwarf/dwarfinfo.py", line 383, in _cached_CU_at_offset
    cu = self._parse_CU_at_offset(offset)
  File "/home/vector35/.binaryninja/python38/site-packages/elftools/dwarf/dwarfinfo.py", line 417, in _parse_CU_at_offset
    cu_structs = DWARFStructs(
  File "/home/vector35/.binaryninja/python38/site-packages/elftools/dwarf/structs.py", line 92, in __init__
    assert address_size == 8 or address_size == 4
AssertionError
Traceback (most recent call last):
  File "/home/vector35/binaryninja/plugins/../python/binaryninja/plugin.py", line 229, in _default_is_valid
    return is_valid(view_obj)
  File "/home/vector35/.binaryninja/repositories/official/plugins/Vector35_dwarf_import/__init__.py", line 92, in is_valid
    reader = BinaryReader(bv.file.raw)
  File "/home/vector35/binaryninja/plugins/../python/binaryninja/binaryview.py", line 8196, in __init__
    _handle = core.BNCreateBinaryReader(view.handle)
AttributeError: 'NoneType' object has no attribute 'handle'
Exception ignored in: <function BinaryReader.__del__ at 0x7fa4fb5a55e0>
Traceback (most recent call last):
  File "/home/vector35/binaryninja/plugins/../python/binaryninja/binaryview.py", line 8209, in __del__
    core.BNFreeBinaryReader(self._handle)
AttributeError: 'BinaryReader' object has no attribute '_handle'