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: unassignedb...@nondot.org
          Reporter: sylvain.a...@ubisoft.com
                CC: akhu...@google.com, alexandre.ga...@ubisoft.com,
                    jdevliegh...@apple.com, keith.wal...@arm.com,
                    llvm-bugs@lists.llvm.org,
                    paul_robin...@playstation.sony.com, r...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to