From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by sourceware.org (Postfix) with ESMTPS id 36F523858D35 for ; Thu, 15 Jun 2023 13:03:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 36F523858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-io1-xd2d.google.com with SMTP id ca18e2360f4ac-777a6ebb542so307818039f.0 for ; Thu, 15 Jun 2023 06:03:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1686834236; x=1689426236; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=yMax9/TV63x412A7H2bli8u01nCC149wCTeWWVTTOmI=; b=OubUD/Nr1uAzmvhjFq1hqYl31IcqMtYNuKPH3sJXnEwwl+tHPeAXFOz5DwsjVjyf43 8YIfl/BJuD8cjisY7U9o3z0dhscJRFV7iOGl0tJ0s+bvz6sN+Rv1RiR+M7Mc+vXvr6hS 6qqezSA8pNSAJwJaPrk7mmrQFD68tp7Z7563wxMpmlz45D86L6AQPqv9/vrBA0Nso1TV m6AokcTvdWI7PZX0wRjGcr6iDBqzI+0xYubGvpfPx8rJ3exUz+Y7Zl8wTclcw+HgF3p/ T0h4XQmfpXiDqdPvoZnaW7OJ8gC/o3NNDPyqQaRUz12aencCeGwmERFw16zVDMki83Dz TsAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686834236; x=1689426236; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=yMax9/TV63x412A7H2bli8u01nCC149wCTeWWVTTOmI=; b=YMRx9/yeTPzLWZR8cCj8rFMVnLR0v2Q7tj1sbHohD3d7Yvva5ZMjcZjUpc21nxeT0l Go0kwEgc7tDgoja1Zd4Dv9xh6TCUNTbCdmzlcji7UabBC0j9IYp4ABz24EFm4LnUNXD8 ggauJpE6SKdy7jVQNxNget1xcv+VvNUtcQJcumuZH5ocf2RrDP4CgqxhRgbatTy7wEle bDZfZGJAq0DPZqjQuf+7ommkxmjFCGXWEyC5DwCnn142DlmN47Ix/o2d6Gh94HXLSa9u nWUNHs8rGEXfRNJyjCdfiuD6qt8EIBggqYYA8sXpLgOz3RnVGhp28qOspjXOqqFRepkW 35RQ== X-Gm-Message-State: AC+VfDx8SYEtBMG7v1PA/MFFQX1VMBhOSUncqupse6ucF1yHmcduocb/ 9XieXQpnf1n8HIB/ExpAFGoAzrcr2sCdWQKwehR/GQ== X-Google-Smtp-Source: ACHHUZ6mjrrY9NhXwzMlnGv01mxXGUq9wtSvYfI8anK0uErqGXpv3UxAR1wvNBuKWvzcRra2C++OBQ== X-Received: by 2002:a6b:f208:0:b0:774:84f4:6ea with SMTP id q8-20020a6bf208000000b0077484f406eamr14883970ioh.11.1686834236191; Thu, 15 Jun 2023 06:03:56 -0700 (PDT) Received: from localhost.localdomain (75-166-136-83.hlrn.qwest.net. [75.166.136.83]) by smtp.gmail.com with ESMTPSA id h4-20020a6b7a04000000b007701de8bb96sm5910357iom.54.2023.06.15.06.03.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 06:03:55 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Fix handling of DW_TAG_unspecified_type for Ada Date: Thu, 15 Jun 2023 07:03:32 -0600 Message-Id: <20230615130332.2447095-1-tromey@adacore.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Commit 80eaec735e ("[gdb/symtab] Handle named DW_TAG_unspecified_type DIE") changed the handling of DW_TAG_unspecified_type. Before this change, such types were not entered into the symbol table. It turns out that, when such a type is in the symtab, it can cause failures in Ada. In particular, a private type in another package may be seen locally as "void". Now, it would probably be better to fix this via check_typedef. However, that is somewhat difficult given the state of the DWARF reader -- in particular with gdb_index, this would require expanding potentially many CUs to find the correct type. Instead, this patch changes gdb to not enter a symbol for an unspecified type -- but only for Ada. --- gdb/dwarf2/read.c | 5 ++++- gdb/testsuite/gdb.ada/py_taft.exp | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index a9c2a7d59d5..3508f2c29ee 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -19316,11 +19316,14 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, sym->set_domain (VAR_DOMAIN); list_to_add = cu->list_in_scope; break; + case DW_TAG_unspecified_type: + if (cu->lang () == language_ada) + break; + /* FALLTHROUGH */ case DW_TAG_array_type: case DW_TAG_base_type: case DW_TAG_subrange_type: case DW_TAG_generic_subrange: - case DW_TAG_unspecified_type: sym->set_aclass_index (LOC_TYPEDEF); sym->set_domain (VAR_DOMAIN); list_to_add = cu->list_in_scope; diff --git a/gdb/testsuite/gdb.ada/py_taft.exp b/gdb/testsuite/gdb.ada/py_taft.exp index 0ce9df72005..1990e7e89ce 100644 --- a/gdb/testsuite/gdb.ada/py_taft.exp +++ b/gdb/testsuite/gdb.ada/py_taft.exp @@ -35,3 +35,8 @@ gdb_test "python print(v.dereference().type.code is gdb.TYPE_CODE_VOID)" \ "False" gdb_test "python print(v.type.strip_typedefs().target().code is gdb.TYPE_CODE_VOID)" \ "False" + +# This was a convenient spot to put a regression test. GNAT will +# create a DW_TAG_unspecified_type in the main.adb CU, and if gdb +# isn't careful, this will result in this 'whatis' yielding 'void'. +gdb_test "whatis pkg.value_record" "type = pkg.value_record" -- 2.40.1