From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2075.outbound.protection.outlook.com [40.107.94.75]) by sourceware.org (Postfix) with ESMTPS id 056B8388C00D for ; Fri, 28 May 2021 15:47:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 056B8388C00D ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fg0Yb+WKdN04Y3WAB0vFm0SRy5k0x6m3YyQKuz1DRN/HXd9xc5A3WzKZUX/f45KcLqvoZHyLWNTyJC7L4dQRcqvbWO08zlqbu3A5q9XkaYHAEbpASTMszLKGWbw9MBYrrQOH3Lsid1Cxpk0j1uDZCjTwK+q4b6Qhmg549T//SkJm/2+cCulg6Jad7W583AKqlq7ERio65snyH+HtVdlGdvxGlLjdBq6CvmuCiOtxK5RWECkJYGYJjyiWC5C5V5A0WuTDsxfy9/4lF7DJVJkeD7IYREhmYmXrWDh8sGfuFCVVqrs3ZpZzqdjkZ182cDOQVKIyeaSbLedp+klha6tvPw== 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=UvzORmfVh32X97PLUqqglh3TjpAj0cIrU5Yi54GUZhs=; b=HgyukSs21SFyNqp0hUKBV4ri3PXK8vBdkdHgUHlPzU6ukewk+9ihpMXpQ7+6rHerZZaI0yLESdNXymIYJXLJ2iqlz9/82isavoQ9F78vud8gQ7z7/kwqvJ55CeS/1YNx6vz6hFAyzNkOqp3NCvlFnshTzRNWrWo7m1F436kjVHWj+xSPqynhaqGUNn2bRLe3hoyETl950OAxGoHTQiwedAAz14aqsQgbDSYU9TKSV3DRK1NMj6ln7ePrzzVBBxCTGl6fc1s2gLogfj7pjmlbmIYXuijGFg+0ftJJPqvX0ci/ds517mnopkA3oDSTGgsZbYXRezkeeyrXaDWVDrtx/g== 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=none sp=none pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none Received: from DM5PR13CA0018.namprd13.prod.outlook.com (2603:10b6:3:23::28) by DM5PR1201MB0172.namprd12.prod.outlook.com (2603:10b6:4:51::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.22; Fri, 28 May 2021 15:47:10 +0000 Received: from DM6NAM11FT006.eop-nam11.prod.protection.outlook.com (2603:10b6:3:23:cafe::6a) by DM5PR13CA0018.outlook.office365.com (2603:10b6:3:23::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4195.9 via Frontend Transport; Fri, 28 May 2021 15:47:10 +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 DM6NAM11FT006.mail.protection.outlook.com (10.13.173.104) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4150.30 via Frontend Transport; Fri, 28 May 2021 15:47:09 +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.2242.4; Fri, 28 May 2021 10:47:08 -0500 From: Zoran Zaric To: Subject: [PATCH v3 06/17] Move dwarf_call to dwarf_expr_context Date: Fri, 28 May 2021 16:46:37 +0100 Message-ID: <20210528154648.60881-7-zoran.zaric@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210528154648.60881-1-zoran.zaric@amd.com> References: <20210528154648.60881-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: 81e61fa2-5dd6-4b47-ab48-08d921efdac2 X-MS-TrafficTypeDiagnostic: DM5PR1201MB0172: 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: GnlHE6Mz3U5rSCamD53qbefBNC3EOdlLPRKlbZWzN+nOZYbQEexb3CGrXCm/anLUplNi3Ax3/QRryCRlHuikiXLl2O7/hrUk2KXUUQf1mxgsCgX0C/OEQ7R7f+c3yVKpo26fwWjVqgeJAes8ZtVonWKQOARgPSIetP0Z/r78SzTL66TqxT5rWX413Cim06JXGiFiQE15z3KYZgg216ivFDcDQm7ajaMzXbi0cmwUk4KTUJAYxxDREST76++BgfoA52u2ybMNVe26ZBDT0BawEg8kCJHvkZ4aCVLdL4yYEF7EdT6ERyeqRHPXjQB970PO5/+hMRbWzUYZ9iQvfd/+9yqQP6/H+OeNA4Gr/reo0c1nZ7cSneraO1f6KSwtWKTYrOGrJ4DIz5xm4PdDWQk0d0gToFg0820cSC+7CxSlpvQnggDyfl5Gz2ML1C1ssIlKm4ohbGfLGqJ9aQhseLQw/Ayp9Z50PimZrQbg1DUhK2hQTRGJPEtuD6bWGf7/sMUe7bJbr3+0+hlq4k+VriWh8hGlrr5ugXmuRLno5C4Kpx6NFz0/BhwyYfEesMFMgxneVbUL+ZB8txgtBrYz/KpQkkyPgdkLblHdiSH8E5Zwycl0KaaoP3QflzIGbJeSkqahvJJFaLGAGExBk+T6hbMTT5QPxGChOp72dVm+oCvZlKbo5pdTSB1XR55ijm6JFyV1 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)(136003)(376002)(346002)(39850400004)(396003)(46966006)(36840700001)(2616005)(8676002)(8936002)(44832011)(316002)(4326008)(1076003)(82310400003)(70206006)(70586007)(5660300002)(47076005)(16526019)(83380400001)(356005)(6916009)(2906002)(36860700001)(478600001)(26005)(186003)(86362001)(81166007)(82740400003)(426003)(336012)(6666004)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2021 15:47:09.9667 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 81e61fa2-5dd6-4b47-ab48-08d921efdac2 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: DM6NAM11FT006.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0172 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: Fri, 28 May 2021 15:47:14 -0000 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 d70f92f27bc..689224b63a3 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -232,6 +232,31 @@ dwarf_expr_context::get_base_type (cu_offset die_cu_off) return result; } +/* See expr.h. */ + +void +dwarf_expr_context::dwarf_call (cu_offset die_cu_off) +{ + ensure_have_per_cu (this->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, this->per_cu, this->per_objfile, + get_pc_from_frame); + + /* DW_OP_call_ref is currently not supported. */ + gdb_assert (block.per_cu == this->per_cu); + + this->eval (block.data, block.size); +} + /* Require that TYPE be an integral type; throw an exception if not. */ static void @@ -1277,7 +1302,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 f14070de522..6b51f2eaae5 100644 --- a/gdb/dwarf2/expr.h +++ b/gdb/dwarf2/expr.h @@ -191,22 +191,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 @@ -242,6 +226,12 @@ struct dwarf_expr_context This can throw an exception if the DIE is invalid or does not represent a base type. */ struct type *get_base_type (cu_offset die_cu_off); + + /* 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 492c1ec9d7c..20da0f45e84 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -249,16 +249,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 f5bd5c57c61..d88239880af 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