68 lines · python
1"""2Test basics of a mini dump taken of a 32-bit process running in WoW643 4WoW64 is the subsystem that lets 32-bit processes run in 64-bit Windows. If you5capture a mini dump of a process running under WoW64 with a 64-bit debugger, you6end up with a dump of the WoW64 layer. In that case, LLDB must do extra work to7get the 32-bit register contexts.8"""9 10import lldb11from lldbsuite.test.decorators import *12from lldbsuite.test.lldbtest import *13from lldbsuite.test import lldbutil14 15 16class Wow64MiniDumpTestCase(TestBase):17 NO_DEBUG_INFO_TESTCASE = True18 19 def test_wow64_mini_dump(self):20 """Test that lldb can read the process information from the minidump."""21 # target create -c fizzbuzz_wow64.dmp22 target = self.dbg.CreateTarget("")23 process = target.LoadCore("fizzbuzz_wow64.dmp")24 self.assertTrue(process, PROCESS_IS_VALID)25 self.assertEqual(process.GetNumThreads(), 1)26 self.assertEqual(process.GetProcessID(), 0x1E9C)27 28 def test_thread_info_in_wow64_mini_dump(self):29 """Test that lldb can read the thread information from the minidump."""30 # target create -c fizzbuzz_wow64.dmp31 target = self.dbg.CreateTarget("")32 process = target.LoadCore("fizzbuzz_wow64.dmp")33 # This process crashed due to an access violation (0xc0000005), but the34 # minidump doesn't have an exception record--perhaps the crash handler35 # ate it.36 # TODO: See if we can recover the exception information from the TEB,37 # which, according to Windbg, has a pointer to an exception list.38 39 # In the dump, none of the threads are stopped, so we cannot use40 # lldbutil.get_stopped_thread.41 thread = process.GetThreadAtIndex(0)42 self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonNone)43 44 def test_stack_info_in_wow64_mini_dump(self):45 """Test that we can see a trivial stack in a VS-generate mini dump."""46 # target create -c fizzbuzz_no_heap.dmp47 target = self.dbg.CreateTarget("")48 process = target.LoadCore("fizzbuzz_wow64.dmp")49 self.assertGreaterEqual(process.GetNumThreads(), 1)50 # This process crashed due to an access violation (0xc0000005), but the51 # minidump doesn't have an exception record--perhaps the crash handler52 # ate it.53 # TODO: See if we can recover the exception information from the TEB,54 # which, according to Windbg, has a pointer to an exception list.55 56 # In the dump, none of the threads are stopped, so we cannot use57 # lldbutil.get_stopped_thread.58 thread = process.GetThreadAtIndex(0)59 # The crash is in main, so there should be at least one frame on the60 # stack.61 self.assertGreaterEqual(thread.GetNumFrames(), 1)62 frame = thread.GetFrameAtIndex(0)63 self.assertTrue(frame.IsValid())64 pc = frame.GetPC()65 eip = frame.FindRegister("pc")66 self.assertTrue(eip.IsValid())67 self.assertEqual(pc, eip.GetValueAsUnsigned())68