RRZE-HPC / OSACA

Open Source Architecture Code Analyzer
GNU Affero General Public License v3.0
296 stars 18 forks source link

[REQUEST] Add support for handling comments generated by fcc compiler at the beginning of instruction code. #103

Open adityauj opened 8 months ago

adityauj commented 8 months ago

Is your feature request related to a problem? Please describe. OSACA is able to parse the asm file generated by fcc compiler. If fcc compiler generates comment at the beginning of each line of asm code, OSACA fails to parse those instructions and throws exception.

Describe the solution you'd like Request to handle such asm files in OSACA. If it would be possible to remove those comments from asm file before parsing begins.

Describe alternatives you've considered Manually removing those comments from asm file.

Additional context Attaching the sample problematic asm file generated by fcc compiler.

Sample ASM .LFB0: .cfi_startproc / 1 / sub sp, sp, 64 .cfi_def_cfa_offset 64 / ??? / stp x29, x30, [sp, 48] // () .cfi_offset 29, -16 .cfi_offset 30, -8 / ??? / str x19, [sp, 40] // () .cfi_offset 19, -24 .loc 1 3 0

Error Executing (compile_kernel): fcc .heat.c_kerncraft/kernel.c -c -I../.local/lib/python3.6/site-packages/kerncraft/headers -o .heat.ckerncraft/A64FX.yml/fcc/-Kfast-DTOFU/kernel.s -Kfast -DTOFU -S -std=c99 Traceback (most recent call last): File "/redacted/.local/lib/python3.6/site-packages/osaca/parser/parser_AArch64.py", line 320, in parse_line result = self.parse_instruction(line) File "/redacted/.local/lib/python3.6/site-packages/osaca/parser/parser_AArch64.py", line 338, in parse_instruction result = self.instruction_parser.parseString(instruction, parseAll=True).asDict() File "/redacted/.local/lib/python3.6/site-packages/pyparsing/util.py", line 256, in _inner return fn(self, *args, **kwargs) File "/redacted/.local/lib/python3.6/site-packages/pyparsing/core.py", line 1197, in parse_string raise exc.with_traceback(None) pyparsing.exceptions.ParseException: Expected W:(.0-9A-Za-z), found '/' (at char 0), (line:1, col:1)

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/redacted/.local/bin/kerncraft", line 11, in load_entry_point('kerncraft==0.8.12', 'console_scripts', 'kerncraft')() File "/redacted/.local/lib/python3.6/site-packages/kerncraft/kerncraft.py", line 402, in main run(parser, args) File "/redacted/.local/lib/python3.6/site-packages/kerncraft/kerncraft.py", line 371, in run model.analyze() File "/redacted/.local/lib/python3.6/site-packages/kerncraft/models/ecm.py", line 445, in analyze self._CPU.analyze() File "/redacted/.local/lib/python3.6/site-packages/kerncraft/models/ecm.py", line 300, in analyze verbose=self.verbose > 2) File "/redacted/.local/lib/python3.6/site-packages/kerncraft/kernel.py", line 1767, in incore_analysis isa=self._machine['isa']) File "/redacted/.local/lib/python3.6/site-packages/kerncraft/incore_model.py", line 558, in asm_instrumentation asm_lines = parse_asm(input_file.read(), isa) File "/redacted/.local/lib/python3.6/site-packages/kerncraft/incore_model.py", line 530, in parse_asm asm_lines = asm_parser.parse_file(code) File "/redacted/.local/lib/python3.6/site-packages/osaca/parser/base_parser.py", line 58, in parse_file asm_instructions.append(self.parse_line(line, i + 1 + start_line)) File "/redacted/.local/lib/python3.6/site-packages/osaca/parser/parser_AArch64.py", line 324, in parse_line ) from e ValueError: Unable to parse '/ 1 /\tsub\tsp, sp, 64' on line 15