llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.02k stars 11.96k forks source link

Lack of debug info for global var in unamed namespace #21017

Open llvmbot opened 10 years ago

llvmbot commented 10 years ago
Bugzilla Link 20643
Version 3.4
OS Linux
Reporter LLVM Bugzilla Contributor
CC @dwblaikie,@DougGregor

Extended Description

$ cat test.cpp namespace B { namespace { class D { public: int i; }; } }

B::D x;

int main() { }

$ clang++ test.cpp -g

$ gdb a.out GNU gdb (GDB) SUSE (7.3-0.10.1) Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "ppc64-suse-linux". For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/... Reading symbols from /nfs/terran/home/zhuhw/working/test/a.out...done. (gdb) ptype x No symbol "x" in current context.

dwblaikie commented 10 years ago

Unused file-scoped entities aren't emitted by LLVM. There's a flag to force it, but nothing to get the "half way" behavior of debug info describing it, but LLVM not emitting it (and thus having the debug info describe that the global variable has been optimized away).

Someone could potentially add this at some point, but not high on anyone's list so far as I know.

llvmbot commented 4 months ago

@llvm/issue-subscribers-debuginfo

Author: None (llvmbot)

| | | | --- | --- | | Bugzilla Link | [20643](https://llvm.org/bz20643) | | Version | 3.4 | | OS | Linux | | Reporter | LLVM Bugzilla Contributor | | CC | @dwblaikie,@DougGregor | ## Extended Description $ cat test.cpp namespace B { namespace { class D { public: int i; }; } } B::D x; int main() { } $ clang++ test.cpp -g $ gdb a.out GNU gdb (GDB) SUSE (7.3-0.10.1) Copyright (C) 2011 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "ppc64-suse-linux". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /nfs/terran/home/zhuhw/working/test/a.out...done. (gdb) ptype x No symbol "x" in current context.