Victor
Victor

Reputation: 1445

What does it mean by "Dwarf Error: DW_FORM_line_strp used without required section"?

I built an ordinary "Hello World" C program with gcc 14.2.0 on macOS Sequoia 15.0, and I ran perfectly. However, when I tried debugging it with gdb, it showed the error message Dwarf Error: DW_FORM_line_strp used without required section. What does this error message mean?

bash-3.2$ cat hello.c
#include <stdio.h>

int main(void)
{
    printf("Hello World\n");
    return 0;
}
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$ ./hello
Hello World
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) list
Dwarf Error: DW_FORM_line_strp used without required section
(gdb) break main
Dwarf Error: DW_FORM_line_strp used without required section
(gdb) 

Upvotes: 0

Views: 200

Answers (1)

Employed Russian
Employed Russian

Reputation: 213879

What does this error message mean?

It means that GDB found a DWARF information entry with DW_FORM_line_strp encoding, which requires .debug_line_str section, but GDB didn't find that section.

From the standard:

If the form code is DW_FORM_line_strp, DW_FORM_strp or DW_FORM_strp_sup, then the string is included in the .debug_line_str, .debug_str or supplementary string section, respectively

In the end, this means that either GCC produced incorrect debugging info, or there is a bug in GDB.

It's best to report this GDB bugzilla, but few GDB developers use MacOS, so I wouldn't expect a speedy fix.

Possible workaround: compile with -gdwarf-4.

Upvotes: 1

Related Questions