[Lldb-commits] [lldb] r134109 - in /lldb/trunk/test/python_api/target: TestTargetAPI.py main.c

Johnny Chen johnny.chen at apple.com
Wed Jun 29 15:45:07 PDT 2011


Author: johnny
Date: Wed Jun 29 17:45:06 2011
New Revision: 134109

URL: http://llvm.org/viewvc/llvm-project?rev=134109&view=rev
Log:
Add test cases to TestTargetAPI.py to exercise the newly added SBTarget.FindGlobalVariables() API.

Modified:
    lldb/trunk/test/python_api/target/TestTargetAPI.py
    lldb/trunk/test/python_api/target/main.c

Modified: lldb/trunk/test/python_api/target/TestTargetAPI.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/target/TestTargetAPI.py?rev=134109&r1=134108&r2=134109&view=diff
==============================================================================
--- lldb/trunk/test/python_api/target/TestTargetAPI.py (original)
+++ lldb/trunk/test/python_api/target/TestTargetAPI.py Wed Jun 29 17:45:06 2011
@@ -14,6 +14,19 @@
 
     @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
     @python_api_test
+    def test_find_global_variables_with_dsym(self):
+        """Exercise SBTaget.FindGlobalVariables() API."""
+        self.buildDsym()
+        self.find_global_variables()
+
+    @python_api_test
+    def test_find_global_variables_with_dwarf(self):
+        """Exercise SBTarget.FindGlobalVariables() API."""
+        self.buildDwarf()
+        self.find_global_variables()
+
+    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
+    @python_api_test
     def test_get_description_with_dsym(self):
         """Exercise SBTaget.GetDescription() API."""
         self.buildDsym()
@@ -58,6 +71,24 @@
         self.line1 = line_number('main.c', '// Find the line number for breakpoint 1 here.')
         self.line2 = line_number('main.c', '// Find the line number for breakpoint 2 here.')
 
+    def find_global_variables(self):
+        """Exercise SBTaget.FindGlobalVariables() API."""
+        exe = os.path.join(os.getcwd(), "a.out")
+
+        # Create a target by the debugger.
+        target = self.dbg.CreateTarget(exe)
+        self.assertTrue(target, VALID_TARGET)
+
+        value_list = target.FindGlobalVariables('my_global_var_of_char_type', 1)
+        self.assertTrue(value_list.GetSize() == 1)
+        my_global_var = value_list.GetValueAtIndex(0)
+        self.expect(my_global_var.GetName(), exe=False,
+            startstr = "my_global_var_of_char_type")
+        self.expect(my_global_var.GetTypeName(), exe=False,
+            startstr = "char")
+        self.expect(my_global_var.GetValue(), exe=False,
+            startstr = "'X'")
+
     def get_description(self):
         """Exercise SBTaget.GetDescription() API."""
         exe = os.path.join(os.getcwd(), "a.out")

Modified: lldb/trunk/test/python_api/target/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/target/main.c?rev=134109&r1=134108&r2=134109&view=diff
==============================================================================
--- lldb/trunk/test/python_api/target/main.c (original)
+++ lldb/trunk/test/python_api/target/main.c Wed Jun 29 17:45:06 2011
@@ -18,6 +18,8 @@
 //
 // The two symbol context should point to the same symbol, i.e., 'a' function.
 
+char my_global_var_of_char_type = 'X'; // Test SBTarget.FindGlobalVariables(...).
+
 int a(int);
 int b(int);
 int c(int);





More information about the lldb-commits mailing list