Skip to content

Conversation

@Nerixyz
Copy link
Contributor

@Nerixyz Nerixyz commented 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.

@Nerixyz Nerixyz requested a review from Michael137 October 29, 2025 17:44
@Nerixyz Nerixyz requested a review from JDevlieghere as a code owner October 29, 2025 17:44
@llvmbot llvmbot added the lldb label Oct 29, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 29, 2025

@llvm/pr-subscribers-lldb

Author: nerix (Nerixyz)

Changes

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). DWARF emitted by clang on Windows doesn't include the public symbols, so LLDB fell back to PDB.


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

1 Files Affected:

  • (modified) lldb/test/API/functionalities/multiple-slides/TestMultipleSlides.py (+3)
diff --git a/lldb/test/API/functionalities/multiple-slides/TestMultipleSlides.py b/lldb/test/API/functionalities/multiple-slides/TestMultipleSlides.py
index 3d6b27fe68a1b..48db92b611cfa 100644
--- a/lldb/test/API/functionalities/multiple-slides/TestMultipleSlides.py
+++ b/lldb/test/API/functionalities/multiple-slides/TestMultipleSlides.py
@@ -12,6 +12,9 @@
 class MultipleSlidesTestCase(TestBase):
     NO_DEBUG_INFO_TESTCASE = True
 
+    # DWARF doesn't include public symbols on Windows, so LLDB falls back to the PDB.
+    # Symbols don't have a size in the native PDB plugin.
+    @skipIfWindows
     def test_mulitple_slides(self):
         """Test that a binary can be slid multiple times correctly."""
         self.build()

@Michael137
Copy link
Member

When using -gdwarf on Windows, Clang (and LLD) also produce a PDB with the public symbols

So if we had used lld when running this test on Windows with DWARF, it would've passed?

This isn't compiled with DWARF, but linked with -gdwarf, so LLD generates a PDB.
@Nerixyz
Copy link
Contributor Author

Nerixyz commented Oct 29, 2025

So if we had used lld when running this test on Windows with DWARF, it would've passed?

Sorry, I was wrong. The intermediate object, main.o, is compiled without debug info. However, the final executable a.out is linked with clang and -gdwarf. Because of this, clang will instruct LLD to build a PDB.

I don't know how this works on other platforms if -g is included when linking. An alternative approach to compile without any debug info would be to set DEBUG_INFO_FLAG to an empty string. The test would fail on Windows too, because the default visibility for symbols is hidden and LLDB wouldn't find the variables.

@Nerixyz
Copy link
Contributor Author

Nerixyz commented Oct 29, 2025

There is still some bug with DWARF not including some public symbols on Windows (e.g. vtable symbols). I found this a while ago, but haven't investigated more.

@Michael137
Copy link
Member

In the interim, to unblock CI i suggest we either xfail the test or explicitly enable the DIA plugin on windows for this test

NO_DEBUG_INFO_TESTCASE = True

# The intermediate object main.o is compiled without debug info, but
# a.out is linked with `-gdwarf` on Windows. This creates a PDB.
Copy link
Member

Choose a reason for hiding this comment

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

Why does -gdwarf make LLD create a PDB? Seems counterintuitive. Is that just some odd side effect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's because of this:

if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7))
CmdArgs.push_back("-debug");

Copy link
Member

@Michael137 Michael137 Oct 29, 2025

Choose a reason for hiding this comment

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

Seems plausible. So clang-cl transforms -gdwarf into /Z7? Worth filing an issue to clarify what's going on

Copy link
Member

Choose a reason for hiding this comment

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

Is Z7 the thing that instructs pdb? Vague memory that some other flag is needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opened #165614.

@Nerixyz Nerixyz enabled auto-merge (squash) October 29, 2025 18:43
@Nerixyz Nerixyz merged commit 17c6c8d into llvm:main Oct 29, 2025
9 of 10 checks passed
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`.
Nerixyz added a commit that referenced this pull request Oct 31, 2025
In #165604, a test was skipped on Windows, because the native PDB plugin
didn't set sizes on symbols. While the test isn't compiled with debug
info, it's linked with `-gdwarf`, causing a PDB to be created on
Windows. This PDB will only contain the public symbols (written by the
linker) and section information. The symbols themselves don't have a
size, however the DIA SDK sets a size for them.
It seems like, for these data symbols, the size given from DIA is the
distance to the next symbol (or the section end).

This PR implements the naive approach for the native plugin. The main
difference is in function/code symbols. There, DIA searches for a
corresponding `S_GPROC32` which have a "code size" that is sometimes
slightly smaller than the difference to the next symbol.
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.

3 participants