Skip to content

Conversation

@Nerixyz
Copy link
Contributor

@Nerixyz Nerixyz commented Oct 28, 2025

All PDB tests now pass when compiled without DIA on Windows, so they pass with the native reader.

With this PR, the default reader changes to the native reader.
The plan is to eventually remove the DIA reader (see https://discourse.llvm.org/t/rfc-removing-the-dia-pdb-plugin-from-lldb/87827 and #114906).

For now, DIA can be used by setting plugin.symbol-file.pdb.reader to dia or by setting LLDB_USE_NATIVE_PDB_READER=0 (mostly undocumented, but used in tests).

@llvmbot
Copy link
Member

llvmbot commented Oct 28, 2025

@llvm/pr-subscribers-lldb

Author: nerix (Nerixyz)

Changes

All PDB tests now pass when compiled without DIA on Windows, so they pass with the native reader.

With this PR, the default reader changes to the native reader.
The plan is to eventually remove the DIA reader (see https://discourse.llvm.org/t/rfc-removing-the-dia-pdb-plugin-from-lldb/87827 and #114906).

For now, DIA can be used by setting plugin.symbol-file.pdb.reader to dia or by setting LLDB_USE_NATIVE_PDB_READER=0 (mostly undocumented, but used in tests).


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

4 Files Affected:

  • (modified) lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp (+6-12)
  • (modified) lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp (+3-3)
  • (modified) lldb/test/Shell/SymbolFile/PDB/native-setting.cpp (+4-4)
  • (modified) llvm/docs/ReleaseNotes.md (+4)
diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index 3b936c06b1072..0ccb1804bb13a 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -83,8 +83,8 @@ constexpr OptionEnumValueElement g_pdb_reader_enums[] = {
     {
         ePDBReaderDefault,
         "default",
-        "Use DIA PDB reader unless LLDB_USE_NATIVE_PDB_READER environment "
-        "variable is set",
+        "Use native PDB reader unless LLDB_USE_NATIVE_PDB_READER environment "
+        "is set to 0",
     },
     {
         ePDBReaderDIA,
@@ -109,16 +109,10 @@ enum {
 static const bool g_should_use_native_reader_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
-
-  return env_value.equals_insensitive("on") ||
-         env_value.equals_insensitive("yes") ||
-         env_value.equals_insensitive("1") ||
-         env_value.equals_insensitive("true");
+  return !env_value.equals_insensitive("off") &&
+         !env_value.equals_insensitive("no") &&
+         !env_value.equals_insensitive("0") &&
+         !env_value.equals_insensitive("false");
 }();
 
 class PluginProperties : public Properties {
diff --git a/lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp b/lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp
index dc26ec8d30cb4..91f451fd0dadc 100644
--- a/lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp
+++ b/lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp
@@ -8,9 +8,9 @@
 // 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=foo %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
-// RUN: env LLDB_USE_NATIVE_PDB_READER=42 %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=ENV0 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=foo %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV1 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=42 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV1 %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' \
diff --git a/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp b/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp
index f5e54592b0b31..54b7f28a71259 100644
--- a/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp
+++ b/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp
@@ -8,9 +8,9 @@
 // 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=foo %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
-// RUN: env LLDB_USE_NATIVE_PDB_READER=42 %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=ENV0 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=foo %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV1 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=42 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV1 %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' \
@@ -36,7 +36,7 @@
 // NO-ENV-NOT: warning:
 // NO-ENV: (lldb) target modules dump symfile
 // NO-ENV: Dumping debug symbols for 1 modules.
-// NO-ENV: SymbolFile pdb
+// NO-ENV: SymbolFile native-pdb
 
 // ENV0-NOT: warning:
 // ENV0: (lldb) target modules dump symfile
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 36383b12788f9..fa99fc0338c56 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -191,6 +191,10 @@ Changes to LLDB
 * The `show-progress` setting, which became a NOOP with the introduction of the
   statusline, now defaults to off and controls using OSC escape codes to show a
   native progress bar in supporting terminals like Ghostty and ConEmu.
+* The default PDB reader on Windows was changed from DIA to native, which uses 
+  LLVM's PDB and CodeView support. You can switch back to the DIA reader with
+  `settings set plugin.symbol-file.pdb.reader dia`. Note that support for the
+  DIA reader will be removed in future versions of LLDB.
 
 Changes to BOLT
 ---------------------------------

Copy link
Member

@Michael137 Michael137 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM, thanks for pushing through! Excited to see one of these plugins go away.

I assume the PDB shell-tests all explicitly turn on DIA? And the native ones turn it off? I.e., all the test coverage remains the same after this patch?

Please let @DavidSpickett and @JDevlieghere also take a look before merging.

Copy link
Collaborator

@DavidSpickett DavidSpickett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a small comment on the release note.

I might have expected to see a lot of tests flip from opting in to opting out, but I think thanks to yours and others' hard work, all the tests run on both plugins now, correct?

@DavidSpickett
Copy link
Collaborator

I also forgot that when not built on Windows, we have always been using native. So this work has improved the remote debugging experience too!

@omjavaid
Copy link
Contributor

Thanks for this.

@medismailben medismailben requested review from azabazno and charles-zablit and removed request for azabazno October 28, 2025 16:29
@Nerixyz
Copy link
Contributor Author

Nerixyz commented Oct 28, 2025

I assume the PDB shell-tests all explicitly turn on DIA? And the native ones turn it off? I.e., all the test coverage remains the same after this patch?

Yes, they use the environment variable:

config.environment["LLDB_USE_NATIVE_PDB_READER"] = "0"

config.environment["LLDB_USE_NATIVE_PDB_READER"] = "1"

Copy link
Member

@JDevlieghere JDevlieghere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a huge achievement. Congratulations and thank you to everyone that helped make this happen.

Copy link
Contributor

@charles-zablit charles-zablit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this!

@DavidSpickett
Copy link
Collaborator

The setting is not in any release yet. Before, you had to use the environment variable.

I did not realise the setting hasn't been around that long. It was added in #151490:

This would make it possible to test both native PDB and DIA PDB in the API tests (see linked PR).

So for as long as we do / might need to do this, the setting remains. Even if we don't mention it in release notes, it is something users can discover. I was wondering if we should remove it so we didn't have one more thing to keep around for another release cycle.

I think not though. If all goes to plan:

  • Native becomes the default in the next release.
  • DIA is removed the release after, and the setting only accepts native.
  • Release after that, if we remember, we can remove the setting. If we forget it's not a big deal, since it's basically read only at that point.

You can merge this whenever you're ready.

@Nerixyz
Copy link
Contributor Author

Nerixyz commented Oct 29, 2025

Thank you to everyone who helped with the native plugin and LLVM's PDB support!

@Nerixyz Nerixyz merged commit 287ca7b into llvm:main Oct 29, 2025
10 of 11 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 29, 2025

LLVM Buildbot has detected a new failure on builder lldb-x86_64-win running on as-builder-10 while building lldb,llvm at step 8 "test-check-lldb-unit".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/211/builds/3312

Here is the relevant piece of the build log for the reference
Step 8 (test-check-lldb-unit) failure: Test just built components: check-lldb-unit completed (failure)
******************** TEST 'lldb-unit :: SymbolFile/PDB/./SymbolFilePDBTests.exe/14/18' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\SymbolFile\PDB\.\SymbolFilePDBTests.exe-lldb-unit-44948-14-18.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=18 GTEST_SHARD_INDEX=14 C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\SymbolFile\PDB\.\SymbolFilePDBTests.exe
--

Script:
--
C:\buildbot\as-builder-10\lldb-x86-64\build\tools\lldb\unittests\SymbolFile\PDB\.\SymbolFilePDBTests.exe --gtest_filter=SymbolFilePDBTests.TestRegexNameMatch
--
unknown file: error: SEH exception with code 0x3221225477 thrown in the test body.
Stack trace:



unknown file
SEH exception with code 0x3221225477 thrown in the test body.
Stack trace:




********************

Step 9 (test-check-lldb-api) failure: Test just built components: check-lldb-api completed (failure)
...
PASS: lldb-api :: functionalities/module_cache/universal/TestModuleCacheUniversal.py (539 of 1318)
PASS: lldb-api :: functionalities/memory/tag/TestMemoryTag.py (540 of 1318)
PASS: lldb-api :: functionalities/multiword-commands/TestMultiWordCommands.py (541 of 1318)
PASS: lldb-api :: functionalities/memory/find/TestMemoryFind.py (542 of 1318)
PASS: lldb-api :: functionalities/gdb_remote_client/TestPlatformKill.py (543 of 1318)
PASS: lldb-api :: functionalities/object-file/TestImageListMultiArchitecture.py (544 of 1318)
PASS: lldb-api :: functionalities/inferior-crashing/recursive-inferior/TestRecursiveInferiorStep.py (545 of 1318)
UNSUPPORTED: lldb-api :: functionalities/param_entry_vals/basic_entry_values/TestBasicEntryValues.py (546 of 1318)
PASS: lldb-api :: functionalities/paths/TestPaths.py (547 of 1318)
UNRESOLVED: lldb-api :: functionalities/multiple-slides/TestMultipleSlides.py (548 of 1318)
******************** TEST 'lldb-api :: functionalities/multiple-slides/TestMultipleSlides.py' FAILED ********************
Script:
--
C:/Python312/python.exe C:/buildbot/as-builder-10/lldb-x86-64/llvm-project/lldb\test\API\dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=C:/buildbot/as-builder-10/lldb-x86-64/build/./lib --env LLVM_INCLUDE_DIR=C:/buildbot/as-builder-10/lldb-x86-64/build/include --env LLVM_TOOLS_DIR=C:/buildbot/as-builder-10/lldb-x86-64/build/./bin --arch x86_64 --build-dir C:/buildbot/as-builder-10/lldb-x86-64/build/lldb-test-build.noindex --lldb-module-cache-dir C:/buildbot/as-builder-10/lldb-x86-64/build/lldb-test-build.noindex/module-cache-lldb\lldb-api --clang-module-cache-dir C:/buildbot/as-builder-10/lldb-x86-64/build/lldb-test-build.noindex/module-cache-clang\lldb-api --executable C:/buildbot/as-builder-10/lldb-x86-64/build/./bin/lldb.exe --compiler C:/buildbot/as-builder-10/lldb-x86-64/build/./bin/clang.exe --dsymutil C:/buildbot/as-builder-10/lldb-x86-64/build/./bin/dsymutil.exe --make C:/ninja/make.exe --llvm-tools-dir C:/buildbot/as-builder-10/lldb-x86-64/build/./bin --lldb-obj-root C:/buildbot/as-builder-10/lldb-x86-64/build/tools/lldb --lldb-libs-dir C:/buildbot/as-builder-10/lldb-x86-64/build/./lib --cmake-build-type Release --skip-category=lldb-dap C:\buildbot\as-builder-10\lldb-x86-64\llvm-project\lldb\test\API\functionalities\multiple-slides -p TestMultipleSlides.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 22.0.0git (https://github.com/llvm/llvm-project.git revision 287ca7b243facc7185bbd9dfdaa5a6a012819e1b)
  clang revision 287ca7b243facc7185bbd9dfdaa5a6a012819e1b
  llvm revision 287ca7b243facc7185bbd9dfdaa5a6a012819e1b
Skipping the following test categories: ['lldb-dap', 'libc++', 'libstdcxx', 'dwo', 'dsym', 'gmodules', 'debugserver', 'objc', 'fork', 'pexpect']


--
Command Output (stderr):
--
FAIL: LLDB (C:\buildbot\as-builder-10\lldb-x86-64\build\bin\clang.exe-x86_64) :: test_mulitple_slides (TestMultipleSlides.MultipleSlidesTestCase.test_mulitple_slides)

======================================================================

ERROR: test_mulitple_slides (TestMultipleSlides.MultipleSlidesTestCase.test_mulitple_slides)

   Test that a binary can be slid multiple times correctly.

----------------------------------------------------------------------

Traceback (most recent call last):

  File "C:\buildbot\as-builder-10\lldb-x86-64\llvm-project\lldb\test\API\functionalities\multiple-slides\TestMultipleSlides.py", line 78, in test_mulitple_slides

    error = target.SetModuleLoadAddress(module, first_size - 64)

            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\buildbot\as-builder-10\lldb-x86-64\build\Lib\site-packages\lldb\__init__.py", line 13519, in SetModuleLoadAddress

    return _lldb.SBTarget_SetModuleLoadAddress(self, module, sections_offset)

Nerixyz added a commit that referenced this pull request Oct 29, 2025
Fixes the failing DIA unit test
(https://lab.llvm.org/buildbot/#/builders/197/builds/10342) after
#165363.

Now that the native plugin is the default, we need to set the symbol
file plugin for DIA via the settings.
Nerixyz added a commit that referenced this pull request Oct 29, 2025
After the default PDB plugin changed to the native one (#165363), this
test failed, because it uses the size of public symbols and the native
plugin sets the size to 0 (as PDB doesn't include this information
explicitly). A PDB was built because the final executable in that test
was linked with `-gdwarf`.
@slydiman
Copy link
Contributor

LLVM Buildbot has detected a new failure on builder lldb-x86_64-win running on as-builder-10 while building lldb,llvm at step 8 "test-check-lldb-unit".

The buildbots lldb-remote-linux-win and lldb-aarch64-windows are broken too.

So, all lldb Windows buildbots are broken. I recommend to revert this patch for now and investigate the problem.

@Nerixyz
Copy link
Contributor Author

Nerixyz commented Oct 29, 2025

The buildbots lldb-remote-linux-win and lldb-aarch64-windows are broken too.

They're no longer broken after the two PRs.

@slydiman
Copy link
Contributor

Ok, thanks.

aokblast pushed a commit to aokblast/llvm-project that referenced this pull request Oct 30, 2025
All PDB tests now pass when compiled without DIA on Windows, so they
pass with the native reader.

With this PR, the default reader changes to the native reader.
The plan is to eventually remove the DIA reader (see
https://discourse.llvm.org/t/rfc-removing-the-dia-pdb-plugin-from-lldb/87827
and llvm#114906).

For now, DIA can be used by setting `plugin.symbol-file.pdb.reader` to
`dia` or by setting `LLDB_USE_NATIVE_PDB_READER=0` (mostly undocumented,
but used in tests).
aokblast pushed a commit to aokblast/llvm-project that referenced this pull request Oct 30, 2025
Fixes the failing DIA unit test
(https://lab.llvm.org/buildbot/#/builders/197/builds/10342) after
llvm#165363.

Now that the native plugin is the default, we need to set the symbol
file plugin for DIA via the settings.
aokblast pushed a commit to aokblast/llvm-project that referenced this pull request Oct 30, 2025
After the default PDB plugin changed to the native one (llvm#165363), this
test failed, because it uses the size of public symbols and the native
plugin sets the size to 0 (as PDB doesn't include this information
explicitly). A PDB was built because the final executable in that test
was linked with `-gdwarf`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants