From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id uDoHAbP+PGCHJAAAWB0awg (envelope-from ) for ; Mon, 01 Mar 2021 09:48:19 -0500 Received: by simark.ca (Postfix, from userid 112) id 018591EF64; Mon, 1 Mar 2021 09:48:18 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 4AEBD1F0B9 for ; Mon, 1 Mar 2021 09:48:03 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B5E25393C038; Mon, 1 Mar 2021 14:48:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B5E25393C038 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614610081; bh=+b4WQSNiXTTYyxs3jBo2veYPOQIF11NMIo8QbsIHlVE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=HuQoSNDL8OnhWRaXtT52QWvi+CDKYfKb3z7uZjnkcJtdLEk+qaKTg9Mhgt0KzAoAu BMYplionJcHJ5c4pPNgm6C9xZlxg+u89nZI31m8N9sOa+pSdcX3EIMcDlaWtalPfZQ Z4W/rVlbQfGMPN+C0PVZzTs5yP/Pc7Abgyi0UUgg= 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 E6D60393BC2F for ; Mon, 1 Mar 2021 14:47:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E6D60393BC2F ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z8CgBmsgODzQFIr4o+zMwLKWAxmHNo21yC8Cdp1Fj481ofZA6j6nfS1P/12Irt5qvxKBuNfj6DhTAjvggU4diPI+wevzIG/zackK5AzK6AgQ2fSYbTiRv3uu3Y56tLVrzTwsDA2Vqk9s7htSa3YIY2uf9OXLj4u3eJUXHb8dOiReHfSFd0XwFYdmTRAu6+jmDAZ5VVWG/i9QybSozMA1LD3dBbdGBW6nHmYHPlyaVeUqyXbmy7Td9eTcW1gSNxUJ92GC3NpNzTmwtuQCaGqvKIvnR51empLGn36Pu7AKXYFBHCCHvP41mdCIoaHXmjpaN91iPq1QkY1BH1N7DbRl1w== 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=+b4WQSNiXTTYyxs3jBo2veYPOQIF11NMIo8QbsIHlVE=; b=ZgvQ1NVvBkmOOTuE0R5Slfg7lh1i7aOUNYFhJCP795SwugngSyjVI+uUKgkDWm4je1e6b92p6HVhEFvoXujxUYZCnP7UztDM+hE4OOZ9XCVGLtcPuYiLgZdKUUK/iXl+f0kcrF222BGE3avGIm9/Ntop53kmQwpwEgvP0lIu04UE6tAWhOguMxWtk8350Ch7EreZisEvjxQI5cA7VALpJq0g0+dIM3lIU/apnaHmWAj9QnmvxEAtxoXN3xTrw3Rsl+T98sfblAlIlGrZrW1Ma95S7Pd1TSEfLgiaxDIBfQNyjhZtlg3QxRKwhvURSUZql0PQZFTp3brvpczXx+pA/A== 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:49 +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:49 +0000 To: gdb-patches@sourceware.org Subject: [PATCH 39/43] Change back the symbol needs to use the evaluator Date: Mon, 1 Mar 2021 14:46:16 +0000 Message-Id: <20210301144620.103016-40-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:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: ebf594d6-0b1e-4dcc-6e90-08d8dcc0ed15 X-MS-TrafficTypeDiagnostic: DM5PR12MB2342: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2331; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Li717G/Tm4m3FtOzEIdpTz2pcxSFlKcIJRw3n1h2FODb1BmlmRCh+KStrHxFwDRDzJhTkIDjgn5BSpzluega2VJNh7kcVVsv3IyaTeqylTQqZ322DOLCqKOCR5RvnaT3w7mrlNelCUceiSKM4JwD6RhMIAQm771M281dcWCTlPE8C/QW/lL1LCMt/T9xO7A+zwrohk0AAqsL0TyzX+aOckdUDAvE8vFFcaH9XD5/Y6kZnkWBj0co+fbA8VphnoH8cCaW/7uw7tea7nzEAI6QpU8dGovWJnmaSrQ+MFYBp9LT9yUACnfiMewSG6In4cnM0NAg2yfczMcOdDdArzDVfbIRxtiBOgrvHcDnjbf/IeemaOu62hcuGKEvgZCMebNpYQauNuQUByD4anWwcQoCfe0BgaqOJI6+1CutQjO3EwPb5RzboVqDR+pVZ6jk/MiuKF0BrgCfK9dsDv9j8nVtVoMsy0fIGFMoRL1Pzq4+Lvus/KknqjFxMG/G1eI607LCIEWSqgTlUQXFs22EX9F/csZnptkY2GXY+kiIaFUgj4H8cUSMV3hXn/DBvqERUEgPi+mcrmVaaJ1Do5B0dFuwbA== 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)(4326008)(478600001)(66556008)(2906002)(66946007)(69590400012)(316002)(52116002)(6666004)(6916009)(2616005)(86362001)(16526019)(6512007)(36756003)(8676002)(8936002)(6506007)(30864003)(5660300002)(186003)(1076003)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?BriZt1xuqNHHCA3XENeyUURyQ30UsBhfDL08jPfWefsoF2Z9pDUEhklmpuU4?= =?us-ascii?Q?SbCde/w8DvmuWnquxa3DCbra2H7Rr4ImKvT0b7jFcZXmt37vW65/DpSEaFIW?= =?us-ascii?Q?i7zs4AxOMMGMac/DWzOucgcn0HGLcPe50EE8gSNtFLaUTWPlWjGHeNz1pVZv?= =?us-ascii?Q?BtNJWlJF5i1L5pL9O8iqbOVofmEPC4HhjfUWV6pp26s8sG+SqDsYvUZzTxOt?= =?us-ascii?Q?PveuW0hUTKpm5IpDH57g6Bp0Xf1XZYopbnzTIwo6GJVvFa5QkUwShMwpK8zi?= =?us-ascii?Q?cyLQRaaI5TiMGhUCBLko+Pks1+x7+bI2vT69N7GS4xwt1AjEFQkUZB0tQYTM?= =?us-ascii?Q?vlkM76sL0GZQkBFvMDqv0frohdffPfYG8jrFn0ZprNBArniU2Qze9VKndmrK?= =?us-ascii?Q?I58o6ebvBjHzRdyVzt3mwaBA8uNZWRtkCnYpc9MYvgygAps4kdAaFU3nrejt?= =?us-ascii?Q?i6QbF4t2OO4r7VsgFROxJ35OYBl1AqF5jJ50tYv1HgSvvdhCLhANZHo9Xgn+?= =?us-ascii?Q?xshLU9EtBN2q0QKZEkSYFfLDRgeioJJ04j2qy8nDo+1naxbgvhRetUgP6OtW?= =?us-ascii?Q?MRwA8mGA2SEmFfS4VtsM+fkSSVu8EcNs/0q9Fo7WTyW0v6QKjPMLghR76JfH?= =?us-ascii?Q?hyHs+iDITTWvEHteus7Jb2G37xZGD7fM2IV/y7YbMB+aYwVi8aF89R1zj3p9?= =?us-ascii?Q?GCmk9Ce8oOtfHY6WE3ZjPQzdoJbvRbVpEUI3+E1RuqrTW2GSmL2rsuGu1oLh?= =?us-ascii?Q?lN0KpGgEAcVTYJKMD53YgNdI5lNRZQau9hSidJ9ygyBfgeBZnOT4zzeuwqnX?= =?us-ascii?Q?rxXi4OcQ5to4M2ND8jqwU/nE84ORowN6MASJg323NNG7KP1kxf6+DTHOpG6x?= =?us-ascii?Q?lf6DioRjh6ov3O8VP3lsRNQy3ONv1L1ol8Mydt24D2VXZvd5XoEeIGUaSumR?= =?us-ascii?Q?lGs3Wy40iWghoSZZt/y24YO/o6e0f/e5R/lcm2RT4ZstBabHUULEBVyYJwCa?= =?us-ascii?Q?xfOHsnAXa5hUjPT1MQuNi3mvXSdB9R4gqqyfSNNPXP0iMPQj6iA9WD7jtJqN?= =?us-ascii?Q?z8+tmbCIk/3K8qtE8GcZI2UYoBBF1KiyY0fBirrJApcdysFbzJNf5eeNTVJb?= =?us-ascii?Q?n6B4YokzupnsC81VquY4dfl11bx/nPzMiDMevGqiGZEYxOXucSONgas+jzP3?= =?us-ascii?Q?T0ZmQKpLi4bxROsRTdXcEHEM7jatG4mPrlH5L8hCUuBN+4PJJVOWDTzDes7Y?= =?us-ascii?Q?dqw9HmiWfgUQFmVNrgf24LkejMbU1JsVNNnzteRYOwnfs/pWp6KdriuGf6ZM?= =?us-ascii?Q?0ZFuk8e3TXc4/SGxNV+/ZsTGuucumFCMeUQ79IUYDNWaRTQ7iDeL7f6UxTjI?= =?us-ascii?Q?a7h1W4b256RyVjoyhZuZ6ve/G4s5?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ebf594d6-0b1e-4dcc-6e90-08d8dcc0ed15 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:24.6339 (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: U+Ud3mKP8OFj0FiKMOV6b/A06U/5egxp/BJywUitwG08LJNyW+nFfPMkaX4E/6+5vyUKPm2TPLmGs0UcLgHtJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB2342 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: , From: Zoran Zaric via Gdb-patches Reply-To: Zoran Zaric Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" With the new design of the DWARF expression evaluator, it is now possible to again use the evaluator for the symbol needs check. This should address the concerns mentioned in the first patch of this series. gdb/ChangeLog: * dwarf2/loc.c (dwarf2_get_symbol_read_needs): Remove function. (dwarf2_loc_desc_get_symbol_read_needs): New function. (locexpr_get_symbol_read_needs): Change to use dwarf2_loc_desc_get_symbol_read_needs function. --- gdb/dwarf2/loc.c | 415 ++--------------------------------------------- 1 file changed, 18 insertions(+), 397 deletions(-) diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 7dfe28c3e46..3ea5d67d517 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1735,403 +1735,28 @@ dwarf2_compile_property_to_c (string_file *stream, expression in EXPR. */ static enum symbol_needs_kind -dwarf2_get_symbol_read_needs (gdb::array_view expr, - dwarf2_per_cu_data *per_cu, - dwarf2_per_objfile *per_objfile, - bfd_endian byte_order, - int addr_size, - int ref_addr_size, - int depth = 0) +dwarf2_loc_desc_get_symbol_read_needs (gdb::array_view expr, + dwarf2_per_cu_data *per_cu, + dwarf2_per_objfile *per_objfile, + struct type *type) { - const gdb_byte *expr_end = expr.data () + expr.size (); - const gdb_byte *op_ptr = expr.data (); - enum symbol_needs_kind symbol_needs = SYMBOL_NEEDS_NONE; - const int max_depth = 256; - - if (depth > max_depth) - error (_("DWARF-2 expression error: Loop detected (%d)."), depth); - - depth++; + scoped_value_mark free_values; - while (op_ptr < expr_end) + try { - enum dwarf_location_atom op - = (enum dwarf_location_atom) *op_ptr++; - uint64_t uoffset; - int64_t offset; - - /* The DWARF expression might have a bug causing an infinite - loop. In that case, quitting is the only way out. */ - QUIT; - - switch (op) - { - case DW_OP_lit0: - case DW_OP_lit1: - case DW_OP_lit2: - case DW_OP_lit3: - case DW_OP_lit4: - case DW_OP_lit5: - case DW_OP_lit6: - case DW_OP_lit7: - case DW_OP_lit8: - case DW_OP_lit9: - case DW_OP_lit10: - case DW_OP_lit11: - case DW_OP_lit12: - case DW_OP_lit13: - case DW_OP_lit14: - case DW_OP_lit15: - case DW_OP_lit16: - case DW_OP_lit17: - case DW_OP_lit18: - case DW_OP_lit19: - case DW_OP_lit20: - case DW_OP_lit21: - case DW_OP_lit22: - case DW_OP_lit23: - case DW_OP_lit24: - case DW_OP_lit25: - case DW_OP_lit26: - case DW_OP_lit27: - case DW_OP_lit28: - case DW_OP_lit29: - case DW_OP_lit30: - case DW_OP_lit31: - case DW_OP_stack_value: - case DW_OP_dup: - case DW_OP_drop: - case DW_OP_swap: - case DW_OP_over: - case DW_OP_rot: - case DW_OP_deref: - case DW_OP_abs: - case DW_OP_neg: - case DW_OP_not: - case DW_OP_and: - case DW_OP_div: - case DW_OP_minus: - case DW_OP_mod: - case DW_OP_mul: - case DW_OP_or: - case DW_OP_plus: - case DW_OP_shl: - case DW_OP_shr: - case DW_OP_shra: - case DW_OP_xor: - case DW_OP_le: - case DW_OP_ge: - case DW_OP_eq: - case DW_OP_lt: - case DW_OP_gt: - case DW_OP_ne: - case DW_OP_GNU_push_tls_address: - case DW_OP_nop: - case DW_OP_GNU_uninit: - case DW_OP_push_object_address: - break; - - case DW_OP_form_tls_address: - if (symbol_needs <= SYMBOL_NEEDS_REGISTERS) - symbol_needs = SYMBOL_NEEDS_REGISTERS; - break; - - case DW_OP_convert: - case DW_OP_GNU_convert: - case DW_OP_reinterpret: - case DW_OP_GNU_reinterpret: - case DW_OP_addrx: - case DW_OP_GNU_addr_index: - case DW_OP_GNU_const_index: - case DW_OP_constu: - case DW_OP_plus_uconst: - case DW_OP_piece: - op_ptr = safe_read_uleb128 (op_ptr, expr_end, &uoffset); - break; - - case DW_OP_consts: - op_ptr = safe_read_sleb128 (op_ptr, expr_end, &offset); - break; - - case DW_OP_bit_piece: - op_ptr = safe_read_uleb128 (op_ptr, expr_end, &uoffset); - op_ptr = safe_read_uleb128 (op_ptr, expr_end, &uoffset); - break; - - case DW_OP_deref_type: - case DW_OP_GNU_deref_type: - op_ptr++; - op_ptr = safe_read_uleb128 (op_ptr, expr_end, &uoffset); - break; - - case DW_OP_addr: - op_ptr += addr_size; - break; - - case DW_OP_const1u: - case DW_OP_const1s: - op_ptr += 1; - break; - - case DW_OP_const2u: - case DW_OP_const2s: - op_ptr += 2; - break; - - case DW_OP_const4s: - case DW_OP_const4u: - op_ptr += 4; - break; - - case DW_OP_const8s: - case DW_OP_const8u: - op_ptr += 8; - break; - - case DW_OP_reg0: - case DW_OP_reg1: - case DW_OP_reg2: - case DW_OP_reg3: - case DW_OP_reg4: - case DW_OP_reg5: - case DW_OP_reg6: - case DW_OP_reg7: - case DW_OP_reg8: - case DW_OP_reg9: - case DW_OP_reg10: - case DW_OP_reg11: - case DW_OP_reg12: - case DW_OP_reg13: - case DW_OP_reg14: - case DW_OP_reg15: - case DW_OP_reg16: - case DW_OP_reg17: - case DW_OP_reg18: - case DW_OP_reg19: - case DW_OP_reg20: - case DW_OP_reg21: - case DW_OP_reg22: - case DW_OP_reg23: - case DW_OP_reg24: - case DW_OP_reg25: - case DW_OP_reg26: - case DW_OP_reg27: - case DW_OP_reg28: - case DW_OP_reg29: - case DW_OP_reg30: - case DW_OP_reg31: - case DW_OP_regx: - case DW_OP_breg0: - case DW_OP_breg1: - case DW_OP_breg2: - case DW_OP_breg3: - case DW_OP_breg4: - case DW_OP_breg5: - case DW_OP_breg6: - case DW_OP_breg7: - case DW_OP_breg8: - case DW_OP_breg9: - case DW_OP_breg10: - case DW_OP_breg11: - case DW_OP_breg12: - case DW_OP_breg13: - case DW_OP_breg14: - case DW_OP_breg15: - case DW_OP_breg16: - case DW_OP_breg17: - case DW_OP_breg18: - case DW_OP_breg19: - case DW_OP_breg20: - case DW_OP_breg21: - case DW_OP_breg22: - case DW_OP_breg23: - case DW_OP_breg24: - case DW_OP_breg25: - case DW_OP_breg26: - case DW_OP_breg27: - case DW_OP_breg28: - case DW_OP_breg29: - case DW_OP_breg30: - case DW_OP_breg31: - case DW_OP_bregx: - case DW_OP_fbreg: - case DW_OP_call_frame_cfa: - case DW_OP_entry_value: - case DW_OP_GNU_entry_value: - case DW_OP_GNU_parameter_ref: - case DW_OP_regval_type: - case DW_OP_GNU_regval_type: - symbol_needs = SYMBOL_NEEDS_FRAME; - break; - - case DW_OP_implicit_value: - op_ptr = safe_read_uleb128 (op_ptr, expr_end, &uoffset); - op_ptr += uoffset; - break; - - case DW_OP_implicit_pointer: - case DW_OP_GNU_implicit_pointer: - op_ptr += ref_addr_size; - op_ptr = safe_read_sleb128 (op_ptr, expr_end, &offset); - break; - - case DW_OP_deref_size: - case DW_OP_pick: - op_ptr++; - break; - - case DW_OP_skip: - op_ptr += 2; - break; - - case DW_OP_bra: - op_ptr += 2; - break; - - case DW_OP_call2: - { - cu_offset cu_off - = (cu_offset) extract_unsigned_integer (op_ptr, 2, byte_order); - op_ptr += 2; - - auto get_frame_pc = [&symbol_needs] () - { - symbol_needs = SYMBOL_NEEDS_FRAME; - return 0; - }; - - struct dwarf2_locexpr_baton baton - = dwarf2_fetch_die_loc_cu_off (cu_off, per_cu, - per_objfile, - get_frame_pc); - - /* If SYMBOL_NEEDS_FRAME is returned from the previous call, - we dont have to check the baton content. */ - if (symbol_needs != SYMBOL_NEEDS_FRAME) - { - gdbarch *arch = baton.per_objfile->objfile->arch (); - gdb::array_view sub_expr (baton.data, - baton.size); - symbol_needs - = dwarf2_get_symbol_read_needs (sub_expr, - baton.per_cu, - baton.per_objfile, - gdbarch_byte_order (arch), - baton.per_cu->addr_size (), - baton.per_cu->ref_addr_size (), - depth); - } - break; - } - - case DW_OP_call4: - { - cu_offset cu_off - = (cu_offset) extract_unsigned_integer (op_ptr, 4, byte_order); - op_ptr += 4; - - auto get_frame_pc = [&symbol_needs] () - { - symbol_needs = SYMBOL_NEEDS_FRAME; - return 0; - }; - - struct dwarf2_locexpr_baton baton - = dwarf2_fetch_die_loc_cu_off (cu_off, per_cu, - per_objfile, - get_frame_pc); - - /* If SYMBOL_NEEDS_FRAME is returned from the previous call, - we dont have to check the baton content. */ - if (symbol_needs != SYMBOL_NEEDS_FRAME) - { - gdbarch *arch = baton.per_objfile->objfile->arch (); - gdb::array_view sub_expr (baton.data, - baton.size); - symbol_needs - = dwarf2_get_symbol_read_needs (sub_expr, - baton.per_cu, - baton.per_objfile, - gdbarch_byte_order (arch), - baton.per_cu->addr_size (), - baton.per_cu->ref_addr_size (), - depth); - } - break; - } - - case DW_OP_GNU_variable_value: - { - sect_offset sect_off - = (sect_offset) extract_unsigned_integer (op_ptr, - ref_addr_size, - byte_order); - op_ptr += ref_addr_size; - - struct type *die_type - = dwarf2_fetch_die_type_sect_off (sect_off, per_cu, - per_objfile); - - if (die_type == NULL) - error (_("Bad DW_OP_GNU_variable_value DIE.")); - - /* Note: Things still work when the following test is - removed. This test and error is here to conform to the - proposed specification. */ - if (die_type->code () != TYPE_CODE_INT - && die_type->code () != TYPE_CODE_PTR) - error (_("Type of DW_OP_GNU_variable_value DIE must be " - "an integer or pointer.")); - - auto get_frame_pc = [&symbol_needs] () - { - symbol_needs = SYMBOL_NEEDS_FRAME; - return 0; - }; - - struct dwarf2_locexpr_baton baton - = dwarf2_fetch_die_loc_sect_off (sect_off, per_cu, - per_objfile, - get_frame_pc, true); - - /* If SYMBOL_NEEDS_FRAME is returned from the previous call, - we dont have to check the baton content. */ - if (symbol_needs != SYMBOL_NEEDS_FRAME) - { - gdbarch *arch = baton.per_objfile->objfile->arch (); - gdb::array_view sub_expr (baton.data, - baton.size); - symbol_needs - = dwarf2_get_symbol_read_needs (sub_expr, - baton.per_cu, - baton.per_objfile, - gdbarch_byte_order (arch), - baton.per_cu->addr_size (), - baton.per_cu->ref_addr_size (), - depth); - } - break; - } - - case DW_OP_const_type: - case DW_OP_GNU_const_type: - op_ptr = safe_read_uleb128 (op_ptr, expr_end, &uoffset); - offset = *op_ptr++; - op_ptr += offset; - break; - - default: - error (_("Unhandled DWARF expression opcode 0x%x"), op); - } - /* If it is known that a frame information is - needed we can stop parsing the expression. */ - if (symbol_needs == SYMBOL_NEEDS_FRAME) - break; + dwarf2_evaluate (expr.data (), expr.size (), true, per_objfile, per_cu, + nullptr, per_cu->addr_size (), nullptr, nullptr, type); + } + catch (const gdb_exception_error &ex) + { + if (ex.error == NOT_AVAILABLE_ERROR) + return SYMBOL_NEEDS_FRAME; } - return symbol_needs; + return SYMBOL_NEEDS_NONE; } + /* A helper function that throws an unimplemented error mentioning a given DWARF operator. */ @@ -2971,15 +2596,11 @@ locexpr_get_symbol_read_needs (struct symbol *symbol) struct dwarf2_locexpr_baton *dlbaton = (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (symbol); - gdbarch *arch = dlbaton->per_objfile->objfile->arch (); gdb::array_view expr (dlbaton->data, dlbaton->size); - return dwarf2_get_symbol_read_needs (expr, - dlbaton->per_cu, - dlbaton->per_objfile, - gdbarch_byte_order (arch), - dlbaton->per_cu->addr_size (), - dlbaton->per_cu->ref_addr_size ()); + return dwarf2_loc_desc_get_symbol_read_needs (expr, dlbaton->per_cu, + dlbaton->per_objfile, + SYMBOL_TYPE (symbol)); } /* Return true if DATA points to the end of a piece. END is one past -- 2.17.1