From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2085.outbound.protection.outlook.com [40.107.93.85]) by sourceware.org (Postfix) with ESMTPS id E23D83858D20 for ; Mon, 12 Jun 2023 13:11:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E23D83858D20 Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OywQyhJhPGXWgPVEoHSkhDyg+g7qdRJvw9vfVFmm8cPA+qTQDOp6N3G1Bia/+CvQfI2dUvsjUL0CfnBfZGyrVL7jwzubtIX3N3zNnsBqjIGtRjGMSkrWI+t8nS+aJwngbP+E3b8Z3/hXrMaOezH8gswwQn0xWIBDif2wdJgrzkXiIaRMQaEqV1EkSQuqkS5AgQUpcbqIITvc0OwEHvPph5FSOK9ZqR9jfPa1h+MUmutASyGqYyaDopU57gdIX26L+H33qxVxD3mb2wX6CAIgp6L5AzE9ol+0ghRqWmCGFH3pV7CPYnujDcuBySlRpbnhdVv2WqUKp0pvOYWXpJwGIA== 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=scc5HL7uI5Qj9Xq6xHkzQ9U0C5XJS/9SiK2u5aOkwVM=; b=FT1YwKJhdt+r9gM7RTmJiOjMwiDN7jHEc256t8lD47T6RbdThJLNPbcl9cUx2aj/uczWQTOz/KqEX+5r7c8H12TJaC5Xqcn0fIEb8yJ5izL1xv+d8dMOqisf3LUpCJU+YhQT3ellfYhLXTs65v1sPvtBCT/Ek4rt/UmutuOsC5QKFH3l/3R8gHfDceJ/h8dbUdfyCuzk/Gwq+mbdBEheI2g48JDY8na6v1v1uSLOdai4Lv7cj9N4L+D04jpKF3o49ycbotUfHVpWlROBOiY6Tg6h80OmA8dvpFRHeUDcVKoRLkgc030mLshn2LZSloYl+s4WTa1yHt6UxlyZ9cRuhg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=scc5HL7uI5Qj9Xq6xHkzQ9U0C5XJS/9SiK2u5aOkwVM=; b=bL9irz05GexCMdW/wI5UN5tUMt7Id6tGXxrDr241T+i4s+PbsP8c652oLSm2p74UedwJlxlNOHI9ozvy8AHevcpmypzRa0LZlFtQ/UuJRwpiEXl7jpwXZ6S3Ir1Cjy8HMXadODFUlSJ34tcrTCTWnhXHna6dT36n81jCPkdY76g= Received: from MW4PR04CA0104.namprd04.prod.outlook.com (2603:10b6:303:83::19) by CH3PR12MB7740.namprd12.prod.outlook.com (2603:10b6:610:145::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Mon, 12 Jun 2023 13:11:02 +0000 Received: from CO1NAM11FT041.eop-nam11.prod.protection.outlook.com (2603:10b6:303:83:cafe::ac) by MW4PR04CA0104.outlook.office365.com (2603:10b6:303:83::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.34 via Frontend Transport; Mon, 12 Jun 2023 13:11:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT041.mail.protection.outlook.com (10.13.174.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6500.21 via Frontend Transport; Mon, 12 Jun 2023 13:11:01 +0000 Received: from khazad-dum.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Mon, 12 Jun 2023 08:10:59 -0500 From: Lancelot SIX To: CC: , Lancelot SIX Subject: [PATCH v2] gdb/testsuite: use proper int size for gdb.dwarf2/symbol_needs_eval*.exp Date: Mon, 12 Jun 2023 14:10:17 +0100 Message-ID: <20230612131017.236363-1-lancelot.six@amd.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT041:EE_|CH3PR12MB7740:EE_ X-MS-Office365-Filtering-Correlation-Id: 58fec719-8985-4695-1be3-08db6b4678ca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ba6DE+QI9SyRM/2ku+h3Ib/V+RJmwiPMsFPKZSZ99YJw+W+IwvQ+TdWqb/APwDGVL6b/8Hgrdupy3qv2gbNPktv9h0qpZ4DgMPVYgcdJ8hLUVKS9+t3jFhSm42K8b/wZchEK9M+tYVVLBkNkiJc842ekCryDW6Z0skBFp91T0rgyrD3QoAxThHlbAJKE5PuzPG26dXkApD0fxdzvkMc7nx4grPwAzAR6OvaS7g3lRoI0FF/hFqj2sZl8HOEfwNbQ1caXC21aGN+idB9JG4vCPR6jY1/y7F+j1GfQ0hU0OWAoLOU/ljQG2JogVEI3eE7P5RfMo+/OJLvq+2rLsrxRlrhNjVjI381B2LEK7hij8f7vgH5SYGvkvilvQ4oi8v7XobkMhv/Ll6eZ/WC0Wi4emRlU2vMyMqiARu6SLyyW1npmB4bSyg+k7ajmbsTq6ncGL5H0kSOorxYqmiLmqutPo72tAWgLXFB1XZWNoPSgjQj0ptfhz+JbVUTR7094BaXtVb09rxKQ7ETKFgZbsCymmBRnvn1e5ITlBBwpwTulyh6Aex5HA9CZFwPSMHwjj80u/nAR5mEJV0o+3bGl9azMkn1vMaPP03M6ghzMcjWCDrS0nOS1jEadOiD5+VUZL4L7vkCsqMji9MBB8/JrE3kjbvftxr1mG9cqYOm5OJMSR+EYBJZAZmWQY2YTk7fxieA3Ovl7d2JdG9ksKkmi4JMiNhgI9D3SQxEBx+2K/JdeNrn7Mq3JeTBHYD4va9I5Ozb8FyydnLs6ugny0czBrOxNBw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(376002)(39860400002)(346002)(136003)(451199021)(46966006)(40470700004)(36840700001)(40460700003)(7696005)(6666004)(966005)(36860700001)(47076005)(426003)(336012)(83380400001)(36756003)(2616005)(86362001)(82310400005)(356005)(82740400003)(81166007)(1076003)(26005)(40480700001)(186003)(16526019)(2906002)(5660300002)(54906003)(8676002)(8936002)(316002)(41300700001)(6916009)(4326008)(70206006)(70586007)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 13:11:01.9888 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 58fec719-8985-4695-1be3-08db6b4678ca X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT041.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7740 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,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: Hi, Here is a quick V2 folowing https://sourceware.org/pipermail/gdb-patches/2023-June/200162.html. Changes since V1: - Removed the `clean_restart` after `prepare_for_testing` as this is redundant. Best, Lancelot. --- We recently realized that symbol_needs_eval_fail.exp and symbol_needs_eval_timeout.exp invalidly dereference an int (4 bytes on x86_64) by reading 8 bytes (the size of a pointer). Here how it goes: In gdb/testsuite/gdb.dwarf2/symbol_needs_eval.c a global variable is defined: int exec_mask = 1; and later both tests build some DWARF using the assembler doing: set exec_mask_var [gdb_target_symbol exec_mask] ... DW_TAG_variable { {DW_AT_name a} {DW_AT_type :$int_type_label} {DW_AT_location { DW_OP_addr $exec_mask_var DW_OP_deref ... } } The definition of the DW_OP_deref (from Dwarf5 2.5.1.3 Stack Operations) says that "The size of the data retrieved from the dereferenced address is the size of an address on the target machine." On x86_64, the size of an int is 4 while the size of an address is 8. The result is that when evaluating this expression, the debugger reads outside of the `a` variable. Fix this by using `DW_OP_deref_size $int_size` instead. To achieve this, this patch adds the necessary steps so we can figure out what `sizeof(int)` evaluates to for the current target. While at it, also change the definition of the int type in the assembled DWARF information so we use the actual target's size for an int instead of the literal 4. Tested on x86_64 Linux. --- gdb/testsuite/gdb.dwarf2/symbol_needs_eval_fail.exp | 12 +++++++++--- .../gdb.dwarf2/symbol_needs_eval_timeout.exp | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/gdb/testsuite/gdb.dwarf2/symbol_needs_eval_fail.exp b/gdb/testsuite/gdb.dwarf2/symbol_needs_eval_fail.exp index cb9826e90df..ec3913cb75f 100644 --- a/gdb/testsuite/gdb.dwarf2/symbol_needs_eval_fail.exp +++ b/gdb/testsuite/gdb.dwarf2/symbol_needs_eval_fail.exp @@ -47,11 +47,17 @@ if { [is_aarch64_target] } { standard_testfile symbol_needs_eval.c ${gdb_test_file_name}-dw.S +if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug}] { + return +} + +set int_size [get_sizeof "int" -1] + # Make some DWARF for the test. set asm_file [standard_output_file $srcfile2] Dwarf::assemble $asm_file { - global dwarf_regnum regname + global dwarf_regnum regname int_size set exec_mask_var [gdb_target_symbol exec_mask] @@ -66,7 +72,7 @@ Dwarf::assemble $asm_file { int_type_label: DW_TAG_base_type { {DW_AT_name "int"} {DW_AT_encoding @DW_ATE_signed} - {DW_AT_byte_size 4 DW_FORM_sdata} + {DW_AT_byte_size $int_size DW_FORM_sdata} } # define artificial variable a @@ -75,7 +81,7 @@ Dwarf::assemble $asm_file { {DW_AT_type :$int_type_label} {DW_AT_location { DW_OP_addr $exec_mask_var - DW_OP_deref + DW_OP_deref_size $int_size # conditional jump to DW_OP_bregx DW_OP_bra 4 diff --git a/gdb/testsuite/gdb.dwarf2/symbol_needs_eval_timeout.exp b/gdb/testsuite/gdb.dwarf2/symbol_needs_eval_timeout.exp index 0e6ee6112ea..fc0b59175b1 100644 --- a/gdb/testsuite/gdb.dwarf2/symbol_needs_eval_timeout.exp +++ b/gdb/testsuite/gdb.dwarf2/symbol_needs_eval_timeout.exp @@ -47,11 +47,17 @@ if { [is_aarch64_target] } { standard_testfile symbol_needs_eval.c ${gdb_test_file_name}-dw.S +if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug}] { + return +} + +set int_size [get_sizeof "int" -1] + # Make some DWARF for the test. set asm_file [standard_output_file $srcfile2] Dwarf::assemble $asm_file { - global dwarf_regnum regname + global dwarf_regnum regname int_size set exec_mask_var [gdb_target_symbol exec_mask] @@ -66,7 +72,7 @@ Dwarf::assemble $asm_file { int_type_label: DW_TAG_base_type { {DW_AT_name "int"} {DW_AT_encoding @DW_ATE_signed} - {DW_AT_byte_size 4 DW_FORM_sdata} + {DW_AT_byte_size $int_size DW_FORM_sdata} } # add info for variable exec_mask @@ -93,7 +99,7 @@ Dwarf::assemble $asm_file { {DW_AT_location { DW_OP_lit1 DW_OP_addr $exec_mask_var - DW_OP_deref + DW_OP_deref_size $int_size # jump to DW_OP_fbreg DW_OP_skip 4 base-commit: 12f7174bf069f407d5b6f12e926ceabe45e450e1 -- 2.34.1