<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - PDB debug info CV_ALLREG_VFRAME issue in 32 bit output, probably alignment problem"
href="https://bugs.llvm.org/show_bug.cgi?id=45114">45114</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>PDB debug info CV_ALLREG_VFRAME issue in 32 bit output, probably alignment problem
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>10.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mirek.fidler@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>First of all I am sorry I could not conjure a simple testcase, but the problem
depends on compiler emitting CV_ALLREG_VFRAME local variable records into the
database and those are hard to reproduce with small code.
I have downloaded toolchain here
<a href="https://github.com/mstorsjo/llvm-mingw/releases">https://github.com/mstorsjo/llvm-mingw/releases</a>
Our small opensource project maintains ide environment that has native .pdb
debugging support (using dbghelp.dll) so I have started experimenting with llvm
pdb output.
C:\upp\bin/clang\bin\i686-w64-mingw32-c++.exe -c -mthreads -g2 -static
-fexceptions -D_DEBUG -O0 -g -gcodeview -fno-limit-debug-info
-fno-omit-frame-pointer -x c++ "C:\u\PdbTests\main.cpp" -o
"C:/out/PdbTests/main.o"
Soon I have found that address of some local variables is 4 bytes off. Further
investigation revealed that the problem was for local variable symbols with
PSYMBOL_INFO.Register == CV_ALLREG_VFRAME.
After some more digging, I believe the issue is related to this:
The start of function looks like
004018D0 push ebp
004018D1 mov ebp,esp <----
004018D3 push esi
004018D4 and esp,byte -0x8 <----
004018D7 sub esp,0xc80
So there is an alignment of esp, but the value in epb is still unaligned.
However the values emmitted to .pdb in PSYMBOL_INFO.Address seem to be relative
to ALIGNED value, which sometimes leads to offset being invalid by 4. (All
further addresses in the code are esp based).
I have tried following workaround in our debugger:
.....
if(pSym->Flags & IMAGEHLP_SYMBOL_INFO_REGRELATIVE) {
if(pSym->Register == CV_ALLREG_VFRAME) {
if(c.pdb->win64)
v.address += c.pdb->GetCpuRegister(*c.context,
CV_AMD64_RBP);
else
{
adr_t ebp =
(adr_t)c.pdb->GetCpuRegister(*c.context, CV_REG_EBP);
if(c.pdb->clang)
ebp &= ~(adr_t)7; // Workaround for
supposed clang/win32 issue
v.address += ebp;
}
}
else
v.address += (adr_t)c.pdb->GetCpuRegister(*c.context,
pSym->Register);
}
.....
and that seems to completely fix the issue, but I think this still counts like
a bug... also posting this here for future reference for other unfortunate
debugger developers...</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>