def testGetParams(self): frame0 = pykd.getFrame() self.assertEqual(["this", "a", "b"], [name for name, param in frame0.getParams()]) frame1 = pykd.getStack()[1] self.assertEqual(["a", "b", "c"], [name for name, param in frame1.getParams()]) self.assertEqual(10, frame1.getParam("a")) self.assertEqual(10, frame1.params["a"]) frame2 = pykd.getStack()[2] self.assertEqual(10, frame2.params["a"]) self.assertEqual(10, frame2.getParam("a"))
def _xpp_raw_frames(): stack = getStack() eval_func_caller_frames = [] for idx, frame in enumerate(stack): if 'evalFunc' in findSymbol(frame.instructionOffset): eval_func_caller_frames.append(stack[idx+1]) return eval_func_caller_frames
def _xpp_raw_frames(): stack = getStack() eval_func_caller_frames = [] for idx, frame in enumerate(stack): if 'evalFunc' in findSymbol(frame.instructionOffset): eval_func_caller_frames.append(stack[idx + 1]) return eval_func_caller_frames
def testGetStack(self): expectedStack = [ 'targetapp!stackTestClass::stackMethod', 'targetapp!stackTestRun2', 'targetapp!stackTestRun1', 'targetapp!stackTestRun' ] realStack = [] for frame in pykd.getStack(): moduleName, symbolName, disp = pykd.findSymbolAndDisp(frame.ip) realStack.append("%s!%s" % (moduleName, symbolName)) self.assertEqual(expectedStack, realStack[0:4])
def testLocalVariable(self): """Start new process and test local variables""" _locProcessId = pykd.startProcess(target.appPath + " -testEnumWindows") with testutils.ContextCallIt( testutils.KillProcess(_locProcessId)) as killStartedProcess: pykd.go() # initial breakpoint -> wmain pykd.go() # wmain -> targetapp!EnumWindowsProc1 testEnumWindowsProc1Locals(self, pykd.getLocals()) pykd.go( ) # targetapp!EnumWindowsProc1 -> targetapp!functionCalledFromEnumWindowsProc1 testEnumWindowsProc1Locals(self, pykd.getStack()[1].locals) pykd.go( ) # targetapp!EnumWindowsProc1 -> targetapp!EnumWindowsProc2 locals = pykd.getLocals() self.assertEqual(len(locals), 2) self.assertTrue(locals[0] == 7 or locals[1] == 7) funcParams = pykd.getParams() self.assertEqual(len(funcParams), 2) self.assertTrue(funcParams[0] == 7 or funcParams[1] == 7)
def testGetLocalsNoSymbol(self): topFrame = pykd.getStack()[-1] self.assertEqual(0, len(topFrame.getLocals()))
def testGetLocals(self): expectedLocals = ["localDouble", "localFloat", "localChars"] frame2 = pykd.getStack()[2] self.assertEqual(expectedLocals, [name for name, param in frame2.getLocals()]) self.assertEqual(0.0, frame2.locals["localDouble"])
def _get_stack_with_frame_numbers(): ret = [] for idx, frame in enumerate(getStack()): frame.frameNumber = idx ret.append(frame) return ret
def get_native_frames_until_first_xpp_frame(): frames = getStack() if _xpp_raw_frames(): first_xpp_frame_number = _xpp_raw_frames()[0].frameNumber frames = [f for f in frames if f.frameNumber < first_xpp_frame_number] return [NativeFrame(f.instructionOffset) for f in frames]