noseglasses / elf_diff

A tool to compare ELF binaries
GNU General Public License v3.0
173 stars 22 forks source link

Pair report generation broken #51

Closed jenswet closed 2 years ago

jenswet commented 2 years ago

Describe the bug The pair report generation fails with an exception.

To Reproduce

 ~ python3 -m elf_diff --bin_prefix arm-none-eabi- --html_file test.html ~/irq_example_c.elf ~/irq_example_cpp.elf 
module_path = /usr/local/lib/python3.9/site-packages/elf_diff
Tools:
   objdump: /usr/local/bin/arm-none-eabi-objdump
   nm:      /usr/local/bin/arm-none-eabi-nm
   size:    /usr/local/bin/arm-none-eabi-size
Symbol selection regex:
   old binary: 'None'
   new binary: 'None'
Symbol exclusion regex:
   old binary: 'None'
   new binary: 'None'
Parsing symbols of old binary (~/irq_example_c.elf)
Parsing symbols of new binary (~/irq_example_cpp.elf)
Symbol Statistics:
   old binary (~/irq_example_c.elf):
      259 total symbol(s)
      259 symbol(s) selected
   new binary (~/irq_example_cpp.elf):
      2 total symbol(s)
      2 symbol(s) selected

   258 persisting symbol(s)
   1 disappeared symbol(s)
   2 new symbol(s)
Analyzing symbol size changes...
100% (258 of 258) |################################################################################################################################################################################| Elapsed Time: 0:00:00 Time:  0:00:00
Analyzing disappeared symbols...
100% (1 of 1) |####################################################################################################################################################################################| Elapsed Time: 0:00:00 Time:  0:00:00
Analyzing new symbols...
100% (2 of 2) |####################################################################################################################################################################################| Elapsed Time: 0:00:00 Time:  0:00:00
Analyzing assembly differences...
100% (258 of 258) |################################################################################################################################################################################| Elapsed Time: 0:00:00 Time:  0:00:00
Detecting symbol similarities...
100% (1 of 1) |####################################################################################################################################################################################| Elapsed Time: 0:00:00 Time:  0:00:00
Preparing persisting symbols ...
100% (258 of 258) |################################################################################################################################################################################| Elapsed Time: 0:00:00 Time:  0:00:00
Preparing disappeared symbols ...
100% (1 of 1) |####################################################################################################################################################################################| Elapsed Time: 0:00:00 Time:  0:00:00
Preparing new symbols ...
100% (2 of 2) |####################################################################################################################################################################################| Elapsed Time: 0:00:00 Time:  0:00:00
Preparing similar symbols ...
100% (1 of 1) |####################################################################################################################################################################################| Elapsed Time: 0:00:00 Time:  0:00:00
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.9/site-packages/elf_diff/__main__.py", line 147, in <module>
    main()
  File "/usr/local/lib/python3.9/site-packages/elf_diff/__main__.py", line 136, in main
    writePairReport(settings)
  File "/usr/local/lib/python3.9/site-packages/elf_diff/__main__.py", line 68, in writePairReport
    single_page_pair_report.writeSinglePageHTMLReport()
  File "/usr/local/lib/python3.9/site-packages/elf_diff/pair_report.py", line 1031, in writeSinglePageHTMLReport
    self.disappeared_symbols_details.getContent()
  File "/usr/local/lib/python3.9/site-packages/elf_diff/pair_report.py", line 64, in getContent
    self.generateContent()
  File "/usr/local/lib/python3.9/site-packages/elf_diff/pair_report.py", line 425, in generateContent
    self.content = f"No functions {self.description}"
AttributeError: 'IsolatedSymbolsDetails' object has no attribute 'description'

Expected behavior That error should not happen.

Desktop (please complete the following information):

Additional context There is a line missing

self.description = description

in here: https://github.com/noseglasses/elf_diff/blob/fa9014bad7fc9fe8c643fd39a30875d3621b8ad9/src/elf_diff/pair_report.py#L419

ghost commented 2 years ago

There seems to be a second bug that occurs after fixing the above:

Analyzing symbol size changes...
100% (1 of 1) |#########################################################################################################################################################################################################################| Elapsed Time: 0:00:00 Time:  0:00:00
Analyzing assembly differences...
100% (1 of 1) |#########################################################################################################################################################################################################################| Elapsed Time: 0:00:00 Time:  0:00:00
Preparing persisting symbols ...
100% (1 of 1) |#########################################################################################################################################################################################################################| Elapsed Time: 0:00:00 Time:  0:00:00
Preparing disappeared symbols ...
- |#                                                                                                                                                                                                                                                 | 0 Elapsed Time: 0:00:00
Preparing new symbols ...
- |#                                                                                                                                                                                                                                                 | 0 Elapsed Time: 0:00:00
Preparing similar symbols ...
- |#                                                                                                                                                                                                                                                 | 0 Elapsed Time: 0:00:00
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.9/site-packages/elf_diff/__main__.py", line 147, in <module>
    main()
  File "/usr/local/lib/python3.9/site-packages/elf_diff/__main__.py", line 136, in main
    writePairReport(settings)
  File "/usr/local/lib/python3.9/site-packages/elf_diff/__main__.py", line 68, in writePairReport
    single_page_pair_report.writeSinglePageHTMLReport()
  File "/usr/local/lib/python3.9/site-packages/elf_diff/pair_report.py", line 1046, in writeSinglePageHTMLReport
    template_keywords.update(self.getSinglePageTemplateKeywords())
  File "/usr/local/lib/python3.9/site-packages/elf_diff/pair_report.py", line 1010, in getSinglePageTemplateKeywords
    "disappeared_symbols_size": self.disappeared_symbols_overview.overall_symbol_size,
AttributeError: 'IsolatedSymbolsOverview' object has no attribute 'overall_symbol_size'

Please check this example to reproduce elf_example.zip

noseglasses commented 2 years ago

@jenswet, would you please check if #55 fixes your second issue?

jenswet commented 2 years ago

@noseglasses, yes, both is fixed in the current master. It'd be great if you can publish a new pip package. Thanks!

noseglasses commented 2 years ago

Thanks for confirming. Python package soon to come.

noseglasses commented 2 years ago

FWIW, hotfix package v0.3.4 released on pypi.