From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2060.outbound.protection.outlook.com [40.107.237.60]) by sourceware.org (Postfix) with ESMTPS id E7CDC393C84B for ; Mon, 1 Mar 2021 14:48:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E7CDC393C84B ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NQghfHoMZ/mss50mUeZYn6UmpbqVqXDzAQqvIwQ+H/J6okWo/dfIejwIGAb1FyeRylfEOY30zKs2sXrR5XXJg2kTmZdjuEOFHqE56wSt8C95OgvvqnCrDFvbGSJIAkCMarPwG/QQhvU7jPS3uomX9dE53YcnuqleXXuJNRcmpgg5aulTsA/YXrImnR0B6UiSjcpBpxZKokMGoL4ugFuNyTCnOyl4RQgLsuVxCmeMNsSmhudPqgtI92pKWevJ8RjT61wcdcznLyreKGkLjqsNifHfAU/bSmvjDZkosRvwhbCpex6Y9CzhX9XJS7kff8LaXSO4p1d+jUxyszEI8+CPKQ== 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-SenderADCheck; bh=vue8O/sDKE2yxJl0Cm+EaYq3CaerRU6SyJG7/I3OMbA=; b=XX9jrhDl8pIGDFyLI4HQmbt6MMs/E8MvWXZm2gankwVgvSIUcHDEPjzHTV4Nrci39Aj0Dx1/JJhNFV2ipUn9wT0y7jimTxzGSTN1iBghAdXrPO86CpND/j1dwtetxV195xizvdU77VPxhfSymzeymciO626neLtD/4I6IdOG+RD03P4A3NimE1vlBc06DawpauJwpVzXsVoyXzbJrU36XWMpQNtFtv99S6DYhxwL8OWE6uL0M88VTGqSMvI3/cAVAEZTgxPG/kbe/bV0BWBNjthUEKNoPGBXhXvhlkIefaokIbpR7RuucwloZTigGi0v/QKKsxl6ccm3IQhufP9+eA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none Received: from DM6PR12MB2762.namprd12.prod.outlook.com (2603:10b6:5:45::15) by DM5PR12MB2342.namprd12.prod.outlook.com (2603:10b6:4:ba::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.28; Mon, 1 Mar 2021 14:47:50 +0000 Received: from DM6PR12MB2762.namprd12.prod.outlook.com ([fe80::31d8:f503:f7b2:f44]) by DM6PR12MB2762.namprd12.prod.outlook.com ([fe80::31d8:f503:f7b2:f44%3]) with mapi id 15.20.3868.033; Mon, 1 Mar 2021 14:47:50 +0000 From: Zoran Zaric To: gdb-patches@sourceware.org Subject: [PATCH 42/43] Add support for DW_OP_LLVM_undefined operation Date: Mon, 1 Mar 2021 14:46:19 +0000 Message-Id: <20210301144620.103016-43-Zoran.Zaric@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210301144620.103016-1-Zoran.Zaric@amd.com> References: <20210301144620.103016-1-Zoran.Zaric@amd.com> Content-Type: text/plain X-Originating-IP: [2a00:23c7:5a85:6801:b4ed:fe7b:8064:d4d] X-ClientProxiedBy: AM0PR04CA0073.eurprd04.prod.outlook.com (2603:10a6:208:be::14) To DM6PR12MB2762.namprd12.prod.outlook.com (2603:10b6:5:45::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a00:23c7:5a85:6801:b4ed:fe7b:8064:d4d) by AM0PR04CA0073.eurprd04.prod.outlook.com (2603:10a6:208:be::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.19 via Frontend Transport; Mon, 1 Mar 2021 14:47:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 22c1103a-40a0-4afa-92bc-08d8dcc0f0a1 X-MS-TrafficTypeDiagnostic: DM5PR12MB2342: X-MS-Exchange-MinimumUrlDomainAge: llvm.org#6197 X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WiD8ErRN/14KVm067jxMExNeKAjOY7Bb/35CcrU69L+EvgxiY7TkX9Pnk7pHF0h4UUxs6/aDBBIskCIuS5iNmxV5yCWGFoWibJR/fbTd3oS31SpluSteS6b4MxCclXGajn79m40NVK9PToN04RK1MVZkmClsPdV+ZUlGVQMSY23rSiEqSVMjengSpbvNGSfOS5B6TVL0CLSZ09cDjAoqHYzrqbt34ffLApQUbTg4XQKu8uYvKtvPyvVRT8ot7Z414f6RXH+LYd8WOiYMm3WUUnF7ayVvuJ1G4uk4sBhTj3RpqQkbgjMqO16hB/ymeuXFM2Virk3+Fm+vSn3ON/HopZLkgJs8Y9taYsFW176ieNfhoGrQ8dQqRB0J4MY8jzPDbW+7pbCK8UqDzotOjKVB2rJn9WBKEx0kRQ6Hiw45WrPyISFpiZF3Ot89HR0PJL6H31SPoH2+H80okkE2n4SJ4QiQmsnRcfPSWzpRgcJf2eavBN0Ftu1ErP5Xn6ZbAAJS5yA2qxQvJH9PdzrXywZrWuOzRfF+Yp6GnjcxhhnP3qn2wWGHpt45OEVFrdCJQJylAmco3bxRgYNad05iRZ5VIIUG9IkcRiQHSgAMNtQNtt3nBmT1xcv067tHF/LErCPetFSQl8Qa0HxOl0B8vvo8bqcODQPfo1JhRMwwYoe6Ub2RQM08i9QElnMzI99VdlNY X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR12MB2762.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(396003)(376002)(39860400002)(136003)(6486002)(66476007)(966005)(4326008)(478600001)(66556008)(2906002)(66946007)(69590400012)(316002)(52116002)(6666004)(6916009)(2616005)(86362001)(16526019)(6512007)(36756003)(8676002)(8936002)(6506007)(5660300002)(186003)(1076003)(83380400001)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?wD28Cc6IIUv9vhAWY4GOaXYpzf8cyOU16D+/Q7hjNgny12IXIHk9koH40HXc?= =?us-ascii?Q?1dw8TKeoBmsR0z/JDc/OPTkTosw8DN65xMXJOJqdYWWSYitPivsyi1xfVcAL?= =?us-ascii?Q?lEER9tRXseDI8RlO4jhOSkxxBFUY9HExLz89txvHNmm90Agrk5IojgXo58uy?= =?us-ascii?Q?4YteJLBzG4RYMCx6/KeWIGM6UkDru2j3V4JXk+egLChXb3GUeoWggc8hcPPn?= =?us-ascii?Q?91rkV5X+KraARuCQssOEZoG3LQQRghgqzMqJmZcNMGaxRbBlKV0Csz+QVCcJ?= =?us-ascii?Q?KWHlnOdEHyETXYHVLkmTSpBtJ0SPH09fXjZx/zGX6doH4yhZxJ3Dda2yTb8B?= =?us-ascii?Q?YeUiMa/4lD6s6yOm0oJ+CO0rW1Agui3nvtTarYWysHgyGQEXx/hD+mu+2gHa?= =?us-ascii?Q?Ck/X+jl/O569IReKmIxECCpH1vVsCBFs0H9YM86Vty1rVLU7M88/+y/WmeYr?= =?us-ascii?Q?UrGnxxgH0Sdl01cqZOwiOyVk744EU47DgikbDiarjoCtFdSL2IYfkUPM6FVf?= =?us-ascii?Q?/5Q1ficpvTJt7/Zd2x3iFgNVU45Go8KI/Rz6FYfTHh0TNlAWkgRyBPdO9MqV?= =?us-ascii?Q?Ud3GXQORiqC+YhXi96yDBrpi+xlowTsO49e6AIKo3zsLHHqTZJqAiJNbJIyk?= =?us-ascii?Q?GgiJNZFUQOWfy0Rf5O1osaKd6L8i0KE3mmoIbDXl2sL7a0yIbB26l6zx89Ex?= =?us-ascii?Q?9TMbA45ieHo0yJVPk1XMlEGVtMIwvF450uWyd219aZXAi9k30kOEJePucnYq?= =?us-ascii?Q?WiTCipL+2z4lJL0eYwTHYguz2TMsUVowMHuspiXd7romIikiZuf02u3Uk5Tj?= =?us-ascii?Q?awYPVQ8b0woPMwNb5ndTgAEe60YcQojwh/Y15EXxWaiACdSbhWCBNAx6fiHo?= =?us-ascii?Q?fmXm5Y9yJZ9SZMLI8WmEhon/mMpZY32OD3K4Bd9WVWfGPk1p2RDFY94jjdPM?= =?us-ascii?Q?Mn4IrnsBmwoIjX/zKfRRYW26ZankiMr6qU+jTLPNvJwVMh+yyyM5pKnntXeH?= =?us-ascii?Q?B9Emvns69XkKIlcYwp9ffrKthX9PhrMyuDEs6TYynGl5lZIeTlZ4mk0oerOe?= =?us-ascii?Q?roJx+WolmguOfMvIgcO2xL5PBgLaXgzZw2qX1YSVlYHiCatHpCWohUxPPsiX?= =?us-ascii?Q?kwgNAI9yrqAyicZPIfWuZ25u6+F39RWSfxlOIZr7JksrIjCEWExobgsjJGTH?= =?us-ascii?Q?8YyyCOvLUpwZVNIYNRlgc+Sm9QqyOFoJ8L3DL3b86f4ev2vYS8EY2z0nz4w7?= =?us-ascii?Q?wGjOcOegGXF/vbKOvoUotU3RzvaAvUCxTPtAoPL2qWxyk/Ne5mtXDmDzOmA2?= =?us-ascii?Q?7mPVMkBgfdqYLAA0aDk5MGhSMXRuM9VODvz24ph9jaozsQjhhOLGzestH+YL?= =?us-ascii?Q?ny2aKd4t8CyP6TCWd/UkKpGpxZtg?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 22c1103a-40a0-4afa-92bc-08d8dcc0f0a1 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB2762.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2021 14:47:30.4216 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fYjUnpRY9uOnywSxEeSOTF3KitE0BfRhUJZtf40oaxJguDnFJSvQ5WNwUwQD+M1OyHDIuyCM8XqbGkxk4Uzu6w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB2342 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Mon, 01 Mar 2021 14:48:02 -0000 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. 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/dw2-llvm-undefined.exp | 144 ++++++++++++++++++ include/dwarf2.def | 1 + 4 files changed, 153 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 58558fa7d22..057d68823f9 100644 --- a/gdb/compile/compile-loc2c.c +++ b/gdb/compile/compile-loc2c.c @@ -361,6 +361,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 19e5f5e93b5..ec7837e1935 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -3838,6 +3838,10 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, } break; + case DW_OP_LLVM_undefined: + result_entry = std::make_shared (this->gdbarch); + break; + default: error (_("Unhandled dwarf expression opcode 0x%x"), op); } 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..be677a1ddce --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw2-llvm-undefined.exp @@ -0,0 +1,144 @@ +# Copyright 2017-2020 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