* [Bug gdb/27494] Handle DW_MACRO_define_strp in version 4 .debug_macro.dwo
2021-03-01 15:47 [Bug gdb/27494] New: Handle DW_MACRO_define_strp in version 4 .debug_macro.dwo vries at gcc dot gnu.org
@ 2021-04-14 13:24 ` vries at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: vries at gcc dot gnu.org @ 2021-04-14 13:24 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=27494
--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
This patch fixes the error message:
...
diff --git a/gdb/dwarf2/macro.c b/gdb/dwarf2/macro.c
index 2ecebe6173c..b8d5676c63b 100644
--- a/gdb/dwarf2/macro.c
+++ b/gdb/dwarf2/macro.c
@@ -502,8 +502,17 @@ dwarf_decode_macro_bytes (dwarf2_per_objfile *per_objfile,
{
LONGEST str_offset;
- str_offset = read_offset (abfd, mac_ptr, offset_size);
- mac_ptr += offset_size;
+ if (DW_MACRO_define_strp == macinfo_type
+ && strcmp (section->s.section->name, ".debug_macro.dwo") ==
0)
+ {
+ str_offset = read_unsigned_leb128 (abfd, mac_ptr,
&bytes_read);
+ mac_ptr += bytes_read;
+ }
+ else
+ {
+ str_offset = read_offset (abfd, mac_ptr, offset_size);
+ mac_ptr += offset_size;
+ }
if (macinfo_type == DW_MACRO_define_sup
|| macinfo_type == DW_MACRO_undef_sup
@@ -866,7 +875,14 @@ dwarf_decode_macros (dwarf2_per_objfile *per_objfile,
read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
mac_ptr += bytes_read;
- mac_ptr += offset_size;
+ if (DW_MACRO_define_strp == macinfo_type
+ && strcmp (section->s.section->name, ".debug_macro.dwo") == 0)
+ {
+ read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
+ mac_ptr += bytes_read;
+ }
+ else
+ mac_ptr += offset_size;
}
break;
case DW_MACRO_define_strx:
...
But a simple example still doesn't work:
...
$ cat test.c
#include <stdio.h>
#define BLA "hello"
int
main (void)
{
printf (BLA "\n");
return 0;
}
$ gcc-10 test.c -ggdb3
$ gdb -q -batch a.out -ex start -ex "info macro BLA"
Temporary breakpoint 1 at 0x40050a: file test.c, line 8.
Temporary breakpoint 1, main () at test.c:8
8 printf (BLA "\n");
Defined at /home/vries/test.c:3
#define BLA "hello"
$ gcc-10 test.c -ggdb3 -gsplit-dwarf
$ gdb -q -batch a.out -ex start -ex "info macro BLA"
Temporary breakpoint 1 at 0x40050a: file test.c, line 8.
Temporary breakpoint 1, main () at test.c:8
8 printf (BLA "\n");
The symbol `BLA' has no definition as a C/C++ preprocessor macro
at <user-defined>:-1
...
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 2+ messages in thread