From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id mD8pO/J7zl9ETQAAWB0awg (envelope-from ) for ; Mon, 07 Dec 2020 14:01:06 -0500 Received: by simark.ca (Postfix, from userid 112) id EAAB91F071; Mon, 7 Dec 2020 14:01:06 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,RDNS_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [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 896791EF4B for ; Mon, 7 Dec 2020 14:01:06 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2852A3950C6E; Mon, 7 Dec 2020 19:01:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2852A3950C6E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1607367666; bh=jmonx9eccYL0lmA7LyBtzbZFPh5X3F4c1tyFz/lVo4k=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=A8Izgfdtohbi5nKLrDVXekzVlgTueqQA/1sXSI4wtBT3tvOkR3n3hOaJVsw5K+D1F WNFF+jCigQZIKwO1DRcYDsHk5cM+3TnDuyTfKVhunTXcgll++4CqxYtypCBja9hp2i jh34YnXQlBW0zHqTK9S8TkHNNzUneSHS4APFWhgU= Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2049.outbound.protection.outlook.com [40.107.244.49]) by sourceware.org (Postfix) with ESMTPS id 9D3DC3951438 for ; Mon, 7 Dec 2020 19:01:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9D3DC3951438 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LTQa0fUEFeHcQQk0WgWqHgCTHvM28r4W0qUBMOnLWUgRICWwxsb3jGLfh1hkyAeTe83FrBO9HIqp5ZPvZ73ZWmMkEpP4fSZ5Gsak2bDiQR7745RomwgwV31x6KX6X8qsdkoJWH+yQdGNWEyYua9Hn4TwJfMLEoMOhiUEukEyv6dEh9tiI6XRkfCj6WFiFhdDJzYMLL2+GoX5XOTHmw0INa5Y8NTx+N0paeiF9RUUEboco7+39CrfwHnsZ5TI2KrCISW9AkzOpSqjvHlUZq+oir2qieOysbijrCXCOoh5cT7+hFjwxQmYRkwjWwPZ/+QY3p4jXGi+OqQP5hHLn4Rq7g== 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=jmonx9eccYL0lmA7LyBtzbZFPh5X3F4c1tyFz/lVo4k=; b=Vndb9dQM3NA6SDnSE25LhOwmV+M0I7bqdL7rqZ7uE9iivKxxzvDySGli3w8LosI+w5CowImiR0laYYhyS2Ir7E8DxPD0UZDz5GC6wWvnyXwjZeiXYWivHTd6WGCLc4+CJdxw5GfA3fPZ68ppF8D2wRhxa180vxzmYP2UfSUeEZgVWPz9f+4qosEvFDzbTHFyOi7TcbwMt/xK5dkxk62WUoq6XgX7+RTk7Vsu1+cJANAEulFvuCef4WTpVhaPYflHd028cAzkGzEpdGh79n48RHfDSGkK6bj1+KTMfxzQVz3Mrkfu7zAo3SIpPfwm9aJoc6BSF7Sd8plO/OAhx7L1Hw== 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 DM6PR12MB4561.namprd12.prod.outlook.com (2603:10b6:5:2ac::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.18; Mon, 7 Dec 2020 19:00:57 +0000 Received: from DM6PR12MB2762.namprd12.prod.outlook.com ([fe80::6841:61df:984b:b3c]) by DM6PR12MB2762.namprd12.prod.outlook.com ([fe80::6841:61df:984b:b3c%3]) with mapi id 15.20.3632.021; Mon, 7 Dec 2020 19:00:57 +0000 To: gdb-patches@sourceware.org Subject: [PATCH 05/30] Move dwarf_call to dwarf_expr_context Date: Mon, 7 Dec 2020 19:00:06 +0000 Message-Id: <20201207190031.13341-6-Zoran.Zaric@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201207190031.13341-1-Zoran.Zaric@amd.com> References: <20201207190031.13341-1-Zoran.Zaric@amd.com> Content-Type: text/plain X-Originating-IP: [2a00:23c7:5a85:6801:5c7:2db6:d2c2:ae4e] X-ClientProxiedBy: AM4PR0101CA0053.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::21) 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:5c7:2db6:d2c2:ae4e) by AM4PR0101CA0053.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3632.17 via Frontend Transport; Mon, 7 Dec 2020 19:00:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 0a0b1548-6739-4878-5d42-08d89ae26e1f X-MS-TrafficTypeDiagnostic: DM6PR12MB4561: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UA5XO0/XZ0iPj8KiYocI4t5oiWXsPNv5Hq491vwQz+Gk+9mggtUIXzPMp0O7+L3zXnkjq8q/3BxRMoBvKk2Qcmmb/T6+5DYm2NUejIPCHMWrcKLYDeRcIvyzprOHw60DFTuJ/vzHaBrPG691nx1YA98+vTWDk9DDh3j+xBSOJCHWa2dcMQ5UxcdBrMk8+JTLPR4DMbbFZSLuro6tzkm6/fri7YnB57Jo6RfrQyWwyTYKUpfQS8rrkVgQFs2f92A+zYO77MUYvrHubwhKxsmDoPMLcv0rmoe/x7U1aJTo/FI62dBHKngcSe8yNwRCkKMoeRerXFRf/F2uuBEXpKG2W3Z6m6dChF+NFBT6G74djFdIbVit4n5YDjiChisJIRbd 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)(376002)(346002)(39860400002)(366004)(136003)(396003)(1076003)(83380400001)(86362001)(6506007)(4326008)(69590400008)(52116002)(36756003)(2906002)(6512007)(8676002)(6486002)(16526019)(2616005)(66946007)(66476007)(66556008)(6916009)(5660300002)(186003)(8936002)(478600001)(6666004)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?cyyy4XLBtMsv2HYZGUq+/c1vT3kIxA6nGUxPjkAz4bIJXLnmO2W3jUJW1yjC?= =?us-ascii?Q?rEZMPf9A56XvqRZ6s6aiQLct4Q4t6DQXDb3G5te72vN0yqd9JMeZ32SObVYt?= =?us-ascii?Q?Iq1jiMWAhclf0DDcaoptX2aS0Dd5/JRM+lmjs33KCEacJlT2D9e4w1APg5RF?= =?us-ascii?Q?TaFTiJms293QE4avfBYzILOO/ZP/yGV1mfvdYM64Nxy3blMdK70cHuz37rOO?= =?us-ascii?Q?C1kkrIozrDw4tk9Mo98U2FFgQG6LB2fhhl7FEtOTP697vodI9TIsXB909+EN?= =?us-ascii?Q?tImdvRK4OotGaMTKCm0nDH8GWcHBkHUpP9zgDGKtrNpTYbdHot1plVRqAwvl?= =?us-ascii?Q?bV/i7eXbDj25269Df7QaMuDbdehyh/+TUYuwNzdbnAV9PqsJRGPvlZsO/SDv?= =?us-ascii?Q?2LeWjCrlO0VVI10CsgBJKb/JZDZvumQtLmLj8ucgs9JRbukq7cOF32djqXaW?= =?us-ascii?Q?3NhOGj0TikeBxX7FuQufeWMr8oRzpeUiNVxP9cZqcxL/gk8zi8qTx7Qc9n41?= =?us-ascii?Q?f/oEbVLZgEEwYJ633NigtSiOsax5eaBEs7vxduTDiqPY/q/ytljmQbLe1dQy?= =?us-ascii?Q?L1czxwHrtfyujzyuEKxCSpQkABzenkDvXfq+TiHFfSi71D7ongJJnDSWMk0p?= =?us-ascii?Q?1IQRubkO6qxHOarZePAcxPAWMFlppdGHFiTXYkweCFy6txYCCoHDTtzNkDo5?= =?us-ascii?Q?9n0NKl7UnV30vcALE83+yPivLyTpVKE2HhFH1VFEqu2lCupZTo8598nZOaN9?= =?us-ascii?Q?OuZHXhBqbWh0Kjeu7bYNTXlnLrXTUgMH+7XVhUxvkadTQT4SLkhmGrBD9Vlu?= =?us-ascii?Q?Y13gWEpxZWn48nA54K8BLC9mxfrY+UCgqgHqELbeUS/4YzrwdrGv1wrRzXmK?= =?us-ascii?Q?JekiUDkQofbr9nOLdn8Epa3pn5mWhZFSRxfCmoYtbB0x4enbltP9vUiCXUlI?= =?us-ascii?Q?kyEoPVslaGtuawpz8mXvPLoHy8Z2kD0qOWEkKAc6qEWzFI7TAK1Y5dxMckKS?= =?us-ascii?Q?3XAhPUk1sg1LpvBgBOlGyQ5gTqxWjRWleediFAkCt/W45YX5OtfrMKKHehCW?= =?us-ascii?Q?h8yoZZ4c?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB2762.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2020 19:00:57.1282 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-Network-Message-Id: 0a0b1548-6739-4878-5d42-08d89ae26e1f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: h/o+jfzmjUfhJ+AKV5QwGMHjwLCO+FuAZKSdTxWpuHwmFJAdvp/LjNVw1zUoRQsKduVG69i2+gWeSHdHdSxcyg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4561 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 Cc: Zoran Zaric Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" From: Zoran Zaric Following the idea of merging the evaluators, the dwarf_call and get_frame_pc method can be moved from dwarf_expr_executor and dwarf_evaluate_loc_desc classes to their base class dwarf_expr_context. Once this is done, the get_frame_pc can be replace with lambda function. gdb/ChangeLog: * dwarf2/expr.c (dwarf_expr_context::dwarf_call): Move from dwarf_evaluate_loc_desc. (dwarf_expr_context::get_frame_pc): Replace with lambda. * dwarf2/expr.h (dwarf_expr_context::get_frame_pc): Remove method. * dwarf2/frame.c (dwarf_expr_executor::dwarf_call): Remove method. (dwarf_expr_executor::get_frame_pc): Remove method. * dwarf2/loc.c (dwarf_evaluate_loc_desc::get_frame_pc): Remove method. (dwarf_evaluate_loc_desc::dwarf_call): Move to dwarf_expr_context. (per_cu_dwarf_call): Inline function. --- gdb/dwarf2/expr.c | 28 +++++++++++++++++++++++++++- gdb/dwarf2/expr.h | 22 ++++++---------------- gdb/dwarf2/frame.c | 10 ---------- gdb/dwarf2/loc.c | 43 ------------------------------------------- 4 files changed, 33 insertions(+), 70 deletions(-) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 29f5f977ac..a5144b692d 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -237,6 +237,31 @@ dwarf_expr_context::get_base_type (cu_offset die_cu_off, int size) return result; } +/* See expr.h. */ + +void +dwarf_expr_context::dwarf_call (cu_offset die_cu_off) +{ + ensure_have_per_cu (per_cu, "DW_OP_call"); + + struct frame_info *frame = this->frame; + + auto get_pc_from_frame = [frame] () + { + ensure_have_frame (frame, "DW_OP_call"); + return get_frame_address_in_block (frame); + }; + + struct dwarf2_locexpr_baton block + = dwarf2_fetch_die_loc_cu_off (die_cu_off, per_cu, per_objfile, + get_pc_from_frame); + + /* DW_OP_call_ref is currently not supported. */ + gdb_assert (block.per_cu == per_cu); + + this->eval (block.data, block.size); +} + /* Require that TYPE be an integral type; throw an exception if not. */ static void @@ -1279,7 +1304,8 @@ dwarf_expr_context::execute_stack_op (const gdb_byte *op_ptr, returned. */ result = value_as_long (fetch (0)); pop (); - result = this->get_tls_address (result); + result = target_translate_tls_address (this->per_objfile->objfile, + result); result_val = value_from_ulongest (address_type, result); break; diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h index e17cd99c25..eb765a28a2 100644 --- a/gdb/dwarf2/expr.h +++ b/gdb/dwarf2/expr.h @@ -195,22 +195,6 @@ struct dwarf_expr_context /* Read LENGTH bytes at ADDR into BUF. */ virtual void read_mem (gdb_byte *buf, CORE_ADDR addr, size_t length) = 0; - /* Return the PC for the frame. */ - virtual CORE_ADDR get_frame_pc () - { - error (_("%s is invalid in this context"), "DW_OP_implicit_pointer"); - } - - /* Return the thread-local storage address for - DW_OP_GNU_push_tls_address or DW_OP_form_tls_address. */ - virtual CORE_ADDR get_tls_address (CORE_ADDR offset) = 0; - - /* Execute DW_AT_location expression for the DWARF expression - subroutine in the DIE at DIE_CU_OFF in the CU. Do not touch - STACK while it being passed to and returned from the called DWARF - subroutine. */ - virtual void dwarf_call (cu_offset die_cu_off) = 0; - /* Push on DWARF stack an entry evaluated for DW_TAG_call_site's parameter matching KIND and KIND_U at the caller of specified BATON. If DEREF_SIZE is not -1 then use DW_AT_call_data_value instead of @@ -247,6 +231,12 @@ struct dwarf_expr_context represent a base type. SIZE is non-zero if this function should verify that the resulting type has the correct size. */ struct type *get_base_type (cu_offset die_cu_off, int size); + + /* Execute DW_AT_location expression for the DWARF expression + subroutine in the DIE at DIE_CU_OFF in the CU. Do not touch + STACK while it being passed to and returned from the called DWARF + subroutine. */ + void dwarf_call (cu_offset die_cu_off); }; /* Return the value of register number REG (a DWARF register number), diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index c93ec5d5a6..af5302bd98 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -248,16 +248,6 @@ class dwarf_expr_executor : public dwarf_expr_context invalid ("DW_OP_push_object_address"); } - CORE_ADDR get_tls_address (CORE_ADDR offset) override - { - invalid ("DW_OP_form_tls_address"); - } - - void dwarf_call (cu_offset die_offset) override - { - invalid ("DW_OP_call*"); - } - private: void invalid (const char *op) ATTRIBUTE_NORETURN diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 21e43e399c..5a2b1b2851 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -600,26 +600,6 @@ func_get_frame_base_dwarf_block (struct symbol *framefunc, CORE_ADDR pc, framefunc->natural_name ()); } -static void -per_cu_dwarf_call (struct dwarf_expr_context *ctx, cu_offset die_offset, - dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile) -{ - struct dwarf2_locexpr_baton block; - - auto get_frame_pc_from_ctx = [ctx] () - { - return ctx->get_frame_pc (); - }; - - block = dwarf2_fetch_die_loc_cu_off (die_offset, per_cu, per_objfile, - get_frame_pc_from_ctx); - - /* DW_OP_call_ref is currently not supported. */ - gdb_assert (block.per_cu == per_cu); - - ctx->eval (block.data, block.size); -} - /* See loc.h. */ struct value * @@ -654,29 +634,6 @@ class dwarf_evaluate_loc_desc : public dwarf_expr_context CORE_ADDR obj_address; - /* Helper function for dwarf2_evaluate_loc_desc. Computes the PC for - the frame in BATON. */ - - CORE_ADDR get_frame_pc () override - { - return get_frame_address_in_block (frame); - } - - /* Using the objfile specified in BATON, find the address for the - current thread's thread-local storage with offset OFFSET. */ - CORE_ADDR get_tls_address (CORE_ADDR offset) override - { - return target_translate_tls_address (per_objfile->objfile, offset); - } - - /* Helper interface of per_cu_dwarf_call for - dwarf2_evaluate_loc_desc. */ - - void dwarf_call (cu_offset die_offset) override - { - per_cu_dwarf_call (this, die_offset, per_cu, per_objfile); - } - /* Callback function for get_object_address. Return the address of the VLA object. */ -- 2.17.1