From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2062.outbound.protection.outlook.com [40.107.94.62]) by sourceware.org (Postfix) with ESMTPS id 2FE853857C53 for ; Fri, 5 Nov 2021 11:39:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2FE853857C53 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Nj3yU68fgZ/KzRqIuAZX/tYAqF7DiUxIIVoBRF1owQt8wXYWh3GEB2t9KZlzsnFHM6OukldOIQlGg8xuhgU9jsEIRIu+OShkxdXB74hHoHxsj0LXknoEJE6XsXWfIF40dHjtdiwWMCme+cBJoiXHogmZW2HgaKS7Oea21W7G1bbrqzBFiMB+AblFrH78MeKEA7ZCyT6ZykVbGGpl8Sqfq5YTFM+7vBHO2WuLXfJSSj4cpJ4KizUR6lnyCEPA2WT0F44e+jdnz5Xa4VBXdMuMB8MfJ5nU23xIUFpY9qdpSU45MNWa7ADcV7f1roYRrqPXpdi+hSLxx+3pEX1UvMJ79w== 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=jfDGv9uWbNVEhJVrm6nFI0CyL72ezcndM0fK7Bp+2Sc=; b=PNkmkzfWLSDOqn62dcNf2kEqlvQux86JX2ddwS8UzjmpSR9lh5jhWlqflIJaCwBoO2ncxBUXNFAYT3PVJZsyZ5Rs4x0hgGRGRb3Z8sHzY1JW7oqUe0sBaMW1c2p4j1QOT/O1rgOPmh9+p/rPwq3HCVPLuca9bcCKmJnlOOl8aj4I2h/vA2DhhQoWBq/iLem+cG+qmud20SsHhoLiWOiRbEMnerRwyfkRgcsa21SXOw4KgkeXKZ3iTeUs/t8hpVVkRaT6iO3NIuE/AWzUA6+RWvxhqLVsUtdQvoNqxonza7zG8zs4BnK3p1TevH/3HY4UqW7XrTBxTJ4mBcRs0aX9GQ== 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 Received: from MWHPR11CA0005.namprd11.prod.outlook.com (2603:10b6:301:1::15) by CY4PR12MB1816.namprd12.prod.outlook.com (2603:10b6:903:11c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10; Fri, 5 Nov 2021 11:39:32 +0000 Received: from CO1NAM11FT043.eop-nam11.prod.protection.outlook.com (2603:10b6:301:1:cafe::8e) by MWHPR11CA0005.outlook.office365.com (2603:10b6:301:1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Fri, 5 Nov 2021 11:39:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; 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; Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT043.mail.protection.outlook.com (10.13.174.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4669.10 via Frontend Transport; Fri, 5 Nov 2021 11:39:31 +0000 Received: from localhost.localdomain (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.2308.15; Fri, 5 Nov 2021 06:39:28 -0500 From: Zoran Zaric To: Subject: [PATCH v4 25/28] Add support for DW_OP_LLVM_undefined operation Date: Fri, 5 Nov 2021 11:38:46 +0000 Message-ID: <20211105113849.118800-26-zoran.zaric@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211105113849.118800-1-zoran.zaric@amd.com> References: <20211105113849.118800-1-zoran.zaric@amd.com> 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-Office365-Filtering-Correlation-Id: 71610278-33e3-4d99-5abb-08d9a050ef03 X-MS-TrafficTypeDiagnostic: CY4PR12MB1816: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QtAyx4xNaH9XPE3ZHTA01q2qRSi+eaDPa2/mBeqo29tIQTgNoGNtPOZr9W49pPiO7MztBSQe2C0XF9fJPe3IRAGQdPldCyvFtSh803BJmDfXKMwE6Bxu3nr3jt9pQQkqDq+2YBZuf+yq69PSLZ3Zh82GTXOQWmBjHPRtMk7iOtTfl8EwqTJwT9+jd/MRd6KER6Xl/RkdmrfiKGhYHuxZfe3Ge+Qn8jqqYoqzRnOvtiDTchjTIzCpnlIEK3FIjaPoAqrTxhMS5kBpb0faX3V7zFnvxpKloKjBIbauuebwphlN8logp2yG+TacbY3NRzbj7ktFU9Tn5KFp6Dw5SwTEQkGWgOtLBQ+IcYqiCjt6qEvXMBi/9uPGUMLsDXUjvxH2jT/p9sgUZ3YxiflJRyknx0SinbUrIQq+GGKTZlCYcMMvai4TcDsdAFRT1HhZEicHyXlOEDG4US+6JqXPXVDwNwoViTYYRg/HZz6E5k58CRpiKT5miaNhMtWNhr8Us95NYyxHNxXqlZdfvUl1vaiUANfTbNd685OyP/HCgePa9OEvWjdxchdpIXhIKLPCiofdWwCqDkRq0lWioCIySWHVTxLLnDZaUt+QVi2R5Zso2Nrpem0ot6X1DBW+jnXX3vmWwfWsnzJJeLqA1eurIMxjz5jvFBIee5xa/sm921G8DKsnVGa9PgyF+mZZeT+ROtSCa+GTabes64AFSKX2U1Al1c0Tw2VlZpgkQAe3eJhkm6lJ/lI8KDgHDfbrBJASiBKgn6MzyFixW0jMvVCy1Vt8Kjz/M1R2dwxUYg15su/sb+9lIXH15n8xXqgWHoB890lThbyCXKVQA9O351ECMOCHoF1kSIRSysq67RD7dNyvgPaH8a6BX8184a+ol6KqHmk3 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:(4636009)(36840700001)(46966006)(316002)(83380400001)(356005)(186003)(16526019)(81166007)(47076005)(2616005)(8936002)(44832011)(5660300002)(336012)(8676002)(36860700001)(1076003)(36756003)(86362001)(2906002)(70206006)(26005)(6916009)(4326008)(70586007)(426003)(966005)(508600001)(82310400003)(6666004)(2004002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2021 11:39:31.5779 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 71610278-33e3-4d99-5abb-08d9a050ef03 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: CO1NAM11FT043.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1816 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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, 05 Nov 2021 11:39:37 -0000 From: Zoran Zaric For the DW_OP_piece and DW_OP_bit_piece operations, in the DWARF 5 standard, it is stated that if the location description (of that piece) is empty, then the piece is describing an undefined location description. The act of allowing any location description to be placed on a DWARF stack means that now a new operations can be defined which could pop more then one location description from a DWARF stack. This means that the old rule is not really applicable any more and a new operation that explicitly pushes an undefined location description on the DWARF stack is needed. This new rule however is fully backward compatibility as described in the document found on: https://llvm.org/docs/AMDGPUDwarfExtensionsForHeterogeneousDebugging.html Under the new definitions for the DW_OP_piece and DW_OP_bit_piece operations. gdb/ChangeLog: * compile/compile-loc2c.c (compute_stack_depth_worker): Add support for new DW_OP_LLVM_undefined operations. * dwarf2/expr.c (dwarf_expr_context::execute_stack_op): Add support for new DW_OP_LLVM_undefined operations. * dwarf2/loc.c (dwarf2_get_symbol_read_needs): Add new DW_OP_LLVM_undefined operation support. include/ChangeLog: * dwarf2.def (DW_OP): New DW_OP_LLVM_undefined operations enumeration. gdb/testsuite/ChangeLog: * gdb.dwarf2/dw2-llvm-undefined.exp: New test. --- gdb/compile/compile-loc2c.c | 4 + gdb/dwarf2/expr.c | 4 + gdb/dwarf2/loc.c | 1 + .../gdb.dwarf2/dw2-llvm-undefined.exp | 144 ++++++++++++++++++ include/dwarf2.def | 1 + 5 files changed, 154 insertions(+) create mode 100644 gdb/testsuite/gdb.dwarf2/dw2-llvm-undefined.exp diff --git a/gdb/compile/compile-loc2c.c b/gdb/compile/compile-loc2c.c index 77eb5a8e19d..89f40e5513a 100644 --- a/gdb/compile/compile-loc2c.c +++ b/gdb/compile/compile-loc2c.c @@ -362,6 +362,10 @@ compute_stack_depth_worker (int start, int *need_tempvar, --stack_depth; break; + case DW_OP_LLVM_undefined: + ++stack_depth; + break; + case DW_OP_LLVM_offset_constu: case DW_OP_nop: break; diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index a0310fef7a4..540bc96a2d0 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -4051,6 +4051,10 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, break; } + case DW_OP_LLVM_undefined: + push (make_unique (arch)); + break; + default: error (_("Unhandled dwarf expression opcode 0x%x"), op); } diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 7c0782404dd..d6e46f07717 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1926,6 +1926,7 @@ dwarf2_get_symbol_read_needs (gdb::array_view expr, case DW_OP_push_object_address: case DW_OP_LLVM_offset: case DW_OP_LLVM_bit_offset: + case DW_OP_LLVM_undefined: break; case DW_OP_form_tls_address: diff --git a/gdb/testsuite/gdb.dwarf2/dw2-llvm-undefined.exp b/gdb/testsuite/gdb.dwarf2/dw2-llvm-undefined.exp new file mode 100644 index 00000000000..2bd678c1e0d --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw2-llvm-undefined.exp @@ -0,0 +1,144 @@ +# Copyright 2017-2021 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test the new DW_OP_LLVM_undefined operation. +# +# The test uses a composite location description, where some pieces +# of that location description are undefined location description. + +load_lib dwarf.exp + +# This test can only be run on targets which support DWARF-2 and use gas. +if {![dwarf2_support]} { + return 0 +} + +# Choose suitable integer registers for the test. + +set dwarf_regnum 0 + +if { [is_aarch64_target] } { + set regname x0 +} elseif { [is_aarch32_target] + || [istarget "s390*-*-*" ] + || [istarget "powerpc*-*-*"] + || [istarget "rs6000*-*-aix*"] } { + set regname r0 +} elseif { [is_x86_like_target] } { + set regname eax +} elseif { [is_amd64_regs_target] } { + set regname rax +} else { + verbose "Skipping ${gdb_test_file_name}." + return +} + +standard_testfile var-access.c ${gdb_test_file_name}-dw.S + +# Make some DWARF for the test. + +set asm_file [standard_output_file $srcfile2] +Dwarf::assemble $asm_file { + global dwarf_regnum regname srcdir subdir srcfile + set buf_src [gdb_target_symbol buf] + + set main_result [function_range main ${srcdir}/${subdir}/${srcfile}] + set main_start [lindex $main_result 0] + set main_length [lindex $main_result 1] + + cu {} { + DW_TAG_compile_unit { + {DW_AT_name var-access.c} + {DW_AT_comp_dir /tmp} + } { + declare_labels int_type_label char_type_label array_type_label + + # define char type + char_type_label: DW_TAG_base_type { + {DW_AT_name "char"} + {DW_AT_encoding @DW_ATE_signed} + {DW_AT_byte_size 1 DW_FORM_sdata} + } + + 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} + } + + array_type_label: DW_TAG_array_type { + {DW_AT_type :$char_type_label} + } { + DW_TAG_subrange_type { + {DW_AT_type :$int_type_label} + {DW_AT_upper_bound 5 DW_FORM_udata} + } + } + + DW_TAG_subprogram { + {DW_AT_name main} + {DW_AT_low_pc $main_start addr} + {DW_AT_high_pc $main_length data8} + } { + + # Array spread in different pieces of which some are + # undefined (1st and sixth bytes) and some are in a + # REGNAME register. + DW_TAG_variable { + {DW_AT_name var_array} + {DW_AT_type :$array_type_label} + {DW_AT_location { + DW_OP_LLVM_undefined + DW_OP_piece 0x1 + DW_OP_regx $dwarf_regnum + DW_OP_piece 0x4 + DW_OP_LLVM_undefined + DW_OP_piece 0x1 + } SPECIAL_expr} + } + + DW_TAG_variable { + {DW_AT_name var_int} + {DW_AT_type :$int_type_label} + {DW_AT_location { + DW_OP_LLVM_undefined + } SPECIAL_expr} + } + } + } + } +} + +if { [prepare_for_testing ${testfile}.exp ${testfile} \ + [list $srcfile $asm_file] {nodebug}] } { + return -1 +} + +if ![runto_main] { + return -1 +} + +gdb_test_no_output "set var \$$regname = 0x04030201" "init reg" + +# Determine byte order. +set endian [get_endianness] + +switch $endian { + little {set val ", 0x1, 0x2, 0x3, 0x4, "} + big {set val ", 0x4, 0x3, 0x2, 0x1, "} +} + +gdb_test "print/x var_array" " = \\{${val}\\}" "var_array print" +gdb_test "print/x var_int" " = " "var_int print" diff --git a/include/dwarf2.def b/include/dwarf2.def index 5e622695d60..1b626362ec4 100644 --- a/include/dwarf2.def +++ b/include/dwarf2.def @@ -708,6 +708,7 @@ DW_OP (DW_OP_AARCH64_operation, 0xea) DW_OP_DUP (DW_OP_LLVM_offset, 0xe3) DW_OP_DUP (DW_OP_LLVM_offset_constu, 0xe4) DW_OP_DUP (DW_OP_LLVM_bit_offset, 0xe5) +DW_OP (DW_OP_LLVM_undefined, 0xe7) DW_END_OP DW_FIRST_ATE (DW_ATE_void, 0x0) -- 2.17.1