I built an ordinary "Hello World" C program with gcc 14.2.0 on macOS Sequoia 15.0, and I ran perfectly, and it was debugged with lldb perfectly. However, when I tried debugging it with gdb, it showed the error message `Dwarf Error: DW_FORM_line_strp used without required section`. ``` bash-3.2$ cat hello.c #include <stdio.h> int main(void) { printf("Hello World\n"); return 0; } bash-3.2$ gcc-14 hello.c -o hello -Wall -O0 -ggdb bash-3.2$ ./hello Hello World bash-3.2$ lldb ./hello (lldb) target create "./hello" Current executable set to '/Users/jianfeiye/test/ctest/hello' (x86_64). (lldb) b main Breakpoint 1: where = hello`main + 4 at hello.c:5:2, address = 0x0000000100000f88 (lldb) run Process 49127 launched: '/Users/jianfeiye/test/ctest/hello' (x86_64) Process 49127 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x0000000100000f88 hello`main at hello.c:5:2 2 3 int main(void) 4 { -> 5 printf("Hello World\n"); 6 return 0; 7 } Target 0: (hello) stopped. (lldb) n Hello World Process 49127 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step over frame #0: 0x0000000100000f97 hello`main at hello.c:6:9 3 int main(void) 4 { 5 printf("Hello World\n"); -> 6 return 0; 7 } Target 0: (hello) stopped. (lldb) Process 49127 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step over frame #0: 0x0000000100000f9c hello`main at hello.c:7:1 4 { 5 printf("Hello World\n"); 6 return 0; -> 7 } Target 0: (hello) stopped. (lldb) c Process 49127 resuming Process 49127 exited with status = 0 (0x00000000) (lldb) q bash-3.2$ gdb ./hello GNU gdb (GDB) 15.2 Copyright (C) 2024 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-apple-darwin23.4.0". Type "show configuration" for configuration details. For bug reporting instructions, please see: <https://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 ./hello... Reading symbols from /Users/jianfeiye/test/ctest/hello.dSYM/Contents/Resources/DWARF/hello... (gdb) break main Dwarf Error: DW_FORM_line_strp used without required section (gdb) list Dwarf Error: DW_FORM_line_strp used without required section (gdb) ```
Here is the version information. ``` bash-3.2$ uname -a Darwin MacBookPro 24.0.0 Darwin Kernel Version 24.0.0: Mon Aug 12 20:54:30 PDT 2024; root:xnu-11215.1.10~2/RELEASE_X86_64 x86_64 bash-3.2$ gcc-14 --version gcc-14 (Homebrew GCC 14.2.0) 14.2.0 Copyright (C) 2024 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. bash-3.2$ gdb --version GNU gdb (GDB) 15.2 Copyright (C) 2024 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. ```
Not sure if it's the same, but I'm getting similar dwarf errors with Apple clang version 17.0.0 (clang-1700.0.13.5): % echo 'int main(){return 0;}' > test.c % clang test.c -g -o test % gdb test GNU gdb (GDB) 16.3 Copyright (C) 2024 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 "--host=aarch64-apple-darwin24.4.0 --target=x86_64-apple-darwin20". Type "show configuration" for configuration details. For bug reporting instructions, please see: <https://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 test... Reading symbols from /Users/sicher/Documents/projects/rforth/test.dSYM/Contents/Resources/DWARF/test... DW_FORM_GNU_str_index or DW_FORM_strx used without .debug_str section in CU at offset 0x0 [in module /Users/sicher/Documents/projects/rforth/test.dSYM/Contents/Resources/DWARF/test] (gdb)
Created attachment 16446 [details] clang with the `-gdwarf-4` option works fine, while gcc still doesn't work I just found out that clang with the `-gdwarf-4` option works fine on GDB debugging. However, gcc is still not supported. OS: macOS Sequoia 15.7.1 (Intel x86-64) gcc: gcc-15 (Homebrew GCC 15.2.0) 15.2.0 clang: Apple clang version 17.0.0 (clang-1700.3.19.1) lldb: lldb-1703.0.31.2 gdb: GNU gdb (GDB) 16.3