Skip to content

Commit 089a1d9

Browse files
committed
[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.
1 parent f513b5f commit 089a1d9

File tree

7 files changed

+33
-9
lines changed

7 files changed

+33
-9
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CXX_SOURCES = main.cpp derived.cpp base.cpp
22

3-
CFLAGS_EXTRAS := $(LIMIT_DEBUG_INFO_FLAGS)
3+
CFLAGS_EXTRAS = $(LIMIT_DEBUG_INFO_FLAGS)
44

55
include Makefile.rules

lldb/test/API/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ class TestWithLimitDebugInfo(TestBase):
88

99
mydir = TestBase.compute_mydir(__file__)
1010

11-
@skipIf(debug_info=no_match(["dwarf"]))
11+
@add_test_categories(["dwarf", "dwo"])
1212
def test_limit_debug_info(self):
1313
self.build()
1414

15+
self._check_info_is_limited()
16+
1517
src_file = os.path.join(self.getSourceDir(), "main.cpp")
1618
src_file_spec = lldb.SBFileSpec(src_file)
1719
self.assertTrue(src_file_spec.IsValid(), "breakpoint file")
@@ -52,6 +54,12 @@ def test_limit_debug_info(self):
5254
self.assertTrue(
5355
v2.IsValid(),
5456
"'expr this' results in a valid SBValue object")
55-
self.assertTrue(
56-
v2.GetError().Success(),
57+
self.assertSuccess(
58+
v2.GetError(),
5759
"'expr this' succeeds without an error.")
60+
61+
def _check_info_is_limited(self):
62+
target = self.dbg.CreateTarget(self.getBuildArtifact("main.o"))
63+
self.assertTrue(target.IsValid())
64+
Foo = target.FindFirstType("Foo")
65+
self.assertFalse(Foo.IsValid())

lldb/test/API/lang/cpp/limit-debug-info/base.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "base.h"
22

3+
FooNS::FooNS() : x(12345) {}
4+
35
void FooNS::bar() {
46
x = 54321;
57
}

lldb/test/API/lang/cpp/limit-debug-info/base.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ class FooNS
55
virtual char baz() = 0;
66

77
protected:
8+
FooNS();
9+
810
int x;
911
};
1012

lldb/test/API/lang/cpp/limit-debug-info/derived.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#include "derived.h"
22

3+
Foo foo1;
4+
Foo foo2;
5+
6+
Foo::Foo() { a = 12345; }
7+
38
char Foo::baz() {
49
return (char)(x&0xff);
510
}

lldb/test/API/lang/cpp/limit-debug-info/derived.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@
33
class Foo : public FooNS
44
{
55
public:
6-
Foo() {
7-
a = 12345;
6+
Foo();
7+
8+
// Deliberately defined by hand.
9+
Foo &operator=(const Foo &rhs) {
10+
a = rhs.a;
11+
return *this;
812
}
913

1014
char baz() override;
1115
int a;
1216
};
1317

18+
extern Foo foo1;
19+
extern Foo foo2;
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#include "derived.h"
22

33
int main() {
4-
Foo f; // break here
5-
f.bar();
6-
return f.baz();
4+
foo1 = foo2; // break here
5+
6+
foo1.bar();
7+
return foo1.baz();
78
}

0 commit comments

Comments
 (0)