Summary: | Handle DW_MACRO_define_strp in version 4 .debug_macro.dwo | ||
---|---|---|---|
Product: | gdb | Reporter: | Tom de Vries <vries> |
Component: | gdb | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | NEW --- | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | HEAD | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Last reconfirmed: |
Description
Tom de Vries
2021-03-01 15:47:11 UTC
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 ... |