<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/101710>101710</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Inconsistent behavior in lldb-shell :: Unwind/windows-unaligned-x86_64.test
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kendalharland
</td>
</tr>
</table>
<pre>
## Overview
My local build of this test produces a binary whose `realign_stack` and `call_func` symbols are not visible to `lldb` so the test fails to match to the expected output of `thread backtrace` as these symbol names appear as empty strings in the stack trace output.
To make this test pass, I had to create [this local patch](https://github.com/llvm/llvm-project/compare/main...kendalharland:llvm-project:kendal/fix-win-unaligned-test) which is certainly not the correct way to fix things but demonstrates my problem well.
## Background
In particular, here are the problems I observe:
1. lld-link does not produce a binary that exports the `realign_stack` and `call_func` symbols which are defined as `.globl` in [windows-unaligned-x86_64-asm.s](https://github.com/llvm/llvm-project/blob/90065da6d5a5f661b60c2f75b0f2dc094d27f4f5/lldb/test/Shell/Unwind/Inputs/windows-unaligned-x86_64-asm.s), even though `lldb-pdbutil` indicates that these symbols are “public” in the final executable:
```
PS C:\workspace\llvm-project> C:\workspace\llvm-project\build\bin\llvm-pdbutil.exe pretty --externals C:\workspace\llvm-project\build\tools\lldb\test\Shell\Unwind\Output\windows-unaligned-x86_64.test.pdb | Select-String -Pattern realign_stack
public [0x0000104e] realign_stack
PS C:\workspace\llvm-project> C:\workspace\llvm-project\build\bin\llvm-pdbutil.exe pretty --externals C:\workspace\llvm-project\build\tools\lldb\test\Shell\Unwind\Output\windows-unaligned-x86_64.test.pdb | Select-String -Pattern call_func
public [0x00001040] call_func
```
As a workaround I’ve manually exported the symbols in build.py using e.g. `/EXPORT:realign_stack`
2. LLDB doesn’t appear to load PDB symbols from a separate `.pdb` file automatically. It’s unclear if the original test author ran into this problem from their [PR discussion](https://reviews.llvm.org/D129455) so as a workaround I added an explicit `add-dysm ...` call to load the symbols.
3. LLDB seems to have a hard time parsing PDB files and crashes when `add-dsym` is called. I believe this is a known issue [[1]](https://github.com/ziglang/zig/issues/13095), [[2]](https://github.com/llvm/llvm-project/issues/91060)]. Given that there are 2 PDB readers to choose from: LLDB’s implementation (default) and the Windows Native reader, as a workaround I’ve used the native one by setting `LLDB_USE_NATIVE_PDB_READER=1`.
## Questions
1. Is there any contributor that is currently running this test in their CI, and if so does it pass? (Perhaps @dzhidzhoev).
2. What toolchain differences would cause the `realign_stack` and `call_func` symbols not to exported in one build vs another? Different assembler? Compiler version? Linker version? I would like to fix this locally and then update the test's `REQUIRES` statement if possible.
3. What needs to be done to make LLDB's build in PDB reader function locally? If this test is running in someone's CI without LLDB_USE_NATIVE_PBD_READER=1, there must be some steps I skipped in setting up PDB support and I'd like to document these.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsV1Fz4jgS_jXipQuXLbAJDzwQCFdUze1kk5nbe0vJVoN1yJJLkiHMr79q2RAyM3u5neetSgWw5Fb31193fxLeq71BXLD8nuXrkehCbd3igEYKXQunhZGj0srzgvEJ4xP4fER3VHhi6Zqly3-eQdtKaCg7pSXYHYRaeQjoA7TOyq5CDwJKZYQ7w6m2HoEVqUOh1d68-CCqAytSEEbS80po_bLrTEXP_LkprfYgHIKxAY7Kq1IjBEtbtZZl3GUh1NifuBNKe1pvRKhq-kJL-NpiFVCC7ULbBXKSFWmoHQoJpagOwYkKoxeeXvA4HA1GNOR-26JwtIhNG87gg1Nm70GZaD7GANHGcELSY9P__0LeHPAWF-E94yvYQi0kOVk5FAGB5fdxUw9oSyGwfM34XR1C69lkyfiG8c1ehbork8o2jG-0Pl4-xq2z_8EqML6pbNMKh4xvGqFMkiTv0skmy3f7J8t-mfHNTr2OT8qMOxPzg3JMHjM-h1OtqhqUhwpdEMroc8wJAVBZ57AKcBJnimanXilYQqjsAkhsrPHBiYAemjOxotTYwAm1fgfUwK97UR32znZG3i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