]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb/symtab] Fix parent map when handling .debug_info and .debug_types
authorAuthor: Tom Tromey <tom@tromey.com>
Wed, 27 Nov 2024 17:48:43 +0000 (18:48 +0100)
committerTom de Vries <tdevries@suse.de>
Wed, 27 Nov 2024 17:48:43 +0000 (18:48 +0100)
commite33e55b6651f230762ccfe248037263e511b41b3
treec8a97ae35a49bd9ba7df72dc8e0f50115bb02e29
parent6f385c1ccdcbfe1d479bbd4407db5ea84299662e
[gdb/symtab] Fix parent map when handling .debug_info and .debug_types

Consider test-case:
...
$ cat test.c
namespace sp1 {
  class A {
    int i;
    const int f1 = 1;
    ...
    const int f29 = 1;
  };
}
sp1::A a;
void _start (void) {}
$ cat test2.c
namespace sp2 {
  class B {
    float f;
    const float f1 = 1;
    ...
    const float f29 = 1;
  };
}
sp2::B b;
...
compiled like this:
...
$ g++ test.c -gdwarf-4 -c -g -fdebug-types-section
$ g++ test2.c -gdwarf-5 -c -g -fdebug-types-section
$ g++ -g test.o test2.o -nostdlib
...

Using:
...
$ gdb -q -batch -iex "maint set worker-threads 0" a.out -ex "maint print objfiles"
...
we get a cooked index entry with incorrect parent:
...
    [29] ((cooked_index_entry *) 0x3c57d1a0)
    name:       B
    canonical:  B
    qualified:  sp1::A::B
    DWARF tag:  DW_TAG_class_type
    flags:      0x0 []
    DIE offset: 0x154
    parent:     ((cooked_index_entry *) 0x3c57d110) [A]
...

The problem is that the parent map assumes that all offsets are in the same
section.

Fix this by using dwarf2_section_info::buffer-relative addresses instead,
which get us instead:
...
    [29] ((cooked_index_entry *) 0x3f0962b0)
    name:       B
    canonical:  B
    qualified:  sp2::B
    DWARF tag:  DW_TAG_class_type
    flags:      0x0 []
    DIE offset: 0x154
    parent:     ((cooked_index_entry *) 0x3f096280) [sp2]
...

Tested on x86_64-linux.

PR symtab/32225
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32225
gdb/dwarf2/parent-map.h
gdb/dwarf2/read.c