From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140074.outbound.protection.outlook.com [40.107.14.74]) by sourceware.org (Postfix) with ESMTPS id 2FFE93858D28 for ; Fri, 19 Aug 2022 10:36:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2FFE93858D28 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=LjEYFvUKGPMh0/YIOrBQU1RujLnknT8aaZSyeueYdCkgRGgxLSaMMH1qSBnnLAwrMgTbXnptQG+cY291pM3t1BsfRu1pdz2O7l0Z1gTvKQzFQArebpfwyS3nBP1/rStpej7HncZI8iOKUlPGZPO3H+9//CMQRpwq998UKjfKBjV4aQ/AX0Rh33p+04wPWQZpfe63vxUtBmftfhfiBX4Qh2HUqhJWRyOuut+8SphckPPPt2WBSDfNdacLLF/O+wAmQlEuggl6ANz6g/sxqrgPOnAzvLAMmZN8Yyk3XXGxjljHlxjbVcoozsN6Yekzhfog7wVWUZDKY82fJ4Iz1UvRIg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=q1/bUdaty41tlrJdInfaFwHKbnObElroUAHl+hpTihs=; b=e62Kld5PiN4SFvyq6VTJBfiAiie9c7dYXq1IxAAxJ6+TeULCl9nU4Z2aC1Y8qXcM05CjZKMkMiXZoYqoQgCvVNScFlD3A49tYdwvFk7KOtzVT0nqaO+Ybs6Ot0LHOEuYkb2kK0KRoUH8yIPuH4Z8uKAy7vD8TTlgdMZp24xgiJk6T2ncBjQDfWQLYBcD8uIKAXhCcVT9ozQcOQ3AN0fW6J4hJVoRYsiCjEq8bZMk9RKDlWRi8UxtyWB1mI1sYzvMdqzGpZ9MZEAkX+oc3UYzh9VV5cAK0He1ABds2Clwa6WyNCe1N4KhMfG9K9zQ6a1cUlVP0F6ifGbk48i8wr2l9w== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from AS9PR04CA0081.eurprd04.prod.outlook.com (2603:10a6:20b:48b::22) by PAXPR08MB6752.eurprd08.prod.outlook.com (2603:10a6:102:131::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Fri, 19 Aug 2022 10:36:04 +0000 Received: from VE1EUR03FT057.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:48b:cafe::3d) by AS9PR04CA0081.outlook.office365.com (2603:10a6:20b:48b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.19 via Frontend Transport; Fri, 19 Aug 2022 10:36:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT057.mail.protection.outlook.com (10.152.19.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.15 via Frontend Transport; Fri, 19 Aug 2022 10:36:03 +0000 Received: ("Tessian outbound 6a3290ff1310:v123"); Fri, 19 Aug 2022 10:36:03 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 67bb1d6fdc86765f X-CR-MTA-TID: 64aa7808 Received: from 4c6e960bcfd4.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D7243816-9CD8-492C-86AE-FC513A7DD0FF.1; Fri, 19 Aug 2022 10:35:55 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4c6e960bcfd4.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 19 Aug 2022 10:35:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aw1MuTaGguZNDQsfO7+KPMb32dQ/5fCDDI3BFIT9l9Qj9tJz2GSfPHtyyIaS3BsCXmFr/P1PqiKGcTqupXQQU4po6zTALpYbGUNTw3OhQH44o7GydMPz/DfYSr1JOsvHQvKQOV71eP+h15qkNYiQXKnVI4skW/COmH2c1MiwemQ2Yi4US8WDVEtDoKXxeeqD/fEFvNDqoVctfkzPuvGnGRpQO/kMH4kNq0JXihmLvbrDv1cuqS7YoiM51axHDXg3QCqt2S7utf3sn4BEs6LxPPBdI+VL62v1mjioCkMI5SRHHL+jdCKCqbYA+aJyIwtV8H8nX/MlDqlRTo8DR89BrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=q1/bUdaty41tlrJdInfaFwHKbnObElroUAHl+hpTihs=; b=ASCdGq5Z91u5kS+a8bMJf5yajnPhnk7sghYchwd4u0xXp3kb6hcFkg2FhcH4c6ZlF5eWCxrWWpNBF0a/J/YAl530Mw1aqFFWMM8BJ9WUkRX/Nqq9KMNInaPw9wZpDOquLMLioxXqPV6Iu2EwML23vuzj+q4I6Or+jrIUjZXobhx0KgAp5d22zXNEwZvJjxYIpr/aH1QyJT8ZqXnaFoirBk5VwA0QxwpKvsvbhvScZqiiz5S9Tz0a+JT8awR/4WwPogWAQgt9sLdHvskusVy0hilsAvzv8yY88uCJs/7xBY724+Y/2ERU+VNghw4oBXCCc/fPevDqBCW7G/hxGDXAWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) by AM6PR08MB5207.eurprd08.prod.outlook.com (2603:10a6:20b:ea::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.16; Fri, 19 Aug 2022 10:35:53 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::cc64:9170:b12d:de8]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::cc64:9170:b12d:de8%4]) with mapi id 15.20.5504.028; Fri, 19 Aug 2022 10:35:52 +0000 Message-ID: <2440df29-1dc2-5fab-09dc-1f43fb37d8b4@arm.com> Date: Fri, 19 Aug 2022 11:35:45 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v3] gdb: call check_typedef at beginning of dwarf_expr_context::fetch_result Content-Language: en-US To: Simon Marchi , Simon Marchi , gdb-patches@sourceware.org References: <20220728153340.4052079-1-simon.marchi@efficios.com> <5ed77384-970f-3e97-0e66-bce2acd28f9a@polymtl.ca> <5bc46c80-545a-a530-8379-b1deb860075d@arm.com> From: Luis Machado In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SA9PR03CA0011.namprd03.prod.outlook.com (2603:10b6:806:20::16) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 07ddb871-7b46-4d21-3f48-08da81ce9dcc X-MS-TrafficTypeDiagnostic: AM6PR08MB5207:EE_|VE1EUR03FT057:EE_|PAXPR08MB6752:EE_ x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 07hOa/9mPTGuFloqSL0lh+xPTIrD5DN1RdJNuj0jrU/kBwDi5q0p4yJm2CKPrMzhAPAmD/6aq/mHP6ZvTTlYNVLiVCKkUonpBvN9fKUvtXOEfu9T7qxm0xMYclef2U8/kt0aM6SVFvuQIcGUChPAgJAoghmMPvr5RHJVahHlfPtxZleS3FVt8uwSbmRZ44BcOg94QIziz3fmBVJ54R3wznKz4kd+4QA1PkkYXs1AHGQMG9bOr88WsEXGB14O1jexVMypiLvfH6kZiH5BDgDoAGd6Of3V+iWTYUUQUl/kkX3sEWc8OETCrXfBE09sxpIn45+DfffWozEsdUjesxnRu4/fn/v9pEEraxpg2UzoH//obVtNyLG3iypg8qGAsVY8GqCjvlY2u+ddtCg2KWq2sI18Y76Fme6nY18LtyjibQuRhjizc/l6x13HpyZFEYiP/YbsAcVJlDECOUbtTWNK2N0HL7KLFPCMrfLeltO4bMDZevnuvNxqI8bE9fi4KQA3FCDZjd6XHQOjFfClfYpmZHz9iLcGAaCtoBd3pvv7Y9MPZB8jX70ua9lJV/fISPMP74+/L3IYuNyj67o1zQnyOOZYhY4GuBxPxkUjw5TbUEZjvd6eALTfFNwi0m7XFb/ZO1lz+eAcEzHlKxOXab4UHMc62iSvd8/1w8x1QbXtqzQ4jM2Q58FuMwyL5CPkCAmO3q/AoQHEZk/MfvugVCeeFNMFw+N/2SuoWYU5uSN10fKTpRf6hwWtAs9XGpuPzy9uDi4AWXFH3X1Ke3jyHB+uuYf37q9yOpLBMMZxiLajlMq+zshlgk2Vi26f+8mOxxXn X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB3919.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(366004)(39860400002)(376002)(396003)(346002)(136003)(31686004)(186003)(44832011)(83380400001)(316002)(26005)(110136005)(2616005)(36756003)(6512007)(41300700001)(6666004)(6506007)(2906002)(53546011)(86362001)(31696002)(5660300002)(8676002)(66946007)(66476007)(66556008)(8936002)(38100700002)(6486002)(966005)(478600001)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5207 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT057.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 99e6d474-18f4-4ed0-23aa-08da81ce9737 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9UckcjJVKbCf4ink7IUou63PA17+BoR5UnbnheTkIQ2qLKSCsxyIknu9fmgwsQedDgTULw5hbKzGg7SzE5YsOp3mBpDA4df7eJoZy+FrM+Rn2lvs+OzOIlyyhKCaiFLdnRlzExU6l7B5aOomYJxDJNJ3z2cfRfxlWDQ/HGUjJ6VtpiFpEUzx/pXTivW6WoJ+Rd9hadR2eEmxtHBbD8rrBeH2xoXCWJrhaJTlihjSUO9Ujp+/jIC4vz8DT6ljuWpcYHOISohLvdOXrS21Kz5XcbKq+lFylyJ58EBe5URhDnq+XcG2Ngo50JJSU7c4Y37q36rCGCMQgYH/KC8zxkeUBg+bKCb1dQgiQOL7xZZFYzPxoxYsf3JDoAPan8GJJPl/iQhA9RdCxYJRduwz+H85vacsH5ziPvBnmniXEr+fa8vngwjuofVPVCqCyjKgbRMbnwbRWar6s/55gJPr41o/Lfca0i5c7da09VTSLzkTTxrGCS3TURNUIha2hp24KXUzBPkDRtGnNxAUk2a4+XlN2ce+2yl/CWli2R3iH/KXa6gyYs03Y237egSNNq2LVf+Oudeh0RZfnNmJvluX/KeksFEKoFzDZiwl7vXFgsLNqggrb5J94RRieNo9XqqzZzNz2uL+XQ6GKxcX6UldPWa2TU3tDPxbQPen7pa6MyIsSkYDYhj/ku569YtvYedWfG2mFbDWcrxzZDPi4JvwOrTVNPApehqkBFP8kEYvToB6jMoiLPl3rxnQks150A6Uulxai1ldKOW+omCWGg5b43MOZs7LTAT5WHVV5JaePAMxD5e2UVu6UBi7Lzv2R1xPpR2R X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230016)(4636009)(136003)(39860400002)(376002)(396003)(346002)(46966006)(36840700001)(40470700004)(44832011)(2906002)(478600001)(41300700001)(70586007)(8676002)(70206006)(40480700001)(82310400005)(6486002)(966005)(86362001)(36756003)(31696002)(31686004)(26005)(53546011)(6506007)(316002)(6512007)(110136005)(6666004)(356005)(81166007)(2616005)(83380400001)(40460700003)(186003)(82740400003)(8936002)(5660300002)(36860700001)(47076005)(336012)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Aug 2022 10:36:03.5594 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 07ddb871-7b46-4d21-3f48-08da81ce9dcc X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT057.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6752 X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, KAM_DMARC_NONE, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY, WEIRD_PORT autolearn=no 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Aug 2022 10:36:09 -0000 On 8/18/22 18:34, Simon Marchi wrote: > On 8/18/22 12:51, Luis Machado wrote: >> On 8/18/22 17:16, Simon Marchi via Gdb-patches wrote: >>> On 7/28/22 11:33, Simon Marchi wrote: >>>> From: Simon Marchi >>>> >>>> New in this version: >>>> >>>> - add architecture check in test >>>> - add aarch64 version of the .S >>>> >>>> Bug 29374 shows this crash: >>>> >>>> $ ./gdb -nx --data-directory=data-directory -q -batch -ex "catch throw" -ex r -ex bt a.out >>>> ... >>>> /home/simark/src/binutils-gdb/gdb/../gdbsupport/array-view.h:217: internal-error: copy: Assertion `dest.size () == src.size ()' failed. >>>> >>>> The backtrace is: >>>> >>>> #0 internal_error (file=0x5555606504c0 "/home/simark/src/binutils-gdb/gdb/../gdbsupport/array-view.h", line=217, fmt=0x55556064b700 "%s: Assertion `%s' failed.") at /home/simark/src/binutils-gdb/gdbsupport/errors.cc:51 >>>> #1 0x000055555d41c0bb in gdb::copy (src=..., dest=...) at /home/simark/src/binutils-gdb/gdb/../gdbsupport/array-view.h:217 >>>> #2 0x000055555deef28c in dwarf_expr_context::fetch_result (this=0x7fffffffb830, type=0x621007a86830, subobj_type=0x621007a86830, subobj_offset=0, as_lval=false) at /home/simark/src/binutils-gdb/gdb/dwarf2/expr.c:1040 >>>> #3 0x000055555def0015 in dwarf_expr_context::evaluate (this=0x7fffffffb830, addr=0x62f00004313e "0", len=1, as_lval=false, per_cu=0x60b000069550, frame=0x621007c9e910, addr_info=0x0, type=0x621007a86830, subobj_type=0x621007a86830, subobj_offset=0) at /home/simark/src/binutils-gdb/gdb/dwarf2/expr.c:1091 >>>> #4 0x000055555e084327 in dwarf2_evaluate_loc_desc_full (type=0x621007a86830, frame=0x621007c9e910, data=0x62f00004313e "0", size=1, per_cu=0x60b000069550, per_objfile=0x613000006080, subobj_type=0x621007a86830, subobj_byte_offset=0, as_lval=false) at /home/simark/src/binutils-gdb/gdb/dwarf2/loc.c:1485 >>>> #5 0x000055555e0849e2 in dwarf2_evaluate_loc_desc (type=0x621007a86830, frame=0x621007c9e910, data=0x62f00004313e "0", size=1, per_cu=0x60b000069550, per_objfile=0x613000006080, as_lval=false) at /home/simark/src/binutils-gdb/gdb/dwarf2/loc.c:1529 >>>> #6 0x000055555e0828c6 in dwarf_entry_parameter_to_value (parameter=0x621007a96e58, deref_size=0x0, type=0x621007a86830, caller_frame=0x621007c9e910, per_cu=0x60b000069550, per_objfile=0x613000006080) at /home/simark/src/binutils-gdb/gdb/dwarf2/loc.c:1235 >>>> #7 0x000055555e082f55 in value_of_dwarf_reg_entry (type=0x621007a86890, frame=0x621007acc510, kind=CALL_SITE_PARAMETER_DWARF_REG, kind_u=...) at /home/simark/src/binutils-gdb/gdb/dwarf2/loc.c:1332 >>>> #8 0x000055555e083449 in value_of_dwarf_block_entry (type=0x621007a86890, frame=0x621007acc510, block=0x61e000033568 "T\004\205\001\240\004\004\243\001T\237\004\240\004\261\004\001T\004\261\004\304\005\004\243\001T\237\004\304\005\310\005\001T\004\310\005\311\005\004\243\001T\237", block_len=1) at /home/simark/src/binutils-gdb/gdb/dwarf2/loc.c:1365 >>>> #9 0x000055555e094d40 in loclist_read_variable_at_entry (symbol=0x621007a99bd0, frame=0x621007acc510) at /home/simark/src/binutils-gdb/gdb/dwarf2/loc.c:3889 >>>> #10 0x000055555f5192e0 in read_frame_arg (fp_opts=..., sym=0x621007a99bd0, frame=0x621007acc510, argp=0x7fffffffbf20, entryargp=0x7fffffffbf60) at /home/simark/src/binutils-gdb/gdb/stack.c:559 >>>> #11 0x000055555f51c352 in print_frame_args (fp_opts=..., func=0x621007a99ad0, frame=0x621007acc510, num=-1, stream=0x6030000bad90) at /home/simark/src/binutils-gdb/gdb/stack.c:887 >>>> #12 0x000055555f521919 in print_frame (fp_opts=..., frame=0x621007acc510, print_level=1, print_what=LOCATION, print_args=1, sal=...) at /home/simark/src/binutils-gdb/gdb/stack.c:1390 >>>> #13 0x000055555f51f22e in print_frame_info (fp_opts=..., frame=0x621007acc510, print_level=1, print_what=LOCATION, print_args=1, set_current_sal=0) at /home/simark/src/binutils-gdb/gdb/stack.c:1116 >>>> #14 0x000055555f526c6d in backtrace_command_1 (fp_opts=..., bt_opts=..., count_exp=0x0, from_tty=0) at /home/simark/src/binutils-gdb/gdb/stack.c:2079 >>>> #15 0x000055555f527ae5 in backtrace_command (arg=0x0, from_tty=0) at /home/simark/src/binutils-gdb/gdb/stack.c:2198 >>>> >>>> The problem is that the type that gets passed down to >>>> dwarf_expr_context::fetch_result (the type of a variable of which we're >>>> trying to read the entry value) is a typedef whose size has never been >>>> computed yet (check_typedef has never been called on it). As we get in >>>> the DWARF_VALUE_STACK case (line 1028 of dwarf2/expr.c), the `len` >>>> variable is therefore set to 0, instead of the actual type length. We >>>> then call allocate_value on subobj_type, which does call check_typedef, >>>> so the length of the typedef gets filled in at that point. We end up >>>> passing to the copy function a source array view of length 0 and a >>>> target array view of length 4, and the assertion fails. >>>> >>>> Fix this by calling check_typedef on both type and subobj_type at the >>>> beginning of fetch_result. >>>> >>>> I tried writing a test for this using the DWARF assembler, but I haven't >>>> succeeded. It's possible that we need to get into this specific code >>>> path (value_of_dwarf_reg_entry and all) to manage to get to >>>> dwarf_expr_context::fetch_result with a typedef type that has never been >>>> resolved. In all my attempts, the typedef would always be resolved >>>> already, so the bug wouldn't show up. >>>> >>>> As a fallback, I made a gdb.dwarf2 test with compiler-generated .S >>>> files. I don't particularly like those, but I think it's better than no >>>> test. The .cpp source code is the smallest reproducer I am able to make >>>> from the reproducer given in the bug (thanks to Pedro for suggestions on >>>> how to minimize it further than I had). Since I tested on both amd64 >>>> and aarch64, I added versions of the test for these two architectures. >>>> >>>> Change-Id: I182733ad08e34df40d8bcc47af72c482fabf4900 >>>> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29374 >>>> --- >>>> gdb/dwarf2/expr.c | 5 + >>>> .../gdb.dwarf2/entry-value-typedef-aarch64.S | 12885 +++++++++++++ >>>> .../gdb.dwarf2/entry-value-typedef-amd64.S | 15545 ++++++++++++++++ >>>> .../gdb.dwarf2/entry-value-typedef.cpp | 36 + >>>> .../gdb.dwarf2/entry-value-typedef.exp | 45 + >>>> 5 files changed, 28516 insertions(+) >>>> create mode 100644 gdb/testsuite/gdb.dwarf2/entry-value-typedef-aarch64.S >>>> create mode 100644 gdb/testsuite/gdb.dwarf2/entry-value-typedef-amd64.S >>>> create mode 100644 gdb/testsuite/gdb.dwarf2/entry-value-typedef.cpp >>>> create mode 100644 gdb/testsuite/gdb.dwarf2/entry-value-typedef.exp >>> >>> I pushed this patch. >>> >>> Simon >> >> It seems newer compilers on aarch64 (g++ 9.4.0 or 11.2.0) don't like this test. They complain with: >> >> gdb compile failed, /usr/bin/ld: /tmp/cc0vjoZT.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZNSsD1Ev@@GLIBCXX_3.4' which may bin >> d externally can not be used when making a shared object; recompile with -fPIC >> /usr/bin/ld: /tmp/cc0vjoZT.o(.text+0x38): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `_ZNSsD1Ev@@GLIBCXX_3.4' >> /usr/bin/ld: final link failed: bad value >> >> So the test doesn't run properly. > > Is is that the old compiler I used (g++ 4.8 on Ubuntu 14.04, on the > compile farm) generated non-position-independent code, but the linker > of the newer toolchains try to build a position-independent executable? > If so, we can re-generate the assembly files with -fPIE, and it should > work, right? I'll give this a try, I have access to an AArch64 machine > with Debian 11 & g++ 10.2.1. > > Simon Yes, that might be the case. Let me know if you'd like me to regenerate it.