[Lldb-commits] [lldb] [lldb][ClangExpressionParser] Reset DiagnosticManager before we creat… (PR #160074)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/160074 …e persistent variables Here's an example crash that we've seen sporadically over the years: ``` 0 libsystem_kernel.dylib 0x19d392388 __pthread_kill + 8 1 libsystem_pthread.dylib0x19d3cb88c pthread_kill + 296 2 libsystem_c.dylib 0x19d29cd04 raise + 32 3 LLDB 0x112cbbc94 SignalHandler(int, __siginfo*, void*) + 324 4 libsystem_platform.dylib 0x19d4056a4 _sigtramp + 56 5 LLDB 0x110dcbd38 clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) + 1216 6 LLDB 0x110dcbd38 clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) + 1216 7 LLDB 0x10de12128 ClangDiagnosticManagerAdapter::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) + 332 8 LLDB 0x1121eb3dc clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const + 200 9 LLDB 0x1121e67a0 clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) + 100 10 LLDB 0x111d766cc IsStructurallyEquivalent(clang::StructuralEquivalenceContext&, clang::FieldDecl*, clang::FieldDecl*, clang::QualType) + 1568 11 LLDB 0x111d71b54 IsStructurallyEquivalent(clang::StructuralEquivalenceContext&, clang::RecordDecl*, clang::RecordDecl*) + 2076 12 LLDB 0x111d6e448 clang::StructuralEquivalenceContext::Finish() + 204 13 LLDB 0x111d6e1e0 clang::StructuralEquivalenceContext::IsEquivalent(clang::Decl*, clang::Decl*) + 32 14 LLDB 0x111d3b788 clang::ASTNodeImporter::IsStructuralMatch(clang::Decl*, clang::Decl*, bool, bool) + 168 15 LLDB 0x111d404e0 clang::ASTNodeImporter::VisitFunctionDecl(clang::FunctionDecl*) + 1300 16 LLDB 0x111d5cae0 clang::ASTImporter::ImportImpl(clang::Decl*) + 24 17 LLDB 0x10ddf30bc lldb_private::ClangASTImporter::ASTImporterDelegate::ImportImpl(clang::Decl*) + 308 18 LLDB 0x111d48140 clang::ASTImporter::Import(clang::Decl*) + 984 19 LLDB 0x10ddee9dc lldb_private::ClangASTImporter::CopyDecl(clang::ASTContext*, clang::Decl*) + 100 20 LLDB 0x10ddfab40 lldb_private::ClangASTSource::FindExternalLexicalDecls(clang::DeclContext const*, llvm::function_ref, llvm::SmallVectorImpl&) + 1692 21 LLDB 0x111e1cb84 clang::DeclContext::LoadLexicalDeclsFromExternalStorage() const + 180 22 LLDB 0x111e1df50 clang::DeclContext::buildLookup() + 204 23 LLDB 0x111e1dcf4 clang::DeclContext::makeDeclVisibleInContextWithFlags(clang::NamedDecl*, bool, bool) + 504 24 LLDB 0x111d3b01c clang::ASTNodeImporter::ImportDeclContext(clang::DeclContext*, bool) + 724 25 LLDB 0x111d62d10 clang::ASTImporter::ImportDefinition(clang::Decl*) + 428 26 LLDB 0x10ddf1cb0 lldb_private::ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo(clang::Decl*, clang::Decl*) + 524 27 LLDB 0x10ddef3c8 (anonymous namespace)::CompleteTagDeclsScope::~CompleteTagDeclsScope() + 616 28 LLDB 0x10ddef6dc lldb_private::ClangASTImporter::DeportDecl(clang::ASTContext*, clang::Decl*) + 436 29 LLDB 0x10ddec3dc lldb_private::ASTResultSynthesizer::CommitPersistentDecls() + 236 30 LLDB 0x10de1091c lldb_private::ClangExpressionParser::ParseInternal(lldb_private::DiagnosticManager&, clang::CodeCompleteConsumer*, unsigned int, unsigned int) + 2292 31 LLDB 0x10de21238 lldb_private::ClangUserExpression::TryParse(lldb_private::DiagnosticManager&, lldb_private::ExecutionContext&, lldb_private::ExecutionPolicy, bool, bool) + 328 ... ``` Here `ASTImporter::IsStructurallyEquivalent` is trying to emit a diagnostic using `ClangExpressionParser`'s `ClangDiagnosticManagerAdapter`. But `TextDiagnosticPrinter::TextDiag` seems to be `nullptr`. This can only happen when we call `HandleDiagnostic` on `ClangDiagnosticManagerAdapter` after we called `EndSourceFile`. Specifically, it looks like when moving a type from `Expression
[Lldb-commits] [lldb] [LLDB][PDB] Warn if DIA plugin is requested but not available (PR #160067)
@@ -117,11 +117,16 @@ bool ShouldUseNativeReaderByDefault() {
!env_value.equals_insensitive("1") &&
!env_value.equals_insensitive("true"))
g_use_native_by_default = false;
+
+#if !LLVM_ENABLE_DIA_SDK || !defined(_WIN32)
+// if the environment value is unset, the native reader is requested
+if (env_value.empty())
+ g_use_native_by_default = true;
+#endif
Michael137 wrote:
I think this function would be clearer if we rewrote it using an
immediately-invoked-lambda:
```
static bool g_use_native_by_default = [] {
llvm::StringRef env_value = ::getenv("LLDB_USE_NATIVE_PDB_READER");
#if !LLVM_ENABLE_DIA_SDK || !defined(_WIN32)
// if the environment value is unset, the native reader is requested
if (env_value.empty())
return true;
#endif
...
}();
```
https://github.com/llvm/llvm-project/pull/160067
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix a bug where an error was emitted for GCC union types. (PR #159401)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/159401 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ClangExpressionParser] Reset DiagnosticManager before we create persistent variables (PR #160074)
https://github.com/adrian-prantl approved this pull request. https://github.com/llvm/llvm-project/pull/160074 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ClangExpressionParser] Reset DiagnosticManager before we create persistent variables (PR #160074)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/160074 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] cbfa5c8 - [lldb][ClangExpressionParser] Reset DiagnosticManager before we create persistent variables (#160074)
Author: Michael Buch Date: 2025-09-22T17:24:15+01:00 New Revision: cbfa5c84f9423b94d499de7995c0f0eeff066c93 URL: https://github.com/llvm/llvm-project/commit/cbfa5c84f9423b94d499de7995c0f0eeff066c93 DIFF: https://github.com/llvm/llvm-project/commit/cbfa5c84f9423b94d499de7995c0f0eeff066c93.diff LOG: [lldb][ClangExpressionParser] Reset DiagnosticManager before we create persistent variables (#160074) Here's an example crash that we've seen sporadically over the years: ``` 0 libsystem_kernel.dylib 0x19d392388 __pthread_kill + 8 1 libsystem_pthread.dylib0x19d3cb88c pthread_kill + 296 2 libsystem_c.dylib 0x19d29cd04 raise + 32 3 LLDB 0x112cbbc94 SignalHandler(int, __siginfo*, void*) + 324 4 libsystem_platform.dylib 0x19d4056a4 _sigtramp + 56 5 LLDB 0x110dcbd38 clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) + 1216 6 LLDB 0x110dcbd38 clang::TextDiagnosticPrinter::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) + 1216 7 LLDB 0x10de12128 ClangDiagnosticManagerAdapter::HandleDiagnostic(clang::DiagnosticsEngine::Level, clang::Diagnostic const&) + 332 8 LLDB 0x1121eb3dc clang::DiagnosticIDs::ProcessDiag(clang::DiagnosticsEngine&) const + 200 9 LLDB 0x1121e67a0 clang::DiagnosticsEngine::EmitCurrentDiagnostic(bool) + 100 10 LLDB 0x111d766cc IsStructurallyEquivalent(clang::StructuralEquivalenceContext&, clang::FieldDecl*, clang::FieldDecl*, clang::QualType) + 1568 11 LLDB 0x111d71b54 IsStructurallyEquivalent(clang::StructuralEquivalenceContext&, clang::RecordDecl*, clang::RecordDecl*) + 2076 12 LLDB 0x111d6e448 clang::StructuralEquivalenceContext::Finish() + 204 13 LLDB 0x111d6e1e0 clang::StructuralEquivalenceContext::IsEquivalent(clang::Decl*, clang::Decl*) + 32 14 LLDB 0x111d3b788 clang::ASTNodeImporter::IsStructuralMatch(clang::Decl*, clang::Decl*, bool, bool) + 168 15 LLDB 0x111d404e0 clang::ASTNodeImporter::VisitFunctionDecl(clang::FunctionDecl*) + 1300 16 LLDB 0x111d5cae0 clang::ASTImporter::ImportImpl(clang::Decl*) + 24 17 LLDB 0x10ddf30bc lldb_private::ClangASTImporter::ASTImporterDelegate::ImportImpl(clang::Decl*) + 308 18 LLDB 0x111d48140 clang::ASTImporter::Import(clang::Decl*) + 984 19 LLDB 0x10ddee9dc lldb_private::ClangASTImporter::CopyDecl(clang::ASTContext*, clang::Decl*) + 100 20 LLDB 0x10ddfab40 lldb_private::ClangASTSource::FindExternalLexicalDecls(clang::DeclContext const*, llvm::function_ref, llvm::SmallVectorImpl&) + 1692 21 LLDB 0x111e1cb84 clang::DeclContext::LoadLexicalDeclsFromExternalStorage() const + 180 22 LLDB 0x111e1df50 clang::DeclContext::buildLookup() + 204 23 LLDB 0x111e1dcf4 clang::DeclContext::makeDeclVisibleInContextWithFlags(clang::NamedDecl*, bool, bool) + 504 24 LLDB 0x111d3b01c clang::ASTNodeImporter::ImportDeclContext(clang::DeclContext*, bool) + 724 25 LLDB 0x111d62d10 clang::ASTImporter::ImportDefinition(clang::Decl*) + 428 26 LLDB 0x10ddf1cb0 lldb_private::ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo(clang::Decl*, clang::Decl*) + 524 27 LLDB 0x10ddef3c8 (anonymous namespace)::CompleteTagDeclsScope::~CompleteTagDeclsScope() + 616 28 LLDB 0x10ddef6dc lldb_private::ClangASTImporter::DeportDecl(clang::ASTContext*, clang::Decl*) + 436 29 LLDB 0x10ddec3dc lldb_private::ASTResultSynthesizer::CommitPersistentDecls() + 236 30 LLDB 0x10de1091c lldb_private::ClangExpressionParser::ParseInternal(lldb_private::DiagnosticManager&, clang::CodeCompleteConsumer*, unsigned int, unsigned int) + 2292 31 LLDB 0x10de21238 lldb_private::ClangUserExpression::TryParse(lldb_private::DiagnosticManager&, lldb_private::ExecutionContext&, lldb_private::ExecutionPolicy, bool, bool) + 328 ... ``` Here `ASTImporter::IsStructurallyEquivalent` is trying to emit a diagnostic using `ClangExpression
[Lldb-commits] [lldb] [LLDB][PDB] Warn if DIA plugin is requested but not available (PR #160067)
@@ -0,0 +1,65 @@ +// REQUIRES: !diasdk, target-windows + +// Test plugin.symbol-file.pdb.reader setting without the DIA SDK +// RUN: %build -o %t.exe -- %s +// RUN: env -u LLDB_USE_NATIVE_PDB_READER %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=NO-ENV %s +// RUN: env LLDB_USE_NATIVE_PDB_READER= %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=NO-ENV %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s +// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV1 %s Michael137 wrote: Can we add tests for setting the variable to something bogus like `foo`? And some number other than `1`? https://github.com/llvm/llvm-project/pull/160067 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][PDB] Warn if DIA plugin is requested but not available (PR #160067)
@@ -136,6 +141,21 @@ class PluginProperties : public Properties {
bool UseNativeReader() const {
#if LLVM_ENABLE_DIA_SDK && defined(_WIN32)
+return IsNativeReaderRequested();
+#else
+if (!IsNativeReaderRequested()) {
+ static std::once_flag g_warning_shown;
+ Debugger::ReportWarning(
Michael137 wrote:
> DIA PDB reader was explicitly requested
This holds because `IsNativeReaderRequested` will only return `false` when a
user specified `LLDB_USE_NATIVE_PDB_READER` to be any non-empty string other
than `on`/`yes`/`1`/`true`, right?
https://github.com/llvm/llvm-project/pull/160067
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][PDB] Warn if DIA plugin is requested but not available (PR #160067)
https://github.com/Nerixyz created
https://github.com/llvm/llvm-project/pull/160067
If LLDB was built without the DIA SDK and the DIA reader is explicitly
requested (through `LLDB_USE_NATIVE_PDB_READER=0` or `settings set
plugin.symbol-file.pdb.reader dia`), LLDB should print a warning, because it
will use the native reader in any case
(https://github.com/llvm/llvm-project/pull/159769#discussion_r2367316980).
This PR adds the warning and a test when LLDB is not built with the SDK on
Windows. I don't think any builder runs this configuration, as there are still
five failing tests. I tested this locally with and without the SDK.
>From 4dab54fd1d003e99ac0b1014b276f0c6d24f9de2 Mon Sep 17 00:00:00 2001
From: Nerixyz
Date: Mon, 22 Sep 2025 12:32:08 +0200
Subject: [PATCH] [LLDB][PDB] Warn if DIA plugin is requested but not available
---
.../Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | 27 ++--
.../SymbolFile/NativePDB/native-setting.cpp | 65 +++
.../Shell/SymbolFile/PDB/native-setting.cpp | 25 +--
3 files changed, 106 insertions(+), 11 deletions(-)
create mode 100644 lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp
diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index 0e2ca1784e7e9..68e229b697116 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -14,6 +14,7 @@
#include "clang/Lex/Lexer.h"
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "lldb/Core/Debugger.h"
#include "lldb/Core/Mangled.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
@@ -105,7 +106,6 @@ enum {
#include "SymbolFilePDBPropertiesEnum.inc"
};
-#if LLVM_ENABLE_DIA_SDK && defined(_WIN32)
bool ShouldUseNativeReaderByDefault() {
static bool g_use_native_by_default = true;
@@ -117,11 +117,16 @@ bool ShouldUseNativeReaderByDefault() {
!env_value.equals_insensitive("1") &&
!env_value.equals_insensitive("true"))
g_use_native_by_default = false;
+
+#if !LLVM_ENABLE_DIA_SDK || !defined(_WIN32)
+// if the environment value is unset, the native reader is requested
+if (env_value.empty())
+ g_use_native_by_default = true;
+#endif
});
return g_use_native_by_default;
}
-#endif
class PluginProperties : public Properties {
public:
@@ -136,6 +141,21 @@ class PluginProperties : public Properties {
bool UseNativeReader() const {
#if LLVM_ENABLE_DIA_SDK && defined(_WIN32)
+return IsNativeReaderRequested();
+#else
+if (!IsNativeReaderRequested()) {
+ static std::once_flag g_warning_shown;
+ Debugger::ReportWarning(
+ "The DIA PDB reader was explicitly requested, but LLDB was built "
+ "without the DIA SDK. The native reader will be used instead.",
+ {}, &g_warning_shown);
+}
+return true;
+#endif
+ }
+
+private:
+ bool IsNativeReaderRequested() const {
auto value =
GetPropertyAtIndexAs(ePropertyReader, ePDBReaderDefault);
switch (value) {
@@ -147,9 +167,6 @@ class PluginProperties : public Properties {
case ePDBReaderDefault:
return ShouldUseNativeReaderByDefault();
}
-#else
-return true;
-#endif
}
};
diff --git a/lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp
b/lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp
new file mode 100644
index 0..fc0ee218dd0d2
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp
@@ -0,0 +1,65 @@
+// REQUIRES: !diasdk, target-windows
+
+// Test plugin.symbol-file.pdb.reader setting without the DIA SDK
+// RUN: %build -o %t.exe -- %s
+// RUN: env -u LLDB_USE_NATIVE_PDB_READER %lldb %t.exe -o 'target modules dump
symfile' 2>&1 | FileCheck --check-prefix=NO-ENV %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER= %lldb %t.exe -o 'target modules dump
symfile' 2>&1 | FileCheck --check-prefix=NO-ENV %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb %t.exe -o 'target modules dump
symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb %t.exe -o 'target modules dump
symfile' 2>&1 | FileCheck --check-prefix=ENV1 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb \
+// RUN: -o 'settings set plugin.symbol-file.pdb.reader dia' \
+// RUN: -o 'target create %t.exe' \
+// RUN: -o 'target modules dump symfile' \
+// RUN: 2>&1 | FileCheck --check-prefix=ENV0-SET-DIA %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb \
+// RUN: -o 'settings set plugin.symbol-file.pdb.reader dia' \
+// RUN: -o 'target create %t.exe' \
+// RUN: -o 'target modules dump symfile' \
+// RUN: 2>&1 | FileCheck --check-prefix=ENV1-SET-DIA %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb \
+// RUN: -o 'settings set plugin.symbol-file.pdb.reader native' \
+// RUN: -o 'target create %t.exe' \
+// RUN: -o 'target modules dump symfile' \
+// RUN: 2>&
[Lldb-commits] [lldb] Fix a bug where an error was emitted for GCC union types. (PR #159401)
https://github.com/Michael137 approved this pull request. Do you have a C++ example snippet of how this happens? https://github.com/llvm/llvm-project/pull/159401 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ClangExpressionParser] Reset DiagnosticManager before we create persistent variables (PR #160074)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/160074 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][PDB] Run UDT layout test with native PDB too (PR #159769)
@@ -1,51 +1,63 @@
REQUIRES: target-windows, lld
RUN: %build --compiler=clang-cl --output=%t.exe %S/Inputs/UdtLayoutTest.cpp
-RUN: %lldb -b -s %S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s
+RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb -b -s
%S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s
+RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -b -s
%S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s
-CHECK:(int) C::abc = 123
+CHECK:(int) {{(::)?}}C::abc = 123
CHECK:(List[16]) ls = {
-CHECK: [15] = {
-CHECK:Prev = nullptr
-CHECK:Next = nullptr
-CHECK:Value = {
-CHECK: B<0> = {
-CHECK:A = {
-CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2)
-CHECK:}
-CHECK:_a = '\x01'
-CHECK:_b = 2
-CHECK:_c = 3
-CHECK: }
-CHECK: B<1> = {
-CHECK:A = {
-CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2)
-CHECK:}
-CHECK:_a = '\x02'
-CHECK:_b = 4
-CHECK:_c = 6
-CHECK: }
-CHECK: B<2> = {
-CHECK:A = {
-CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2)
-CHECK:}
-CHECK:_a = '\x03'
-CHECK:_b = 6
-CHECK:_c = 9
-CHECK: }
-CHECK: B<3> = {
-CHECK:A = {
-CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2)
-CHECK:}
-CHECK:_a = '\x04'
-CHECK:_b = 8
-CHECK:_c = 12
-CHECK: }
-CHECK: A = {
-CHECK:_u = (_u1 = '\x02', _u2 = 2, _u3 = 2)
-CHECK: }
-CHECK: _x = 5
-CHECK: _y = 10
-CHECK: _z = '\x0f'
-CHECK:}
-CHECK: }
-CHECK:}
+
+CHECK: [14] = {
Nerixyz wrote:
This would fail if LLDB is compiled without DIA support. In that case, the
native plugin would always be used, and it would fail the check intended for
DIA.
I could also mark the whole test as DIA-only and add a second
`udt-layout-native.test` for the native plugin.
https://github.com/llvm/llvm-project/pull/159769
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][PDB] Run UDT layout test with native PDB too (PR #159769)
@@ -1,51 +1,63 @@
REQUIRES: target-windows, lld
RUN: %build --compiler=clang-cl --output=%t.exe %S/Inputs/UdtLayoutTest.cpp
-RUN: %lldb -b -s %S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s
+RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb -b -s
%S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s
+RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -b -s
%S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s
-CHECK:(int) C::abc = 123
+CHECK:(int) {{(::)?}}C::abc = 123
CHECK:(List[16]) ls = {
-CHECK: [15] = {
-CHECK:Prev = nullptr
-CHECK:Next = nullptr
-CHECK:Value = {
-CHECK: B<0> = {
-CHECK:A = {
-CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2)
-CHECK:}
-CHECK:_a = '\x01'
-CHECK:_b = 2
-CHECK:_c = 3
-CHECK: }
-CHECK: B<1> = {
-CHECK:A = {
-CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2)
-CHECK:}
-CHECK:_a = '\x02'
-CHECK:_b = 4
-CHECK:_c = 6
-CHECK: }
-CHECK: B<2> = {
-CHECK:A = {
-CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2)
-CHECK:}
-CHECK:_a = '\x03'
-CHECK:_b = 6
-CHECK:_c = 9
-CHECK: }
-CHECK: B<3> = {
-CHECK:A = {
-CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2)
-CHECK:}
-CHECK:_a = '\x04'
-CHECK:_b = 8
-CHECK:_c = 12
-CHECK: }
-CHECK: A = {
-CHECK:_u = (_u1 = '\x02', _u2 = 2, _u3 = 2)
-CHECK: }
-CHECK: _x = 5
-CHECK: _y = 10
-CHECK: _z = '\x0f'
-CHECK:}
-CHECK: }
-CHECK:}
+
+CHECK: [14] = {
Michael137 wrote:
Does LLDB complain if a user requests the DIA plugin but LLDB was compiled
without DIA support? If not, I think it's worth investigating
> I could also mark the whole test as DIA-only and add a second
> udt-layout-native.test for the native plugin.
Yea I would prefer that. It would be nice if as many of the NativePDB tests
stayed in the NativePDB subdirectory as possible. That way we don't need to
worry about losing coverage when we delete the PDB plugin
https://github.com/llvm/llvm-project/pull/159769
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] DRAFT: [lldb][DWARFASTParserClang] Remove old workaround (PR #160132)
https://github.com/Michael137 updated
https://github.com/llvm/llvm-project/pull/160132
>From 6293105c42e29cc9151eaac33a4208a91e40a0e9 Mon Sep 17 00:00:00 2001
From: Michael Buch
Date: Mon, 22 Sep 2025 16:02:35 +0100
Subject: [PATCH 1/2] Init
---
.../SymbolFile/DWARF/DWARFASTParserClang.cpp | 40 ---
1 file changed, 8 insertions(+), 32 deletions(-)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 5ffb4423969ca..dd51c02ff4bd1 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3126,38 +3126,14 @@ void DWARFASTParserClang::ParseSingleMember(
if (!member_clang_type.IsCompleteType())
member_clang_type.GetCompleteType();
- {
-// Older versions of clang emit the same DWARF for array[0] and array[1].
If
-// the current field is at the end of the structure, then there is
-// definitely no room for extra elements and we override the type to
-// array[0]. This was fixed by f454dfb6b5af.
-CompilerType member_array_element_type;
-uint64_t member_array_size;
-bool member_array_is_incomplete;
-
-if (member_clang_type.IsArrayType(&member_array_element_type,
- &member_array_size,
- &member_array_is_incomplete) &&
-!member_array_is_incomplete) {
- uint64_t parent_byte_size =
- parent_die.GetAttributeValueAsUnsigned(DW_AT_byte_size, UINT64_MAX);
-
- if (attrs.member_byte_offset >= parent_byte_size) {
-if (member_array_size != 1 &&
-(member_array_size != 0 ||
- attrs.member_byte_offset > parent_byte_size)) {
- module_sp->ReportError(
- "{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
- " which extends beyond the bounds of {3:x8}",
- die.GetID(), attrs.name,
- attrs.encoding_form.Reference().GetOffset(), parent_die.GetID());
-}
-
-member_clang_type =
-m_ast.CreateArrayType(member_array_element_type, 0, false);
- }
-}
- }
+ if (attrs.member_byte_offset != UINT32_MAX
+ && attrs.member_byte_offset > parent_byte_size
+ &&
llvm::expectedToOptional(member_clang_type.GetByteSize(nullptr)).value_or(0) >
0)
+module_sp->ReportError(
+"{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
+" which extends beyond the bounds of {3:x8}",
+die.GetID(), attrs.name,
+attrs.encoding_form.Reference().GetOffset(), parent_die.GetID());
TypeSystemClang::RequireCompleteType(member_clang_type);
>From 9dc1fa8a2143c4fe3fe26ea084e2670b7617683e Mon Sep 17 00:00:00 2001
From: Michael Buch
Date: Mon, 22 Sep 2025 16:37:56 +0100
Subject: [PATCH 2/2] Init
---
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index dd51c02ff4bd1..f47722c027470 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3127,7 +3127,7 @@ void DWARFASTParserClang::ParseSingleMember(
member_clang_type.GetCompleteType();
if (attrs.member_byte_offset != UINT32_MAX
- && attrs.member_byte_offset > parent_byte_size
+ && attrs.member_byte_offset >= parent_byte_size
&&
llvm::expectedToOptional(member_clang_type.GetByteSize(nullptr)).value_or(0) >
0)
module_sp->ReportError(
"{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] DRAFT: [lldb][DWARFASTParserClang] Remove old workaround (PR #160132)
https://github.com/Michael137 created
https://github.com/llvm/llvm-project/pull/160132
None
>From 6293105c42e29cc9151eaac33a4208a91e40a0e9 Mon Sep 17 00:00:00 2001
From: Michael Buch
Date: Mon, 22 Sep 2025 16:02:35 +0100
Subject: [PATCH] Init
---
.../SymbolFile/DWARF/DWARFASTParserClang.cpp | 40 ---
1 file changed, 8 insertions(+), 32 deletions(-)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 5ffb4423969ca..dd51c02ff4bd1 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3126,38 +3126,14 @@ void DWARFASTParserClang::ParseSingleMember(
if (!member_clang_type.IsCompleteType())
member_clang_type.GetCompleteType();
- {
-// Older versions of clang emit the same DWARF for array[0] and array[1].
If
-// the current field is at the end of the structure, then there is
-// definitely no room for extra elements and we override the type to
-// array[0]. This was fixed by f454dfb6b5af.
-CompilerType member_array_element_type;
-uint64_t member_array_size;
-bool member_array_is_incomplete;
-
-if (member_clang_type.IsArrayType(&member_array_element_type,
- &member_array_size,
- &member_array_is_incomplete) &&
-!member_array_is_incomplete) {
- uint64_t parent_byte_size =
- parent_die.GetAttributeValueAsUnsigned(DW_AT_byte_size, UINT64_MAX);
-
- if (attrs.member_byte_offset >= parent_byte_size) {
-if (member_array_size != 1 &&
-(member_array_size != 0 ||
- attrs.member_byte_offset > parent_byte_size)) {
- module_sp->ReportError(
- "{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
- " which extends beyond the bounds of {3:x8}",
- die.GetID(), attrs.name,
- attrs.encoding_form.Reference().GetOffset(), parent_die.GetID());
-}
-
-member_clang_type =
-m_ast.CreateArrayType(member_array_element_type, 0, false);
- }
-}
- }
+ if (attrs.member_byte_offset != UINT32_MAX
+ && attrs.member_byte_offset > parent_byte_size
+ &&
llvm::expectedToOptional(member_clang_type.GetByteSize(nullptr)).value_or(0) >
0)
+module_sp->ReportError(
+"{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
+" which extends beyond the bounds of {3:x8}",
+die.GetID(), attrs.name,
+attrs.encoding_form.Reference().GetOffset(), parent_die.GetID());
TypeSystemClang::RequireCompleteType(member_clang_type);
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] DRAFT: [lldb][DWARFASTParserClang] Remove old workaround (PR #160132)
https://github.com/Michael137 updated
https://github.com/llvm/llvm-project/pull/160132
>From 6293105c42e29cc9151eaac33a4208a91e40a0e9 Mon Sep 17 00:00:00 2001
From: Michael Buch
Date: Mon, 22 Sep 2025 16:02:35 +0100
Subject: [PATCH 1/4] Init
---
.../SymbolFile/DWARF/DWARFASTParserClang.cpp | 40 ---
1 file changed, 8 insertions(+), 32 deletions(-)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 5ffb4423969ca..dd51c02ff4bd1 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3126,38 +3126,14 @@ void DWARFASTParserClang::ParseSingleMember(
if (!member_clang_type.IsCompleteType())
member_clang_type.GetCompleteType();
- {
-// Older versions of clang emit the same DWARF for array[0] and array[1].
If
-// the current field is at the end of the structure, then there is
-// definitely no room for extra elements and we override the type to
-// array[0]. This was fixed by f454dfb6b5af.
-CompilerType member_array_element_type;
-uint64_t member_array_size;
-bool member_array_is_incomplete;
-
-if (member_clang_type.IsArrayType(&member_array_element_type,
- &member_array_size,
- &member_array_is_incomplete) &&
-!member_array_is_incomplete) {
- uint64_t parent_byte_size =
- parent_die.GetAttributeValueAsUnsigned(DW_AT_byte_size, UINT64_MAX);
-
- if (attrs.member_byte_offset >= parent_byte_size) {
-if (member_array_size != 1 &&
-(member_array_size != 0 ||
- attrs.member_byte_offset > parent_byte_size)) {
- module_sp->ReportError(
- "{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
- " which extends beyond the bounds of {3:x8}",
- die.GetID(), attrs.name,
- attrs.encoding_form.Reference().GetOffset(), parent_die.GetID());
-}
-
-member_clang_type =
-m_ast.CreateArrayType(member_array_element_type, 0, false);
- }
-}
- }
+ if (attrs.member_byte_offset != UINT32_MAX
+ && attrs.member_byte_offset > parent_byte_size
+ &&
llvm::expectedToOptional(member_clang_type.GetByteSize(nullptr)).value_or(0) >
0)
+module_sp->ReportError(
+"{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
+" which extends beyond the bounds of {3:x8}",
+die.GetID(), attrs.name,
+attrs.encoding_form.Reference().GetOffset(), parent_die.GetID());
TypeSystemClang::RequireCompleteType(member_clang_type);
>From 9dc1fa8a2143c4fe3fe26ea084e2670b7617683e Mon Sep 17 00:00:00 2001
From: Michael Buch
Date: Mon, 22 Sep 2025 16:37:56 +0100
Subject: [PATCH 2/4] Init
---
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index dd51c02ff4bd1..f47722c027470 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3127,7 +3127,7 @@ void DWARFASTParserClang::ParseSingleMember(
member_clang_type.GetCompleteType();
if (attrs.member_byte_offset != UINT32_MAX
- && attrs.member_byte_offset > parent_byte_size
+ && attrs.member_byte_offset >= parent_byte_size
&&
llvm::expectedToOptional(member_clang_type.GetByteSize(nullptr)).value_or(0) >
0)
module_sp->ReportError(
"{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
>From 4775a63360110eec1dc8aabd46b786369d10ee8c Mon Sep 17 00:00:00 2001
From: Michael Buch
Date: Mon, 22 Sep 2025 16:38:15 +0100
Subject: [PATCH 3/4] fixup! clang-format
---
.../Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | 7 ---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index f47722c027470..39ef3f77ca218 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3126,9 +3126,10 @@ void DWARFASTParserClang::ParseSingleMember(
if (!member_clang_type.IsCompleteType())
member_clang_type.GetCompleteType();
- if (attrs.member_byte_offset != UINT32_MAX
- && attrs.member_byte_offset >= parent_byte_size
- &&
llvm::expectedToOptional(member_clang_type.GetByteSize(nullptr)).value_or(0) >
0)
+ if (attrs.member_byte_offset != UINT32_MAX &&
+ attrs.member_byte_offset >= parent_byte_size &&
+ llvm::expectedToOptional(member_clang_type.GetByteSize(nullptr))
+ .value_or(0) > 0)
module_sp->ReportError(
"{0:x8}:
[Lldb-commits] [lldb] [lldb] Use APSInt's right shift operator in Scalar (PR #160149)
https://github.com/kuilpd created
https://github.com/llvm/llvm-project/pull/160149
Right shift operator in `Scalar` didn't check if the value is unsigned to
perform a logical right shift. Use the right shift operator from `APSInt` that
does this check.
>From 085e848344f5772b3d1481c24ca6471fe45c9138 Mon Sep 17 00:00:00 2001
From: Ilia Kuklin
Date: Mon, 22 Sep 2025 20:05:57 +0500
Subject: [PATCH] [lldb] Use APSInt's right shift operator in Scalar
---
lldb/source/Utility/Scalar.cpp| 20 +++-
lldb/unittests/Utility/ScalarTest.cpp | 3 +++
2 files changed, 6 insertions(+), 17 deletions(-)
diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index c8766bdf2aee7..f2c18cdd896da 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -471,24 +471,10 @@ bool Scalar::ShiftRightLogical(const Scalar &rhs) {
}
Scalar &Scalar::operator>>=(const Scalar &rhs) {
- switch (m_type) {
- case e_void:
- case e_float:
+ if (m_type == e_int && rhs.m_type == e_int)
+m_integer >>= rhs.m_integer.getZExtValue();
+ else
m_type = e_void;
-break;
-
- case e_int:
-switch (rhs.m_type) {
-case e_void:
-case e_float:
- m_type = e_void;
- break;
-case e_int:
- m_integer = m_integer.ashr(rhs.m_integer);
- break;
-}
-break;
- }
return *this;
}
diff --git a/lldb/unittests/Utility/ScalarTest.cpp
b/lldb/unittests/Utility/ScalarTest.cpp
index 6d5caef42bee4..e6d7479b59fee 100644
--- a/lldb/unittests/Utility/ScalarTest.cpp
+++ b/lldb/unittests/Utility/ScalarTest.cpp
@@ -118,11 +118,14 @@ TEST(ScalarTest, RightShiftOperator) {
int a = 0x1000;
int b = 0x;
int c = 4;
+ unsigned d = 0x;
Scalar a_scalar(a);
Scalar b_scalar(b);
Scalar c_scalar(c);
+ Scalar d_scalar(d);
ASSERT_EQ(a >> c, a_scalar >> c_scalar);
ASSERT_EQ(b >> c, b_scalar >> c_scalar);
+ ASSERT_EQ(d >> c, d_scalar >> c_scalar);
}
TEST(ScalarTest, GetBytes) {
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [cmake][lldb][test] Respect LIBCXX_LIBDIR_SUBDIR (PR #159106)
https://github.com/tambry edited https://github.com/llvm/llvm-project/pull/159106 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use APSInt's right shift operator in Scalar (PR #160149)
@@ -118,11 +118,14 @@ TEST(ScalarTest, RightShiftOperator) {
int a = 0x1000;
int b = 0x;
int c = 4;
+ unsigned d = 0x;
Scalar a_scalar(a);
Scalar b_scalar(b);
Scalar c_scalar(c);
+ Scalar d_scalar(d);
ASSERT_EQ(a >> c, a_scalar >> c_scalar);
ASSERT_EQ(b >> c, b_scalar >> c_scalar);
+ ASSERT_EQ(d >> c, d_scalar >> c_scalar);
Michael137 wrote:
Maybe also add a test for `unsigned short`?
https://github.com/llvm/llvm-project/pull/160149
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][PDB] Warn if DIA plugin is requested but not available (PR #160067)
https://github.com/Nerixyz updated
https://github.com/llvm/llvm-project/pull/160067
>From 4dab54fd1d003e99ac0b1014b276f0c6d24f9de2 Mon Sep 17 00:00:00 2001
From: Nerixyz
Date: Mon, 22 Sep 2025 12:32:08 +0200
Subject: [PATCH 1/4] [LLDB][PDB] Warn if DIA plugin is requested but not
available
---
.../Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | 27 ++--
.../SymbolFile/NativePDB/native-setting.cpp | 65 +++
.../Shell/SymbolFile/PDB/native-setting.cpp | 25 +--
3 files changed, 106 insertions(+), 11 deletions(-)
create mode 100644 lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp
diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index 0e2ca1784e7e9..68e229b697116 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -14,6 +14,7 @@
#include "clang/Lex/Lexer.h"
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "lldb/Core/Debugger.h"
#include "lldb/Core/Mangled.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
@@ -105,7 +106,6 @@ enum {
#include "SymbolFilePDBPropertiesEnum.inc"
};
-#if LLVM_ENABLE_DIA_SDK && defined(_WIN32)
bool ShouldUseNativeReaderByDefault() {
static bool g_use_native_by_default = true;
@@ -117,11 +117,16 @@ bool ShouldUseNativeReaderByDefault() {
!env_value.equals_insensitive("1") &&
!env_value.equals_insensitive("true"))
g_use_native_by_default = false;
+
+#if !LLVM_ENABLE_DIA_SDK || !defined(_WIN32)
+// if the environment value is unset, the native reader is requested
+if (env_value.empty())
+ g_use_native_by_default = true;
+#endif
});
return g_use_native_by_default;
}
-#endif
class PluginProperties : public Properties {
public:
@@ -136,6 +141,21 @@ class PluginProperties : public Properties {
bool UseNativeReader() const {
#if LLVM_ENABLE_DIA_SDK && defined(_WIN32)
+return IsNativeReaderRequested();
+#else
+if (!IsNativeReaderRequested()) {
+ static std::once_flag g_warning_shown;
+ Debugger::ReportWarning(
+ "The DIA PDB reader was explicitly requested, but LLDB was built "
+ "without the DIA SDK. The native reader will be used instead.",
+ {}, &g_warning_shown);
+}
+return true;
+#endif
+ }
+
+private:
+ bool IsNativeReaderRequested() const {
auto value =
GetPropertyAtIndexAs(ePropertyReader, ePDBReaderDefault);
switch (value) {
@@ -147,9 +167,6 @@ class PluginProperties : public Properties {
case ePDBReaderDefault:
return ShouldUseNativeReaderByDefault();
}
-#else
-return true;
-#endif
}
};
diff --git a/lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp
b/lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp
new file mode 100644
index 0..fc0ee218dd0d2
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp
@@ -0,0 +1,65 @@
+// REQUIRES: !diasdk, target-windows
+
+// Test plugin.symbol-file.pdb.reader setting without the DIA SDK
+// RUN: %build -o %t.exe -- %s
+// RUN: env -u LLDB_USE_NATIVE_PDB_READER %lldb %t.exe -o 'target modules dump
symfile' 2>&1 | FileCheck --check-prefix=NO-ENV %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER= %lldb %t.exe -o 'target modules dump
symfile' 2>&1 | FileCheck --check-prefix=NO-ENV %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb %t.exe -o 'target modules dump
symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb %t.exe -o 'target modules dump
symfile' 2>&1 | FileCheck --check-prefix=ENV1 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb \
+// RUN: -o 'settings set plugin.symbol-file.pdb.reader dia' \
+// RUN: -o 'target create %t.exe' \
+// RUN: -o 'target modules dump symfile' \
+// RUN: 2>&1 | FileCheck --check-prefix=ENV0-SET-DIA %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb \
+// RUN: -o 'settings set plugin.symbol-file.pdb.reader dia' \
+// RUN: -o 'target create %t.exe' \
+// RUN: -o 'target modules dump symfile' \
+// RUN: 2>&1 | FileCheck --check-prefix=ENV1-SET-DIA %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb \
+// RUN: -o 'settings set plugin.symbol-file.pdb.reader native' \
+// RUN: -o 'target create %t.exe' \
+// RUN: -o 'target modules dump symfile' \
+// RUN: 2>&1 | FileCheck --check-prefix=ENV0-SET-NATIVE %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb \
+// RUN: -o 'settings set plugin.symbol-file.pdb.reader native' \
+// RUN: -o 'target create %t.exe' \
+// RUN: -o 'target modules dump symfile' \
+// RUN: 2>&1 | FileCheck --check-prefix=ENV1-SET-NATIVE %s
+
+// NO-ENV-NOT: warning:
+// NO-ENV: (lldb) target modules dump symfile
+// NO-ENV: Dumping debug symbols for 1 modules.
+// NO-ENV: SymbolFile native-pdb
+
+// ENV0: warning: The DIA PDB reader was explicitly requested, but LLDB w
[Lldb-commits] [lldb] [vscode-lldb] Restart server when lldb-dap binary has changed (PR #159797)
https://github.com/royitaqi edited https://github.com/llvm/llvm-project/pull/159797 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use APSInt's right shift operator in Scalar (PR #160149)
https://github.com/Michael137 approved this pull request. https://github.com/llvm/llvm-project/pull/160149 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use APSInt's right shift operator in Scalar (PR #160149)
https://github.com/kuilpd updated
https://github.com/llvm/llvm-project/pull/160149
>From 085e848344f5772b3d1481c24ca6471fe45c9138 Mon Sep 17 00:00:00 2001
From: Ilia Kuklin
Date: Mon, 22 Sep 2025 20:05:57 +0500
Subject: [PATCH 1/2] [lldb] Use APSInt's right shift operator in Scalar
---
lldb/source/Utility/Scalar.cpp| 20 +++-
lldb/unittests/Utility/ScalarTest.cpp | 3 +++
2 files changed, 6 insertions(+), 17 deletions(-)
diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index c8766bdf2aee7..f2c18cdd896da 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -471,24 +471,10 @@ bool Scalar::ShiftRightLogical(const Scalar &rhs) {
}
Scalar &Scalar::operator>>=(const Scalar &rhs) {
- switch (m_type) {
- case e_void:
- case e_float:
+ if (m_type == e_int && rhs.m_type == e_int)
+m_integer >>= rhs.m_integer.getZExtValue();
+ else
m_type = e_void;
-break;
-
- case e_int:
-switch (rhs.m_type) {
-case e_void:
-case e_float:
- m_type = e_void;
- break;
-case e_int:
- m_integer = m_integer.ashr(rhs.m_integer);
- break;
-}
-break;
- }
return *this;
}
diff --git a/lldb/unittests/Utility/ScalarTest.cpp
b/lldb/unittests/Utility/ScalarTest.cpp
index 6d5caef42bee4..e6d7479b59fee 100644
--- a/lldb/unittests/Utility/ScalarTest.cpp
+++ b/lldb/unittests/Utility/ScalarTest.cpp
@@ -118,11 +118,14 @@ TEST(ScalarTest, RightShiftOperator) {
int a = 0x1000;
int b = 0x;
int c = 4;
+ unsigned d = 0x;
Scalar a_scalar(a);
Scalar b_scalar(b);
Scalar c_scalar(c);
+ Scalar d_scalar(d);
ASSERT_EQ(a >> c, a_scalar >> c_scalar);
ASSERT_EQ(b >> c, b_scalar >> c_scalar);
+ ASSERT_EQ(d >> c, d_scalar >> c_scalar);
}
TEST(ScalarTest, GetBytes) {
>From c91fdc810d0d59b53bc27f2a5c774c29c5eb6c0a Mon Sep 17 00:00:00 2001
From: Ilia Kuklin
Date: Mon, 22 Sep 2025 22:27:07 +0500
Subject: [PATCH 2/2] Add a test for unsigned short
---
lldb/unittests/Utility/ScalarTest.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lldb/unittests/Utility/ScalarTest.cpp
b/lldb/unittests/Utility/ScalarTest.cpp
index e6d7479b59fee..869a5809e6d14 100644
--- a/lldb/unittests/Utility/ScalarTest.cpp
+++ b/lldb/unittests/Utility/ScalarTest.cpp
@@ -119,13 +119,16 @@ TEST(ScalarTest, RightShiftOperator) {
int b = 0x;
int c = 4;
unsigned d = 0x;
+ unsigned short e = 0x;
Scalar a_scalar(a);
Scalar b_scalar(b);
Scalar c_scalar(c);
Scalar d_scalar(d);
+ Scalar e_scalar(e);
ASSERT_EQ(a >> c, a_scalar >> c_scalar);
ASSERT_EQ(b >> c, b_scalar >> c_scalar);
ASSERT_EQ(d >> c, d_scalar >> c_scalar);
+ ASSERT_EQ(e >> c, e_scalar >> c_scalar);
}
TEST(ScalarTest, GetBytes) {
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [vscode-lldb] Restart server when lldb-dap binary has changed (PR #159797)
royitaqi wrote: @walter-erquinigo: Gentle ping. Since your last review, I have: - Used `chokidar`. - Rebased on latest main. - When both the lldb-dap binary and the arguments have changed, I made the dialog box show both changes (see the first screenshot in the patch's description). https://github.com/llvm/llvm-project/pull/159797 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix deadlock in parallel module loading with separate symbol thread pool (PR #160225)
https://github.com/GeorgeHuyubo created
https://github.com/llvm/llvm-project/pull/160225
Fixes a deadlock that occurs during parallel module loading when symbol indexing
operations conflict with module list access. The deadlock happens when:
- Thread A (symbol loading): holds Module.m_mutex → tries
ModuleList.m_modules_mutex
- Thread B (parallel module loading): holds ModuleList.m_modules_mutex → tries
Module.m_mutex
Solution: Create a dedicated symbol thread pool separate from the main thread
pool
used for parallel module loading. This isolates DWARF indexing operations from
module loading operations, preventing the mutex ordering conflict.
Changes:
- Add Debugger::GetSymbolThreadPool() alongside existing GetThreadPool()
- Update ManualDWARFIndex to use symbol thread pool for indexing operations
- Initialize/cleanup symbol thread pool in Debugger::Initialize/Terminate
This maintains performance while eliminating the deadlock without major
architectural changes to the threading model.
>From cfe6fdcee8a8083f2bead5e684208e0657811efe Mon Sep 17 00:00:00 2001
From: George Hu
Date: Mon, 22 Sep 2025 20:48:57 -0700
Subject: [PATCH] [lldb] Fix deadlock in parallel module loading with separate
symbol thread pool
---
lldb/include/lldb/Core/Debugger.h | 5 +
lldb/source/Core/Debugger.cpp | 15 +++
.../Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp | 6 --
3 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/lldb/include/lldb/Core/Debugger.h
b/lldb/include/lldb/Core/Debugger.h
index 250ad64b76d9a..c3019ccb3077d 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -506,6 +506,11 @@ class Debugger : public
std::enable_shared_from_this,
/// Shared thread pool. Use only with ThreadPoolTaskGroup.
static llvm::ThreadPoolInterface &GetThreadPool();
+ /// Dedicated symbol thread pool to prevent deadlock with module loading.
+ /// Use this for symbol indexing operations that might need to access
+ /// the shared module list while holding module mutexes.
+ static llvm::ThreadPoolInterface &GetSymbolThreadPool();
+
/// Report warning events.
///
/// Warning events will be delivered to any debuggers that have listeners
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index ed674ee1275c7..9646748784f35 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -110,6 +110,7 @@ static std::recursive_mutex *g_debugger_list_mutex_ptr =
static Debugger::DebuggerList *g_debugger_list_ptr =
nullptr; // NOTE: intentional leak to avoid issues with C++ destructor
chain
static llvm::DefaultThreadPool *g_thread_pool = nullptr;
+static llvm::DefaultThreadPool *g_symbol_thread_pool = nullptr;
static constexpr OptionEnumValueElement g_show_disassembly_enum_values[] = {
{
@@ -715,6 +716,7 @@ void Debugger::Initialize(LoadPluginCallbackType
load_plugin_callback) {
g_debugger_list_mutex_ptr = new std::recursive_mutex();
g_debugger_list_ptr = new DebuggerList();
g_thread_pool = new llvm::DefaultThreadPool(llvm::optimal_concurrency());
+ g_symbol_thread_pool = new
llvm::DefaultThreadPool(llvm::optimal_concurrency());
g_load_plugin_callback = load_plugin_callback;
}
@@ -731,6 +733,13 @@ void Debugger::Terminate() {
if (g_thread_pool) {
// The destructor will wait for all the threads to complete.
delete g_thread_pool;
+g_thread_pool = nullptr;
+ }
+
+ if (g_symbol_thread_pool) {
+// The destructor will wait for all the threads to complete.
+delete g_symbol_thread_pool;
+g_symbol_thread_pool = nullptr;
}
if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
@@ -2383,3 +2392,9 @@ llvm::ThreadPoolInterface &Debugger::GetThreadPool() {
"Debugger::GetThreadPool called before Debugger::Initialize");
return *g_thread_pool;
}
+
+llvm::ThreadPoolInterface &Debugger::GetSymbolThreadPool() {
+ assert(g_symbol_thread_pool &&
+ "Debugger::GetSymbolThreadPool called before Debugger::Initialize");
+ return *g_symbol_thread_pool;
+}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index d90108f687f84..ae6529f9e0c89 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -86,10 +86,12 @@ void ManualDWARFIndex::Index() {
total_progress, /*debugger=*/nullptr,
Progress::kDefaultHighFrequencyReportTime);
+ // Use separate symbol thread pool to avoid deadlock with module loading
// Share one thread pool across operations to avoid the overhead of
// recreating the threads.
- llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool());
- const size_t num_threads = Debugger::GetThreadPool().getMaxConcurrency();
+ llvm::ThreadPoolTaskGroup task_group(Debugger::GetSymbolT
[Lldb-commits] [lldb] [lldb] Enable locate module callback for main executable (PR #160199)
GeorgeHuyubo wrote: > 2. It sucks we have to have two code paths for locating modules, one for > shared libraries, one for main executable. I wonder if we should consolidate > to a central place? Like `ModuleList::GetSharedModule`? Thought about this too, but `ModuleList::GetSharedModule` is a static method, I wanted to avoid passing in Platform as an extra parameter which might cause more refactoring and focused on making this work for our use case https://github.com/llvm/llvm-project/pull/160199 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix deadlock in parallel module loading with separate symbol thread pool (PR #160225)
https://github.com/GeorgeHuyubo updated
https://github.com/llvm/llvm-project/pull/160225
>From b4f6da6ff87b109d21bb1cc4e309d698cc0e99fe Mon Sep 17 00:00:00 2001
From: George Hu
Date: Mon, 22 Sep 2025 20:48:57 -0700
Subject: [PATCH] [lldb] Fix deadlock in parallel module loading with separate
symbol thread pool
---
lldb/include/lldb/Core/Debugger.h | 5 +
lldb/source/Core/Debugger.cpp | 15 +++
.../Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp | 6 --
3 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/lldb/include/lldb/Core/Debugger.h
b/lldb/include/lldb/Core/Debugger.h
index 250ad64b76d9a..c3019ccb3077d 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -506,6 +506,11 @@ class Debugger : public
std::enable_shared_from_this,
/// Shared thread pool. Use only with ThreadPoolTaskGroup.
static llvm::ThreadPoolInterface &GetThreadPool();
+ /// Dedicated symbol thread pool to prevent deadlock with module loading.
+ /// Use this for symbol indexing operations that might need to access
+ /// the shared module list while holding module mutexes.
+ static llvm::ThreadPoolInterface &GetSymbolThreadPool();
+
/// Report warning events.
///
/// Warning events will be delivered to any debuggers that have listeners
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index ed674ee1275c7..9646748784f35 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -110,6 +110,7 @@ static std::recursive_mutex *g_debugger_list_mutex_ptr =
static Debugger::DebuggerList *g_debugger_list_ptr =
nullptr; // NOTE: intentional leak to avoid issues with C++ destructor
chain
static llvm::DefaultThreadPool *g_thread_pool = nullptr;
+static llvm::DefaultThreadPool *g_symbol_thread_pool = nullptr;
static constexpr OptionEnumValueElement g_show_disassembly_enum_values[] = {
{
@@ -715,6 +716,7 @@ void Debugger::Initialize(LoadPluginCallbackType
load_plugin_callback) {
g_debugger_list_mutex_ptr = new std::recursive_mutex();
g_debugger_list_ptr = new DebuggerList();
g_thread_pool = new llvm::DefaultThreadPool(llvm::optimal_concurrency());
+ g_symbol_thread_pool = new
llvm::DefaultThreadPool(llvm::optimal_concurrency());
g_load_plugin_callback = load_plugin_callback;
}
@@ -731,6 +733,13 @@ void Debugger::Terminate() {
if (g_thread_pool) {
// The destructor will wait for all the threads to complete.
delete g_thread_pool;
+g_thread_pool = nullptr;
+ }
+
+ if (g_symbol_thread_pool) {
+// The destructor will wait for all the threads to complete.
+delete g_symbol_thread_pool;
+g_symbol_thread_pool = nullptr;
}
if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
@@ -2383,3 +2392,9 @@ llvm::ThreadPoolInterface &Debugger::GetThreadPool() {
"Debugger::GetThreadPool called before Debugger::Initialize");
return *g_thread_pool;
}
+
+llvm::ThreadPoolInterface &Debugger::GetSymbolThreadPool() {
+ assert(g_symbol_thread_pool &&
+ "Debugger::GetSymbolThreadPool called before Debugger::Initialize");
+ return *g_symbol_thread_pool;
+}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index d90108f687f84..27298be688261 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -86,10 +86,12 @@ void ManualDWARFIndex::Index() {
total_progress, /*debugger=*/nullptr,
Progress::kDefaultHighFrequencyReportTime);
+ // Use separate symbol thread pool to avoid deadlock with module loading
// Share one thread pool across operations to avoid the overhead of
// recreating the threads.
- llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool());
- const size_t num_threads = Debugger::GetThreadPool().getMaxConcurrency();
+ llvm::ThreadPoolTaskGroup task_group(Debugger::GetSymbolThreadPool());
+ const size_t num_threads =
+ Debugger::GetSymbolThreadPool().getMaxConcurrency();
// Run a function for each compile unit in parallel using as many threads as
// are available. This is significantly faster than submiting a new task for
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix deadlock in parallel module loading with separate symbol thread pool (PR #160225)
https://github.com/GeorgeHuyubo updated
https://github.com/llvm/llvm-project/pull/160225
>From f9edaeca77dd44dc36f3e44acaaea1249d0d9b71 Mon Sep 17 00:00:00 2001
From: George Hu
Date: Mon, 22 Sep 2025 20:48:57 -0700
Subject: [PATCH] [lldb] Fix deadlock in parallel module loading with separate
symbol thread pool
---
lldb/include/lldb/Core/Debugger.h | 5 +
lldb/source/Core/Debugger.cpp | 15 +++
.../Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp | 6 --
3 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/lldb/include/lldb/Core/Debugger.h
b/lldb/include/lldb/Core/Debugger.h
index 250ad64b76d9a..c3019ccb3077d 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -506,6 +506,11 @@ class Debugger : public
std::enable_shared_from_this,
/// Shared thread pool. Use only with ThreadPoolTaskGroup.
static llvm::ThreadPoolInterface &GetThreadPool();
+ /// Dedicated symbol thread pool to prevent deadlock with module loading.
+ /// Use this for symbol indexing operations that might need to access
+ /// the shared module list while holding module mutexes.
+ static llvm::ThreadPoolInterface &GetSymbolThreadPool();
+
/// Report warning events.
///
/// Warning events will be delivered to any debuggers that have listeners
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index ed674ee1275c7..9646748784f35 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -110,6 +110,7 @@ static std::recursive_mutex *g_debugger_list_mutex_ptr =
static Debugger::DebuggerList *g_debugger_list_ptr =
nullptr; // NOTE: intentional leak to avoid issues with C++ destructor
chain
static llvm::DefaultThreadPool *g_thread_pool = nullptr;
+static llvm::DefaultThreadPool *g_symbol_thread_pool = nullptr;
static constexpr OptionEnumValueElement g_show_disassembly_enum_values[] = {
{
@@ -715,6 +716,7 @@ void Debugger::Initialize(LoadPluginCallbackType
load_plugin_callback) {
g_debugger_list_mutex_ptr = new std::recursive_mutex();
g_debugger_list_ptr = new DebuggerList();
g_thread_pool = new llvm::DefaultThreadPool(llvm::optimal_concurrency());
+ g_symbol_thread_pool = new
llvm::DefaultThreadPool(llvm::optimal_concurrency());
g_load_plugin_callback = load_plugin_callback;
}
@@ -731,6 +733,13 @@ void Debugger::Terminate() {
if (g_thread_pool) {
// The destructor will wait for all the threads to complete.
delete g_thread_pool;
+g_thread_pool = nullptr;
+ }
+
+ if (g_symbol_thread_pool) {
+// The destructor will wait for all the threads to complete.
+delete g_symbol_thread_pool;
+g_symbol_thread_pool = nullptr;
}
if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
@@ -2383,3 +2392,9 @@ llvm::ThreadPoolInterface &Debugger::GetThreadPool() {
"Debugger::GetThreadPool called before Debugger::Initialize");
return *g_thread_pool;
}
+
+llvm::ThreadPoolInterface &Debugger::GetSymbolThreadPool() {
+ assert(g_symbol_thread_pool &&
+ "Debugger::GetSymbolThreadPool called before Debugger::Initialize");
+ return *g_symbol_thread_pool;
+}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index d90108f687f84..27298be688261 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -86,10 +86,12 @@ void ManualDWARFIndex::Index() {
total_progress, /*debugger=*/nullptr,
Progress::kDefaultHighFrequencyReportTime);
+ // Use separate symbol thread pool to avoid deadlock with module loading
// Share one thread pool across operations to avoid the overhead of
// recreating the threads.
- llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool());
- const size_t num_threads = Debugger::GetThreadPool().getMaxConcurrency();
+ llvm::ThreadPoolTaskGroup task_group(Debugger::GetSymbolThreadPool());
+ const size_t num_threads =
+ Debugger::GetSymbolThreadPool().getMaxConcurrency();
// Run a function for each compile unit in parallel using as many threads as
// are available. This is significantly faster than submiting a new task for
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix deadlock in parallel module loading with separate symbol thread pool (PR #160225)
https://github.com/GeorgeHuyubo updated
https://github.com/llvm/llvm-project/pull/160225
>From 51e9f664a755da9175a29ca0537cf8996dd97fb9 Mon Sep 17 00:00:00 2001
From: George Hu
Date: Mon, 22 Sep 2025 20:48:57 -0700
Subject: [PATCH] [lldb] Fix deadlock in parallel module loading with separate
symbol thread pool
---
lldb/include/lldb/Core/Debugger.h| 5 +
lldb/source/Core/Debugger.cpp| 16
.../SymbolFile/DWARF/ManualDWARFIndex.cpp| 6 --
3 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/lldb/include/lldb/Core/Debugger.h
b/lldb/include/lldb/Core/Debugger.h
index 250ad64b76d9a..c3019ccb3077d 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -506,6 +506,11 @@ class Debugger : public
std::enable_shared_from_this,
/// Shared thread pool. Use only with ThreadPoolTaskGroup.
static llvm::ThreadPoolInterface &GetThreadPool();
+ /// Dedicated symbol thread pool to prevent deadlock with module loading.
+ /// Use this for symbol indexing operations that might need to access
+ /// the shared module list while holding module mutexes.
+ static llvm::ThreadPoolInterface &GetSymbolThreadPool();
+
/// Report warning events.
///
/// Warning events will be delivered to any debuggers that have listeners
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index ed674ee1275c7..9e662d5b6a024 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -110,6 +110,7 @@ static std::recursive_mutex *g_debugger_list_mutex_ptr =
static Debugger::DebuggerList *g_debugger_list_ptr =
nullptr; // NOTE: intentional leak to avoid issues with C++ destructor
chain
static llvm::DefaultThreadPool *g_thread_pool = nullptr;
+static llvm::DefaultThreadPool *g_symbol_thread_pool = nullptr;
static constexpr OptionEnumValueElement g_show_disassembly_enum_values[] = {
{
@@ -715,6 +716,8 @@ void Debugger::Initialize(LoadPluginCallbackType
load_plugin_callback) {
g_debugger_list_mutex_ptr = new std::recursive_mutex();
g_debugger_list_ptr = new DebuggerList();
g_thread_pool = new llvm::DefaultThreadPool(llvm::optimal_concurrency());
+ g_symbol_thread_pool =
+ new llvm::DefaultThreadPool(llvm::optimal_concurrency());
g_load_plugin_callback = load_plugin_callback;
}
@@ -731,6 +734,13 @@ void Debugger::Terminate() {
if (g_thread_pool) {
// The destructor will wait for all the threads to complete.
delete g_thread_pool;
+g_thread_pool = nullptr;
+ }
+
+ if (g_symbol_thread_pool) {
+// The destructor will wait for all the threads to complete.
+delete g_symbol_thread_pool;
+g_symbol_thread_pool = nullptr;
}
if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
@@ -2383,3 +2393,9 @@ llvm::ThreadPoolInterface &Debugger::GetThreadPool() {
"Debugger::GetThreadPool called before Debugger::Initialize");
return *g_thread_pool;
}
+
+llvm::ThreadPoolInterface &Debugger::GetSymbolThreadPool() {
+ assert(g_symbol_thread_pool &&
+ "Debugger::GetSymbolThreadPool called before Debugger::Initialize");
+ return *g_symbol_thread_pool;
+}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index d90108f687f84..27298be688261 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -86,10 +86,12 @@ void ManualDWARFIndex::Index() {
total_progress, /*debugger=*/nullptr,
Progress::kDefaultHighFrequencyReportTime);
+ // Use separate symbol thread pool to avoid deadlock with module loading
// Share one thread pool across operations to avoid the overhead of
// recreating the threads.
- llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool());
- const size_t num_threads = Debugger::GetThreadPool().getMaxConcurrency();
+ llvm::ThreadPoolTaskGroup task_group(Debugger::GetSymbolThreadPool());
+ const size_t num_threads =
+ Debugger::GetSymbolThreadPool().getMaxConcurrency();
// Run a function for each compile unit in parallel using as many threads as
// are available. This is significantly faster than submiting a new task for
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Enable locate module callback for main executable (PR #160199)
https://github.com/GeorgeHuyubo ready_for_review https://github.com/llvm/llvm-project/pull/160199 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix deadlock in parallel module loading with separate symbol thread pool (PR #160225)
llvmbot wrote:
@llvm/pr-subscribers-lldb
Author: None (GeorgeHuyubo)
Changes
Fixes a deadlock that occurs during parallel module loading when symbol indexing
operations conflict with module list access. The deadlock happens when:
- Thread A (symbol loading): holds Module.m_mutex → tries
ModuleList.m_modules_mutex
- Thread B (parallel module loading): holds ModuleList.m_modules_mutex → tries
Module.m_mutex
Solution: Create a dedicated symbol thread pool separate from the main thread
pool
used for parallel module loading. This isolates DWARF indexing operations from
module loading operations, preventing the mutex ordering conflict.
Changes:
- Add Debugger::GetSymbolThreadPool() alongside existing GetThreadPool()
- Update ManualDWARFIndex to use symbol thread pool for indexing operations
- Initialize/cleanup symbol thread pool in Debugger::Initialize/Terminate
This maintains performance while eliminating the deadlock without major
architectural changes to the threading model.
---
Full diff: https://github.com/llvm/llvm-project/pull/160225.diff
3 Files Affected:
- (modified) lldb/include/lldb/Core/Debugger.h (+5)
- (modified) lldb/source/Core/Debugger.cpp (+16)
- (modified) lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp (+4-2)
``diff
diff --git a/lldb/include/lldb/Core/Debugger.h
b/lldb/include/lldb/Core/Debugger.h
index 250ad64b76d9a..c3019ccb3077d 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -506,6 +506,11 @@ class Debugger : public
std::enable_shared_from_this,
/// Shared thread pool. Use only with ThreadPoolTaskGroup.
static llvm::ThreadPoolInterface &GetThreadPool();
+ /// Dedicated symbol thread pool to prevent deadlock with module loading.
+ /// Use this for symbol indexing operations that might need to access
+ /// the shared module list while holding module mutexes.
+ static llvm::ThreadPoolInterface &GetSymbolThreadPool();
+
/// Report warning events.
///
/// Warning events will be delivered to any debuggers that have listeners
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index ed674ee1275c7..9e662d5b6a024 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -110,6 +110,7 @@ static std::recursive_mutex *g_debugger_list_mutex_ptr =
static Debugger::DebuggerList *g_debugger_list_ptr =
nullptr; // NOTE: intentional leak to avoid issues with C++ destructor
chain
static llvm::DefaultThreadPool *g_thread_pool = nullptr;
+static llvm::DefaultThreadPool *g_symbol_thread_pool = nullptr;
static constexpr OptionEnumValueElement g_show_disassembly_enum_values[] = {
{
@@ -715,6 +716,8 @@ void Debugger::Initialize(LoadPluginCallbackType
load_plugin_callback) {
g_debugger_list_mutex_ptr = new std::recursive_mutex();
g_debugger_list_ptr = new DebuggerList();
g_thread_pool = new llvm::DefaultThreadPool(llvm::optimal_concurrency());
+ g_symbol_thread_pool =
+ new llvm::DefaultThreadPool(llvm::optimal_concurrency());
g_load_plugin_callback = load_plugin_callback;
}
@@ -731,6 +734,13 @@ void Debugger::Terminate() {
if (g_thread_pool) {
// The destructor will wait for all the threads to complete.
delete g_thread_pool;
+g_thread_pool = nullptr;
+ }
+
+ if (g_symbol_thread_pool) {
+// The destructor will wait for all the threads to complete.
+delete g_symbol_thread_pool;
+g_symbol_thread_pool = nullptr;
}
if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
@@ -2383,3 +2393,9 @@ llvm::ThreadPoolInterface &Debugger::GetThreadPool() {
"Debugger::GetThreadPool called before Debugger::Initialize");
return *g_thread_pool;
}
+
+llvm::ThreadPoolInterface &Debugger::GetSymbolThreadPool() {
+ assert(g_symbol_thread_pool &&
+ "Debugger::GetSymbolThreadPool called before Debugger::Initialize");
+ return *g_symbol_thread_pool;
+}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index d90108f687f84..27298be688261 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -86,10 +86,12 @@ void ManualDWARFIndex::Index() {
total_progress, /*debugger=*/nullptr,
Progress::kDefaultHighFrequencyReportTime);
+ // Use separate symbol thread pool to avoid deadlock with module loading
// Share one thread pool across operations to avoid the overhead of
// recreating the threads.
- llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool());
- const size_t num_threads = Debugger::GetThreadPool().getMaxConcurrency();
+ llvm::ThreadPoolTaskGroup task_group(Debugger::GetSymbolThreadPool());
+ const size_t num_threads =
+ Debugger::GetSymbolThreadPool().getMaxConcurrency();
// Run a function for each compile unit in parallel using as many threads as
/
[Lldb-commits] [lldb] [lldb] Fix deadlock in parallel module loading with separate symbol thread pool (PR #160225)
https://github.com/GeorgeHuyubo ready_for_review https://github.com/llvm/llvm-project/pull/160225 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Rework how we pass the execution context to the statusline (PR #159887)
@@ -35,9 +35,7 @@ using namespace lldb_private;
Statusline::Statusline(Debugger &debugger)
: m_debugger(debugger), m_terminal_width(m_debugger.GetTerminalWidth()),
- m_terminal_height(m_debugger.GetTerminalHeight()) {
- Enable();
-}
+ m_terminal_height(m_debugger.GetTerminalHeight()) {}
jimingham wrote:
This seems like an orthogonal change, why is this here?
https://github.com/llvm/llvm-project/pull/159887
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Enable locate module callback for main executable (PR #160199)
github-actions[bot] wrote:
:warning: C/C++ code formatter, clang-format found issues in your code.
:warning:
You can test this locally with the following command:
``bash
git-clang-format --diff origin/main HEAD --extensions cpp --
lldb/source/Target/Platform.cpp
``
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
View the diff from clang-format here.
``diff
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index 1b2ac3aa9..2ec4e97f6 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -751,17 +751,19 @@ Platform::ResolveExecutable(const ModuleSpec &module_spec,
if (resolved_module_spec.GetArchitecture().IsValid() ||
resolved_module_spec.GetUUID().IsValid()) {
// Call locate module callback first to give it a chance to find/register
-// symbol file specs for the main executable, similar to how shared
libraries
-// are handled in Platform::GetRemoteSharedModule()
+// symbol file specs for the main executable, similar to how shared
+// libraries are handled in Platform::GetRemoteSharedModule()
FileSpec symbol_file_spec;
CallLocateModuleCallbackIfSet(resolved_module_spec, exe_module_sp,
symbol_file_spec, nullptr);
Status error;
if (!exe_module_sp) {
- // If locate module callback didn't provide a module, fallback to
standard path
+ // If locate module callback didn't provide a module, fallback to
standard
+ // path
error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
- module_search_paths_ptr, nullptr,
nullptr);
+ module_search_paths_ptr, nullptr,
+ nullptr);
}
if (exe_module_sp && exe_module_sp->GetObjectFile()) {
@@ -769,7 +771,8 @@ Platform::ResolveExecutable(const ModuleSpec &module_spec,
if (symbol_file_spec) {
exe_module_sp->SetSymbolFileFileSpec(symbol_file_spec);
}
- return error; // Return the actual status from GetSharedModule (or
success from callback)
+ return error; // Return the actual status from GetSharedModule (or
success
+// from callback)
}
exe_module_sp.reset();
}
``
https://github.com/llvm/llvm-project/pull/160199
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Enable locate module callback for main executable (PR #160199)
https://github.com/GeorgeHuyubo created
https://github.com/llvm/llvm-project/pull/160199
Main executables were bypassing the locate module callback that shared
libraries use, preventing custom symbol file location logic from working
consistently.
Fixed by modifying Platform::ResolveExecutable() to call
CallLocateModuleCallbackIfSet() first, then fallback to the standard
ModuleList::GetSharedModule() path if needed.
This ensures both main executables and shared libraries get the same
callback treatment for symbol file resolution.
>From 8d5907bbc71c0155bbaee7eba5d81197ac7ae251 Mon Sep 17 00:00:00 2001
From: George Hu
Date: Mon, 22 Sep 2025 13:42:31 -0700
Subject: [PATCH] Call locate module callback for main executable
---
lldb/source/Target/Platform.cpp | 25 -
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index 8681adaf5ea76..1b2ac3aa94aef 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -750,12 +750,27 @@ Platform::ResolveExecutable(const ModuleSpec &module_spec,
if (resolved_module_spec.GetArchitecture().IsValid() ||
resolved_module_spec.GetUUID().IsValid()) {
-Status error =
-ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
-module_search_paths_ptr, nullptr, nullptr);
+// Call locate module callback first to give it a chance to find/register
+// symbol file specs for the main executable, similar to how shared
libraries
+// are handled in Platform::GetRemoteSharedModule()
+FileSpec symbol_file_spec;
+CallLocateModuleCallbackIfSet(resolved_module_spec, exe_module_sp,
+ symbol_file_spec, nullptr);
-if (exe_module_sp && exe_module_sp->GetObjectFile())
- return error;
+Status error;
+if (!exe_module_sp) {
+ // If locate module callback didn't provide a module, fallback to
standard path
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ module_search_paths_ptr, nullptr,
nullptr);
+}
+
+if (exe_module_sp && exe_module_sp->GetObjectFile()) {
+ // Set the symbol file if locate module callback returned one
+ if (symbol_file_spec) {
+exe_module_sp->SetSymbolFileFileSpec(symbol_file_spec);
+ }
+ return error; // Return the actual status from GetSharedModule (or
success from callback)
+}
exe_module_sp.reset();
}
// No valid architecture was specified or the exact arch wasn't found.
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][PDB] Run UDT layout test with native PDB too (PR #159769)
https://github.com/Nerixyz updated
https://github.com/llvm/llvm-project/pull/159769
>From d2c6336279358e570dcdc4e4a1ce75baf0a048ee Mon Sep 17 00:00:00 2001
From: Nerixyz
Date: Mon, 22 Sep 2025 11:57:34 +0200
Subject: [PATCH] [LLDB][PDB] Run UDT layout test with native PDB too
---
.../SymbolFile/NativePDB/udt-layout.test | 129 ++
.../test/Shell/SymbolFile/PDB/udt-layout.test | 2 +-
2 files changed, 130 insertions(+), 1 deletion(-)
create mode 100644 lldb/test/Shell/SymbolFile/NativePDB/udt-layout.test
diff --git a/lldb/test/Shell/SymbolFile/NativePDB/udt-layout.test
b/lldb/test/Shell/SymbolFile/NativePDB/udt-layout.test
new file mode 100644
index 0..6e971541de60c
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/NativePDB/udt-layout.test
@@ -0,0 +1,129 @@
+# REQUIRES: target-windows
+
+# Test UDT layout reconstruction
+# RUN: split-file %s %t
+# RUN: %build --compiler=clang-cl -o %t.exe -- %t/main.cpp
+# RUN: %lldb -f %t.exe -s %t/commands.input 2>&1 | FileCheck %s
+
+#--- main.cpp
+
+// this is from the DIA plugin (UdtLayoutTest.cpp)
+struct A {
+ explicit A(int u) { _u._u3 = u; }
+ A(const A &) = default;
+ virtual ~A() = default;
+
+private:
+ union U {
+char _u1;
+short _u2;
+int _u3;
+ };
+
+ A::U _u;
+};
+
+#pragma pack(push, 1)
+template struct B : public virtual A {
+ B(char a, unsigned short b, int c) : A(a + b + c), _a(a), _b(b), _c(c) {}
+
+private:
+ char _a;
+ unsigned short : 3;
+ unsigned short _b : 6;
+ unsigned short : 4;
+ int _c;
+};
+#pragma pack(pop)
+
+#pragma pack(push, 16)
+class C : private virtual B<0>, public virtual B<1>, private B<2>, public B<3>
{
+public:
+ C(char x, char y, char z)
+ : A(x - y + z), B<0>(x, y, z), B<1>(x * 2, y * 2, z * 2),
+B<2>(x * 3, y * 3, z * 3), B<3>(x * 4, y * 4, z * 4), _x(x * 5),
+_y(y * 5), _z(z * 5) {}
+
+ static int abc;
+
+private:
+ int _x;
+ short _y;
+ char _z;
+};
+int C::abc = 123;
+#pragma pack(pop)
+
+class List {
+public:
+ List() = default;
+ List(List *p, List *n, C v) : Prev(p), Next(n), Value(v) {}
+
+private:
+ List *Prev = nullptr;
+ List *Next = nullptr;
+ C Value{1, 2, 3};
+};
+
+int main() {
+ List ls[16];
+ return 0; // break here
+}
+
+#--- commands.input
+
+settings set target.max-children-depth 10
+br set -p "break here"
+run
+target variable
+frame variable
+quit
+
+# CHECK: (int) ::C::abc = 123
+
+# CHECK: (List[16]) ls = {
+# CHECK:[15] = {
+# CHECK-NEXT: Prev = nullptr
+# CHECK-NEXT: Next = nullptr
+# CHECK-NEXT: Value = {
+# CHECK-NEXT: B<2> = {
+# CHECK-NEXT: A = {
+# CHECK-NEXT: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2)
+# CHECK-NEXT: }
+# CHECK-NEXT: _a = '\x03'
+# CHECK-NEXT: _b = 6
+# CHECK-NEXT: _c = 9
+# CHECK-NEXT: }
+# CHECK-NEXT: B<3> = {
+# CHECK-NEXT: A = {
+# CHECK-NEXT: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2)
+# CHECK-NEXT: }
+# CHECK-NEXT: _a = '\x04'
+# CHECK-NEXT: _b = 8
+# CHECK-NEXT: _c = 12
+# CHECK-NEXT: }
+# CHECK-NEXT: A = {
+# CHECK-NEXT: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2)
+# CHECK-NEXT: }
+# CHECK-NEXT: B<0> = {
+# CHECK-NEXT: A = {
+# CHECK-NEXT: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2)
+# CHECK-NEXT: }
+# CHECK-NEXT: _a = '\x01'
+# CHECK-NEXT: _b = 2
+# CHECK-NEXT: _c = 3
+# CHECK-NEXT: }
+# CHECK-NEXT: B<1> = {
+# CHECK-NEXT: A = {
+# CHECK-NEXT: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2)
+# CHECK-NEXT: }
+# CHECK-NEXT: _a = '\x02'
+# CHECK-NEXT: _b = 4
+# CHECK-NEXT: _c = 6
+# CHECK-NEXT: }
+# CHECK-NEXT: _x = 5
+# CHECK-NEXT: _y = 10
+# CHECK-NEXT: _z = '\x0f'
+# CHECK-NEXT: }
+# CHECK-NEXT: }
+# CHECK-NEXT: }
diff --git a/lldb/test/Shell/SymbolFile/PDB/udt-layout.test
b/lldb/test/Shell/SymbolFile/PDB/udt-layout.test
index bc68539e25ec1..619646b3f12ba 100644
--- a/lldb/test/Shell/SymbolFile/PDB/udt-layout.test
+++ b/lldb/test/Shell/SymbolFile/PDB/udt-layout.test
@@ -1,4 +1,4 @@
-REQUIRES: target-windows, lld
+REQUIRES: target-windows, lld, diasdk
RUN: %build --compiler=clang-cl --output=%t.exe %S/Inputs/UdtLayoutTest.cpp
RUN: %lldb -b -s %S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][PDB] Run UDT layout test with native PDB too (PR #159769)
@@ -1,51 +1,63 @@
REQUIRES: target-windows, lld
RUN: %build --compiler=clang-cl --output=%t.exe %S/Inputs/UdtLayoutTest.cpp
-RUN: %lldb -b -s %S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s
+RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb -b -s
%S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s
+RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -b -s
%S/Inputs/UdtLayoutTest.script -- %t.exe | FileCheck %s
-CHECK:(int) C::abc = 123
+CHECK:(int) {{(::)?}}C::abc = 123
CHECK:(List[16]) ls = {
-CHECK: [15] = {
-CHECK:Prev = nullptr
-CHECK:Next = nullptr
-CHECK:Value = {
-CHECK: B<0> = {
-CHECK:A = {
-CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2)
-CHECK:}
-CHECK:_a = '\x01'
-CHECK:_b = 2
-CHECK:_c = 3
-CHECK: }
-CHECK: B<1> = {
-CHECK:A = {
-CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2)
-CHECK:}
-CHECK:_a = '\x02'
-CHECK:_b = 4
-CHECK:_c = 6
-CHECK: }
-CHECK: B<2> = {
-CHECK:A = {
-CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2)
-CHECK:}
-CHECK:_a = '\x03'
-CHECK:_b = 6
-CHECK:_c = 9
-CHECK: }
-CHECK: B<3> = {
-CHECK:A = {
-CHECK: _u = (_u1 = '\x02', _u2 = 2, _u3 = 2)
-CHECK:}
-CHECK:_a = '\x04'
-CHECK:_b = 8
-CHECK:_c = 12
-CHECK: }
-CHECK: A = {
-CHECK:_u = (_u1 = '\x02', _u2 = 2, _u3 = 2)
-CHECK: }
-CHECK: _x = 5
-CHECK: _y = 10
-CHECK: _z = '\x0f'
-CHECK:}
-CHECK: }
-CHECK:}
+
+CHECK: [14] = {
Nerixyz wrote:
I added a separate test to the native plugin now.
> Does LLDB complain if a user requests the DIA plugin but LLDB was compiled
> without DIA support? If not, I think it's worth investigating
This isn't the case right now. I'll take a look at printing a warning.
https://github.com/llvm/llvm-project/pull/159769
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][ClangExpressionParser] Reset DiagnosticManager before we create persistent variables (PR #160074)
Michael137 wrote: The `m_passthrough` guard was added in https://github.com/llvm/llvm-project/commit/4e969da33e113dffc1dfcf5c5e3ef97e3b594161 I assume something got refactored since then that broke it again. Or maybe it was fixing a different codepath leading to this crash https://github.com/llvm/llvm-project/pull/160074 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix a bug where an error was emitted for GCC union types. (PR #159401)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/159401 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reland #158161 with cmake fix (PR #159842)
https://github.com/satyajanga approved this pull request. Looks good to me ! https://github.com/llvm/llvm-project/pull/159842 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Reland #158161 with cmake fix (PR #159842)
https://github.com/satyajanga closed https://github.com/llvm/llvm-project/pull/159842 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [LLDB][PDB] Warn if DIA plugin is requested but not available (PR #160067)
https://github.com/Nerixyz updated
https://github.com/llvm/llvm-project/pull/160067
>From 4dab54fd1d003e99ac0b1014b276f0c6d24f9de2 Mon Sep 17 00:00:00 2001
From: Nerixyz
Date: Mon, 22 Sep 2025 12:32:08 +0200
Subject: [PATCH 1/2] [LLDB][PDB] Warn if DIA plugin is requested but not
available
---
.../Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | 27 ++--
.../SymbolFile/NativePDB/native-setting.cpp | 65 +++
.../Shell/SymbolFile/PDB/native-setting.cpp | 25 +--
3 files changed, 106 insertions(+), 11 deletions(-)
create mode 100644 lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp
diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index 0e2ca1784e7e9..68e229b697116 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -14,6 +14,7 @@
#include "clang/Lex/Lexer.h"
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "lldb/Core/Debugger.h"
#include "lldb/Core/Mangled.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
@@ -105,7 +106,6 @@ enum {
#include "SymbolFilePDBPropertiesEnum.inc"
};
-#if LLVM_ENABLE_DIA_SDK && defined(_WIN32)
bool ShouldUseNativeReaderByDefault() {
static bool g_use_native_by_default = true;
@@ -117,11 +117,16 @@ bool ShouldUseNativeReaderByDefault() {
!env_value.equals_insensitive("1") &&
!env_value.equals_insensitive("true"))
g_use_native_by_default = false;
+
+#if !LLVM_ENABLE_DIA_SDK || !defined(_WIN32)
+// if the environment value is unset, the native reader is requested
+if (env_value.empty())
+ g_use_native_by_default = true;
+#endif
});
return g_use_native_by_default;
}
-#endif
class PluginProperties : public Properties {
public:
@@ -136,6 +141,21 @@ class PluginProperties : public Properties {
bool UseNativeReader() const {
#if LLVM_ENABLE_DIA_SDK && defined(_WIN32)
+return IsNativeReaderRequested();
+#else
+if (!IsNativeReaderRequested()) {
+ static std::once_flag g_warning_shown;
+ Debugger::ReportWarning(
+ "The DIA PDB reader was explicitly requested, but LLDB was built "
+ "without the DIA SDK. The native reader will be used instead.",
+ {}, &g_warning_shown);
+}
+return true;
+#endif
+ }
+
+private:
+ bool IsNativeReaderRequested() const {
auto value =
GetPropertyAtIndexAs(ePropertyReader, ePDBReaderDefault);
switch (value) {
@@ -147,9 +167,6 @@ class PluginProperties : public Properties {
case ePDBReaderDefault:
return ShouldUseNativeReaderByDefault();
}
-#else
-return true;
-#endif
}
};
diff --git a/lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp
b/lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp
new file mode 100644
index 0..fc0ee218dd0d2
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp
@@ -0,0 +1,65 @@
+// REQUIRES: !diasdk, target-windows
+
+// Test plugin.symbol-file.pdb.reader setting without the DIA SDK
+// RUN: %build -o %t.exe -- %s
+// RUN: env -u LLDB_USE_NATIVE_PDB_READER %lldb %t.exe -o 'target modules dump
symfile' 2>&1 | FileCheck --check-prefix=NO-ENV %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER= %lldb %t.exe -o 'target modules dump
symfile' 2>&1 | FileCheck --check-prefix=NO-ENV %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb %t.exe -o 'target modules dump
symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb %t.exe -o 'target modules dump
symfile' 2>&1 | FileCheck --check-prefix=ENV1 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb \
+// RUN: -o 'settings set plugin.symbol-file.pdb.reader dia' \
+// RUN: -o 'target create %t.exe' \
+// RUN: -o 'target modules dump symfile' \
+// RUN: 2>&1 | FileCheck --check-prefix=ENV0-SET-DIA %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb \
+// RUN: -o 'settings set plugin.symbol-file.pdb.reader dia' \
+// RUN: -o 'target create %t.exe' \
+// RUN: -o 'target modules dump symfile' \
+// RUN: 2>&1 | FileCheck --check-prefix=ENV1-SET-DIA %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb \
+// RUN: -o 'settings set plugin.symbol-file.pdb.reader native' \
+// RUN: -o 'target create %t.exe' \
+// RUN: -o 'target modules dump symfile' \
+// RUN: 2>&1 | FileCheck --check-prefix=ENV0-SET-NATIVE %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb \
+// RUN: -o 'settings set plugin.symbol-file.pdb.reader native' \
+// RUN: -o 'target create %t.exe' \
+// RUN: -o 'target modules dump symfile' \
+// RUN: 2>&1 | FileCheck --check-prefix=ENV1-SET-NATIVE %s
+
+// NO-ENV-NOT: warning:
+// NO-ENV: (lldb) target modules dump symfile
+// NO-ENV: Dumping debug symbols for 1 modules.
+// NO-ENV: SymbolFile native-pdb
+
+// ENV0: warning: The DIA PDB reader was explicitly requested, but LLDB w
[Lldb-commits] [lldb] [lldb] Introduce Process::FixAnyAddressPreservingAuthentication (PR #159785)
DavidSpickett wrote: > In a very ideal world, I would love if we could not strip anything, ever. But > this places some burden on codegen of the expression evaluator, for all > languages and all ABIs. I don't think it's doable right now. Yes we're getting into a pointers as capabilities sort of model, except they don't always have the same contents like CHERI does and then we're tracking what's essentially provenance to say what's in the unused bits. Which we might have to do one day but I'd prefer to put it off as long as possible. > We could also just say "FixAddressForExpressionEvaluation", given how that's > the only use case I know of today. This is fine with me. It's for code generation and expression evaluation is our only code generation (ignoring the IR interpreter). > A little bit of background, I think everyone understands the basic idea of > what Felipe is doing here & why, but I think outlining where we are could be > helpful. I haven't seen anyone deploying MTE or PAC this extensively on Linux, but this all fits with my theoretical understanding of it. So there are times when you know you have to strip the PAC bits, because the loads do not have a preceding auth. But also, there are times when you do need to keep the PAC bits, because the loads **do** have a preceeding auth, right? Like in your example where you JIT extra code to sign the pointers. You do that because the code that uses them expects to be able to authenticate them. So how do we discriminate between those 2 scenarios? Or do we not. Do the pointers get stripped by the method this PR adds, then the extra code resigns it in-process. https://github.com/llvm/llvm-project/pull/159785 ___ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Use APSInt's right shift operator in Scalar (PR #160149)
llvmbot wrote:
@llvm/pr-subscribers-lldb
Author: Ilia Kuklin (kuilpd)
Changes
Right shift operator in `Scalar` didn't check if the value is unsigned to
perform a logical right shift. Use the right shift operator from `APSInt` that
does this check.
---
Full diff: https://github.com/llvm/llvm-project/pull/160149.diff
2 Files Affected:
- (modified) lldb/source/Utility/Scalar.cpp (+3-17)
- (modified) lldb/unittests/Utility/ScalarTest.cpp (+3)
``diff
diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index c8766bdf2aee7..f2c18cdd896da 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -471,24 +471,10 @@ bool Scalar::ShiftRightLogical(const Scalar &rhs) {
}
Scalar &Scalar::operator>>=(const Scalar &rhs) {
- switch (m_type) {
- case e_void:
- case e_float:
+ if (m_type == e_int && rhs.m_type == e_int)
+m_integer >>= rhs.m_integer.getZExtValue();
+ else
m_type = e_void;
-break;
-
- case e_int:
-switch (rhs.m_type) {
-case e_void:
-case e_float:
- m_type = e_void;
- break;
-case e_int:
- m_integer = m_integer.ashr(rhs.m_integer);
- break;
-}
-break;
- }
return *this;
}
diff --git a/lldb/unittests/Utility/ScalarTest.cpp
b/lldb/unittests/Utility/ScalarTest.cpp
index 6d5caef42bee4..e6d7479b59fee 100644
--- a/lldb/unittests/Utility/ScalarTest.cpp
+++ b/lldb/unittests/Utility/ScalarTest.cpp
@@ -118,11 +118,14 @@ TEST(ScalarTest, RightShiftOperator) {
int a = 0x1000;
int b = 0x;
int c = 4;
+ unsigned d = 0x;
Scalar a_scalar(a);
Scalar b_scalar(b);
Scalar c_scalar(c);
+ Scalar d_scalar(d);
ASSERT_EQ(a >> c, a_scalar >> c_scalar);
ASSERT_EQ(b >> c, b_scalar >> c_scalar);
+ ASSERT_EQ(d >> c, d_scalar >> c_scalar);
}
TEST(ScalarTest, GetBytes) {
``
https://github.com/llvm/llvm-project/pull/160149
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
