Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 916747

Summary: sys-devel/clang: installed debug information seem to be empty
Product: Gentoo Linux Reporter: gerion <gerion.entrup>
Component: Current packagesAssignee: Gentoo Linux bug wranglers <bug-wranglers>
Status: RESOLVED INVALID    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description gerion 2023-11-03 10:40:53 UTC
I just tried to debug clang:14 itself but GDB cannot load its debug information. sys-devel/clang is compiled with use debug.

MWE:
```
$ gdb clang-14
GNU gdb (Gentoo 13.2 vanilla) 13.2
Copyright (C) 2023 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 "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from clang-14...
Reading symbols from /usr/lib/debug//usr/lib/llvm/14/bin/clang-14.debug...
(No debugging symbols found in /usr/lib/debug//usr/lib/llvm/14/bin/clang-14.debug)
(gdb) 
```

Inspecting the debug file itself:
```
$ objdump -g /usr/lib/debug/usr/lib/llvm/14/bin/clang-14.debug

/usr/lib/debug/usr/lib/llvm/14/bin/clang-14.debug:     file format elf64-x86-64

Contents of the .eh_frame section (loaded from /usr/lib/debug/usr/lib/llvm/14/bin/clang-14.debug):


00000000 ZERO terminator

```

The debug file contains symbols, though. I'm not sure, if the debug file should contain debug information but I have expected it.

The clang binary itself has some debug information but also links to the external debug file:
```
Contents of the .gnu_debuglink section (loaded from /usr/lib/llvm/14/bin/clang-14):

  Separate debug info file: clang-14.debug
  CRC value: 0x7bd1d29
```
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-11-03 10:43:51 UTC
Note that USE=debug has nothing to do with debug symbols.

See https://wiki.gentoo.org/wiki/Debugging#Per-package.

Anyway, if I had to guess, this is because debugedit lacks support for dwarf5. This would be a problem if you built clang with clang.
Comment 2 gerion 2023-11-03 11:05:20 UTC
Ok, I have `splitdebug` activated and clang is compiled with the system default (should be GCC). I will try to recompile it with `-g`.

Is it possible that splitdebug make Portage to split out a debug section that is more less empty since Clang was compiled without debug information?

Also, I have some debug information. For example, pressing <TAB> when defining a break point give some symbols.
Comment 3 gerion 2023-11-04 20:03:13 UTC
Actually compiling with debug information (-ggdb) fixes the problem.