[Lldb-commits] [lldb] [lldb][TypeSystemClang] Add warning and defensive checks when ASTContext is not fully initialized (PR #110481)

2024-09-30 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

As this comment around target initialization implies:
```
  // This can be NULL if we don't know anything about the architecture or if
  // the target for an architecture isn't enabled in the llvm/clang that we
  // built
```

There are cases where we might fail to call `InitBuiltinTypes` when creating 
the backing `ASTContext` for a `TypeSystemClang`. If that happens, the builtins 
`QualType`s, e.g., `VoidPtrTy`/`IntTy`/etc., are not initialized and 
dereferencing them as we do in `GetBuiltinTypeForEncodingAndBitSize` (and other 
places) will lead to nullptr-dereferences. Example backtrace:
```
(lldb) run
Assertion failed: (!isNull() && "Cannot retrieve a NULL type pointer"), 
function getCommonPtr, file Type.h, line 958.
Process 2680 stopped
* thread #15, name = '', 
stop reason = hit program assert
frame #4: 0x00010cdf3cdc 
liblldb.20.0.0git.dylib`DWARFASTParserClang::ExtractIntFromFormValue(lldb_private::CompilerType
 const&, lldb_private::plugin::dwarf::DWARFFormValue const&) const 
(.cold.1) + 
liblldb.20.0.0git.dylib`DWARFASTParserClang::ParseObjCMethod(lldb_private::ObjCLanguage::MethodName
 const&, lldb_private::plugin::dwarf::DWARFDIE const&, 
lldb_private::CompilerType, ParsedDWARFTypeAttributes
, bool) (.cold.1):
->  0x10cdf3cdc <+0>:  stpx29, x30, [sp, #-0x10]!
0x10cdf3ce0 <+4>:  movx29, sp
0x10cdf3ce4 <+8>:  adrp   x0, 545
0x10cdf3ce8 <+12>: addx0, x0, #0xa25 ; "ParseObjCMethod"
Target 0: (lldb) stopped.
(lldb) bt
* thread #15, name = '', 
stop reason = hit program assert
frame #0: 0x000180d08600 libsystem_kernel.dylib`__pthread_kill 
+ 8
frame #1: 0x000180d40f50 libsystem_pthread.dylib`pthread_kill + 
288
frame #2: 0x000180c4d908 libsystem_c.dylib`abort + 128
frame #3: 0x000180c4cc1c libsystem_c.dylib`__assert_rtn + 284
  * frame #4: 0x00010cdf3cdc 
liblldb.20.0.0git.dylib`DWARFASTParserClang::ExtractIntFromFormValue(lldb_private::CompilerType
 const&, lldb_private::plugin::dwarf::DWARFFormValue const&) const 
(.cold.1) + 
frame #5: 0x000109d30acc 
liblldb.20.0.0git.dylib`lldb_private::TypeSystemClang::GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding,
 unsigned long) + 1188
frame #6: 0x000109aaaed4 
liblldb.20.0.0git.dylib`DynamicLoaderMacOS::NotifyBreakpointHit(void*, 
lldb_private::StoppointCallbackContext*, unsigned long long, unsigned long 
long) + 384
```

This patch adds a one-time user-visible warning for when we fail to initialize 
the AST to indicate that initialization went wrong for the given target. 
Additionally, we add checks for whether one of the `ASTContext` `QualType`s is 
invalid before dereferencing any builtin types.

The warning would look as follows:
```
(lldb) target create "a.out"
Current executable set to 'a.out' (arm64).
(lldb) b main
warning: Failed to initialize builtin ASTContext types for target 
'some-unknown-triple'. Printing variables may behave unexpectedly.
Breakpoint 1: where = a.out`main + 8 at stepping.cpp:5:14, address = 
0x00013f90
```

rdar://134869779

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


1 Files Affected:

- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+24-4) 


``diff
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index b0f49ebf2d2cbb..2f423269fecd2d 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -54,6 +54,7 @@
 #include "Plugins/ExpressionParser/Clang/ClangUserExpression.h"
 #include "Plugins/ExpressionParser/Clang/ClangUtil.h"
 #include "Plugins/ExpressionParser/Clang/ClangUtilityFunction.h"
+#include "lldb/Core/Debugger.h"
 #include "lldb/Core/DumpDataExtractor.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
@@ -697,10 +698,19 @@ void TypeSystemClang::CreateASTContext() {
   TargetInfo *target_info = getTargetInfo();
   if (target_info)
 m_ast_up->InitBuiltinTypes(*target_info);
-  else if (auto *log = GetLog(LLDBLog::Expressions))
-LLDB_LOG(log,
- "Failed to initialize builtin ASTContext types for target '{0}'",
- m_target_triple);
+  else {
+std::string err =
+llvm::formatv(
+"Failed to initialize builtin ASTContext types for target '{0}'. "
+"Printing variables may behave unexpectedly.",
+m_target_triple)
+.str();
+
+LLDB_LOG(GetLog(LLDBLog::Expressions), err.c_str());
+
+static std::once_flag s_uninitialized_target_warning;
+Debugger::ReportWarning(std::move(err), /*debugger_id=*/std::nullopt, 
&s_uninitialized_target_warning);
+  }
 
   GetASTMap().Insert(m_ast_up.get(), this);
 
@@ -749,6 +759,11 @@ CompilerType
 TypeSys

[Lldb-commits] [lldb] [lldb][TypeSystemClang] Add warning and defensive checks when ASTContext is not fully initialized (PR #110481)

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

https://github.com/Michael137 created 
https://github.com/llvm/llvm-project/pull/110481

As this comment around target initialization implies:
```
  // This can be NULL if we don't know anything about the architecture or if
  // the target for an architecture isn't enabled in the llvm/clang that we
  // built
```

There are cases where we might fail to call `InitBuiltinTypes` when creating 
the backing `ASTContext` for a `TypeSystemClang`. If that happens, the builtins 
`QualType`s, e.g., `VoidPtrTy`/`IntTy`/etc., are not initialized and 
dereferencing them as we do in `GetBuiltinTypeForEncodingAndBitSize` (and other 
places) will lead to nullptr-dereferences. Example backtrace:
```
(lldb) run
Assertion failed: (!isNull() && "Cannot retrieve a NULL type pointer"), 
function getCommonPtr, file Type.h, line 958.
Process 2680 stopped
* thread #15, name = '', stop reason = 
hit program assert
frame #4: 0x00010cdf3cdc 
liblldb.20.0.0git.dylib`DWARFASTParserClang::ExtractIntFromFormValue(lldb_private::CompilerType
 const&, lldb_private::plugin::dwarf::DWARFFormValue const&) const (.cold.1) + 
liblldb.20.0.0git.dylib`DWARFASTParserClang::ParseObjCMethod(lldb_private::ObjCLanguage::MethodName
 const&, lldb_private::plugin::dwarf::DWARFDIE const&, 
lldb_private::CompilerType, ParsedDWARFTypeAttributes
, bool) (.cold.1):
->  0x10cdf3cdc <+0>:  stpx29, x30, [sp, #-0x10]!
0x10cdf3ce0 <+4>:  movx29, sp
0x10cdf3ce4 <+8>:  adrp   x0, 545
0x10cdf3ce8 <+12>: addx0, x0, #0xa25 ; "ParseObjCMethod"
Target 0: (lldb) stopped.
(lldb) bt
* thread #15, name = '', stop reason = 
hit program assert
frame #0: 0x000180d08600 libsystem_kernel.dylib`__pthread_kill + 8
frame #1: 0x000180d40f50 libsystem_pthread.dylib`pthread_kill + 288
frame #2: 0x000180c4d908 libsystem_c.dylib`abort + 128
frame #3: 0x000180c4cc1c libsystem_c.dylib`__assert_rtn + 284
  * frame #4: 0x00010cdf3cdc 
liblldb.20.0.0git.dylib`DWARFASTParserClang::ExtractIntFromFormValue(lldb_private::CompilerType
 const&, lldb_private::plugin::dwarf::DWARFFormValue const&) const (.cold.1) + 
frame #5: 0x000109d30acc 
liblldb.20.0.0git.dylib`lldb_private::TypeSystemClang::GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding,
 unsigned long) + 1188
frame #6: 0x000109aaaed4 
liblldb.20.0.0git.dylib`DynamicLoaderMacOS::NotifyBreakpointHit(void*, 
lldb_private::StoppointCallbackContext*, unsigned long long, unsigned long 
long) + 384
```

This patch adds a one-time user-visible warning for when we fail to initialize 
the AST to indicate that initialization went wrong for the given target. 
Additionally, we add checks for whether one of the `ASTContext` `QualType`s is 
invalid before dereferencing any builtin types.

The warning would look as follows:
```
(lldb) target create "a.out"
Current executable set to 'a.out' (arm64).
(lldb) b main
warning: Failed to initialize builtin ASTContext types for target 
'some-unknown-triple'. Printing variables may behave unexpectedly.
Breakpoint 1: where = a.out`main + 8 at stepping.cpp:5:14, address = 
0x00013f90
```

rdar://134869779

>From 0669f9fbeddaf81edfca7e81f4883a1b95a780f6 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 30 Sep 2024 10:53:47 +0100
Subject: [PATCH] [lldb][TypeSystemClang] Add warning and defensive checks when
 ASTContext is not fully initialized

---
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 28 ---
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index b0f49ebf2d2cbb..2f423269fecd2d 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -54,6 +54,7 @@
 #include "Plugins/ExpressionParser/Clang/ClangUserExpression.h"
 #include "Plugins/ExpressionParser/Clang/ClangUtil.h"
 #include "Plugins/ExpressionParser/Clang/ClangUtilityFunction.h"
+#include "lldb/Core/Debugger.h"
 #include "lldb/Core/DumpDataExtractor.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
@@ -697,10 +698,19 @@ void TypeSystemClang::CreateASTContext() {
   TargetInfo *target_info = getTargetInfo();
   if (target_info)
 m_ast_up->InitBuiltinTypes(*target_info);
-  else if (auto *log = GetLog(LLDBLog::Expressions))
-LLDB_LOG(log,
- "Failed to initialize builtin ASTContext types for target '{0}'",
- m_target_triple);
+  else {
+std::string err =
+llvm::formatv(
+"Failed to initialize builtin ASTContext types for target '{0}'. "
+"Printing variables may behave unexpectedly.",
+m_target_triple)
+.str();
+
+LLDB_LOG(GetLog(LLDBLog::Expressions), err.c_str());
+
+static std::once_flag s_uninitialized_target_warning;
+Debugger::ReportWarning(std::move(err), /*debugger_id=*/std::nullopt, 
&s_uninitialized_target_wa

[Lldb-commits] [lldb] [lldb][TypeSystemClang] Add warning and defensive checks when ASTContext is not fully initialized (PR #110481)

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

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/110481

>From 0669f9fbeddaf81edfca7e81f4883a1b95a780f6 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 30 Sep 2024 10:53:47 +0100
Subject: [PATCH 1/3] [lldb][TypeSystemClang] Add warning and defensive checks
 when ASTContext is not fully initialized

---
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 28 ---
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index b0f49ebf2d2cbb..2f423269fecd2d 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -54,6 +54,7 @@
 #include "Plugins/ExpressionParser/Clang/ClangUserExpression.h"
 #include "Plugins/ExpressionParser/Clang/ClangUtil.h"
 #include "Plugins/ExpressionParser/Clang/ClangUtilityFunction.h"
+#include "lldb/Core/Debugger.h"
 #include "lldb/Core/DumpDataExtractor.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
@@ -697,10 +698,19 @@ void TypeSystemClang::CreateASTContext() {
   TargetInfo *target_info = getTargetInfo();
   if (target_info)
 m_ast_up->InitBuiltinTypes(*target_info);
-  else if (auto *log = GetLog(LLDBLog::Expressions))
-LLDB_LOG(log,
- "Failed to initialize builtin ASTContext types for target '{0}'",
- m_target_triple);
+  else {
+std::string err =
+llvm::formatv(
+"Failed to initialize builtin ASTContext types for target '{0}'. "
+"Printing variables may behave unexpectedly.",
+m_target_triple)
+.str();
+
+LLDB_LOG(GetLog(LLDBLog::Expressions), err.c_str());
+
+static std::once_flag s_uninitialized_target_warning;
+Debugger::ReportWarning(std::move(err), /*debugger_id=*/std::nullopt, 
&s_uninitialized_target_warning);
+  }
 
   GetASTMap().Insert(m_ast_up.get(), this);
 
@@ -749,6 +759,11 @@ CompilerType
 TypeSystemClang::GetBuiltinTypeForEncodingAndBitSize(Encoding encoding,
  size_t bit_size) {
   ASTContext &ast = getASTContext();
+  if (!ast.VoidPtrTy) {
+LLDB_LOG(GetLog(LLDBLog::Expressions), "{0} failed: builtin types on 
ASTContext were not initialized properly.", __func__);
+return {};
+  }
+
   switch (encoding) {
   case eEncodingInvalid:
 if (QualTypeMatchesBitSize(bit_size, ast, ast.VoidPtrTy))
@@ -891,6 +906,11 @@ CompilerType 
TypeSystemClang::GetBuiltinTypeForDWARFEncodingAndBitSize(
 llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size) {
   ASTContext &ast = getASTContext();
 
+  if (!ast.VoidPtrTy) {
+LLDB_LOG(GetLog(LLDBLog::Expressions), "{0} failed: builtin types on 
ASTContext were not initialized properly.", __func__);
+return {};
+  }
+
   switch (dw_ate) {
   default:
 break;

>From 46c4015cd76709bae4b9e38eff312ad58225b62a Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 30 Sep 2024 11:16:06 +0100
Subject: [PATCH 2/3] fixup! format

---
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 2f423269fecd2d..9ba5d0a79445e8 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -759,6 +759,7 @@ CompilerType
 TypeSystemClang::GetBuiltinTypeForEncodingAndBitSize(Encoding encoding,
  size_t bit_size) {
   ASTContext &ast = getASTContext();
+
   if (!ast.VoidPtrTy) {
 LLDB_LOG(GetLog(LLDBLog::Expressions), "{0} failed: builtin types on 
ASTContext were not initialized properly.", __func__);
 return {};

>From caed9b07141176ab202d8c95bf0ffa4f59dce1d3 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 30 Sep 2024 11:16:31 +0100
Subject: [PATCH 3/3] fixup! clang-format

---
 .../Plugins/TypeSystem/Clang/TypeSystemClang.cpp| 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 9ba5d0a79445e8..02d6675ddc811e 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -709,7 +709,8 @@ void TypeSystemClang::CreateASTContext() {
 LLDB_LOG(GetLog(LLDBLog::Expressions), err.c_str());
 
 static std::once_flag s_uninitialized_target_warning;
-Debugger::ReportWarning(std::move(err), /*debugger_id=*/std::nullopt, 
&s_uninitialized_target_warning);
+Debugger::ReportWarning(std::move(err), /*debugger_id=*/std::nullopt,
+&s_uninitialized_target_warning);
   }
 
   GetASTMap().Insert(m_ast_up.get(), this);
@@ -761,7 +7

[Lldb-commits] [lldb] [lldb][TypeSystemClang] Add warning and defensive checks when ASTContext is not fully initialized (PR #110481)

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

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/110481

>From 0669f9fbeddaf81edfca7e81f4883a1b95a780f6 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 30 Sep 2024 10:53:47 +0100
Subject: [PATCH 1/2] [lldb][TypeSystemClang] Add warning and defensive checks
 when ASTContext is not fully initialized

---
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 28 ---
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index b0f49ebf2d2cbb..2f423269fecd2d 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -54,6 +54,7 @@
 #include "Plugins/ExpressionParser/Clang/ClangUserExpression.h"
 #include "Plugins/ExpressionParser/Clang/ClangUtil.h"
 #include "Plugins/ExpressionParser/Clang/ClangUtilityFunction.h"
+#include "lldb/Core/Debugger.h"
 #include "lldb/Core/DumpDataExtractor.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
@@ -697,10 +698,19 @@ void TypeSystemClang::CreateASTContext() {
   TargetInfo *target_info = getTargetInfo();
   if (target_info)
 m_ast_up->InitBuiltinTypes(*target_info);
-  else if (auto *log = GetLog(LLDBLog::Expressions))
-LLDB_LOG(log,
- "Failed to initialize builtin ASTContext types for target '{0}'",
- m_target_triple);
+  else {
+std::string err =
+llvm::formatv(
+"Failed to initialize builtin ASTContext types for target '{0}'. "
+"Printing variables may behave unexpectedly.",
+m_target_triple)
+.str();
+
+LLDB_LOG(GetLog(LLDBLog::Expressions), err.c_str());
+
+static std::once_flag s_uninitialized_target_warning;
+Debugger::ReportWarning(std::move(err), /*debugger_id=*/std::nullopt, 
&s_uninitialized_target_warning);
+  }
 
   GetASTMap().Insert(m_ast_up.get(), this);
 
@@ -749,6 +759,11 @@ CompilerType
 TypeSystemClang::GetBuiltinTypeForEncodingAndBitSize(Encoding encoding,
  size_t bit_size) {
   ASTContext &ast = getASTContext();
+  if (!ast.VoidPtrTy) {
+LLDB_LOG(GetLog(LLDBLog::Expressions), "{0} failed: builtin types on 
ASTContext were not initialized properly.", __func__);
+return {};
+  }
+
   switch (encoding) {
   case eEncodingInvalid:
 if (QualTypeMatchesBitSize(bit_size, ast, ast.VoidPtrTy))
@@ -891,6 +906,11 @@ CompilerType 
TypeSystemClang::GetBuiltinTypeForDWARFEncodingAndBitSize(
 llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size) {
   ASTContext &ast = getASTContext();
 
+  if (!ast.VoidPtrTy) {
+LLDB_LOG(GetLog(LLDBLog::Expressions), "{0} failed: builtin types on 
ASTContext were not initialized properly.", __func__);
+return {};
+  }
+
   switch (dw_ate) {
   default:
 break;

>From 46c4015cd76709bae4b9e38eff312ad58225b62a Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 30 Sep 2024 11:16:06 +0100
Subject: [PATCH 2/2] fixup! format

---
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 2f423269fecd2d..9ba5d0a79445e8 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -759,6 +759,7 @@ CompilerType
 TypeSystemClang::GetBuiltinTypeForEncodingAndBitSize(Encoding encoding,
  size_t bit_size) {
   ASTContext &ast = getASTContext();
+
   if (!ast.VoidPtrTy) {
 LLDB_LOG(GetLog(LLDBLog::Expressions), "{0} failed: builtin types on 
ASTContext were not initialized properly.", __func__);
 return {};

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


[Lldb-commits] [lldb] [lldb][TypeSystemClang] Add warning and defensive checks when ASTContext is not fully initialized (PR #110481)

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

Michael137 wrote:

There's a couple more places we use these types unconditionally that I haven't 
added checks to.

Should be testable by creating a `TypeSystemClang` with an empty triple and 
calling one of these APIs on it.

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


[Lldb-commits] [lldb] Fix an integer trunctation issues for the DW_AT_frame_base DWARF loca… (PR #110388)

2024-09-30 Thread via lldb-commits

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


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


[Lldb-commits] [lldb] b086f75 - Fix an integer trunctation issues for the DW_AT_frame_base DWARF location expression (#110388)

2024-09-30 Thread via lldb-commits

Author: Greg Clayton
Date: 2024-09-30T09:04:09-07:00
New Revision: b086f7591ce8d4f810a472554d38b4437dff6919

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

LOG: Fix an integer trunctation issues for the DW_AT_frame_base DWARF location 
expression (#110388)

This patch allows offsets to the DW_AT_frame_base to exceed 4GB. Prior
to this, for any .debug_info.dwo offset that exceeded 4GB, we would
truncate the offset to the DW_AT_frame_base expression bytes to be 32
bit only. Changing the offset to 64 bits restores correct functionality.

No test for this as we don't want to create a .dwp file that has a
.debug_info.dwo size that is over 4GB.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 77ef59d605c9c4..66d0bc4b90cb52 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -229,9 +229,9 @@ bool DWARFDebugInfoEntry::GetDIENamesAndRanges(
 case DW_AT_frame_base:
   if (frame_base) {
 if (form_value.BlockData()) {
-  uint32_t block_offset =
+  uint64_t block_offset =
   form_value.BlockData() - data.GetDataStart();
-  uint32_t block_length = form_value.Unsigned();
+  uint64_t block_length = form_value.Unsigned();
   *frame_base =
   DWARFExpressionList(module,
   DWARFExpression(DataExtractor(



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


[Lldb-commits] [lldb] Fix an integer trunctation issues for the DW_AT_frame_base DWARF loca… (PR #110388)

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

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


[Lldb-commits] [lldb] [lldb][TypeSystemClang] Add warning and defensive checks when ASTContext is not fully initialized (PR #110481)

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

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/110481

>From 0669f9fbeddaf81edfca7e81f4883a1b95a780f6 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 30 Sep 2024 10:53:47 +0100
Subject: [PATCH 1/4] [lldb][TypeSystemClang] Add warning and defensive checks
 when ASTContext is not fully initialized

---
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 28 ---
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index b0f49ebf2d2cbb..2f423269fecd2d 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -54,6 +54,7 @@
 #include "Plugins/ExpressionParser/Clang/ClangUserExpression.h"
 #include "Plugins/ExpressionParser/Clang/ClangUtil.h"
 #include "Plugins/ExpressionParser/Clang/ClangUtilityFunction.h"
+#include "lldb/Core/Debugger.h"
 #include "lldb/Core/DumpDataExtractor.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
@@ -697,10 +698,19 @@ void TypeSystemClang::CreateASTContext() {
   TargetInfo *target_info = getTargetInfo();
   if (target_info)
 m_ast_up->InitBuiltinTypes(*target_info);
-  else if (auto *log = GetLog(LLDBLog::Expressions))
-LLDB_LOG(log,
- "Failed to initialize builtin ASTContext types for target '{0}'",
- m_target_triple);
+  else {
+std::string err =
+llvm::formatv(
+"Failed to initialize builtin ASTContext types for target '{0}'. "
+"Printing variables may behave unexpectedly.",
+m_target_triple)
+.str();
+
+LLDB_LOG(GetLog(LLDBLog::Expressions), err.c_str());
+
+static std::once_flag s_uninitialized_target_warning;
+Debugger::ReportWarning(std::move(err), /*debugger_id=*/std::nullopt, 
&s_uninitialized_target_warning);
+  }
 
   GetASTMap().Insert(m_ast_up.get(), this);
 
@@ -749,6 +759,11 @@ CompilerType
 TypeSystemClang::GetBuiltinTypeForEncodingAndBitSize(Encoding encoding,
  size_t bit_size) {
   ASTContext &ast = getASTContext();
+  if (!ast.VoidPtrTy) {
+LLDB_LOG(GetLog(LLDBLog::Expressions), "{0} failed: builtin types on 
ASTContext were not initialized properly.", __func__);
+return {};
+  }
+
   switch (encoding) {
   case eEncodingInvalid:
 if (QualTypeMatchesBitSize(bit_size, ast, ast.VoidPtrTy))
@@ -891,6 +906,11 @@ CompilerType 
TypeSystemClang::GetBuiltinTypeForDWARFEncodingAndBitSize(
 llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size) {
   ASTContext &ast = getASTContext();
 
+  if (!ast.VoidPtrTy) {
+LLDB_LOG(GetLog(LLDBLog::Expressions), "{0} failed: builtin types on 
ASTContext were not initialized properly.", __func__);
+return {};
+  }
+
   switch (dw_ate) {
   default:
 break;

>From 46c4015cd76709bae4b9e38eff312ad58225b62a Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 30 Sep 2024 11:16:06 +0100
Subject: [PATCH 2/4] fixup! format

---
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 2f423269fecd2d..9ba5d0a79445e8 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -759,6 +759,7 @@ CompilerType
 TypeSystemClang::GetBuiltinTypeForEncodingAndBitSize(Encoding encoding,
  size_t bit_size) {
   ASTContext &ast = getASTContext();
+
   if (!ast.VoidPtrTy) {
 LLDB_LOG(GetLog(LLDBLog::Expressions), "{0} failed: builtin types on 
ASTContext were not initialized properly.", __func__);
 return {};

>From caed9b07141176ab202d8c95bf0ffa4f59dce1d3 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 30 Sep 2024 11:16:31 +0100
Subject: [PATCH 3/4] fixup! clang-format

---
 .../Plugins/TypeSystem/Clang/TypeSystemClang.cpp| 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 9ba5d0a79445e8..02d6675ddc811e 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -709,7 +709,8 @@ void TypeSystemClang::CreateASTContext() {
 LLDB_LOG(GetLog(LLDBLog::Expressions), err.c_str());
 
 static std::once_flag s_uninitialized_target_warning;
-Debugger::ReportWarning(std::move(err), /*debugger_id=*/std::nullopt, 
&s_uninitialized_target_warning);
+Debugger::ReportWarning(std::move(err), /*debugger_id=*/std::nullopt,
+&s_uninitialized_target_warning);
   }
 
   GetASTMap().Insert(m_ast_up.get(), this);
@@ -761,7 +7

[Lldb-commits] [lldb] [LLDB][ProcessELFCore] Add Description to ProcessELFCore/ELFThread stop reasons (PR #110065)

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


@@ -556,6 +558,34 @@ Status ELFLinuxSigInfo::Parse(const DataExtractor &data, 
const ArchSpec &arch) {
   si_signo = data.GetU32(&offset);
   si_errno = data.GetU32(&offset);
   si_code = data.GetU32(&offset);
+  // 64b ELF have a 4 byte pad.
+  if (data.GetAddressByteSize() == 8)
+offset += 4;
+  switch (si_signo) {
+  case SIGFPE:
+  case SIGILL:
+  case SIGSEGV:
+  case SIGBUS:
+  case SIGTRAP:
+addr = (void *)data.GetAddress(&offset);

clayborg wrote:

don't cast to `void *`, just leave as an addr_t as suggested in previous inline 
comment.

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


[Lldb-commits] [lldb] [LLDB][ProcessELFCore] Add Description to ProcessELFCore/ELFThread stop reasons (PR #110065)

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

https://github.com/clayborg requested changes to this pull request.


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


[Lldb-commits] [lldb] [LLDB][ProcessELFCore] Add Description to ProcessELFCore/ELFThread stop reasons (PR #110065)

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


@@ -75,16 +75,25 @@ struct ELFLinuxPrStatus {
 static_assert(sizeof(ELFLinuxPrStatus) == 112,
   "sizeof ELFLinuxPrStatus is not correct!");
 
+union ELFSigval {
+  int sival_int;
+  void *sival_ptr;
+};
+
 struct ELFLinuxSigInfo {
-  int32_t si_signo;
-  int32_t si_code;
+  int32_t si_signo; // Order matters for the first 3.
   int32_t si_errno;
+  int32_t si_code;
+  void *addr;   /* faulting insn/memory ref. */
+  int32_t addr_lsb; /* Valid LSB of the reported address.  */

clayborg wrote:

Can we name this one as similar to the exact siginfo structure?

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


[Lldb-commits] [lldb] [LLDB][ProcessELFCore] Add Description to ProcessELFCore/ELFThread stop reasons (PR #110065)

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


@@ -75,16 +75,25 @@ struct ELFLinuxPrStatus {
 static_assert(sizeof(ELFLinuxPrStatus) == 112,
   "sizeof ELFLinuxPrStatus is not correct!");
 
+union ELFSigval {
+  int sival_int;
+  void *sival_ptr;
+};
+
 struct ELFLinuxSigInfo {
-  int32_t si_signo;
-  int32_t si_code;
+  int32_t si_signo; // Order matters for the first 3.
   int32_t si_errno;
+  int32_t si_code;
+  void *addr;   /* faulting insn/memory ref. */

clayborg wrote:

use `lldb::addr_t` as this debugger might be compiled for 32 bit architectures 
and we might debug a 64 bit target. Rename to `si_addr`? 

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


[Lldb-commits] [lldb] [lldb][TypeSystemClang] Add warning and defensive checks when ASTContext is not fully initialized (PR #110481)

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

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/110481

>From cba9ca2f2337c605d6992f3eece96e6ff15da8fe Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 30 Sep 2024 10:53:47 +0100
Subject: [PATCH] [lldb][TypeSystemClang] Add warning and defensive checks when
 ASTContext is not fully initialized

---
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 39 +--
 lldb/unittests/Symbol/TestTypeSystemClang.cpp | 32 +++
 2 files changed, 67 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index b0f49ebf2d2cbb..8af52fc61dd06d 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -54,6 +54,7 @@
 #include "Plugins/ExpressionParser/Clang/ClangUserExpression.h"
 #include "Plugins/ExpressionParser/Clang/ClangUtil.h"
 #include "Plugins/ExpressionParser/Clang/ClangUtilityFunction.h"
+#include "lldb/Core/Debugger.h"
 #include "lldb/Core/DumpDataExtractor.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
@@ -697,10 +698,20 @@ void TypeSystemClang::CreateASTContext() {
   TargetInfo *target_info = getTargetInfo();
   if (target_info)
 m_ast_up->InitBuiltinTypes(*target_info);
-  else if (auto *log = GetLog(LLDBLog::Expressions))
-LLDB_LOG(log,
- "Failed to initialize builtin ASTContext types for target '{0}'",
- m_target_triple);
+  else {
+std::string err =
+llvm::formatv(
+"Failed to initialize builtin ASTContext types for target '{0}'. "
+"Printing variables may behave unexpectedly.",
+m_target_triple)
+.str();
+
+LLDB_LOG(GetLog(LLDBLog::Expressions), err.c_str());
+
+static std::once_flag s_uninitialized_target_warning;
+Debugger::ReportWarning(std::move(err), /*debugger_id=*/std::nullopt,
+&s_uninitialized_target_warning);
+  }
 
   GetASTMap().Insert(m_ast_up.get(), this);
 
@@ -749,6 +760,10 @@ CompilerType
 TypeSystemClang::GetBuiltinTypeForEncodingAndBitSize(Encoding encoding,
  size_t bit_size) {
   ASTContext &ast = getASTContext();
+
+  if (!ast.VoidPtrTy)
+return {};
+
   switch (encoding) {
   case eEncodingInvalid:
 if (QualTypeMatchesBitSize(bit_size, ast, ast.VoidPtrTy))
@@ -891,6 +906,9 @@ CompilerType 
TypeSystemClang::GetBuiltinTypeForDWARFEncodingAndBitSize(
 llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size) {
   ASTContext &ast = getASTContext();
 
+  if (!ast.VoidPtrTy)
+return {};
+
   switch (dw_ate) {
   default:
 break;
@@ -2335,6 +2353,9 @@ CompilerType 
TypeSystemClang::GetIntTypeFromBitSize(size_t bit_size,
 bool is_signed) {
   clang::ASTContext &ast = getASTContext();
 
+  if (!ast.VoidPtrTy)
+return {};
+
   if (is_signed) {
 if (bit_size == ast.getTypeSize(ast.SignedCharTy))
   return GetType(ast.SignedCharTy);
@@ -2376,6 +2397,9 @@ CompilerType 
TypeSystemClang::GetIntTypeFromBitSize(size_t bit_size,
 }
 
 CompilerType TypeSystemClang::GetPointerSizedIntType(bool is_signed) {
+  if (!getASTContext().VoidPtrTy)
+return {};
+
   return GetIntTypeFromBitSize(
   getASTContext().getTypeSize(getASTContext().VoidPtrTy), is_signed);
 }
@@ -7453,6 +7477,13 @@ clang::FieldDecl *TypeSystemClang::AddFieldToRecordType(
 
   clang::Expr *bit_width = nullptr;
   if (bitfield_bit_size != 0) {
+if (clang_ast.IntTy.isNull()) {
+  LLDB_LOG(
+  GetLog(LLDBLog::Expressions),
+  "{0} failed: builtin ASTContext types have not been initialized");
+  return nullptr;
+}
+
 llvm::APInt bitfield_bit_size_apint(clang_ast.getTypeSize(clang_ast.IntTy),
 bitfield_bit_size);
 bit_width = new (clang_ast)
diff --git a/lldb/unittests/Symbol/TestTypeSystemClang.cpp 
b/lldb/unittests/Symbol/TestTypeSystemClang.cpp
index 7d64e1cdd56f64..0733e42bb46331 100644
--- a/lldb/unittests/Symbol/TestTypeSystemClang.cpp
+++ b/lldb/unittests/Symbol/TestTypeSystemClang.cpp
@@ -13,6 +13,7 @@
 #include "lldb/Core/Declaration.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/HostInfo.h"
+#include "lldb/lldb-enumerations.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/ExprCXX.h"
@@ -231,6 +232,37 @@ TEST_F(TestTypeSystemClang, 
TestBuiltinTypeForEncodingAndBitSize) {
   VerifyEncodingAndBitSize(*m_ast, eEncodingIEEE754, 64);
 }
 
+TEST_F(TestTypeSystemClang, TestBuiltinTypeForEmptyTriple) {
+  // Test that we can access type-info of builtin Clang AST
+  // types without crashing even when the target triple is
+  // empty.
+
+  TypeSystemClang ast("empty triple AST", llvm::Triple{});
+
+  // This test only makes sense if the builtin ASTContext types were
+  

[Lldb-commits] [lldb] [lldb] Removed gdbserver ports map from lldb-server (PR #104238)

2024-09-30 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

Polite ping.
Let's complite this PR, please.

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


[Lldb-commits] [lldb] [LLDB][ProcessELFCore] Add Description to ProcessELFCore/ELFThread stop reasons (PR #110065)

2024-09-30 Thread Jacob Lalonde via lldb-commits


@@ -75,16 +75,25 @@ struct ELFLinuxPrStatus {
 static_assert(sizeof(ELFLinuxPrStatus) == 112,
   "sizeof ELFLinuxPrStatus is not correct!");
 
+union ELFSigval {
+  int sival_int;
+  void *sival_ptr;
+};
+
 struct ELFLinuxSigInfo {
-  int32_t si_signo;
-  int32_t si_code;
+  int32_t si_signo; // Order matters for the first 3.
   int32_t si_errno;
+  int32_t si_code;
+  void *addr;   /* faulting insn/memory ref. */
+  int32_t addr_lsb; /* Valid LSB of the reported address.  */

Jlalond wrote:

We can't use the `si_` prefixed variables because `siginfo_t.h` defines these 
all as Macros in the global namespace, and I didn't want to couple our build to 
the existence of that macro

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


[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-09-30 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo created 
https://github.com/llvm/llvm-project/pull/110543

I'm developing the Mojo language, and some symbol breakpoints don't work 
because of two reasons that got fixed1:

- There's a prune step that operates on the assuption that the symbol is 
C-like. That was discarding lots of the Mojo breakpoints
- When finding functions for symbol breakpoints with eFunctionNameTypeFull, 
LLDB was only matching die.getMangledName() and not die.GetName(). The latter 
is the one useful for Mojo, because the former has some unreadable format in 
Mojo that is not exposed to the user. This shouldn't cause any regression for 
C-like languages, as the prune step would sanitize them anyway, but it's useful 
for languages like Mojo.

>From 9ac2f9b2eb34e7495e60500ce9b90cc9370e8709 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 30 Sep 2024 13:33:35 -0400
Subject: [PATCH] [LLDB] Fix symbol breakpoint lookups for non-C-like languages

I'm developing the Mojo language, and some symbol breakpoints don't work 
because of two reasons that got fixed1:

- There's a prune step that operates on the assuption that the symbol is 
C-like. That was discarding lots of the Mojo breakpoints
- When finding functions for symbol breakpoints with eFunctionNameTypeFull, 
LLDB was only matching die.getMangledName() and not die.GetName(). The latter 
is the one useful for Mojo, because the former has some unreadable format in 
Mojo that is not exposed to the user. This shouldn't cause any regression for 
C-like languages, as the prune step would sanitize them anyway, but it's useful 
for languages like Mojo.
---
 lldb/source/Breakpoint/BreakpointResolverName.cpp  | 14 +++---
 lldb/source/Core/Module.cpp|  4 
 .../source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp |  3 ++-
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp 
b/lldb/source/Breakpoint/BreakpointResolverName.cpp
index 264638eb836dc6..77ddd86302cd1d 100644
--- a/lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -24,10 +24,10 @@
 using namespace lldb;
 using namespace lldb_private;
 
-BreakpointResolverName::BreakpointResolverName(const BreakpointSP &bkpt,
-const char *name_cstr, FunctionNameType name_type_mask,
-LanguageType language, Breakpoint::MatchType type, lldb::addr_t offset,
-bool skip_prologue)
+BreakpointResolverName::BreakpointResolverName(
+const BreakpointSP &bkpt, const char *name_cstr,
+FunctionNameType name_type_mask, LanguageType language,
+Breakpoint::MatchType type, lldb::addr_t offset, bool skip_prologue)
 : BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
   m_match_type(type), m_language(language), m_skip_prologue(skip_prologue) 
{
   if (m_match_type == Breakpoint::Regexp) {
@@ -237,9 +237,9 @@ void BreakpointResolverName::AddNameLookup(ConstString name,
   if (Language *lang = Language::FindPlugin(m_language)) {
 add_variant_funcs(lang);
   } else {
-// Most likely m_language is eLanguageTypeUnknown. We check each language 
for
-// possible variants or more qualified names and create lookups for those 
as
-// well.
+// Most likely m_language is eLanguageTypeUnknown. We check each language
+// for possible variants or more qualified names and create lookups for
+// those as well.
 Language::ForEach(add_variant_funcs);
   }
 }
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 88cc957e91fac4..29b419e9969743 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -797,6 +797,10 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
 while (i < sc_list.GetSize()) {
   if (!sc_list.GetContextAtIndex(i, sc))
 break;
+  if (!lldb_private::Language::LanguageIsCFamily(sc.GetLanguage())) {
+++i;
+continue;
+  }
   // Make sure the mangled and demangled names don't match before we try to
   // pull anything out
   ConstString mangled_name(sc.GetFunctionName(Mangled::ePreferMangled));
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
index eafddbad03f57b..7bf53dce1b1b07 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
@@ -59,7 +59,8 @@ bool DWARFIndex::ProcessFunctionDIE(
 return true;
 
   // In case of a full match, we just insert everything we find.
-  if (name_type_mask & eFunctionNameTypeFull && die.GetMangledName() == name)
+  if (name_type_mask & eFunctionNameTypeFull &&
+  (die.GetMangledName() == name || die.GetName() == name))
 return callback(die);
 
   // If looking for ObjC selectors, we need to also check if the name is a

___
lldb-commits mailing list
lldb-commits@lists.llvm.org

[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-09-30 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Walter Erquinigo (walter-erquinigo)


Changes

I'm developing the Mojo language, and some symbol breakpoints don't work 
because of two reasons that this PR fixes:

- There's a prune step that operates on the assuption that the symbol is 
C-like. That was discarding lots of the Mojo breakpoints
- When finding functions for symbol breakpoints with eFunctionNameTypeFull, 
LLDB was only matching die.getMangledName() and not die.GetName(). The latter 
is the one useful for Mojo, because the former has some unreadable format in 
Mojo that is not exposed to the user. This shouldn't cause any regression for 
C-like languages, as the prune step would sanitize them anyway, but it's useful 
for languages like Mojo.

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


3 Files Affected:

- (modified) lldb/source/Breakpoint/BreakpointResolverName.cpp (+7-7) 
- (modified) lldb/source/Core/Module.cpp (+4) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp (+2-1) 


``diff
diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp 
b/lldb/source/Breakpoint/BreakpointResolverName.cpp
index 264638eb836dc6..77ddd86302cd1d 100644
--- a/lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -24,10 +24,10 @@
 using namespace lldb;
 using namespace lldb_private;
 
-BreakpointResolverName::BreakpointResolverName(const BreakpointSP &bkpt,
-const char *name_cstr, FunctionNameType name_type_mask,
-LanguageType language, Breakpoint::MatchType type, lldb::addr_t offset,
-bool skip_prologue)
+BreakpointResolverName::BreakpointResolverName(
+const BreakpointSP &bkpt, const char *name_cstr,
+FunctionNameType name_type_mask, LanguageType language,
+Breakpoint::MatchType type, lldb::addr_t offset, bool skip_prologue)
 : BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
   m_match_type(type), m_language(language), m_skip_prologue(skip_prologue) 
{
   if (m_match_type == Breakpoint::Regexp) {
@@ -237,9 +237,9 @@ void BreakpointResolverName::AddNameLookup(ConstString name,
   if (Language *lang = Language::FindPlugin(m_language)) {
 add_variant_funcs(lang);
   } else {
-// Most likely m_language is eLanguageTypeUnknown. We check each language 
for
-// possible variants or more qualified names and create lookups for those 
as
-// well.
+// Most likely m_language is eLanguageTypeUnknown. We check each language
+// for possible variants or more qualified names and create lookups for
+// those as well.
 Language::ForEach(add_variant_funcs);
   }
 }
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 88cc957e91fac4..29b419e9969743 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -797,6 +797,10 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
 while (i < sc_list.GetSize()) {
   if (!sc_list.GetContextAtIndex(i, sc))
 break;
+  if (!lldb_private::Language::LanguageIsCFamily(sc.GetLanguage())) {
+++i;
+continue;
+  }
   // Make sure the mangled and demangled names don't match before we try to
   // pull anything out
   ConstString mangled_name(sc.GetFunctionName(Mangled::ePreferMangled));
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
index eafddbad03f57b..7bf53dce1b1b07 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
@@ -59,7 +59,8 @@ bool DWARFIndex::ProcessFunctionDIE(
 return true;
 
   // In case of a full match, we just insert everything we find.
-  if (name_type_mask & eFunctionNameTypeFull && die.GetMangledName() == name)
+  if (name_type_mask & eFunctionNameTypeFull &&
+  (die.GetMangledName() == name || die.GetName() == name))
 return callback(die);
 
   // If looking for ObjC selectors, we need to also check if the name is a

``




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


[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-09-30 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] 78ff340 - [LLDB][Minidump] Fix bug where we were using the wrong collection for thread stacks (#110579)

2024-09-30 Thread via lldb-commits

Author: Jacob Lalonde
Date: 2024-09-30T17:56:32-07:00
New Revision: 78ff3401482384203b8ea664eee20fb81f8fb933

URL: 
https://github.com/llvm/llvm-project/commit/78ff3401482384203b8ea664eee20fb81f8fb933
DIFF: 
https://github.com/llvm/llvm-project/commit/78ff3401482384203b8ea664eee20fb81f8fb933.diff

LOG: [LLDB][Minidump] Fix bug where we were using the wrong collection for 
thread stacks (#110579)

In my prior two save core API's, I experimented on how to save stacks
with the new API. I incorrectly left these in, as the existing
`m_thread_by_range_end` was the correct choice.

I have removed the no-op collection, and moved to use the proper one.
It's worth noting this was not caught by testing because we do not
verify where the items are contained in the minidump. This would require
a test being aware of how minidumps are structured, or adding a textual
tool that we can then scan the output of.

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index 3f1e25f730a184..f6c16b6e3d96ae 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -853,7 +853,7 @@ Status MinidumpFileBuilder::AddMemoryList() {
   uint64_t total_size = GetCurrentDataEndOffset();
   auto iterator = all_core_memory_vec.begin();
   while (iterator != all_core_memory_vec.end()) {
-if (m_saved_stack_ranges.count(iterator->range.start()) > 0) {
+if (m_thread_by_range_end.count(iterator->range.end()) > 0) {
   // We don't save stacks twice.
   ranges_32.push_back(*iterator);
   total_size +=

diff  --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
index d5eac9015ac422..a4240f871c8a2f 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
@@ -172,7 +172,6 @@ class MinidumpFileBuilder {
   // to duplicate it in the exception data.
   std::unordered_map
   m_tid_to_reg_ctx;
-  std::unordered_set m_saved_stack_ranges;
   lldb::FileUP m_core_file;
   lldb_private::SaveCoreOptions m_save_core_options;
 };



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


[Lldb-commits] [lldb] [LLDB][Minidump] Fix bug where we were using the wrong collection for thread stacks (PR #110579)

2024-09-30 Thread Jacob Lalonde via lldb-commits

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


[Lldb-commits] [libcxx] [lldb] [lldb][libc++] Hide all libc++ implementation details from stacktraces (PR #108870)

2024-09-30 Thread Adrian Vogelsgesang via lldb-commits

vogelsgesang wrote:

(I will be waiting for one or two more weeks before merging this, in case there 
are any additional comments)

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


[Lldb-commits] [lldb] [lldb][TypeSystemClang] Add warning and defensive checks when ASTContext is not fully initialized (PR #110481)

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

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/110481

>From 0669f9fbeddaf81edfca7e81f4883a1b95a780f6 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 30 Sep 2024 10:53:47 +0100
Subject: [PATCH 1/5] [lldb][TypeSystemClang] Add warning and defensive checks
 when ASTContext is not fully initialized

---
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 28 ---
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index b0f49ebf2d2cbb..2f423269fecd2d 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -54,6 +54,7 @@
 #include "Plugins/ExpressionParser/Clang/ClangUserExpression.h"
 #include "Plugins/ExpressionParser/Clang/ClangUtil.h"
 #include "Plugins/ExpressionParser/Clang/ClangUtilityFunction.h"
+#include "lldb/Core/Debugger.h"
 #include "lldb/Core/DumpDataExtractor.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
@@ -697,10 +698,19 @@ void TypeSystemClang::CreateASTContext() {
   TargetInfo *target_info = getTargetInfo();
   if (target_info)
 m_ast_up->InitBuiltinTypes(*target_info);
-  else if (auto *log = GetLog(LLDBLog::Expressions))
-LLDB_LOG(log,
- "Failed to initialize builtin ASTContext types for target '{0}'",
- m_target_triple);
+  else {
+std::string err =
+llvm::formatv(
+"Failed to initialize builtin ASTContext types for target '{0}'. "
+"Printing variables may behave unexpectedly.",
+m_target_triple)
+.str();
+
+LLDB_LOG(GetLog(LLDBLog::Expressions), err.c_str());
+
+static std::once_flag s_uninitialized_target_warning;
+Debugger::ReportWarning(std::move(err), /*debugger_id=*/std::nullopt, 
&s_uninitialized_target_warning);
+  }
 
   GetASTMap().Insert(m_ast_up.get(), this);
 
@@ -749,6 +759,11 @@ CompilerType
 TypeSystemClang::GetBuiltinTypeForEncodingAndBitSize(Encoding encoding,
  size_t bit_size) {
   ASTContext &ast = getASTContext();
+  if (!ast.VoidPtrTy) {
+LLDB_LOG(GetLog(LLDBLog::Expressions), "{0} failed: builtin types on 
ASTContext were not initialized properly.", __func__);
+return {};
+  }
+
   switch (encoding) {
   case eEncodingInvalid:
 if (QualTypeMatchesBitSize(bit_size, ast, ast.VoidPtrTy))
@@ -891,6 +906,11 @@ CompilerType 
TypeSystemClang::GetBuiltinTypeForDWARFEncodingAndBitSize(
 llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size) {
   ASTContext &ast = getASTContext();
 
+  if (!ast.VoidPtrTy) {
+LLDB_LOG(GetLog(LLDBLog::Expressions), "{0} failed: builtin types on 
ASTContext were not initialized properly.", __func__);
+return {};
+  }
+
   switch (dw_ate) {
   default:
 break;

>From 46c4015cd76709bae4b9e38eff312ad58225b62a Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 30 Sep 2024 11:16:06 +0100
Subject: [PATCH 2/5] fixup! format

---
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 2f423269fecd2d..9ba5d0a79445e8 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -759,6 +759,7 @@ CompilerType
 TypeSystemClang::GetBuiltinTypeForEncodingAndBitSize(Encoding encoding,
  size_t bit_size) {
   ASTContext &ast = getASTContext();
+
   if (!ast.VoidPtrTy) {
 LLDB_LOG(GetLog(LLDBLog::Expressions), "{0} failed: builtin types on 
ASTContext were not initialized properly.", __func__);
 return {};

>From caed9b07141176ab202d8c95bf0ffa4f59dce1d3 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 30 Sep 2024 11:16:31 +0100
Subject: [PATCH 3/5] fixup! clang-format

---
 .../Plugins/TypeSystem/Clang/TypeSystemClang.cpp| 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 9ba5d0a79445e8..02d6675ddc811e 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -709,7 +709,8 @@ void TypeSystemClang::CreateASTContext() {
 LLDB_LOG(GetLog(LLDBLog::Expressions), err.c_str());
 
 static std::once_flag s_uninitialized_target_warning;
-Debugger::ReportWarning(std::move(err), /*debugger_id=*/std::nullopt, 
&s_uninitialized_target_warning);
+Debugger::ReportWarning(std::move(err), /*debugger_id=*/std::nullopt,
+&s_uninitialized_target_warning);
   }
 
   GetASTMap().Insert(m_ast_up.get(), this);
@@ -761,7 +7

[Lldb-commits] [lldb] [lldb] Symlink Python binding to fully soversioned library (PR #110557)

2024-09-30 Thread Raul Tambre via lldb-commits

https://github.com/tambry created 
https://github.com/llvm/llvm-project/pull/110557

In Debian packaging the soversionless library is typically put into a -dev 
package and links to the current soversion things should be built against.  
This means that installing the bindings requires unnecessarily installing the 
-dev package in addition to the library package itself.  
There's no downside to linking to the full soversion since I don't think 
liblldb and the bindings are compatible across major versions anyway.

>From b2285e0bd808cc876e69061127c3bc5fb5066074 Mon Sep 17 00:00:00 2001
From: Raul Tambre 
Date: Mon, 30 Sep 2024 22:20:12 +0300
Subject: [PATCH] [lldb] Symlink Python binding to fully soversioned library

In Debian packaging the soversionless library is typically put into a -dev 
package and links to the current soversion things should be built against.
This means that installing the bindings requires unnecessarily installing the 
-dev package in addition to the library package itself.
There's no downside to linking to the full soversion since I don't think 
liblldb and the bindings are compatible across major versions anyway.
---
 lldb/bindings/python/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/bindings/python/CMakeLists.txt 
b/lldb/bindings/python/CMakeLists.txt
index 69306a384e0b1c..136cdba65b37f8 100644
--- a/lldb/bindings/python/CMakeLists.txt
+++ b/lldb/bindings/python/CMakeLists.txt
@@ -137,7 +137,7 @@ function(finish_swig_python swig_target 
lldb_python_bindings_dir lldb_python_tar
   if(LLDB_BUILD_FRAMEWORK)
 set(LIBLLDB_SYMLINK_DEST 
"${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/LLDB")
   else()
-set(LIBLLDB_SYMLINK_DEST 
"${LLVM_SHLIB_OUTPUT_INTDIR}/liblldb${CMAKE_SHARED_LIBRARY_SUFFIX}")
+set(LIBLLDB_SYMLINK_DEST 
"${LLVM_SHLIB_OUTPUT_INTDIR}/liblldb${CMAKE_SHARED_LIBRARY_SUFFIX}.${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
   endif()
   set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb${LLDB_PYTHON_EXT_SUFFIX}")
   create_relative_symlink(${swig_target} ${LIBLLDB_SYMLINK_DEST}

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


[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-09-30 Thread via lldb-commits

jimingham wrote:

That sounds entirely appropriate.

Jim


> On Sep 30, 2024, at 1:49 PM, Walter Erquinigo ***@***.***> wrote:
> 
> 
> @walter-erquinigo commented on this pull request.
> 
> In lldb/source/Core/Module.cpp 
> :
> 
> > @@ -797,6 +797,10 @@ void Module::LookupInfo::Prune(SymbolContextList 
> > &sc_list,
>  while (i < sc_list.GetSize()) {
>if (!sc_list.GetContextAtIndex(i, sc))
>  break;
> +  if (!lldb_private::Language::LanguageIsCFamily(sc.GetLanguage())) {
> What you say makes sense.
> @jimingham  , what about me moving the 
> implementation of this second part of the Prune method (line 790 onwards) to 
> Language plugins? I could then create the method
> SymbolLookupPruneHook(SymbolContextList &sc_list, size_t start_idx, 
> Module::LookupInfo &lookup_info, Module &module)
> 
> That would be very convenient because I could implement this in my own 
> language plugin for further refinements.
> 
> What do you think?
> 
> —
> Reply to this email directly, view it on GitHub 
> , or 
> unsubscribe 
> .
> You are receiving this because you were mentioned.
> 



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


[Lldb-commits] [libcxx] [lldb] [lldb][libc++] Hide all libc++ implementation details from stacktraces (PR #108870)

2024-09-30 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl approved this pull request.

The regexes look sane (and sufficiently restricted) to me, thanks!

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


[Lldb-commits] [lldb] [LLDB][Minidump] Fix bug where we were using the wrong collection for stacks in mmeory 32 (PR #110579)

2024-09-30 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jacob Lalonde (Jlalond)


Changes

In my prior two save core API's, I experimented on how to save stacks with the 
new API. I incorrectly left these in, as the existing `m_thread_by_range_end` 
was the correct choice.

I have removed the no-op collection, and moved to use the proper one. It's 
worth noting this was not caught by testing because we do not verify where the 
items are contained in the minidump. This would require a test being aware of 
how minidumps are structured, or adding a textual tool that we can then scan 
the output of.

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


2 Files Affected:

- (modified) lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
(+1-1) 
- (modified) lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h (-1) 


``diff
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index 3f1e25f730a184..f6c16b6e3d96ae 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -853,7 +853,7 @@ Status MinidumpFileBuilder::AddMemoryList() {
   uint64_t total_size = GetCurrentDataEndOffset();
   auto iterator = all_core_memory_vec.begin();
   while (iterator != all_core_memory_vec.end()) {
-if (m_saved_stack_ranges.count(iterator->range.start()) > 0) {
+if (m_thread_by_range_end.count(iterator->range.end()) > 0) {
   // We don't save stacks twice.
   ranges_32.push_back(*iterator);
   total_size +=
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
index d5eac9015ac422..a4240f871c8a2f 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
@@ -172,7 +172,6 @@ class MinidumpFileBuilder {
   // to duplicate it in the exception data.
   std::unordered_map
   m_tid_to_reg_ctx;
-  std::unordered_set m_saved_stack_ranges;
   lldb::FileUP m_core_file;
   lldb_private::SaveCoreOptions m_save_core_options;
 };

``




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


[Lldb-commits] [lldb] [LLDB][Minidump] Fix bug where we were using the wrong collection for stacks in mmeory 32 (PR #110579)

2024-09-30 Thread Jacob Lalonde via lldb-commits

https://github.com/Jlalond created 
https://github.com/llvm/llvm-project/pull/110579

In my prior two save core API's, I experimented on how to save stacks with the 
new API. I incorrectly left these in, as the existing `m_thread_by_range_end` 
was the correct choice.

I have removed the no-op collection, and moved to use the proper one. It's 
worth noting this was not caught by testing because we do not verify where the 
items are contained in the minidump. This would require a test being aware of 
how minidumps are structured, or adding a textual tool that we can then scan 
the output of.

>From eb75f72abac9c8f2bb5c7614a36cdea23da9066d Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Mon, 30 Sep 2024 14:38:14 -0700
Subject: [PATCH] Fix bug where we were using the wrong collection for stacks
 in mmeory 32

---
 lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp | 2 +-
 lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h   | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index 3f1e25f730a184..f6c16b6e3d96ae 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -853,7 +853,7 @@ Status MinidumpFileBuilder::AddMemoryList() {
   uint64_t total_size = GetCurrentDataEndOffset();
   auto iterator = all_core_memory_vec.begin();
   while (iterator != all_core_memory_vec.end()) {
-if (m_saved_stack_ranges.count(iterator->range.start()) > 0) {
+if (m_thread_by_range_end.count(iterator->range.end()) > 0) {
   // We don't save stacks twice.
   ranges_32.push_back(*iterator);
   total_size +=
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
index d5eac9015ac422..a4240f871c8a2f 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
@@ -172,7 +172,6 @@ class MinidumpFileBuilder {
   // to duplicate it in the exception data.
   std::unordered_map
   m_tid_to_reg_ctx;
-  std::unordered_set m_saved_stack_ranges;
   lldb::FileUP m_core_file;
   lldb_private::SaveCoreOptions m_save_core_options;
 };

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


[Lldb-commits] [lldb] [lldb][TypeSystemClang] Add warning and defensive checks when ASTContext is not fully initialized (PR #110481)

2024-09-30 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl approved this pull request.


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


[Lldb-commits] [lldb] Add warning message to `session save` when transcript isn't saved. (PR #109020)

2024-09-30 Thread Tom Yang via lldb-commits

https://github.com/zhyty updated 
https://github.com/llvm/llvm-project/pull/109020

>From 60045b710e1102d6f220dfd4367f997b73bb64df Mon Sep 17 00:00:00 2001
From: Tom Yang 
Date: Tue, 17 Sep 2024 09:56:09 -0700
Subject: [PATCH 1/2] Add warning message to `session save` when transcript
 isn't saved.

Somewhat recently, we made the change to hide the behavior to save LLDB
session history to the transcript buffer behind the flag
`interpreter.save-transcript`.
---
 lldb/source/Commands/CommandObjectSession.cpp |  3 +-
 .../source/Interpreter/CommandInterpreter.cpp |  2 ++
 .../Interpreter/InterpreterProperties.td  |  2 +-
 .../commands/session/save/TestSessionSave.py  | 29 +++
 4 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Commands/CommandObjectSession.cpp 
b/lldb/source/Commands/CommandObjectSession.cpp
index c381ba4f74f120..3f714cec414695 100644
--- a/lldb/source/Commands/CommandObjectSession.cpp
+++ b/lldb/source/Commands/CommandObjectSession.cpp
@@ -19,7 +19,8 @@ class CommandObjectSessionSave : public CommandObjectParsed {
   : CommandObjectParsed(interpreter, "session save",
 "Save the current session transcripts to a file.\n"
 "If no file if specified, transcripts will be "
-"saved to a temporary file.",
+"saved to a temporary file.\n"
+"Note: transcripts will only be saved if 
interpreter.save-transcript is true.\n",
 "session save [file]") {
 AddSimpleArgumentList(eArgTypePath, eArgRepeatOptional);
   }
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index b93f47a8a8d5ec..05426771ba0335 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -3306,6 +3306,8 @@ bool CommandInterpreter::SaveTranscript(
   result.SetStatus(eReturnStatusSuccessFinishNoResult);
   result.AppendMessageWithFormat("Session's transcripts saved to %s\n",
  output_file->c_str());
+  if (!GetSaveTranscript())
+result.AppendError("Note: the setting interpreter.save-transcript is set 
to false, so the transcript might not have been recorded.");
 
   if (GetOpenTranscriptInEditor() && Host::IsInteractiveGraphicSession()) {
 const FileSpec file_spec;
diff --git a/lldb/source/Interpreter/InterpreterProperties.td 
b/lldb/source/Interpreter/InterpreterProperties.td
index a5fccbbca091cf..834f7be17480c6 100644
--- a/lldb/source/Interpreter/InterpreterProperties.td
+++ b/lldb/source/Interpreter/InterpreterProperties.td
@@ -16,7 +16,7 @@ let Definition = "interpreter" in {
   def SaveSessionOnQuit: Property<"save-session-on-quit", "Boolean">,
 Global,
 DefaultFalse,
-Desc<"If true, LLDB will save the session's transcripts before quitting.">;
+Desc<"If true, LLDB will save the session's transcripts before quitting. 
Note: transcripts will only be saved if interpreter.save-transcript is true.">;
   def OpenTranscriptInEditor: Property<"open-transcript-in-editor", "Boolean">,
 Global,
 DefaultTrue,
diff --git a/lldb/test/API/commands/session/save/TestSessionSave.py 
b/lldb/test/API/commands/session/save/TestSessionSave.py
index aa99bcd56aed46..c81ff645d9d3b8 100644
--- a/lldb/test/API/commands/session/save/TestSessionSave.py
+++ b/lldb/test/API/commands/session/save/TestSessionSave.py
@@ -85,6 +85,8 @@ def test_session_save(self):
 interpreter.HandleCommand("session save", res)
 self.assertTrue(res.Succeeded())
 raw += self.raw_transcript_builder(cmd, res)
+# Also check that we don't print an error message about an empty 
transcript.
+self.assertNotIn("interpreter.save-transcript is set to false", 
res.GetError())
 
 with open(os.path.join(td.name, os.listdir(td.name)[0]), "r") as file:
 content = file.read()
@@ -93,6 +95,33 @@ def test_session_save(self):
 for line in lines:
 self.assertIn(line, content)
 
+@no_debug_info_test
+def test_session_save_no_transcript_warning(self):
+interpreter = self.dbg.GetCommandInterpreter()
+
+self.runCmd("settings set interpreter.save-transcript false")
+
+# These commands won't be saved, so are arbitrary.
+commands = [
+"p 1",
+"settings set interpreter.save-session-on-quit true",
+"fr v",
+"settings set interpreter.echo-comment-commands true",
+]
+
+for command in commands:
+res = lldb.SBCommandReturnObject()
+interpreter.HandleCommand(command, res)
+
+output_file = self.getBuildArtifact('my-session')
+
+res = lldb.SBCommandReturnObject()
+interpreter.HandleCommand("session save " + output_file, res)
+self.assertTrue(res.Succeeded())
+# We should war

[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-09-30 Thread Walter Erquinigo via lldb-commits


@@ -24,10 +24,10 @@
 using namespace lldb;
 using namespace lldb_private;
 
-BreakpointResolverName::BreakpointResolverName(const BreakpointSP &bkpt,

walter-erquinigo wrote:

Good catch, I didn't realize the formatter changes this file.

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


[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-09-30 Thread Walter Erquinigo via lldb-commits


@@ -797,6 +797,10 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
 while (i < sc_list.GetSize()) {
   if (!sc_list.GetContextAtIndex(i, sc))
 break;
+  if (!lldb_private::Language::LanguageIsCFamily(sc.GetLanguage())) {

walter-erquinigo wrote:

What you say makes sense.
@jimingham , what about me moving the implementation of this second part of the 
Prune method (line 790 onwards) to Language plugins? I could then create the 
method 
```SymbolLookupPruneHook(SymbolContextList &sc_list, size_t start_idx, 
Module::LookupInfo &lookup_info, Module &module)```

That would be very convenient because I could implement this in my own language 
plugin for further refinements.

What do you think?

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


[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-09-30 Thread via lldb-commits


@@ -24,10 +24,10 @@
 using namespace lldb;
 using namespace lldb_private;
 
-BreakpointResolverName::BreakpointResolverName(const BreakpointSP &bkpt,

jimingham wrote:

There are only reformattings in this file, unless I'm missing something.  Good 
to leave this sort of change out of patches that actually do something.

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


[Lldb-commits] [lldb] [lldb] Symlink Python binding to fully soversioned library (PR #110557)

2024-09-30 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Raul Tambre (tambry)


Changes

In Debian packaging the soversionless library is typically put into a -dev 
package and links to the current soversion things should be built against.  
This means that installing the bindings requires unnecessarily installing the 
-dev package in addition to the library package itself.  
There's no downside to linking to the full soversion since I don't think 
liblldb and the bindings are compatible across major versions anyway.

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


1 Files Affected:

- (modified) lldb/bindings/python/CMakeLists.txt (+1-1) 


``diff
diff --git a/lldb/bindings/python/CMakeLists.txt 
b/lldb/bindings/python/CMakeLists.txt
index 69306a384e0b1c..136cdba65b37f8 100644
--- a/lldb/bindings/python/CMakeLists.txt
+++ b/lldb/bindings/python/CMakeLists.txt
@@ -137,7 +137,7 @@ function(finish_swig_python swig_target 
lldb_python_bindings_dir lldb_python_tar
   if(LLDB_BUILD_FRAMEWORK)
 set(LIBLLDB_SYMLINK_DEST 
"${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/LLDB")
   else()
-set(LIBLLDB_SYMLINK_DEST 
"${LLVM_SHLIB_OUTPUT_INTDIR}/liblldb${CMAKE_SHARED_LIBRARY_SUFFIX}")
+set(LIBLLDB_SYMLINK_DEST 
"${LLVM_SHLIB_OUTPUT_INTDIR}/liblldb${CMAKE_SHARED_LIBRARY_SUFFIX}.${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
   endif()
   set(LIBLLDB_SYMLINK_OUTPUT_FILE "_lldb${LLDB_PYTHON_EXT_SUFFIX}")
   create_relative_symlink(${swig_target} ${LIBLLDB_SYMLINK_DEST}

``




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


[Lldb-commits] [lldb] [llvm] [LLDB][Minidump] Add breakpoint stop reasons to the minidump. (PR #108448)

2024-09-30 Thread Jacob Lalonde via lldb-commits

https://github.com/Jlalond updated 
https://github.com/llvm/llvm-project/pull/108448

>From d3137f697e130598b6ff7fa61b4cd098cb9e1b2a Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 12 Sep 2024 13:10:58 -0700
Subject: [PATCH 1/7] Create set for the stop reasons we collect, and add
 breakpoint to it.

---
 .../ObjectFile/Minidump/MinidumpFileBuilder.cpp | 13 +++--
 .../ObjectFile/Minidump/MinidumpFileBuilder.h   |  4 +++-
 2 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index 3f1e25f730a184..1f5c7c878904bb 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -75,8 +75,7 @@ Status 
MinidumpFileBuilder::AddHeaderAndCalculateDirectories() {
 StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
 if (stop_info_sp) {
   const StopReason &stop_reason = stop_info_sp->GetStopReason();
-  if (stop_reason == StopReason::eStopReasonException ||
-  stop_reason == StopReason::eStopReasonSignal)
+  if (m_thread_stop_reasons.count(stop_reason) > 0)
 m_expected_directories++;
 }
   }
@@ -686,16 +685,10 @@ Status MinidumpFileBuilder::AddExceptions() {
   for (const ThreadSP &thread_sp : thread_list) {
 StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
 bool add_exception = false;
-if (stop_info_sp) {
-  switch (stop_info_sp->GetStopReason()) {
-  case eStopReasonSignal:
-  case eStopReasonException:
+if (stop_info_sp && 
m_thread_stop_reasons.count(stop_info_sp->GetStopReason()) > 0) {
 add_exception = true;
-break;
-  default:
-break;
-  }
 }
+
 if (add_exception) {
   constexpr size_t minidump_exception_size =
   sizeof(llvm::minidump::ExceptionStream);
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
index d5eac9015ac422..cdfc704a5679d7 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
@@ -174,7 +174,9 @@ class MinidumpFileBuilder {
   m_tid_to_reg_ctx;
   std::unordered_set m_saved_stack_ranges;
   lldb::FileUP m_core_file;
-  lldb_private::SaveCoreOptions m_save_core_options;
+  lldb_private::SaveCoreOptions m_save_core_options; 
+  const std::unordered_set m_thread_stop_reasons = 
{lldb::StopReason::eStopReasonException, lldb::StopReason::eStopReasonSignal,
+  lldb::StopReason::eStopReasonBreakpoint };
 };
 
 #endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_MINIDUMP_MINIDUMPFILEBUILDER_H

>From 9bf0b14cc4aa66224fe8d3840e6700d3f04513f9 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 12 Sep 2024 13:30:04 -0700
Subject: [PATCH 2/7] Make const set with the stop reasons

---
 .../ObjectFile/Minidump/MinidumpFileBuilder.cpp   | 11 +--
 .../Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h |  4 +---
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
index 1f5c7c878904bb..34083959d33650 100644
--- a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
+++ b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
@@ -54,6 +54,13 @@ using namespace lldb;
 using namespace lldb_private;
 using namespace llvm::minidump;
 
+// Set of all the stop reasons minidumps will collect.
+const std::unordered_set 
MinidumpFileBuilder::thread_stop_reasons {
+  lldb::StopReason::eStopReasonException,
+  lldb::StopReason::eStopReasonSignal,
+  lldb::StopReason::eStopReasonBreakpoint,
+};
+
 Status MinidumpFileBuilder::AddHeaderAndCalculateDirectories() {
   // First set the offset on the file, and on the bytes saved
   m_saved_data_size = HEADER_SIZE;
@@ -75,7 +82,7 @@ Status 
MinidumpFileBuilder::AddHeaderAndCalculateDirectories() {
 StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
 if (stop_info_sp) {
   const StopReason &stop_reason = stop_info_sp->GetStopReason();
-  if (m_thread_stop_reasons.count(stop_reason) > 0)
+  if (thread_stop_reasons.count(stop_reason) > 0)
 m_expected_directories++;
 }
   }
@@ -685,7 +692,7 @@ Status MinidumpFileBuilder::AddExceptions() {
   for (const ThreadSP &thread_sp : thread_list) {
 StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
 bool add_exception = false;
-if (stop_info_sp && 
m_thread_stop_reasons.count(stop_info_sp->GetStopReason()) > 0) {
+if (stop_info_sp && 
thread_stop_reasons.count(stop_info_sp->GetStopReason()) > 0) {
 add_exception = true;
 }
 
diff --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
index cd

[Lldb-commits] [lldb] Add warning message to `session save` when transcript isn't saved. (PR #109020)

2024-09-30 Thread Tom Yang via lldb-commits

https://github.com/zhyty updated 
https://github.com/llvm/llvm-project/pull/109020

>From 60045b710e1102d6f220dfd4367f997b73bb64df Mon Sep 17 00:00:00 2001
From: Tom Yang 
Date: Tue, 17 Sep 2024 09:56:09 -0700
Subject: [PATCH 1/2] Add warning message to `session save` when transcript
 isn't saved.

Somewhat recently, we made the change to hide the behavior to save LLDB
session history to the transcript buffer behind the flag
`interpreter.save-transcript`.
---
 lldb/source/Commands/CommandObjectSession.cpp |  3 +-
 .../source/Interpreter/CommandInterpreter.cpp |  2 ++
 .../Interpreter/InterpreterProperties.td  |  2 +-
 .../commands/session/save/TestSessionSave.py  | 29 +++
 4 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Commands/CommandObjectSession.cpp 
b/lldb/source/Commands/CommandObjectSession.cpp
index c381ba4f74f120..3f714cec414695 100644
--- a/lldb/source/Commands/CommandObjectSession.cpp
+++ b/lldb/source/Commands/CommandObjectSession.cpp
@@ -19,7 +19,8 @@ class CommandObjectSessionSave : public CommandObjectParsed {
   : CommandObjectParsed(interpreter, "session save",
 "Save the current session transcripts to a file.\n"
 "If no file if specified, transcripts will be "
-"saved to a temporary file.",
+"saved to a temporary file.\n"
+"Note: transcripts will only be saved if 
interpreter.save-transcript is true.\n",
 "session save [file]") {
 AddSimpleArgumentList(eArgTypePath, eArgRepeatOptional);
   }
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp 
b/lldb/source/Interpreter/CommandInterpreter.cpp
index b93f47a8a8d5ec..05426771ba0335 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -3306,6 +3306,8 @@ bool CommandInterpreter::SaveTranscript(
   result.SetStatus(eReturnStatusSuccessFinishNoResult);
   result.AppendMessageWithFormat("Session's transcripts saved to %s\n",
  output_file->c_str());
+  if (!GetSaveTranscript())
+result.AppendError("Note: the setting interpreter.save-transcript is set 
to false, so the transcript might not have been recorded.");
 
   if (GetOpenTranscriptInEditor() && Host::IsInteractiveGraphicSession()) {
 const FileSpec file_spec;
diff --git a/lldb/source/Interpreter/InterpreterProperties.td 
b/lldb/source/Interpreter/InterpreterProperties.td
index a5fccbbca091cf..834f7be17480c6 100644
--- a/lldb/source/Interpreter/InterpreterProperties.td
+++ b/lldb/source/Interpreter/InterpreterProperties.td
@@ -16,7 +16,7 @@ let Definition = "interpreter" in {
   def SaveSessionOnQuit: Property<"save-session-on-quit", "Boolean">,
 Global,
 DefaultFalse,
-Desc<"If true, LLDB will save the session's transcripts before quitting.">;
+Desc<"If true, LLDB will save the session's transcripts before quitting. 
Note: transcripts will only be saved if interpreter.save-transcript is true.">;
   def OpenTranscriptInEditor: Property<"open-transcript-in-editor", "Boolean">,
 Global,
 DefaultTrue,
diff --git a/lldb/test/API/commands/session/save/TestSessionSave.py 
b/lldb/test/API/commands/session/save/TestSessionSave.py
index aa99bcd56aed46..c81ff645d9d3b8 100644
--- a/lldb/test/API/commands/session/save/TestSessionSave.py
+++ b/lldb/test/API/commands/session/save/TestSessionSave.py
@@ -85,6 +85,8 @@ def test_session_save(self):
 interpreter.HandleCommand("session save", res)
 self.assertTrue(res.Succeeded())
 raw += self.raw_transcript_builder(cmd, res)
+# Also check that we don't print an error message about an empty 
transcript.
+self.assertNotIn("interpreter.save-transcript is set to false", 
res.GetError())
 
 with open(os.path.join(td.name, os.listdir(td.name)[0]), "r") as file:
 content = file.read()
@@ -93,6 +95,33 @@ def test_session_save(self):
 for line in lines:
 self.assertIn(line, content)
 
+@no_debug_info_test
+def test_session_save_no_transcript_warning(self):
+interpreter = self.dbg.GetCommandInterpreter()
+
+self.runCmd("settings set interpreter.save-transcript false")
+
+# These commands won't be saved, so are arbitrary.
+commands = [
+"p 1",
+"settings set interpreter.save-session-on-quit true",
+"fr v",
+"settings set interpreter.echo-comment-commands true",
+]
+
+for command in commands:
+res = lldb.SBCommandReturnObject()
+interpreter.HandleCommand(command, res)
+
+output_file = self.getBuildArtifact('my-session')
+
+res = lldb.SBCommandReturnObject()
+interpreter.HandleCommand("session save " + output_file, res)
+self.assertTrue(res.Succeeded())
+# We should war

[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-09-30 Thread via lldb-commits


@@ -797,6 +797,10 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
 while (i < sc_list.GetSize()) {
   if (!sc_list.GetContextAtIndex(i, sc))
 break;
+  if (!lldb_private::Language::LanguageIsCFamily(sc.GetLanguage())) {

jimingham wrote:

This sort of code in generic parts of lldb is formally wrong, you shouldn't 
pretend to know that only C does something, you should ask the language plugin 
for the current context to do the job for you, and if it's a no-op, it should 
be that in the language plugin.

Of course, the code below this which you are circumventing ALSO doesn't belong 
in Module.cpp since it explicitly mentions CPlusPlusLanguage.

OTOH, maybe this should get a pass because you didn't cause the problem.  OTOH, 
given you're adding support for a new and enough different language that it 
trips up on these sorts of things, for your purposes, making sure these little 
tasks are properly factored out is of more importance, perhaps...

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


[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-09-30 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/110543

>From 15132008232d446036a43a8ed3eed5883f80a2d5 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 30 Sep 2024 13:33:35 -0400
Subject: [PATCH] [LLDB] Fix symbol breakpoint lookups for non-C-like languages

I'm developing the Mojo language, and some symbol breakpoints don't work 
because of two reasons that got fixed1:

- There's a prune step that operates on the assuption that the symbol is 
C-like. That was discarding lots of the Mojo breakpoints
- When finding functions for symbol breakpoints with eFunctionNameTypeFull, 
LLDB was only matching die.getMangledName() and not die.GetName(). The latter 
is the one useful for Mojo, because the former has some unreadable format in 
Mojo that is not exposed to the user. This shouldn't cause any regression for 
C-like languages, as the prune step would sanitize them anyway, but it's useful 
for languages like Mojo.
---
 lldb/include/lldb/Target/Language.h   | 16 
 lldb/source/Core/Module.cpp   | 32 ++--
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  | 38 +++
 .../Language/CPlusPlus/CPlusPlusLanguage.h|  3 ++
 .../Plugins/SymbolFile/DWARF/DWARFIndex.cpp   |  3 +-
 5 files changed, 63 insertions(+), 29 deletions(-)

diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index 41d8eeef469eab..f44f9fc08e7970 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -16,6 +16,7 @@
 #include 
 
 #include "lldb/Core/Highlighter.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/DataFormatters/DumpValueObjectOptions.h"
 #include "lldb/DataFormatters/FormatClasses.h"
@@ -379,6 +380,21 @@ class Language : public PluginInterface {
   /// Python uses \b except. Defaults to \b catch.
   virtual llvm::StringRef GetCatchKeyword() const { return "catch"; }
 
+  /// Method invoked by \a Module::LookupInfo::Prune used to filter out symbol
+  /// search results.
+  ///
+  /// \param[in] sc A symbol that passed the common symbol search lookup
+  ///   process.
+  /// \param[in] lookup_info The full lookup info.
+  ///
+  /// \return whether the given symbol should be discarded from the search
+  /// results.
+  virtual bool
+  SymbolLookupHookShouldPruneResult(const SymbolContext &sc,
+const Module::LookupInfo &lookup_info) {
+return false;
+  }
+
 protected:
   // Classes that inherit from Language can see and modify these
 
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 88cc957e91fac4..0cc21c61a3dfa7 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -787,40 +787,16 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
 }
   }
 
-  // If we have only full name matches we might have tried to set breakpoint on
-  // "func" and specified eFunctionNameTypeFull, but we might have found
-  // "a::func()", "a::b::func()", "c::func()", "func()" and "func". Only
-  // "func()" and "func" should end up matching.
   if (m_name_type_mask == eFunctionNameTypeFull) {
 SymbolContext sc;
 size_t i = start_idx;
 while (i < sc_list.GetSize()) {
   if (!sc_list.GetContextAtIndex(i, sc))
 break;
-  // Make sure the mangled and demangled names don't match before we try to
-  // pull anything out
-  ConstString mangled_name(sc.GetFunctionName(Mangled::ePreferMangled));
-  ConstString full_name(sc.GetFunctionName());
-  if (mangled_name != m_name && full_name != m_name) {
-CPlusPlusLanguage::MethodName cpp_method(full_name);
-if (cpp_method.IsValid()) {
-  if (cpp_method.GetContext().empty()) {
-if (cpp_method.GetBasename().compare(m_name) != 0) {
-  sc_list.RemoveContextAtIndex(i);
-  continue;
-}
-  } else {
-std::string qualified_name;
-llvm::StringRef anon_prefix("(anonymous namespace)");
-if (cpp_method.GetContext() == anon_prefix)
-  qualified_name = cpp_method.GetBasename().str();
-else
-  qualified_name = cpp_method.GetScopeQualifiedName();
-if (qualified_name != m_name.GetCString()) {
-  sc_list.RemoveContextAtIndex(i);
-  continue;
-}
-  }
+  if (Language *languagePlugin = Language::FindPlugin(sc.GetLanguage())) {
+if (languagePlugin->SymbolLookupHookShouldPruneResult(sc, *this)) {
+  sc_list.RemoveContextAtIndex(i);
+  continue;
 }
   }
   ++i;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 06c827c2543f40..c2b07bdc3a3c65 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/C

[Lldb-commits] [lldb] [LLDB][Minidump] Fix bug where we were using the wrong collection for thread stacks (PR #110579)

2024-09-30 Thread Jacob Lalonde via lldb-commits

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


[Lldb-commits] [lldb] [LLDB][Minidump] Fix bug where we were using the wrong collection for stacks (PR #110579)

2024-09-30 Thread Jacob Lalonde via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-09-30 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/110543

>From dcc5c787a7c146942fed66da5df01ef5a4401744 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 30 Sep 2024 13:33:35 -0400
Subject: [PATCH] [LLDB] Fix symbol breakpoint lookups for non-C-like languages

I'm developing the Mojo language, and some symbol breakpoints don't work 
because of two reasons that got fixed1:

- There's a prune step that operates on the assuption that the symbol is 
C-like. That was discarding lots of the Mojo breakpoints
- When finding functions for symbol breakpoints with eFunctionNameTypeFull, 
LLDB was only matching die.getMangledName() and not die.GetName(). The latter 
is the one useful for Mojo, because the former has some unreadable format in 
Mojo that is not exposed to the user. This shouldn't cause any regression for 
C-like languages, as the prune step would sanitize them anyway, but it's useful 
for languages like Mojo.
---
 lldb/include/lldb/Target/Language.h   |  7 
 lldb/source/Core/Module.cpp   | 32 ++--
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  | 38 +++
 .../Language/CPlusPlus/CPlusPlusLanguage.h|  3 ++
 .../Plugins/SymbolFile/DWARF/DWARFIndex.cpp   |  3 +-
 5 files changed, 54 insertions(+), 29 deletions(-)

diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index 41d8eeef469eab..c815a073a5228f 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -16,6 +16,7 @@
 #include 
 
 #include "lldb/Core/Highlighter.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/DataFormatters/DumpValueObjectOptions.h"
 #include "lldb/DataFormatters/FormatClasses.h"
@@ -379,6 +380,12 @@ class Language : public PluginInterface {
   /// Python uses \b except. Defaults to \b catch.
   virtual llvm::StringRef GetCatchKeyword() const { return "catch"; }
 
+  virtual bool
+  SymbolLookupHookShouldPruneResult(const SymbolContext &sc,
+const Module::LookupInfo &lookup_info) {
+return false;
+  }
+
 protected:
   // Classes that inherit from Language can see and modify these
 
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 88cc957e91fac4..0cc21c61a3dfa7 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -787,40 +787,16 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
 }
   }
 
-  // If we have only full name matches we might have tried to set breakpoint on
-  // "func" and specified eFunctionNameTypeFull, but we might have found
-  // "a::func()", "a::b::func()", "c::func()", "func()" and "func". Only
-  // "func()" and "func" should end up matching.
   if (m_name_type_mask == eFunctionNameTypeFull) {
 SymbolContext sc;
 size_t i = start_idx;
 while (i < sc_list.GetSize()) {
   if (!sc_list.GetContextAtIndex(i, sc))
 break;
-  // Make sure the mangled and demangled names don't match before we try to
-  // pull anything out
-  ConstString mangled_name(sc.GetFunctionName(Mangled::ePreferMangled));
-  ConstString full_name(sc.GetFunctionName());
-  if (mangled_name != m_name && full_name != m_name) {
-CPlusPlusLanguage::MethodName cpp_method(full_name);
-if (cpp_method.IsValid()) {
-  if (cpp_method.GetContext().empty()) {
-if (cpp_method.GetBasename().compare(m_name) != 0) {
-  sc_list.RemoveContextAtIndex(i);
-  continue;
-}
-  } else {
-std::string qualified_name;
-llvm::StringRef anon_prefix("(anonymous namespace)");
-if (cpp_method.GetContext() == anon_prefix)
-  qualified_name = cpp_method.GetBasename().str();
-else
-  qualified_name = cpp_method.GetScopeQualifiedName();
-if (qualified_name != m_name.GetCString()) {
-  sc_list.RemoveContextAtIndex(i);
-  continue;
-}
-  }
+  if (Language *languagePlugin = Language::FindPlugin(sc.GetLanguage())) {
+if (languagePlugin->SymbolLookupHookShouldPruneResult(sc, *this)) {
+  sc_list.RemoveContextAtIndex(i);
+  continue;
 }
   }
   ++i;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 06c827c2543f40..c2b07bdc3a3c65 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1759,3 +1759,41 @@ bool CPlusPlusLanguage::GetFunctionDisplayName(
 
   return false;
 }
+
+bool CPlusPlusLanguage::SymbolLookupHookShouldPruneResult(
+const SymbolContext &sc, const Module::LookupInfo &lookup_info) {
+  // If we have only full name matches we might have tried to set breakpoint on
+  // "func" and sp

[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-09-30 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/110543

>From d3aa6a3726224c51dc838dd72fef40e9520fd8de Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 30 Sep 2024 13:33:35 -0400
Subject: [PATCH] [LLDB] Fix symbol breakpoint lookups for non-C-like languages

I'm developing the Mojo language, and some symbol breakpoints don't work 
because of two reasons that got fixed1:

- There's a prune step that operates on the assuption that the symbol is 
C-like. That was discarding lots of the Mojo breakpoints
- When finding functions for symbol breakpoints with eFunctionNameTypeFull, 
LLDB was only matching die.getMangledName() and not die.GetName(). The latter 
is the one useful for Mojo, because the former has some unreadable format in 
Mojo that is not exposed to the user. This shouldn't cause any regression for 
C-like languages, as the prune step would sanitize them anyway, but it's useful 
for languages like Mojo.
---
 lldb/include/lldb/Target/Language.h   | 12 ++
 lldb/source/Core/Module.cpp   | 32 ++--
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  | 38 +++
 .../Language/CPlusPlus/CPlusPlusLanguage.h|  3 ++
 .../Plugins/SymbolFile/DWARF/DWARFIndex.cpp   |  3 +-
 5 files changed, 59 insertions(+), 29 deletions(-)

diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index 41d8eeef469eab..84640bb21221f8 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -16,6 +16,7 @@
 #include 
 
 #include "lldb/Core/Highlighter.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/DataFormatters/DumpValueObjectOptions.h"
 #include "lldb/DataFormatters/FormatClasses.h"
@@ -379,6 +380,17 @@ class Language : public PluginInterface {
   /// Python uses \b except. Defaults to \b catch.
   virtual llvm::StringRef GetCatchKeyword() const { return "catch"; }
 
+  /// Method invoked by \a Module::LookupInfo::Prune used to filter out symbol
+  /// search results.
+  ///
+  /// \return whether the given symbol should be discarded from the search
+  /// returns.
+  virtual bool
+  SymbolLookupHookShouldPruneResult(const SymbolContext &sc,
+const Module::LookupInfo &lookup_info) {
+return false;
+  }
+
 protected:
   // Classes that inherit from Language can see and modify these
 
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 88cc957e91fac4..0cc21c61a3dfa7 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -787,40 +787,16 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
 }
   }
 
-  // If we have only full name matches we might have tried to set breakpoint on
-  // "func" and specified eFunctionNameTypeFull, but we might have found
-  // "a::func()", "a::b::func()", "c::func()", "func()" and "func". Only
-  // "func()" and "func" should end up matching.
   if (m_name_type_mask == eFunctionNameTypeFull) {
 SymbolContext sc;
 size_t i = start_idx;
 while (i < sc_list.GetSize()) {
   if (!sc_list.GetContextAtIndex(i, sc))
 break;
-  // Make sure the mangled and demangled names don't match before we try to
-  // pull anything out
-  ConstString mangled_name(sc.GetFunctionName(Mangled::ePreferMangled));
-  ConstString full_name(sc.GetFunctionName());
-  if (mangled_name != m_name && full_name != m_name) {
-CPlusPlusLanguage::MethodName cpp_method(full_name);
-if (cpp_method.IsValid()) {
-  if (cpp_method.GetContext().empty()) {
-if (cpp_method.GetBasename().compare(m_name) != 0) {
-  sc_list.RemoveContextAtIndex(i);
-  continue;
-}
-  } else {
-std::string qualified_name;
-llvm::StringRef anon_prefix("(anonymous namespace)");
-if (cpp_method.GetContext() == anon_prefix)
-  qualified_name = cpp_method.GetBasename().str();
-else
-  qualified_name = cpp_method.GetScopeQualifiedName();
-if (qualified_name != m_name.GetCString()) {
-  sc_list.RemoveContextAtIndex(i);
-  continue;
-}
-  }
+  if (Language *languagePlugin = Language::FindPlugin(sc.GetLanguage())) {
+if (languagePlugin->SymbolLookupHookShouldPruneResult(sc, *this)) {
+  sc_list.RemoveContextAtIndex(i);
+  continue;
 }
   }
   ++i;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 06c827c2543f40..c2b07bdc3a3c65 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1759,3 +1759,41 @@ bool CPlusPlusLanguage::GetFunctionDisplayName(
 
   return false;
 }
+
+bool CPlusPlusLanguage::Sy

[Lldb-commits] [lldb] [LLDB] Fix symbol breakpoint lookups for non-C-like languages (PR #110543)

2024-09-30 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/110543

>From f1088d6f159363086cb040783106ebf18130f645 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Mon, 30 Sep 2024 13:33:35 -0400
Subject: [PATCH] [LLDB] Fix symbol breakpoint lookups for non-C-like languages

I'm developing the Mojo language, and some symbol breakpoints don't work 
because of two reasons that got fixed1:

- There's a prune step that operates on the assuption that the symbol is 
C-like. That was discarding lots of the Mojo breakpoints
- When finding functions for symbol breakpoints with eFunctionNameTypeFull, 
LLDB was only matching die.getMangledName() and not die.GetName(). The latter 
is the one useful for Mojo, because the former has some unreadable format in 
Mojo that is not exposed to the user. This shouldn't cause any regression for 
C-like languages, as the prune step would sanitize them anyway, but it's useful 
for languages like Mojo.
---
 lldb/include/lldb/Target/Language.h   | 16 
 lldb/source/Core/Module.cpp   | 32 ++--
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  | 38 +++
 .../Language/CPlusPlus/CPlusPlusLanguage.h|  3 ++
 .../Plugins/SymbolFile/DWARF/DWARFIndex.cpp   |  3 +-
 5 files changed, 63 insertions(+), 29 deletions(-)

diff --git a/lldb/include/lldb/Target/Language.h 
b/lldb/include/lldb/Target/Language.h
index 41d8eeef469eab..f44f9fc08e7970 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -16,6 +16,7 @@
 #include 
 
 #include "lldb/Core/Highlighter.h"
+#include "lldb/Core/Module.h"
 #include "lldb/Core/PluginInterface.h"
 #include "lldb/DataFormatters/DumpValueObjectOptions.h"
 #include "lldb/DataFormatters/FormatClasses.h"
@@ -379,6 +380,21 @@ class Language : public PluginInterface {
   /// Python uses \b except. Defaults to \b catch.
   virtual llvm::StringRef GetCatchKeyword() const { return "catch"; }
 
+  /// Method invoked by \a Module::LookupInfo::Prune used to filter out symbol
+  /// search results.
+  ///
+  /// \param[in] sc A symbol that passed the common symbol search lookup
+  ///   process.
+  /// \param[in] lookup_info The full lookup info.
+  ///
+  /// \return whether the given symbol should be discarded from the search
+  /// results.
+  virtual bool
+  SymbolLookupHookShouldPruneResult(const SymbolContext &sc,
+const Module::LookupInfo &lookup_info) {
+return false;
+  }
+
 protected:
   // Classes that inherit from Language can see and modify these
 
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 88cc957e91fac4..0cc21c61a3dfa7 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -787,40 +787,16 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
 }
   }
 
-  // If we have only full name matches we might have tried to set breakpoint on
-  // "func" and specified eFunctionNameTypeFull, but we might have found
-  // "a::func()", "a::b::func()", "c::func()", "func()" and "func". Only
-  // "func()" and "func" should end up matching.
   if (m_name_type_mask == eFunctionNameTypeFull) {
 SymbolContext sc;
 size_t i = start_idx;
 while (i < sc_list.GetSize()) {
   if (!sc_list.GetContextAtIndex(i, sc))
 break;
-  // Make sure the mangled and demangled names don't match before we try to
-  // pull anything out
-  ConstString mangled_name(sc.GetFunctionName(Mangled::ePreferMangled));
-  ConstString full_name(sc.GetFunctionName());
-  if (mangled_name != m_name && full_name != m_name) {
-CPlusPlusLanguage::MethodName cpp_method(full_name);
-if (cpp_method.IsValid()) {
-  if (cpp_method.GetContext().empty()) {
-if (cpp_method.GetBasename().compare(m_name) != 0) {
-  sc_list.RemoveContextAtIndex(i);
-  continue;
-}
-  } else {
-std::string qualified_name;
-llvm::StringRef anon_prefix("(anonymous namespace)");
-if (cpp_method.GetContext() == anon_prefix)
-  qualified_name = cpp_method.GetBasename().str();
-else
-  qualified_name = cpp_method.GetScopeQualifiedName();
-if (qualified_name != m_name.GetCString()) {
-  sc_list.RemoveContextAtIndex(i);
-  continue;
-}
-  }
+  if (Language *languagePlugin = Language::FindPlugin(sc.GetLanguage())) {
+if (languagePlugin->SymbolLookupHookShouldPruneResult(sc, *this)) {
+  sc_list.RemoveContextAtIndex(i);
+  continue;
 }
   }
   ++i;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 06c827c2543f40..a9fc0cb0f2d911 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/C