[Debug] Dwarf generated incomplete in some case

I try to build the mold by llvmorg-14.0.6

use command make CXX=clang++ CC=clang CXXFLAGS="-g --gcc-toolchain=/path/to/toolchain/"
The compilation process is working fine, but when I try to debug the mold using GDB,
I got the error Dwarf Error: DW_FORM_strx1 found in non-DWO CU.

I try to use gcc 11.0.0 to compile and then debug in same gdb, it works normally.

So I’m wondering where this might be a problem.

This is a known issue. GDB older then v10.1 does not support some DWARFv5 features, while clang gets DWARFv5 enabled by default. You can either use newer version of GDB or switch to DWARFv4 (-gdwarf-4).
Here are some details Gdb < 10.1 can't read clang's DWARF v5 - #12 by tstellar.

1 Like