From 073954a792b3911f07b1dd22a8e0ffcc89ed3080 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sun, 20 Jun 2021 10:22:01 -0600 Subject: [PATCH] Let skip_one_die not skip children This patch adds an option to skip_one_die that causes it not to skip child DIEs. This is needed in the new scanner. --- gdb/dwarf2/read.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 2ec4a49b592..af9602da1dd 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1442,7 +1442,8 @@ static void dwarf2_symbol_mark_computed (const struct attribute *attr, static const gdb_byte *skip_one_die (const struct die_reader_specs *reader, const gdb_byte *info_ptr, - const struct abbrev_info *abbrev); + const struct abbrev_info *abbrev, + bool do_skip_children = true); static hashval_t partial_die_hash (const void *item); @@ -8337,12 +8338,15 @@ skip_children (const struct die_reader_specs *reader, const gdb_byte *info_ptr) /* Scan the debug information for CU starting at INFO_PTR in buffer BUFFER. INFO_PTR should point just after the initial uleb128 of a DIE, and the abbrev corresponding to that skipped uleb128 should be passed in - ABBREV. Returns a pointer to this DIE's sibling, skipping any - children. */ + ABBREV. + + If DO_SKIP_CHILDREN is true, or if the DIE has no children, this + returns a pointer to this DIE's sibling, skipping any children. + Otherwise, returns a pointer to the DIE's first child. */ static const gdb_byte * skip_one_die (const struct die_reader_specs *reader, const gdb_byte *info_ptr, - const struct abbrev_info *abbrev) + const struct abbrev_info *abbrev, bool do_skip_children) { unsigned int bytes_read; struct attribute attr; @@ -8355,7 +8359,7 @@ skip_one_die (const struct die_reader_specs *reader, const gdb_byte *info_ptr, for (i = 0; i < abbrev->num_attrs; i++) { /* The only abbrev we care about is DW_AT_sibling. */ - if (abbrev->attrs[i].name == DW_AT_sibling) + if (do_skip_children && abbrev->attrs[i].name == DW_AT_sibling) { read_attribute (reader, &attr, &abbrev->attrs[i], info_ptr); if (attr.form == DW_FORM_ref_addr) @@ -8472,7 +8476,7 @@ skip_one_die (const struct die_reader_specs *reader, const gdb_byte *info_ptr, } } - if (abbrev->has_children) + if (do_skip_children && abbrev->has_children) return skip_children (reader, info_ptr); else return info_ptr; -- 2.30.2