Skip to content

Commit 7d518af

Browse files
Merge pull request #8517 from Michael137/bugfix/lldb-type-lookup-fix
[cherry-pick][swift/release/6.0] [lldb] Fix type lookup in DWARF .o files via debug map (llvm#87177)
2 parents fce7267 + c02cfa3 commit 7d518af

File tree

5 files changed

+32
-23
lines changed

5 files changed

+32
-23
lines changed

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ void SymbolFileDWARFDebugMap::FindTypes(const TypeQuery &query,
12441244
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
12451245
ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
12461246
oso_dwarf->FindTypes(query, results);
1247-
return !results.Done(query); // Keep iterating if we aren't done.
1247+
return results.Done(query); // Keep iterating if we aren't done.
12481248
});
12491249
}
12501250

@@ -1376,7 +1376,7 @@ void SymbolFileDWARFDebugMap::ParseDeclsForContext(
13761376
lldb_private::CompilerDeclContext decl_ctx) {
13771377
ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
13781378
oso_dwarf->ParseDeclsForContext(decl_ctx);
1379-
return true; // Keep iterating
1379+
return false; // Keep iterating
13801380
});
13811381
}
13821382

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
CXX_SOURCES := main.cpp
1+
CXX_SOURCES := main.cpp other.cpp
22
include Makefile.rules

lldb/test/API/functionalities/type_find_first/TestFindFirstType.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,31 @@
88

99

1010
class TypeFindFirstTestCase(TestBase):
11-
12-
NO_DEBUG_INFO_TESTCASE = True
13-
1411
def test_find_first_type(self):
1512
"""
16-
Test SBTarget::FindFirstType() and SBModule::FindFirstType() APIs.
13+
Test SBTarget::FindFirstType() and SBModule::FindFirstType() APIs.
1714
18-
This function had regressed after some past modification of the type
19-
lookup internal code where if we had multiple types with the same
20-
basename, FindFirstType() could end up failing depending on which
21-
type was found first in the debug info indexes. This test will
22-
ensure this doesn't regress in the future.
15+
This function had regressed after some past modification of the type
16+
lookup internal code where if we had multiple types with the same
17+
basename, FindFirstType() could end up failing depending on which
18+
type was found first in the debug info indexes. This test will
19+
ensure this doesn't regress in the future.
20+
21+
The test also looks for a type defined in a different compilation unit
22+
to verify that SymbolFileDWARFDebugMap searches each symbol file in a
23+
module.
2324
"""
2425
self.build()
2526
target = self.createTestTarget()
26-
# Test the SBTarget APIs for FindFirstType
27-
integer_type = target.FindFirstType("Integer::Point")
28-
self.assertTrue(integer_type.IsValid())
29-
float_type = target.FindFirstType("Float::Point")
30-
self.assertTrue(float_type.IsValid())
31-
32-
# Test the SBModule APIs for FindFirstType
3327
exe_module = target.GetModuleAtIndex(0)
3428
self.assertTrue(exe_module.IsValid())
35-
integer_type = exe_module.FindFirstType("Integer::Point")
36-
self.assertTrue(integer_type.IsValid())
37-
float_type = exe_module.FindFirstType("Float::Point")
38-
self.assertTrue(float_type.IsValid())
29+
# Test the SBTarget and SBModule APIs for FindFirstType
30+
for api in [target, exe_module]:
31+
integer_type = api.FindFirstType("Integer::Point")
32+
self.assertTrue(integer_type.IsValid())
33+
float_type = api.FindFirstType("Float::Point")
34+
self.assertTrue(float_type.IsValid())
35+
external_type = api.FindFirstType("OtherCompilationUnit::Type")
36+
self.assertTrue(external_type.IsValid())
37+
nonexistent_type = api.FindFirstType("NonexistentType")
38+
self.assertFalse(nonexistent_type.IsValid())

lldb/test/API/functionalities/type_find_first/main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ struct Point {
1010
};
1111
} // namespace Float
1212

13+
namespace OtherCompilationUnit {
14+
void Function();
15+
} // namespace OtherCompilationUnit
16+
1317
int main(int argc, char const *argv[]) {
1418
Integer::Point ip = {2, 3};
1519
Float::Point fp = {2.0, 3.0};
20+
OtherCompilationUnit::Function();
1621
return 0;
1722
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace OtherCompilationUnit {
2+
struct Type {};
3+
void Function() { Type typeIsActuallyUsed; }
4+
} // namespace OtherCompilationUnit

0 commit comments

Comments
 (0)