quarkslab / quokka

Quokka: A Fast and Accurate Binary Exporter
https://quarkslab.github.io/quokka/
Apache License 2.0
172 stars 13 forks source link

Cannot obtain pypcode instructions #33

Closed rc-94 closed 6 months ago

rc-94 commented 6 months ago

Hello,

When I tried to access the corresponding pcode instructions of a block, I encounter the following error :

>>> import quokka
>>> p = quokka.Program('x86-gcc-7-O0_fips.so.Quokka', 'x86-gcc-7-O0_fips.so')
>>> for ffa, ff in p.items():
...     for (addr, bb) in ff.blocks.items():
...             print(bb.pcode_insts)

Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
  File "/usr/lib/python3.11/functools.py", line 1001, in __get__
    val = self.func(instance)
          ^^^^^^^^^^^^^^^^^^^
  File "/home/rcohen/Documents/ressources/experiments/current/sog/HermesSim/binaries/Dataset-1/openssl/venv/lib/python3.11/site-packages/quokka/block.py", line 263, in pcode_insts
    return pypcode_decode_block(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rcohen/Documents/ressources/experiments/current/sog/HermesSim/binaries/Dataset-1/openssl/venv/lib/python3.11/site-packages/quokka/backends/pypcode.py", line 142, in pypcode_decode_block
    first_instruction: Optional[quokka.Instruction] = next(block.instructions, None)
                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'ValuesView' object is not an iterator

I'm using the latest version of Quokka (0.5.5) and the version 2.1.0 of pypcode. Do you have any idea in order to solve the problem ?

Thanks

patacca commented 6 months ago

This has been fixed in commit https://github.com/quarkslab/quokka/commit/a7a54a2f2a12a0ecac2f3bcf64b26432f2215f45

Regrettably we didn't publish a new version of quokka alongside it. I will do it now. In any case if you build yourself the python module from the main branch it should work