cgccgdbdwarf

gdb doesn't support DWARF 5 macro sections?


#include <stdio.h>
#define A "hello world\n"
void main()
{
    printf(A);
}
$ gcc -gdwarf-4 -g3 a.c \
&& gdb -ex 'set confirm off' \
       -ex 'break main' \
       -ex 'run' \
       -ex 'p A' \
       -ex q \
       a.out
...
Breakpoint 1, main () at a.c:5
5       printf(A);
$1 = "hello world\n"

$ gcc -gdwarf-5 -g3 a.c \
&& gdb -ex 'set confirm off' \
       -ex 'break main' \
       -ex 'run' \
       -ex 'p A' \
       -ex q \
       a.out
...
Breakpoint 1, main () at a.c:5
5       printf(A);
No symbol "A" in current context.

$ gcc --version
gcc (GCC) 12.2.1 20230201
...

$ gdb --version
GNU gdb (GDB) 12.1
...

Solution

  • As ssbssa suggested this looks like a bug in gdb-12.1. The fix is released in gdb-13.1