panda-re / panda

Platform for Architecture-Neutral Dynamic Analysis
https://panda.re
Other
2.48k stars 479 forks source link

python: callback procname parameter does not work #782

Closed gergelyrevay closed 4 years ago

gergelyrevay commented 4 years ago

When trying to use the procname parameter in callbacks in the python interface, like here (examples/block_count.py):

@panda.cb_before_block_exec(procname="bash")
def before_block_execute(cpustate, transblock):
    global blocks

I get the following error multiple times:

From cffi callback <function Panda._register_internal_asid_changed_cb.<locals>.__get_pending_procname_change at 0x7f84beca1400>:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/pandare/panda.py", line 2036, in __get_pending_procname_change
    self._procname_changed(cpu, name)
AttributeError: 'Panda' object has no attribute '_procname_changed'

From panda.py it seems that _procname_changed should be a function, and it is being called at various places, however, I don't seem to find the implementation of it:

root@ubuntu:~/10_break/panda# git grep "procname_changed"
panda/python/core/pandare/panda.py:                self._procname_changed(cpu, name)
panda/python/core/pandare/panda.py:                self._procname_changed(cpu, name)
panda/python/core/pandare/panda.py:            if so, call panda._procname_changed(cpu, name). Otherwise, we enable __get_pending_procname_change CB, which
panda/python/core/pandare/panda.py:            panda._procname_changed(cpu, name)
panda/python/core/pandare/panda.py:            else: # We do know this ASID->procname, just call procname_changed
panda/python/core/pandare/panda.py:                self._procname_changed(cpustate, self.asid_mapping[new_asid])

last commit:

root@ubuntu:~/10_break/panda# git log
commit a2949ced08add4fac072236c67426c348f8f3f6d (HEAD -> master, origin/master, origin/HEAD)
Author: tnballo <tnballo@users.noreply.github.com>
Date:   Tue Oct 6 17:35:48 2020 -0400

    Update for current pypanda arch str field
AndrewFasano commented 4 years ago

It took a bit to track this down, but it looks like @lacraig2 accidentally deleted that function here. https://github.com/panda-re/panda/commit/a3988c1fd2a8c50123f3d621299c723acd4531c0#diff-761044d412cf27757e5f5ef652cbbdaeL476.

@lacraig2 can you bring it back?

lacraig2 commented 4 years ago

This was deleted when introducing hooks2. I've issued #783 to resolve this issue.