[Lldb-commits] [lldb] Fix DWARF locations when we have large .dwp files. (PR #87164)

2024-03-30 Thread Greg Clayton via lldb-commits

https://github.com/clayborg created 
https://github.com/llvm/llvm-project/pull/87164

We have the ability to load .dwp files with a .debug_info.dwo section that 
exceeds 4GB. There were 4 locations that were using 32 bit offsets and lengths 
to extract variable locations, and if a DIE was over the 4GB barrier, we would 
truncate the block offset for the variable locations and the variable 
expression would be garbage. This fixes the issues. It isn't possible to add a 
test for this as we don't want to create a 4GB .dwp file on test machines.

>From 91b6bea2668426393f9d1ae7564c869b3438f603 Mon Sep 17 00:00:00 2001
From: Greg Clayton 
Date: Sat, 30 Mar 2024 10:56:39 -0700
Subject: [PATCH] Fix DWARF locations when we have large .dwp files.

We have the ability to load .dwp files with a .debug_info.dwo section that 
exceeds 4GB. There were 4 locations that were using 32 bit offsets and lengths 
to extract variable locations, and if a DIE was over the 4GB barrier, we would 
truncate the block offset for the variable locations and the variable 
expression would be garbage. This fixes the issues. It isn't possible to add a 
test for this as we don't want to create a 4GB .dwp file on test machines.
---
 .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 1164bc62682a9a..49f13d2c89e380 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3420,8 +3420,8 @@ static DWARFExpressionList 
GetExprListFromAtLocation(DWARFFormValue form_value,
   if (DWARFFormValue::IsBlockForm(form_value.Form())) {
 const DWARFDataExtractor &data = die.GetData();
 
-uint32_t block_offset = form_value.BlockData() - data.GetDataStart();
-uint32_t block_length = form_value.Unsigned();
+uint64_t block_offset = form_value.BlockData() - data.GetDataStart();
+uint64_t block_length = form_value.Unsigned();
 return DWARFExpressionList(
 module, DataExtractor(data, block_offset, block_length), die.GetCU());
   }
@@ -3450,9 +3450,9 @@ GetExprListFromAtConstValue(DWARFFormValue form_value, 
ModuleSP module,
   const DWARFDataExtractor &debug_info_data = die.GetData();
   if (DWARFFormValue::IsBlockForm(form_value.Form())) {
 // Retrieve the value as a block expression.
-uint32_t block_offset =
+uint64_t block_offset =
 form_value.BlockData() - debug_info_data.GetDataStart();
-uint32_t block_length = form_value.Unsigned();
+uint64_t block_length = form_value.Unsigned();
 return DWARFExpressionList(
 module, DataExtractor(debug_info_data, block_offset, block_length),
 die.GetCU());
@@ -4061,8 +4061,8 @@ CollectCallSiteParameters(ModuleSP module, DWARFDIE 
call_site_die) {
   if (!DWARFFormValue::IsBlockForm(form_value.Form()))
 return {};
   auto data = child.GetData();
-  uint32_t block_offset = form_value.BlockData() - data.GetDataStart();
-  uint32_t block_length = form_value.Unsigned();
+  uint64_t block_offset = form_value.BlockData() - data.GetDataStart();
+  uint64_t block_length = form_value.Unsigned();
   return DWARFExpressionList(
   module, DataExtractor(data, block_offset, block_length),
   child.GetCU());
@@ -4167,8 +4167,8 @@ SymbolFileDWARF::CollectCallEdges(ModuleSP module, 
DWARFDIE function_die) {
 }
 
 auto data = child.GetData();
-uint32_t block_offset = form_value.BlockData() - data.GetDataStart();
-uint32_t block_length = form_value.Unsigned();
+uint64_t block_offset = form_value.BlockData() - data.GetDataStart();
+uint64_t block_length = form_value.Unsigned();
 call_target = DWARFExpressionList(
 module, DataExtractor(data, block_offset, block_length),
 child.GetCU());

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Fix DWARF locations when we have large .dwp files. (PR #87164)

2024-03-30 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Greg Clayton (clayborg)


Changes

We have the ability to load .dwp files with a .debug_info.dwo section that 
exceeds 4GB. There were 4 locations that were using 32 bit offsets and lengths 
to extract variable locations, and if a DIE was over the 4GB barrier, we would 
truncate the block offset for the variable locations and the variable 
expression would be garbage. This fixes the issues. It isn't possible to add a 
test for this as we don't want to create a 4GB .dwp file on test machines.

---
Full diff: https://github.com/llvm/llvm-project/pull/87164.diff


1 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+8-8) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 1164bc62682a9a..49f13d2c89e380 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3420,8 +3420,8 @@ static DWARFExpressionList 
GetExprListFromAtLocation(DWARFFormValue form_value,
   if (DWARFFormValue::IsBlockForm(form_value.Form())) {
 const DWARFDataExtractor &data = die.GetData();
 
-uint32_t block_offset = form_value.BlockData() - data.GetDataStart();
-uint32_t block_length = form_value.Unsigned();
+uint64_t block_offset = form_value.BlockData() - data.GetDataStart();
+uint64_t block_length = form_value.Unsigned();
 return DWARFExpressionList(
 module, DataExtractor(data, block_offset, block_length), die.GetCU());
   }
@@ -3450,9 +3450,9 @@ GetExprListFromAtConstValue(DWARFFormValue form_value, 
ModuleSP module,
   const DWARFDataExtractor &debug_info_data = die.GetData();
   if (DWARFFormValue::IsBlockForm(form_value.Form())) {
 // Retrieve the value as a block expression.
-uint32_t block_offset =
+uint64_t block_offset =
 form_value.BlockData() - debug_info_data.GetDataStart();
-uint32_t block_length = form_value.Unsigned();
+uint64_t block_length = form_value.Unsigned();
 return DWARFExpressionList(
 module, DataExtractor(debug_info_data, block_offset, block_length),
 die.GetCU());
@@ -4061,8 +4061,8 @@ CollectCallSiteParameters(ModuleSP module, DWARFDIE 
call_site_die) {
   if (!DWARFFormValue::IsBlockForm(form_value.Form()))
 return {};
   auto data = child.GetData();
-  uint32_t block_offset = form_value.BlockData() - data.GetDataStart();
-  uint32_t block_length = form_value.Unsigned();
+  uint64_t block_offset = form_value.BlockData() - data.GetDataStart();
+  uint64_t block_length = form_value.Unsigned();
   return DWARFExpressionList(
   module, DataExtractor(data, block_offset, block_length),
   child.GetCU());
@@ -4167,8 +4167,8 @@ SymbolFileDWARF::CollectCallEdges(ModuleSP module, 
DWARFDIE function_die) {
 }
 
 auto data = child.GetData();
-uint32_t block_offset = form_value.BlockData() - data.GetDataStart();
-uint32_t block_length = form_value.Unsigned();
+uint64_t block_offset = form_value.BlockData() - data.GetDataStart();
+uint64_t block_length = form_value.Unsigned();
 call_target = DWARFExpressionList(
 module, DataExtractor(data, block_offset, block_length),
 child.GetCU());

``




https://github.com/llvm/llvm-project/pull/87164
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Fix DWARF locations when we have large .dwp files. (PR #87164)

2024-03-30 Thread via lldb-commits

https://github.com/kusmour approved this pull request.

Looks straight forward. Tried the patch locally and it worked!

https://github.com/llvm/llvm-project/pull/87164
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix type lookup in DWARF .o files via debug map (PR #87177)

2024-03-30 Thread Pablo Busse via lldb-commits

https://github.com/pabusse created 
https://github.com/llvm/llvm-project/pull/87177

An inverted condition causes `SymbolFileDWARFDebugMap::FindTypes` to bail out 
after inspecting the first .o file in each module.

The same kind of bug is found in 
`SymbolFileDWARFDebugMap::ParseDeclsForContext`.

Correct both early exit conditions and add a regression test for lookup of up a 
type defined in a secondary compilation unit.

Fixes #87176

>From 70938a5d70d3d1e861fd8439bd01ebf737252329 Mon Sep 17 00:00:00 2001
From: Pablo Busse 
Date: Sat, 30 Mar 2024 19:09:40 -0700
Subject: [PATCH] [lldb] Fix type lookup in DWARF .o files via debug map

An inverted condition causes SymbolFileDWARFDebugMap::FindTypes to bail out
after inspecting the first .o file in each module.

The same kind of bug is found in SymbolFileDWARFDebugMap::ParseDeclsForContext.

This change fixes the early-exit conditions and adds a regression test for
lookup of up a type defined in a secondary compilation unit.
---
 .../DWARF/SymbolFileDWARFDebugMap.cpp |  4 +--
 .../functionalities/type_find_first/Makefile  |  2 +-
 .../type_find_first/TestFindFirstType.py  | 27 ++-
 .../functionalities/type_find_first/main.cpp  |  5 
 .../functionalities/type_find_first/other.cpp |  4 +++
 5 files changed, 26 insertions(+), 16 deletions(-)
 create mode 100644 lldb/test/API/functionalities/type_find_first/other.cpp

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index 6dd3eb3677b7af..4bc2cfd60688a8 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -1233,7 +1233,7 @@ void SymbolFileDWARFDebugMap::FindTypes(const TypeQuery 
&query,
   std::lock_guard guard(GetModuleMutex());
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
 oso_dwarf->FindTypes(query, results);
-return !results.Done(query); // Keep iterating if we aren't done.
+return results.Done(query); // Keep iterating if we aren't done.
   });
 }
 
@@ -1391,7 +1391,7 @@ void SymbolFileDWARFDebugMap::ParseDeclsForContext(
 lldb_private::CompilerDeclContext decl_ctx) {
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
 oso_dwarf->ParseDeclsForContext(decl_ctx);
-return true; // Keep iterating
+return false; // Keep iterating
   });
 }
 
diff --git a/lldb/test/API/functionalities/type_find_first/Makefile 
b/lldb/test/API/functionalities/type_find_first/Makefile
index 3d0b98f13f3d7b..e027553c7a6b09 100644
--- a/lldb/test/API/functionalities/type_find_first/Makefile
+++ b/lldb/test/API/functionalities/type_find_first/Makefile
@@ -1,2 +1,2 @@
-CXX_SOURCES := main.cpp
+CXX_SOURCES := main.cpp other.cpp
 include Makefile.rules
diff --git a/lldb/test/API/functionalities/type_find_first/TestFindFirstType.py 
b/lldb/test/API/functionalities/type_find_first/TestFindFirstType.py
index 6347a35e72ea3f..4e0ee2ca685e73 100644
--- a/lldb/test/API/functionalities/type_find_first/TestFindFirstType.py
+++ b/lldb/test/API/functionalities/type_find_first/TestFindFirstType.py
@@ -8,8 +8,6 @@
 
 
 class TypeFindFirstTestCase(TestBase):
-NO_DEBUG_INFO_TESTCASE = True
-
 def test_find_first_type(self):
 """
 Test SBTarget::FindFirstType() and SBModule::FindFirstType() APIs.
@@ -19,19 +17,22 @@ def test_find_first_type(self):
 basename, FindFirstType() could end up failing depending on which
 type was found first in the debug info indexes. This test will
 ensure this doesn't regress in the future.
+
+The test also looks for a type defined in a different compilation unit
+to verify that SymbolFileDWARFDebugMap searches each symbol file in a
+module.
 """
 self.build()
 target = self.createTestTarget()
-# Test the SBTarget APIs for FindFirstType
-integer_type = target.FindFirstType("Integer::Point")
-self.assertTrue(integer_type.IsValid())
-float_type = target.FindFirstType("Float::Point")
-self.assertTrue(float_type.IsValid())
-
-# Test the SBModule APIs for FindFirstType
 exe_module = target.GetModuleAtIndex(0)
 self.assertTrue(exe_module.IsValid())
-integer_type = exe_module.FindFirstType("Integer::Point")
-self.assertTrue(integer_type.IsValid())
-float_type = exe_module.FindFirstType("Float::Point")
-self.assertTrue(float_type.IsValid())
+# Test the SBTarget and SBModule APIs for FindFirstType
+for api in [target, exe_module]:
+integer_type = api.FindFirstType("Integer::Point")
+self.assertTrue(integer_type.IsValid())
+float_type = api.FindFirstType("Float::Point")
+self.assertTrue(float_type.IsValid())
+external_type = api.FindFirstType("OtherCompilationUnit::Type");
+self

[Lldb-commits] [lldb] [lldb] Fix type lookup in DWARF .o files via debug map (PR #87177)

2024-03-30 Thread via lldb-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

https://github.com/llvm/llvm-project/pull/87177
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix type lookup in DWARF .o files via debug map (PR #87177)

2024-03-30 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pablo Busse (pabusse)


Changes

An inverted condition causes `SymbolFileDWARFDebugMap::FindTypes` to bail out 
after inspecting the first .o file in each module.

The same kind of bug is found in 
`SymbolFileDWARFDebugMap::ParseDeclsForContext`.

Correct both early exit conditions and add a regression test for lookup of up a 
type defined in a secondary compilation unit.

Fixes #87176

---
Full diff: https://github.com/llvm/llvm-project/pull/87177.diff


5 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
(+2-2) 
- (modified) lldb/test/API/functionalities/type_find_first/Makefile (+1-1) 
- (modified) lldb/test/API/functionalities/type_find_first/TestFindFirstType.py 
(+14-13) 
- (modified) lldb/test/API/functionalities/type_find_first/main.cpp (+5) 
- (added) lldb/test/API/functionalities/type_find_first/other.cpp (+4) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index 6dd3eb3677b7af..4bc2cfd60688a8 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -1233,7 +1233,7 @@ void SymbolFileDWARFDebugMap::FindTypes(const TypeQuery 
&query,
   std::lock_guard guard(GetModuleMutex());
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
 oso_dwarf->FindTypes(query, results);
-return !results.Done(query); // Keep iterating if we aren't done.
+return results.Done(query); // Keep iterating if we aren't done.
   });
 }
 
@@ -1391,7 +1391,7 @@ void SymbolFileDWARFDebugMap::ParseDeclsForContext(
 lldb_private::CompilerDeclContext decl_ctx) {
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
 oso_dwarf->ParseDeclsForContext(decl_ctx);
-return true; // Keep iterating
+return false; // Keep iterating
   });
 }
 
diff --git a/lldb/test/API/functionalities/type_find_first/Makefile 
b/lldb/test/API/functionalities/type_find_first/Makefile
index 3d0b98f13f3d7b..e027553c7a6b09 100644
--- a/lldb/test/API/functionalities/type_find_first/Makefile
+++ b/lldb/test/API/functionalities/type_find_first/Makefile
@@ -1,2 +1,2 @@
-CXX_SOURCES := main.cpp
+CXX_SOURCES := main.cpp other.cpp
 include Makefile.rules
diff --git a/lldb/test/API/functionalities/type_find_first/TestFindFirstType.py 
b/lldb/test/API/functionalities/type_find_first/TestFindFirstType.py
index 6347a35e72ea3f..4e0ee2ca685e73 100644
--- a/lldb/test/API/functionalities/type_find_first/TestFindFirstType.py
+++ b/lldb/test/API/functionalities/type_find_first/TestFindFirstType.py
@@ -8,8 +8,6 @@
 
 
 class TypeFindFirstTestCase(TestBase):
-NO_DEBUG_INFO_TESTCASE = True
-
 def test_find_first_type(self):
 """
 Test SBTarget::FindFirstType() and SBModule::FindFirstType() APIs.
@@ -19,19 +17,22 @@ def test_find_first_type(self):
 basename, FindFirstType() could end up failing depending on which
 type was found first in the debug info indexes. This test will
 ensure this doesn't regress in the future.
+
+The test also looks for a type defined in a different compilation unit
+to verify that SymbolFileDWARFDebugMap searches each symbol file in a
+module.
 """
 self.build()
 target = self.createTestTarget()
-# Test the SBTarget APIs for FindFirstType
-integer_type = target.FindFirstType("Integer::Point")
-self.assertTrue(integer_type.IsValid())
-float_type = target.FindFirstType("Float::Point")
-self.assertTrue(float_type.IsValid())
-
-# Test the SBModule APIs for FindFirstType
 exe_module = target.GetModuleAtIndex(0)
 self.assertTrue(exe_module.IsValid())
-integer_type = exe_module.FindFirstType("Integer::Point")
-self.assertTrue(integer_type.IsValid())
-float_type = exe_module.FindFirstType("Float::Point")
-self.assertTrue(float_type.IsValid())
+# Test the SBTarget and SBModule APIs for FindFirstType
+for api in [target, exe_module]:
+integer_type = api.FindFirstType("Integer::Point")
+self.assertTrue(integer_type.IsValid())
+float_type = api.FindFirstType("Float::Point")
+self.assertTrue(float_type.IsValid())
+external_type = api.FindFirstType("OtherCompilationUnit::Type");
+self.assertTrue(external_type.IsValid())
+nonexistent_type = api.FindFirstType("NonexistentType");
+self.assertFalse(nonexistent_type.IsValid())
diff --git a/lldb/test/API/functionalities/type_find_first/main.cpp 
b/lldb/test/API/functionalities/type_find_first/main.cpp
index f4e467286004d6..bbb060872a1e9a 100644
--- a/lldb/test/API/functionalities/type_find_first/main.cpp
+++ b/lldb/test/API/functionalities/type_find_first/main.cpp
@@ -10,8 +1

[Lldb-commits] [lldb] [lldb] Fix type lookup in DWARF .o files via debug map (PR #87177)

2024-03-30 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
a67b9326cd0448072a1192951f12f3927f31af8c...70938a5d70d3d1e861fd8439bd01ebf737252329
 lldb/test/API/functionalities/type_find_first/TestFindFirstType.py
``





View the diff from darker here.


``diff
--- TestFindFirstType.py2024-03-31 02:26:14.00 +
+++ TestFindFirstType.py2024-03-31 04:00:07.626963 +
@@ -30,9 +30,9 @@
 for api in [target, exe_module]:
 integer_type = api.FindFirstType("Integer::Point")
 self.assertTrue(integer_type.IsValid())
 float_type = api.FindFirstType("Float::Point")
 self.assertTrue(float_type.IsValid())
-external_type = api.FindFirstType("OtherCompilationUnit::Type");
+external_type = api.FindFirstType("OtherCompilationUnit::Type")
 self.assertTrue(external_type.IsValid())
-nonexistent_type = api.FindFirstType("NonexistentType");
+nonexistent_type = api.FindFirstType("NonexistentType")
 self.assertFalse(nonexistent_type.IsValid())

``




https://github.com/llvm/llvm-project/pull/87177
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix type lookup in DWARF .o files via debug map (PR #87177)

2024-03-30 Thread Marc Auberer via lldb-commits

marcauberer wrote:

@pabusse Hi, thanks for the patch!
Please remove the semicolons from the python code to make the formatting check 
pass.

https://github.com/llvm/llvm-project/pull/87177
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix type lookup in DWARF .o files via debug map (PR #87177)

2024-03-30 Thread Michael Buch via lldb-commits

Michael137 wrote:

Thanks for the patch, sounds like it should fix 
https://github.com/llvm/llvm-project/issues/86184

https://github.com/llvm/llvm-project/pull/87177
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix type lookup in DWARF .o files via debug map (PR #87177)

2024-03-30 Thread Michael Buch via lldb-commits

https://github.com/Michael137 approved this pull request.


https://github.com/llvm/llvm-project/pull/87177
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix type lookup in DWARF .o files via debug map (PR #87177)

2024-03-30 Thread Pablo Busse via lldb-commits

https://github.com/pabusse updated 
https://github.com/llvm/llvm-project/pull/87177

>From 70938a5d70d3d1e861fd8439bd01ebf737252329 Mon Sep 17 00:00:00 2001
From: Pablo Busse 
Date: Sat, 30 Mar 2024 19:09:40 -0700
Subject: [PATCH 1/2] [lldb] Fix type lookup in DWARF .o files via debug map

An inverted condition causes SymbolFileDWARFDebugMap::FindTypes to bail out
after inspecting the first .o file in each module.

The same kind of bug is found in SymbolFileDWARFDebugMap::ParseDeclsForContext.

This change fixes the early-exit conditions and adds a regression test for
lookup of up a type defined in a secondary compilation unit.
---
 .../DWARF/SymbolFileDWARFDebugMap.cpp |  4 +--
 .../functionalities/type_find_first/Makefile  |  2 +-
 .../type_find_first/TestFindFirstType.py  | 27 ++-
 .../functionalities/type_find_first/main.cpp  |  5 
 .../functionalities/type_find_first/other.cpp |  4 +++
 5 files changed, 26 insertions(+), 16 deletions(-)
 create mode 100644 lldb/test/API/functionalities/type_find_first/other.cpp

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index 6dd3eb3677b7af..4bc2cfd60688a8 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -1233,7 +1233,7 @@ void SymbolFileDWARFDebugMap::FindTypes(const TypeQuery 
&query,
   std::lock_guard guard(GetModuleMutex());
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
 oso_dwarf->FindTypes(query, results);
-return !results.Done(query); // Keep iterating if we aren't done.
+return results.Done(query); // Keep iterating if we aren't done.
   });
 }
 
@@ -1391,7 +1391,7 @@ void SymbolFileDWARFDebugMap::ParseDeclsForContext(
 lldb_private::CompilerDeclContext decl_ctx) {
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
 oso_dwarf->ParseDeclsForContext(decl_ctx);
-return true; // Keep iterating
+return false; // Keep iterating
   });
 }
 
diff --git a/lldb/test/API/functionalities/type_find_first/Makefile 
b/lldb/test/API/functionalities/type_find_first/Makefile
index 3d0b98f13f3d7b..e027553c7a6b09 100644
--- a/lldb/test/API/functionalities/type_find_first/Makefile
+++ b/lldb/test/API/functionalities/type_find_first/Makefile
@@ -1,2 +1,2 @@
-CXX_SOURCES := main.cpp
+CXX_SOURCES := main.cpp other.cpp
 include Makefile.rules
diff --git a/lldb/test/API/functionalities/type_find_first/TestFindFirstType.py 
b/lldb/test/API/functionalities/type_find_first/TestFindFirstType.py
index 6347a35e72ea3f..4e0ee2ca685e73 100644
--- a/lldb/test/API/functionalities/type_find_first/TestFindFirstType.py
+++ b/lldb/test/API/functionalities/type_find_first/TestFindFirstType.py
@@ -8,8 +8,6 @@
 
 
 class TypeFindFirstTestCase(TestBase):
-NO_DEBUG_INFO_TESTCASE = True
-
 def test_find_first_type(self):
 """
 Test SBTarget::FindFirstType() and SBModule::FindFirstType() APIs.
@@ -19,19 +17,22 @@ def test_find_first_type(self):
 basename, FindFirstType() could end up failing depending on which
 type was found first in the debug info indexes. This test will
 ensure this doesn't regress in the future.
+
+The test also looks for a type defined in a different compilation unit
+to verify that SymbolFileDWARFDebugMap searches each symbol file in a
+module.
 """
 self.build()
 target = self.createTestTarget()
-# Test the SBTarget APIs for FindFirstType
-integer_type = target.FindFirstType("Integer::Point")
-self.assertTrue(integer_type.IsValid())
-float_type = target.FindFirstType("Float::Point")
-self.assertTrue(float_type.IsValid())
-
-# Test the SBModule APIs for FindFirstType
 exe_module = target.GetModuleAtIndex(0)
 self.assertTrue(exe_module.IsValid())
-integer_type = exe_module.FindFirstType("Integer::Point")
-self.assertTrue(integer_type.IsValid())
-float_type = exe_module.FindFirstType("Float::Point")
-self.assertTrue(float_type.IsValid())
+# Test the SBTarget and SBModule APIs for FindFirstType
+for api in [target, exe_module]:
+integer_type = api.FindFirstType("Integer::Point")
+self.assertTrue(integer_type.IsValid())
+float_type = api.FindFirstType("Float::Point")
+self.assertTrue(float_type.IsValid())
+external_type = api.FindFirstType("OtherCompilationUnit::Type");
+self.assertTrue(external_type.IsValid())
+nonexistent_type = api.FindFirstType("NonexistentType");
+self.assertFalse(nonexistent_type.IsValid())
diff --git a/lldb/test/API/functionalities/type_find_first/main.cpp 
b/lldb/test/API/functionalities/type_find_first/main.cpp
index f4e467286004d6..bbb060872a1e9a 100644
--- a/lldb/test/AP