[Lldb-commits] [lldb] r107330 - in /lldb/trunk/test: array_types/TestArrayTypes.py class_types/TestClassTypes.py
Johnny Chen
johnny.chen at apple.com
Wed Jun 30 15:16:25 PDT 2010
Author: johnny
Date: Wed Jun 30 17:16:25 2010
New Revision: 107330
URL: http://llvm.org/viewvc/llvm-project?rev=107330&view=rev
Log:
Added TestClassTypes.py to test setting a breakpoint on a class constructor and
do 'variable list this' command when stopped.
Applied some cleanup on TestArrayTypes.py. In particular, specify the absolute
path to the object file in order not to confuse the debugger.
Added:
lldb/trunk/test/class_types/TestClassTypes.py
Modified:
lldb/trunk/test/array_types/TestArrayTypes.py
Modified: lldb/trunk/test/array_types/TestArrayTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=107330&r1=107329&r2=107330&view=diff
==============================================================================
--- lldb/trunk/test/array_types/TestArrayTypes.py (original)
+++ lldb/trunk/test/array_types/TestArrayTypes.py Wed Jun 30 17:16:25 2010
@@ -25,8 +25,10 @@
def test_array_types(self):
"""Test 'variable list var_name' on some variables with array types."""
res = lldb.SBCommandReturnObject()
- self.ci.HandleCommand("file a.out", res)
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.ci.HandleCommand("file " + exe, res)
self.assertTrue(res.Succeeded())
+
self.ci.HandleCommand("breakpoint set -f main.c -l 42", res)
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith(
@@ -46,15 +48,16 @@
self.ci.HandleCommand("variable list strings", res);
self.assertTrue(res.Succeeded())
- self.assertTrue(res.GetOutput().startswith('(char *[4])') and
- res.GetOutput().find('(char *) strings[0]') and
- res.GetOutput().find('(char *) strings[1]') and
- res.GetOutput().find('(char *) strings[2]') and
- res.GetOutput().find('(char *) strings[3]') and
- res.GetOutput().find('Hello') and
- res.GetOutput().find('Hola') and
- res.GetOutput().find('Bonjour') and
- res.GetOutput().find('Guten Tag'))
+ output = res.GetOutput()
+ self.assertTrue(output.startswith('(char *[4])') and
+ output.find('(char *) strings[0]') and
+ output.find('(char *) strings[1]') and
+ output.find('(char *) strings[2]') and
+ output.find('(char *) strings[3]') and
+ output.find('Hello') and
+ output.find('Hola') and
+ output.find('Bonjour') and
+ output.find('Guten Tag'))
self.ci.HandleCommand("variable list char_16", res);
self.assertTrue(res.Succeeded())
Added: lldb/trunk/test/class_types/TestClassTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=107330&view=auto
==============================================================================
--- lldb/trunk/test/class_types/TestClassTypes.py (added)
+++ lldb/trunk/test/class_types/TestClassTypes.py Wed Jun 30 17:16:25 2010
@@ -0,0 +1,60 @@
+"""Test breakpoint on a class constructor; and variable list the this object."""
+
+import os
+import lldb
+import unittest
+
+class TestClassTypes(unittest.TestCase):
+
+ def setUp(self):
+ # Save old working directory.
+ self.oldcwd = os.getcwd()
+ # Change current working directory if ${LLDB_TEST} is defined.
+ if ("LLDB_TEST" in os.environ):
+ os.chdir(os.path.join(os.environ["LLDB_TEST"], "class_types"));
+ self.dbg = lldb.SBDebugger.Create()
+ self.dbg.SetAsync(False)
+ self.ci = self.dbg.GetCommandInterpreter()
+ if not self.ci:
+ raise Exception('Could not get the command interpreter')
+
+ def tearDown(self):
+ # Restore old working directory.
+ os.chdir(self.oldcwd)
+
+ def test_class_types(self):
+ """Test 'variable list this' when stopped on a class constructor."""
+ res = lldb.SBCommandReturnObject()
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.ci.HandleCommand("file " + exe, res)
+ self.assertTrue(res.Succeeded())
+
+ self.ci.HandleCommand("breakpoint set -f main.cpp -l 73", res)
+ self.assertTrue(res.Succeeded())
+ self.assertTrue(res.GetOutput().startswith(
+ "Breakpoint created: 1: file ='main.cpp', line = 73, locations = 1"))
+
+ self.ci.HandleCommand("run", res)
+ self.assertTrue(res.Succeeded())
+
+ self.ci.HandleCommand("breakpoint list", res)
+ self.assertTrue(res.Succeeded())
+ self.assertTrue(res.GetOutput().find('resolved, hit count = 1'))
+
+ self.ci.HandleCommand("thread list", res)
+ self.assertTrue(res.Succeeded())
+ self.assertTrue(res.GetOutput().find('state is Stopped') and
+ res.GetOutput().find('stop reason = breakpoint'))
+
+ self.ci.HandleCommand("variable list this", res);
+ self.assertTrue(res.Succeeded())
+ self.assertTrue(res.GetOutput().startswith('(class C *const) this = '))
+
+ self.ci.HandleCommand("continue", res)
+ self.assertTrue(res.Succeeded())
+
+
+if __name__ == '__main__':
+ lldb.SBDebugger.Initialize()
+ unittest.main()
+ lldb.SBDebugger.Terminate()
More information about the lldb-commits
mailing list