I’m on Ubuntu 20.04 and I was testing different versions of clang. I downloaded clang-13.0.0, clang-14.0.0 and clang-15.0.6 all from LLVM Releases. I extracted and renamed the directories clang13
, clang14
and clang15
.
I wrote a hello world C++ program and named it main.cxx and then compiled it by the 3 versions of clang:
$ clang13/bin/clang++ -g main.cxx -o 13
$ clang14/bin/clang++ -g main.cxx -o 14
$ clang15/bin/clang++ -g main.cxx -o 15
Then I ran 13
under GDB doing gdb ./13
I got:
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
Copyright (C) 2020 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-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
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 13...
(gdb)
So it’s working fine.
But if I do the same with 14
and 15
, I get:
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
Copyright (C) 2020 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-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
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 15...
Dwarf Error: DW_FORM_strx1 found in non-DWO CU [in module /home/metal888/Downloads/clang_d/clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04/15]
(No debugging symbols found in 15)
(gdb)
So why GDB cannot read debugging symbols from 14
and 15
? What’s wrong? How can i fix this?
Additional info:
$ file 13 14 15
13: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
14: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
15: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped
Also:
$ clang13/bin/clang++ --version
clang version 13.0.0 (https://github.com/llvm/llvm-project/ 24c8eaec9467b2aaf70b0db33a4e4dd415139a50)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: blabla
$ clang14/bin/clang++ --version
clang version 14.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: blabla
$ clang15/bin/clang++ --version
clang version 15.0.6
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: blabla