def getdisresult(self, frame): """ return (possibly cached) pydis result for the given frame. """ try: return self._cache[id(frame.pycode)] except KeyError: res = self._cache[id(frame.pycode)] = pydis.pydis(frame.pycode) assert res is not None return res
def test_trace_oneop(self): def app_f(): x = 1 x + 1 res = self.perform_trace(app_f) disresult = pydis.pydis(app_f) uw = self.space.unwrap ops = res.getoperations() op_start = self.get_operation(ops, trace.CallBegin, "add") args = [uw(x) for x in op_start.callinfo.args] assert args == [1, 1] op_end = self.get_operation(ops, trace.CallFinished, "add") assert uw(op_end.res) == 2
def test_some_builtin2(self): def app_f(): filter(None, []) # filter implemented in appspace -> has many more bytecodes res = self.perform_trace(app_f) disresult = pydis.pydis(app_f) assert len(disresult.bytecodes) <= len(list(res.getbytecodes()))
def test_some_builtin1(self): def app_f(): len([1,2,3,4,5]) res = self.perform_trace(app_f) disresult = pydis.pydis(app_f) assert len(disresult.bytecodes) == len(list(res.getbytecodes()))
def test_simpletrace(self): def app_f(): pass res = self.perform_trace(app_f) disresult = pydis.pydis(app_f) assert disresult.bytecodes == list(res.getbytecodes())