<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 - [Codeview] Missing debug info for constant globals that are not used by code"
href="https://bugs.llvm.org/show_bug.cgi?id=47580">47580</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[Codeview] Missing debug info for constant globals that are not used by code
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>DebugInfo
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>sylvain.audi@ubisoft.com
</td>
</tr>
<tr>
<th>CC</th>
<td>akhuang@google.com, alexandre.ganea@ubisoft.com, jdevlieghere@apple.com, keith.walker@arm.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com, rnk@google.com
</td>
</tr></table>
<p>
<div>
<pre>Here is a test case covering several cases of the same issue:
//------------------------------------------------------------
// main.cpp
//
//------------------------------------------------------------
struct A {
static const int const_A = 3;
static constexpr int constexpr_A = 4;
static constexpr const int constexprconst_A = 5;
static const int constOutside_A;
};
const int A::constOutside_A = 6;
static const int globalStaticConst = 10;
static constexpr int globalStaticConstexpr = 11;
const int globalConst = 12;
constexpr int globalConstexpr = 13;
int main() {
A a;
return 0;
}
//------------------------------------------------------------
Compiling with clang-cl.exe:
clang-cl.exe main.cpp /nologo /EHsc- /Z7 /std:c++17 /GS- /GR- /c
/Fo:main-clangcl.obj
lld-link.exe /DEBUG main-clangcl.obj
Compiling with Microsoft's cl.exe:
cl.exe main.cpp /nologo /EHsc- /Z7 /std:c++17 /GS- /GR- /c /Fo:main-msvc.obj
main.cpp
lld-link.exe /DEBUG main-msvc.obj
In Visual Studio 2019 debugger, trying to display those values (through the
Watch Window):
1) main-MSVC.exe
-> "A" : symbol exists, can expand to display members with their value
-> "globalStaticConst" etc: displayed with value
2) main-clangcl.exe
"A" symbols exists, can expand to display members, but the values are replaced
with an error message "An unspecified error has occurred", except for
constexprconst_A (which was evaluated in main()) and constOutside_A.
Note that the behavior is the same when compiling with clang argument
`-fno-limit-debug-info`.
Comparing the output of `llvm-pdbutil dump --symbols` on both obj files, we can
see a few S_CONSTANT entries that appear on msvc but not clangcl:
Symbols
============================================================
Mod 0000 | `.debug$S`:
(...)
0 | S_CONSTANT [size = 21] `B::const_B`
type = 0x1003 (const int), value = 3
0 | S_CONSTANT [size = 25] `B::constexpr_B`
type = 0x1003 (const int), value = 4
0 | S_CONSTANT [size = 30] `B::constexprconst_B`
type = 0x1003 (const int), value = 5
etc
It would be nice to have these values shown when debugging.
If I understand correctly, the goal is to have the informations about those
constants ready at CodeViewDebug::endModule(), so that they can be emitted in
CodeViewDebug::emitDebugInfoForGlobals().
@rnk, would you know where to gather those symbols information?</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>