[Lldb-commits] [lldb] r366507 - Add an expectedFailure test for type finding.
Jim Ingham via lldb-commits
lldb-commits at lists.llvm.org
Thu Jul 18 15:21:16 PDT 2019
Author: jingham
Date: Thu Jul 18 15:21:16 2019
New Revision: 366507
URL: http://llvm.org/viewvc/llvm-project?rev=366507&view=rev
Log:
Add an expectedFailure test for type finding.
When two .c files define a type of the same name, lldb
just picks one and uses it regardless of context. That is
not correct. When stopped in a frame in one of the .c files
that define this type, it should use that local definition.
This commit just adds a test that checks for the correct
behavior. It is currently xfailed.
Added:
lldb/trunk/packages/Python/lldbsuite/test/lang/c/local_types/
lldb/trunk/packages/Python/lldbsuite/test/lang/c/local_types/TestUseClosestType.py
lldb/trunk/packages/Python/lldbsuite/test/lang/c/local_types/main.c
lldb/trunk/packages/Python/lldbsuite/test/lang/c/local_types/other.c
Added: lldb/trunk/packages/Python/lldbsuite/test/lang/c/local_types/TestUseClosestType.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/local_types/TestUseClosestType.py?rev=366507&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/c/local_types/TestUseClosestType.py (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/local_types/TestUseClosestType.py Thu Jul 18 15:21:16 2019
@@ -0,0 +1,56 @@
+"""
+If there is a definition of a type in the current
+Execution Context's CU, then we should use that type
+even if there are other definitions of the type in other
+CU's. Assert that that is true.
+"""
+
+from __future__ import print_function
+
+
+import os
+import time
+import re
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+
+class TestUseClosestType(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ NO_DEBUG_INFO_TESTCASE = True
+
+ @expectedFailureAll(bugnumber="<rdar://problem/53262085>")
+ def test_use_in_expr(self):
+ """Use the shadowed type directly, see if we get a conflicting type definition."""
+ self.build()
+ self.main_source_file = lldb.SBFileSpec("main.c")
+ self.expr_test()
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+
+ def run_and_check_expr(self, num_children, child_type):
+ frame = self.thread.GetFrameAtIndex(0)
+ result = frame.EvaluateExpression("struct Foo *$mine = (struct Foo *) malloc(sizeof(struct Foo)); $mine")
+ self.assertTrue(result.GetError().Success(), "Failed to parse an expression using a multiply defined type: %s"%(result.GetError().GetCString()), )
+ self.assertEqual(result.GetTypeName(), "struct Foo *", "The result has the right typename.")
+ self.assertEqual(result.GetNumChildren(), num_children, "Got the right number of children")
+ self.assertEqual(result.GetChildAtIndex(0).GetTypeName(), child_type, "Got the right type.")
+
+ def expr_test(self):
+ """ Run to a breakpoint in main.c, check that an expression referring to Foo gets the
+ local three int version. Then run to a breakpoint in other.c and check that an
+ expression referring to Foo gets the two char* version. """
+
+ (target, process, self.thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
+ "Set a breakpoint in main", self.main_source_file)
+
+ self.run_and_check_expr(3, "int")
+ lldbutil.run_to_source_breakpoint(self, "Set a breakpoint in other", lldb.SBFileSpec("other.c"))
+ self.run_and_check_expr(2, "char *")
+
Added: lldb/trunk/packages/Python/lldbsuite/test/lang/c/local_types/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/local_types/main.c?rev=366507&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/c/local_types/main.c (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/local_types/main.c Thu Jul 18 15:21:16 2019
@@ -0,0 +1,16 @@
+extern int callme(int input);
+
+struct Foo {
+ int a;
+ int b;
+ int c;
+};
+
+int
+main(int argc, char **argv)
+{
+ // Set a breakpoint in main
+ struct Foo mine = {callme(argc), 10, 20};
+ return mine.a;
+}
+
Added: lldb/trunk/packages/Python/lldbsuite/test/lang/c/local_types/other.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/c/local_types/other.c?rev=366507&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/c/local_types/other.c (added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/c/local_types/other.c Thu Jul 18 15:21:16 2019
@@ -0,0 +1,11 @@
+struct Foo {
+ char *ptr1;
+ char *ptr2;
+};
+
+int
+callme(int input)
+{
+ struct Foo myFoo = { "string one", "Set a breakpoint in other"};
+ return myFoo.ptr1[0] + myFoo.ptr2[0] + input;
+}
More information about the lldb-commits
mailing list