[llvm-bugs] [Bug 47580] New: [Codeview] Missing debug info for constant globals that are not used by code

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 18 11:57:01 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47580

            Bug ID: 47580
           Summary: [Codeview] Missing debug info for constant globals
                    that are not used by code
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: DebugInfo
          Assignee: unassignedbugs at nondot.org
          Reporter: sylvain.audi at ubisoft.com
                CC: akhuang at google.com, alexandre.ganea at ubisoft.com,
                    jdevlieghere at apple.com, keith.walker at arm.com,
                    llvm-bugs at lists.llvm.org,
                    paul_robinson at playstation.sony.com, rnk at google.com

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?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200918/9abf83e4/attachment.html>


More information about the llvm-bugs mailing list