From patchwork Thu Sep 26 13:05:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 98008 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 082BD3858D39 for ; Thu, 26 Sep 2024 13:05:28 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id C440C3858C50 for ; Thu, 26 Sep 2024 13:04:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C440C3858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C440C3858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727355901; cv=none; b=tPlpShQxlDW6YVvvvqz5gPeUv1D9IvBXCajaT6ZQKP/XjPTnrMa7vckFcTq0lzIFKgFOM4lHGIYJHeiGwd2j+9+lZijvuQ/4tp0b9uwGEvNKhaPPVCPAOIzHOJ4bHL4yHFRtXfRB5QIzlwwWo3WIUc15YVb4oDeMOVnBoSvbhkY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727355901; c=relaxed/simple; bh=gqmNyh3zx8NsZEwXHDtr7tM8t2B/jdz86vmj+MS31WE=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=emEvrx8pimJea5bgNACUd4bhxw7JFP4q+TJYtfFNitWrTgKgUXeBFBN6QW7pj5ZfcnB+7lAFEsd4tpVTItsc9X5bXe65BPS8OwDQ/YICzmHIbCJ/i6bIcc9yv3vnbVJUQwzWhQKFOnawwE3fIvdk7Bs8Zb/kcSchihf4BxMlmHc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D18D41F871 for ; Thu, 26 Sep 2024 13:04:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1727355893; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ehEN9YaBlIJMJdS1a3l3qheaciNa1XZVflZrvkz5hSQ=; b=tsyU12XZul95TpYhOkyhqRqboMgk3BNqx692shayv0o2RyVqMKFsAZVdQ3AqIxKwl1WMkO +Jb9soaolVQByKWF4wVasM9FqXl17aOGyDJuhz+PWiYjkXnVgemEV7rBjqIOjJPgdFZC9u 7g4h/nZlBqVH+oN7Ngb2MIZHhfwoxB0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1727355893; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ehEN9YaBlIJMJdS1a3l3qheaciNa1XZVflZrvkz5hSQ=; b=tkO1KCHy6VLpuifi7zHkY0WPKqB818ZN4amT+r/58GJId9Q8U+FlYf+MuVWZnESojXL7pr bN6kDFjN7BmbMtDQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=tsyU12XZ; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=tkO1KCHy DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1727355893; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ehEN9YaBlIJMJdS1a3l3qheaciNa1XZVflZrvkz5hSQ=; b=tsyU12XZul95TpYhOkyhqRqboMgk3BNqx692shayv0o2RyVqMKFsAZVdQ3AqIxKwl1WMkO +Jb9soaolVQByKWF4wVasM9FqXl17aOGyDJuhz+PWiYjkXnVgemEV7rBjqIOjJPgdFZC9u 7g4h/nZlBqVH+oN7Ngb2MIZHhfwoxB0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1727355893; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ehEN9YaBlIJMJdS1a3l3qheaciNa1XZVflZrvkz5hSQ=; b=tkO1KCHy6VLpuifi7zHkY0WPKqB818ZN4amT+r/58GJId9Q8U+FlYf+MuVWZnESojXL7pr bN6kDFjN7BmbMtDQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id BBE0113793 for ; Thu, 26 Sep 2024 13:04:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id ieCgLPVb9WZRXgAAD6G6ig (envelope-from ) for ; Thu, 26 Sep 2024 13:04:53 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH v2 1/2] [gdb/symtab] Fix parent of enumerator Date: Thu, 26 Sep 2024 15:05:08 +0200 Message-Id: <20240926130509.7960-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Rspamd-Queue-Id: D18D41F871 X-Spam-Score: -5.01 X-Rspamd-Action: no action X-Spamd-Result: default: False [-5.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RCPT_COUNT_ONE(0.00)[1]; FUZZY_BLOCKED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; ARC_NA(0.00)[]; TO_DN_NONE(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid, suse.de:dkim, imap1.dmz-prg2.suse.org:rdns, imap1.dmz-prg2.suse.org:helo] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Level: X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org As mentioned in commit 489b82720f5 ('[gdb/symtab] Revert "Change handling of DW_TAG_enumeration_type in DWARF scanner"'), when doing "maint print objfiles" in test-case gdb.dwarf2/enum-type.exp, for val1 we get an entry without parent: ... [27] ((cooked_index_entry *) 0x7fbbb4002ef0) name: val1 canonical: val1 qualified: val1 DWARF tag: DW_TAG_enumerator flags: 0x0 [] DIE offset: 0x124 parent: ((cooked_index_entry *) 0) ... This happens here in cooked_indexer::index_dies: ... info_ptr = recurse (reader, info_ptr, is_enum_class ? this_entry : parent_entry, fully); ... when we're passing down a nullptr parent_entry, while the parent of this_entry is deferred. Fix this in cooked_indexer::index_dies by passing down a deffered parent instead, such that we get: ... [27] ((cooked_index_entry *) 0x7ff0e4002ef0)^M name: val1^M canonical: val1^M qualified: ns::val1^M DWARF tag: DW_TAG_enumerator^M flags: 0x0 []^M DIE offset: 0x124^M parent: ((cooked_index_entry *) 0x7ff0e4002f20) [ns]^M ... Tested on x86_64-linux. --- gdb/dwarf2/read.c | 46 ++++++++++++++++++++------ gdb/testsuite/gdb.dwarf2/enum-type.exp | 15 +++++++++ 2 files changed, 51 insertions(+), 10 deletions(-) base-commit: 174e5e38b92c2cd381feffa644de2b12ce0980a8 diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 193a52ef6e0..1a386b8d542 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -96,6 +96,7 @@ #include "run-on-main-thread.h" #include "dwarf2/parent-map.h" #include "dwarf2/error.h" +#include /* When == 1, print basic high level tracing messages. When > 1, be more verbose. @@ -4486,7 +4487,7 @@ class cooked_indexer bool is_dwz, bool for_scanning); - /* Index DIEs in the READER starting at INFO_PTR. PARENT_ENTRY is + /* Index DIEs in the READER starting at INFO_PTR. PARENT is the entry for the enclosing scope (nullptr at top level). FULLY is true when a full scan must be done -- in some languages, function scopes must be fully explored in order to find nested @@ -4494,7 +4495,8 @@ class cooked_indexer reading stopped. */ const gdb_byte *index_dies (cutu_reader *reader, const gdb_byte *info_ptr, - const cooked_index_entry *parent_entry, + std::variant parent, bool fully); /* Scan the attributes for a given DIE and update the out @@ -4524,7 +4526,8 @@ class cooked_indexer m_die_range_map and then calling index_dies. */ const gdb_byte *recurse (cutu_reader *reader, const gdb_byte *info_ptr, - const cooked_index_entry *parent_entry, + std::variant parent_entry, bool fully); /* The storage object, where the results are kept. */ @@ -16417,10 +16420,15 @@ cooked_indexer::index_imported_unit (cutu_reader *reader, const gdb_byte * cooked_indexer::recurse (cutu_reader *reader, const gdb_byte *info_ptr, - const cooked_index_entry *parent_entry, + std::variant parent, bool fully) { - info_ptr = index_dies (reader, info_ptr, parent_entry, fully); + info_ptr = index_dies (reader, info_ptr, parent, fully); + + if (parent.index () != 0) + return info_ptr; + const cooked_index_entry *parent_entry = std::get<0> (parent); if (parent_entry != nullptr) { @@ -16441,7 +16449,8 @@ cooked_indexer::recurse (cutu_reader *reader, const gdb_byte * cooked_indexer::index_dies (cutu_reader *reader, const gdb_byte *info_ptr, - const cooked_index_entry *parent_entry, + std::variant parent, bool fully) { const gdb_byte *end_ptr = (reader->buffer @@ -16468,15 +16477,20 @@ cooked_indexer::index_dies (cutu_reader *reader, { info_ptr = skip_one_die (reader, info_ptr, abbrev, !fully); if (fully && abbrev->has_children) - info_ptr = index_dies (reader, info_ptr, parent_entry, fully); + info_ptr = index_dies (reader, info_ptr, parent, fully); continue; } const char *name = nullptr; const char *linkage_name = nullptr; parent_map::addr_type defer {}; + if (parent.index () == 1) + defer = std::get<1> (parent); cooked_index_flag flags = IS_STATIC; sect_offset sibling {}; + const cooked_index_entry *parent_entry = nullptr; + if (parent.index () == 0) + parent_entry = std::get<0> (parent); const cooked_index_entry *this_parent_entry = parent_entry; bool is_enum_class = false; @@ -16560,9 +16574,21 @@ cooked_indexer::index_dies (cutu_reader *reader, the enum itself as the parent, yielding names like "enum_class::enumerator"; otherwise we inject the names into our own parent scope. */ - info_ptr = recurse (reader, info_ptr, - is_enum_class ? this_entry : parent_entry, - fully); + { + std::variant recurse_parent; + if (is_enum_class) + { + gdb_assert (this_entry != nullptr); + recurse_parent = this_entry; + } + else if (defer != 0) + recurse_parent = defer; + else + recurse_parent = parent_entry; + + info_ptr = recurse (reader, info_ptr, recurse_parent, fully); + } continue; case DW_TAG_module: diff --git a/gdb/testsuite/gdb.dwarf2/enum-type.exp b/gdb/testsuite/gdb.dwarf2/enum-type.exp index b2b3dc6c828..ec12db57c8c 100644 --- a/gdb/testsuite/gdb.dwarf2/enum-type.exp +++ b/gdb/testsuite/gdb.dwarf2/enum-type.exp @@ -114,3 +114,18 @@ gdb_test "ptype enum EU" "type = enum EU {TWO = 2}" \ gdb_test_no_output "set lang c++" gdb_test "ptype enum EU" "type = enum EU : unsigned int {TWO = 2}" \ "ptype EU in C++" + +gdb_test "p ns::val1" \ + " = ns::val1" + +require !readnow +require {string equal [have_index $binfile] ""} + +set re_ws "\[ \t\]" + +gdb_test_lines "maint print objfiles" \ + "val1 has a parent" \ + [multi_line \ + "" \ + "$re_ws+qualified:$re_ws+ns::val1" \ + ".*"] From patchwork Thu Sep 26 13:05:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 98007 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ECF4C3858435 for ; Thu, 26 Sep 2024 13:05:27 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id D8DE03858C62 for ; Thu, 26 Sep 2024 13:04:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D8DE03858C62 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D8DE03858C62 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727355901; cv=none; b=yDNtnguZ+9D24YGNeHBb8Mcbr7CrusWvFFhNSHToaGan4eBRg1huPOPhW8q8/6UUReOA9shxpWFs49SVF7CpoaHqCWdGC8p/YBnyafmFsjfB0RrohhJBHvPzQBRrTwPlH1579iO4sHxJX+P5PAx8/hmkcBw0Y6miHmiP0vyXfAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727355901; c=relaxed/simple; bh=BQbij9Jy0CiGFibI4beDjxtoPY+OXQAsDBH27Pm/3KU=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=cAWFmOOOUFDL68bXZWWmSe/54oM2J08YNZT2oq3ZLXARN/U8x0+img/BsI8oKQjqR988Y+sqpw48gWWeFVhLhF8U+lDvfpFPGlAExubBIiwMtgGhxfjoONqlAK3rPuzq9NNpayvnFHJSmPujCHlphRxprYIxabEIMXRgSfiVxFQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0468421B29 for ; Thu, 26 Sep 2024 13:04:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1727355894; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/jT3890cxEFdnVRTSSN5QVxaWiQxLuPdfF+h6QxOdv4=; b=BdifP6qtQK6Iecrtm2KBpIOT+FE1vaktSErIZ6969QzcGYqjN5dS64Yb6ixwavzWQ65QYP kgCPIKOYDeq4djfQtMm8Cn6jGu7Q0P19jlCjUdzzUo7X5hQWy0s13F+FhiyCcKiepRn1Xf 6CwbZhLx/5c8uK5rk5k6aA5sHp9xfXA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1727355894; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/jT3890cxEFdnVRTSSN5QVxaWiQxLuPdfF+h6QxOdv4=; b=iMZA6yrBvpOFhkKYpHJA1LCpw0m+qATnMOVC0EKO7BpkTOyb8iIoqA0Sdkf7psqP8fCzy8 cl/kT+XjX/vckuDQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1727355894; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/jT3890cxEFdnVRTSSN5QVxaWiQxLuPdfF+h6QxOdv4=; b=BdifP6qtQK6Iecrtm2KBpIOT+FE1vaktSErIZ6969QzcGYqjN5dS64Yb6ixwavzWQ65QYP kgCPIKOYDeq4djfQtMm8Cn6jGu7Q0P19jlCjUdzzUo7X5hQWy0s13F+FhiyCcKiepRn1Xf 6CwbZhLx/5c8uK5rk5k6aA5sHp9xfXA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1727355894; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/jT3890cxEFdnVRTSSN5QVxaWiQxLuPdfF+h6QxOdv4=; b=iMZA6yrBvpOFhkKYpHJA1LCpw0m+qATnMOVC0EKO7BpkTOyb8iIoqA0Sdkf7psqP8fCzy8 cl/kT+XjX/vckuDQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D6A7D13ABC for ; Thu, 26 Sep 2024 13:04:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id iGIjM/Vb9WZRXgAAD6G6ig (envelope-from ) for ; Thu, 26 Sep 2024 13:04:53 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH v2 2/2] [gdb/symtab] Fix gdb.dwarf2/enum-type-c++.exp with cc-with-debug-types Date: Thu, 26 Sep 2024 15:05:09 +0200 Message-Id: <20240926130509.7960-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240926130509.7960-1-tdevries@suse.de> References: <20240926130509.7960-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.80 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org When running test-case gdb.dwarf2/enum-type-c++.exp with target board cc-with-debug-types, we run into: ... (gdb) FAIL: gdb.dwarf2/enum-type-c++.exp: val1 has a parent ... because val1 has no parent: ... [31] ((cooked_index_entry *) 0x7efedc002e90) name: val1 canonical: val1 qualified: val1 DWARF tag: DW_TAG_enumerator flags: 0x0 [] DIE offset: 0xef parent: ((cooked_index_entry *) 0) ... [37] ((cooked_index_entry *) 0x38ffd280) name: val1 canonical: val1 qualified: val1 DWARF tag: DW_TAG_enumerator flags: 0x0 [] DIE offset: 0xef parent: ((cooked_index_entry *) 0) ... There are two entries, which seems to be an inefficiency, but for now let's focus on the correctness issue. The debug info for val1 looks like this: ... <1>: Abbrev Number: 2 (DW_TAG_namespace) DW_AT_name : ns DW_AT_declaration : 1 <2>: Abbrev Number: 12 (DW_TAG_class_type) DW_AT_name : A DW_AT_declaration : 1 <3>: Abbrev Number: 13 (DW_TAG_enumeration_type) DW_AT_declaration : 1 <1>
: Abbrev Number: 14 (DW_TAG_enumeration_type) DW_AT_specification: <0xd6> <2>: Abbrev Number: 5 (DW_TAG_enumerator) DW_AT_name : val1 DW_AT_const_value : 1 ... Fix this by: - adding a cooked index entry for DIE 0xcb (and consequently for child DIE 0xd3), by marking it interesting, - making sure that the entry for DIE 0xcb has a name, and - using the entry for DIE 0xd3 as parent entry for DIE 0xdd. Tested on aarch64-linux. --- gdb/dwarf2/abbrev.c | 3 ++- gdb/dwarf2/read.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gdb/dwarf2/abbrev.c b/gdb/dwarf2/abbrev.c index bae8d8b3bed..c30db1ee31a 100644 --- a/gdb/dwarf2/abbrev.c +++ b/gdb/dwarf2/abbrev.c @@ -276,7 +276,8 @@ abbrev_table::read (struct dwarf2_section_info *section, } else if ((cur_abbrev->tag == DW_TAG_structure_type || cur_abbrev->tag == DW_TAG_class_type - || cur_abbrev->tag == DW_TAG_union_type) + || cur_abbrev->tag == DW_TAG_union_type + || cur_abbrev->tag == DW_TAG_namespace) && cur_abbrev->has_children) { /* We have to record this as interesting, regardless of how diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 1a386b8d542..023f6677e31 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -16261,7 +16261,8 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu, want to treat them as definitions. */ if ((abbrev->tag == DW_TAG_class_type || abbrev->tag == DW_TAG_structure_type - || abbrev->tag == DW_TAG_union_type) + || abbrev->tag == DW_TAG_union_type + || abbrev->tag == DW_TAG_namespace) && abbrev->has_children) *flags |= IS_TYPE_DECLARATION; else @@ -16585,7 +16586,7 @@ cooked_indexer::index_dies (cutu_reader *reader, else if (defer != 0) recurse_parent = defer; else - recurse_parent = parent_entry; + recurse_parent = this_parent_entry; info_ptr = recurse (reader, info_ptr, recurse_parent, fully); }