summaryrefslogtreecommitdiff
path: root/lldb/test/API/functionalities/limit-debug-info
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2020-07-07 15:28:24 +0200
committerPavel Labath <pavel@labath.sk>2020-07-27 12:58:22 +0200
commit1956cf1042d3c406d9e9cefe47d3b43adf2bdbe1 (patch)
tree1548e47874f4769256e31223342337609e595cc0 /lldb/test/API/functionalities/limit-debug-info
parent6701c0bf730157775736c1314758e89bfdccb14a (diff)
[lldb/DWARF] Don't treat class declarations with children as definitions
Summary: This effectively reverts r188124, which added code to handle (DW_AT_)declarations of structures with some kinds of children as definitions. The commit message claims this is a workaround for some kind of debug info produced by gcc. However, it does not go into specifics, so it's hard to reproduce or verify that this is indeed still a problem. Having this code is definitely a problem though, because it mistakenly declares incomplete dwarf declarations to be complete. Both clang (with -flimit-debug-info) and gcc (by default) generate DW_AT_declarations of structs with children. This happens when full debug info for a class is not emitted in a given compile unit (e.g. because of vtable homing), but the class has inline methods which are used in the given compile unit. In that case, the compilers emit a DW_AT_declaration of a class, but add a DW_TAG_subprogram child to it to describe the inlined instance of the method. Even though the class tag has some children, it definitely does not contain enough information to construct a full class definition (most notably, it lacks any members). Keeping the class as incomplete allows us to search for a real definition in other modules, helping the -flimit-debug-info flow. And in case the definition is not found we can display a error message saying that, instead of just showing an empty struct. Reviewers: clayborg, aprantl, JDevlieghere, shafik Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D83302
Diffstat (limited to 'lldb/test/API/functionalities/limit-debug-info')
-rw-r--r--lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py25
-rw-r--r--lldb/test/API/functionalities/limit-debug-info/main.cpp5
-rw-r--r--lldb/test/API/functionalities/limit-debug-info/one.cpp3
-rw-r--r--lldb/test/API/functionalities/limit-debug-info/onetwo.h15
-rw-r--r--lldb/test/API/functionalities/limit-debug-info/two.cpp4
5 files changed, 48 insertions, 4 deletions
diff --git a/lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py b/lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
index 9408ad6eee1d..aa383d0005e4 100644
--- a/lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
+++ b/lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
@@ -38,7 +38,8 @@ class LimitDebugInfoTestCase(TestBase):
self._check_debug_info_is_limited(target)
- self.registerSharedLibrariesWithTarget(target, ["one", "two"])
+ lldbutil.run_to_name_breakpoint(self, "main",
+ extra_images=["one", "two"])
# But when other shared libraries are loaded, we should be able to see
# all members.
@@ -58,6 +59,10 @@ class LimitDebugInfoTestCase(TestBase):
self.expect_expr("array_of_two[2].one[2].member", result_value="174")
self.expect_expr("array_of_two[2].member", result_value="274")
+ self.expect_expr("get_one().member", result_value="124")
+ self.expect_expr("get_two().one().member", result_value="124")
+ self.expect_expr("get_two().member", result_value="224")
+
@skipIf(bugnumber="pr46284", debug_info="gmodules")
@skipIfWindows # Clang emits type info even with -flimit-debug-info
def test_two_debug(self):
@@ -66,7 +71,8 @@ class LimitDebugInfoTestCase(TestBase):
self._check_debug_info_is_limited(target)
- self.registerSharedLibrariesWithTarget(target, ["one", "two"])
+ lldbutil.run_to_name_breakpoint(self, "main",
+ extra_images=["one", "two"])
# This time, we should only see the members from the second library.
self.expect_expr("inherits_from_one.member", result_value="47")
@@ -91,6 +97,12 @@ class LimitDebugInfoTestCase(TestBase):
substrs=["no member named 'member' in 'array::One'"])
self.expect_expr("array_of_two[2].member", result_value="274")
+ self.expect("expr get_one().member", error=True,
+ substrs=["calling 'get_one' with incomplete return type 'result::One'"])
+ self.expect("expr get_two().one().member", error=True,
+ substrs=["calling 'one' with incomplete return type 'result::One'"])
+ self.expect_expr("get_two().member", result_value="224")
+
@skipIf(bugnumber="pr46284", debug_info="gmodules")
@skipIfWindows # Clang emits type info even with -flimit-debug-info
def test_one_debug(self):
@@ -99,7 +111,8 @@ class LimitDebugInfoTestCase(TestBase):
self._check_debug_info_is_limited(target)
- self.registerSharedLibrariesWithTarget(target, ["one", "two"])
+ lldbutil.run_to_name_breakpoint(self, "main",
+ extra_images=["one", "two"])
# In this case we should only see the members from the second library.
# Note that we cannot see inherits_from_two.one because without debug
@@ -126,3 +139,9 @@ class LimitDebugInfoTestCase(TestBase):
substrs=["no member named 'one' in 'array::Two'"])
self.expect("expr array_of_two[2].member", error=True,
substrs=["no member named 'member' in 'array::Two'"])
+
+ self.expect_expr("get_one().member", result_value="124")
+ self.expect("expr get_two().one().member", error=True,
+ substrs=["calling 'get_two' with incomplete return type 'result::Two'"])
+ self.expect("expr get_two().member", error=True,
+ substrs=["calling 'get_two' with incomplete return type 'result::Two'"])
diff --git a/lldb/test/API/functionalities/limit-debug-info/main.cpp b/lldb/test/API/functionalities/limit-debug-info/main.cpp
index 0a25de13d9fb..1aad7e6f1e61 100644
--- a/lldb/test/API/functionalities/limit-debug-info/main.cpp
+++ b/lldb/test/API/functionalities/limit-debug-info/main.cpp
@@ -25,4 +25,7 @@ struct TwoAsMember {
array::One array_of_one[3];
array::Two array_of_two[3];
-int main() { return 0; }
+result::One get_one() { return result::One(124); }
+result::Two get_two() { return result::Two(224); }
+
+int main() { return get_one().member; }
diff --git a/lldb/test/API/functionalities/limit-debug-info/one.cpp b/lldb/test/API/functionalities/limit-debug-info/one.cpp
index c1eb6310dd67..70353a084edc 100644
--- a/lldb/test/API/functionalities/limit-debug-info/one.cpp
+++ b/lldb/test/API/functionalities/limit-debug-info/one.cpp
@@ -3,3 +3,6 @@
One::~One() = default;
member::One::~One() = default;
array::One::~One() = default;
+
+result::One::One(int member) : member(member) {}
+result::One::~One() = default;
diff --git a/lldb/test/API/functionalities/limit-debug-info/onetwo.h b/lldb/test/API/functionalities/limit-debug-info/onetwo.h
index 67609dd7ff61..24a18f6a5dcc 100644
--- a/lldb/test/API/functionalities/limit-debug-info/onetwo.h
+++ b/lldb/test/API/functionalities/limit-debug-info/onetwo.h
@@ -39,3 +39,18 @@ struct Two {
virtual ~Two();
};
} // namespace array
+
+namespace result {
+struct One {
+ int member;
+ One(int member);
+ virtual ~One();
+};
+
+struct Two {
+ int member;
+ Two(int member);
+ One one() const;
+ virtual ~Two();
+};
+} // namespace result
diff --git a/lldb/test/API/functionalities/limit-debug-info/two.cpp b/lldb/test/API/functionalities/limit-debug-info/two.cpp
index 04683da6e9cc..468cb91f6a5c 100644
--- a/lldb/test/API/functionalities/limit-debug-info/two.cpp
+++ b/lldb/test/API/functionalities/limit-debug-info/two.cpp
@@ -3,3 +3,7 @@
Two::~Two() = default;
member::Two::~Two() = default;
array::Two::~Two() = default;
+
+result::Two::Two(int member) : member(member) {}
+result::Two::~Two() = default;
+result::One result::Two::one() const { return One(member - 100); }