[Lldb-commits] [lldb] 089a1d9 - [lldb] Fix TestWithLimitDebugInfo.py

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 27 06:09:43 PDT 2022


Author: Pavel Labath
Date: 2022-04-27T15:08:58+02:00
New Revision: 089a1d9deba5579487d77c97241b3f9e5e3d4745

URL: https://github.com/llvm/llvm-project/commit/089a1d9deba5579487d77c97241b3f9e5e3d4745
DIFF: https://github.com/llvm/llvm-project/commit/089a1d9deba5579487d77c97241b3f9e5e3d4745.diff

LOG: [lldb] Fix TestWithLimitDebugInfo.py

The test was broken (in the sense that it was not testing what it was
supposed to test) in two ways:
- a Makefile refactor caused it to stop being built with
  -flimit-debug-info
- clang's constructor homing changed the "home" of the type

This patch fixes the Makefile, and modifies the source code to produce
the same result with both type homing strategies. Due to constructor
homing I had to use a different implicitly-defined function for the test
-- I chose the assignment operator.

I also added some sanity checks to the test to ensure that the test is
indeed operating on limited debug info.

Added: 
    

Modified: 
    lldb/test/API/lang/cpp/limit-debug-info/Makefile
    lldb/test/API/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py
    lldb/test/API/lang/cpp/limit-debug-info/base.cpp
    lldb/test/API/lang/cpp/limit-debug-info/base.h
    lldb/test/API/lang/cpp/limit-debug-info/derived.cpp
    lldb/test/API/lang/cpp/limit-debug-info/derived.h
    lldb/test/API/lang/cpp/limit-debug-info/main.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/lang/cpp/limit-debug-info/Makefile b/lldb/test/API/lang/cpp/limit-debug-info/Makefile
index ba7e01537522..30230b3469ac 100644
--- a/lldb/test/API/lang/cpp/limit-debug-info/Makefile
+++ b/lldb/test/API/lang/cpp/limit-debug-info/Makefile
@@ -1,5 +1,5 @@
 CXX_SOURCES = main.cpp derived.cpp base.cpp
 
-CFLAGS_EXTRAS := $(LIMIT_DEBUG_INFO_FLAGS)
+CFLAGS_EXTRAS = $(LIMIT_DEBUG_INFO_FLAGS)
 
 include Makefile.rules

diff  --git a/lldb/test/API/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py b/lldb/test/API/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py
index 69caf94bd33a..9956bed5eb50 100644
--- a/lldb/test/API/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py
+++ b/lldb/test/API/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py
@@ -8,10 +8,12 @@ class TestWithLimitDebugInfo(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
-    @skipIf(debug_info=no_match(["dwarf"]))
+    @add_test_categories(["dwarf", "dwo"])
     def test_limit_debug_info(self):
         self.build()
 
+        self._check_info_is_limited()
+
         src_file = os.path.join(self.getSourceDir(), "main.cpp")
         src_file_spec = lldb.SBFileSpec(src_file)
         self.assertTrue(src_file_spec.IsValid(), "breakpoint file")
@@ -52,6 +54,12 @@ def test_limit_debug_info(self):
         self.assertTrue(
             v2.IsValid(),
             "'expr this' results in a valid SBValue object")
-        self.assertTrue(
-            v2.GetError().Success(),
+        self.assertSuccess(
+            v2.GetError(),
             "'expr this' succeeds without an error.")
+
+    def _check_info_is_limited(self):
+        target = self.dbg.CreateTarget(self.getBuildArtifact("main.o"))
+        self.assertTrue(target.IsValid())
+        Foo = target.FindFirstType("Foo")
+        self.assertFalse(Foo.IsValid())

diff  --git a/lldb/test/API/lang/cpp/limit-debug-info/base.cpp b/lldb/test/API/lang/cpp/limit-debug-info/base.cpp
index 4023bdbc64af..296864488820 100644
--- a/lldb/test/API/lang/cpp/limit-debug-info/base.cpp
+++ b/lldb/test/API/lang/cpp/limit-debug-info/base.cpp
@@ -1,5 +1,7 @@
 #include "base.h"
 
+FooNS::FooNS() : x(12345) {}
+
 void FooNS::bar() {
     x = 54321;
 }

diff  --git a/lldb/test/API/lang/cpp/limit-debug-info/base.h b/lldb/test/API/lang/cpp/limit-debug-info/base.h
index d3a09572bd25..f4da76701c78 100644
--- a/lldb/test/API/lang/cpp/limit-debug-info/base.h
+++ b/lldb/test/API/lang/cpp/limit-debug-info/base.h
@@ -5,6 +5,8 @@ class FooNS
     virtual char baz() = 0;
 
 protected:
+    FooNS();
+
     int x;
 };
 

diff  --git a/lldb/test/API/lang/cpp/limit-debug-info/derived.cpp b/lldb/test/API/lang/cpp/limit-debug-info/derived.cpp
index 9d773593eb51..911fe3d9bc17 100644
--- a/lldb/test/API/lang/cpp/limit-debug-info/derived.cpp
+++ b/lldb/test/API/lang/cpp/limit-debug-info/derived.cpp
@@ -1,5 +1,10 @@
 #include "derived.h"
 
+Foo foo1;
+Foo foo2;
+
+Foo::Foo() { a = 12345; }
+
 char Foo::baz() {
     return (char)(x&0xff);
 }

diff  --git a/lldb/test/API/lang/cpp/limit-debug-info/derived.h b/lldb/test/API/lang/cpp/limit-debug-info/derived.h
index 46b3f83b9f74..8f95c52a595f 100644
--- a/lldb/test/API/lang/cpp/limit-debug-info/derived.h
+++ b/lldb/test/API/lang/cpp/limit-debug-info/derived.h
@@ -3,11 +3,17 @@
 class Foo : public FooNS
 {
 public:
-    Foo() {
-        a = 12345;
+    Foo();
+
+    // Deliberately defined by hand.
+    Foo &operator=(const Foo &rhs) {
+      a = rhs.a;
+      return *this;
     }
 
     char baz() override;
     int a;
 };
 
+extern Foo foo1;
+extern Foo foo2;

diff  --git a/lldb/test/API/lang/cpp/limit-debug-info/main.cpp b/lldb/test/API/lang/cpp/limit-debug-info/main.cpp
index 64e0349b5826..35cb0373ae39 100644
--- a/lldb/test/API/lang/cpp/limit-debug-info/main.cpp
+++ b/lldb/test/API/lang/cpp/limit-debug-info/main.cpp
@@ -1,7 +1,8 @@
 #include "derived.h"
 
 int main() {
-    Foo f; // break here
-    f.bar();
-    return f.baz();
+    foo1 = foo2; // break here
+
+    foo1.bar();
+    return foo1.baz();
 }


        


More information about the lldb-commits mailing list