amccarth created this revision.
amccarth added a reviewer: zturner.
amccarth added a subscriber: lldb-commits.

More mini dump tests to make sure we can see a stack with several levels and 
inspect local variables.

http://reviews.llvm.org/D15435

Files:
  packages/Python/lldbsuite/test/functionalities/postmortem/minidump/Makefile
  
packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
  packages/Python/lldbsuite/test/functionalities/postmortem/minidump/main.cpp

Index: packages/Python/lldbsuite/test/functionalities/postmortem/minidump/main.cpp
===================================================================
--- /dev/null
+++ packages/Python/lldbsuite/test/functionalities/postmortem/minidump/main.cpp
@@ -0,0 +1,21 @@
+int global = 42;
+
+int
+bar(int x)
+{
+  int y = 4*x + global;
+  return y;
+}
+
+int
+foo(int x)
+{
+  int y = 2*bar(3*x);
+  return y;
+}
+
+int
+main()
+{
+  return 0 * foo(1);
+}
Index: packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
===================================================================
--- packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
+++ packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
@@ -34,7 +34,7 @@
 
     @no_debug_info_test
     def test_stack_info_in_mini_dump(self):
-        """Test that we can see the stack."""
+        """Test that we can see a trivial stack."""
         self.assertEqual(self.process.GetNumThreads(), 1)
         thread = self.process.GetThreadAtIndex(0)
         # The crash is in main, so there should be one frame on the stack.
@@ -46,6 +46,73 @@
         self.assertTrue(eip.IsValid())
         self.assertEqual(pc, eip.GetValueAsUnsigned())
 
+    @not_remote_testsuite_ready
+    @skipUnlessWindows
+    def test_deeper_stack_in_mini_dump(self):
+        """Test that we can examine a more interesting stack in a mini dump."""
+        self.build()
+        exe = os.path.join(os.getcwd(), "a.out")
+        core = os.path.join(os.getcwd(), "core.dmp")
+        try:
+            # Set a breakpoint and capture a mini dump.
+            target = self.dbg.CreateTarget(exe)
+            breakpoint = target.BreakpointCreateByName("bar")
+            process = target.LaunchSimple(None, None, self.get_process_working_directory())
+            self.assertEqual(process.GetState(), lldb.eStateStopped)
+            self.assertTrue(process.SaveCore(core))
+            self.assertTrue(os.path.isfile(core))
+            self.assertTrue(process.Kill().Success())
+
+            # Launch with the mini dump, and inspect the stack.
+            target = self.dbg.CreateTarget(None)
+            process = target.LoadCore(core)
+            thread = process.GetThreadAtIndex(0)
+
+            expected_stack = { 0: 'bar', 1: 'foo', 2: 'main' }
+            self.assertEqual(thread.GetNumFrames(), len(expected_stack))
+            for index, name in expected_stack.iteritems():
+                frame = thread.GetFrameAtIndex(index)
+                self.assertTrue(frame.IsValid())
+                function_name = frame.GetFunctionName()
+                self.assertTrue(name in function_name)
+
+        finally:
+            # Clean up the mini dump file.
+            self.assertTrue(self.dbg.DeleteTarget(target))
+            if (os.path.isfile(core)):
+                os.unlink(core)
+
+    @not_remote_testsuite_ready
+    @skipUnlessWindows
+    def test_local_variables_in_mini_dump(self):
+        """Test that we can examine local variables in a mini dump."""
+        self.build()
+        exe = os.path.join(os.getcwd(), "a.out")
+        core = os.path.join(os.getcwd(), "core.dmp")
+        try:
+            # Set a breakpoint and capture a mini dump.
+            target = self.dbg.CreateTarget(exe)
+            breakpoint = target.BreakpointCreateByName("bar")
+            process = target.LaunchSimple(None, None, self.get_process_working_directory())
+            self.assertEqual(process.GetState(), lldb.eStateStopped)
+            self.assertTrue(process.SaveCore(core))
+            self.assertTrue(os.path.isfile(core))
+            self.assertTrue(process.Kill().Success())
+
+            # Launch with the mini dump, and inspect a local variable.
+            target = self.dbg.CreateTarget(None)
+            process = target.LoadCore(core)
+            thread = process.GetThreadAtIndex(0)
+            frame = thread.GetFrameAtIndex(0)
+            value = frame.EvaluateExpression('x')
+            self.assertEqual(value.GetValueAsSigned(), 3)
+
+        finally:
+            # Clean up the mini dump file.
+            self.assertTrue(self.dbg.DeleteTarget(target))
+            if (os.path.isfile(core)):
+                os.unlink(core)
+
     def setUp(self):
         # Call super's setUp().
         TestBase.setUp(self)
Index: packages/Python/lldbsuite/test/functionalities/postmortem/minidump/Makefile
===================================================================
--- /dev/null
+++ packages/Python/lldbsuite/test/functionalities/postmortem/minidump/Makefile
@@ -0,0 +1,6 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
+
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to