From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2045.outbound.protection.outlook.com [40.107.92.45]) by sourceware.org (Postfix) with ESMTPS id 19D573857C44 for ; Thu, 14 Oct 2021 09:33:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 19D573857C44 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MlrCFBkteC6Ts1QW679LwuM3QWBEj+GPuZaskf0pOLspbbj+sK0is9n0UQPNGAdXTZRO+Jod61fpBiVGgzkKkuzYKpKdEPbcEqjkIIQ8rno546rkqkBTFi5iCGJK+prIdCvGd5C6PVdmRp1nTu1CnPJ8yIWBz3ytNq+i6SwJvaF0EqmNvQPdvy60jwla6TZpKDeSW/bFNIvU/NBOx/JrFuCaNRYzkXXWnprt6qXhKM5vdobkqWVjt1kzpQpKeJIvVE80wZwbnxjm0ZqbWYR3jMimXlZM4m+hsuRgm67rCzagyqdWK8K7rV/Ofn6Pu08uvb2BjGmKk4+1QrWNRp2x2Q== 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=LCUHQZnIKNS6AkIJfQ8rY5lGnfvkaRmtrngeOqXD8Ac=; b=TmXJt9dWVk5DpcwqmsSDpWbOZDHadVhllUxJY0JxA9tmTZNi1eGWCl80JTi9pawAr63F5q1939TqijiUSXyqjJss+RscGIihPCylitQL3Jasj9jrPZFw0AjDD9dO0kpnRwfa0p/KWpirkB940AlwMPext4PpGWFZPt0hwP6GEEnpPJH3CvkkV5hQLpylPORub57WCgqleSQ5x8ZgdwE+wFBqA4BscA6/imijJh1UobOm6n0/Q3LEh9p6y/DP/SwmwPlDrrqkxEwzgcpe1GbkgtgeYf6Pj3S0RNr/NR7prOKfl8y2XnmgVkG88yuSlD5+RWmhqNadXqc0qgKLB9F6Lg== 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 DM5PR13CA0032.namprd13.prod.outlook.com (2603:10b6:3:7b::18) by BYAPR12MB3046.namprd12.prod.outlook.com (2603:10b6:a03:aa::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.22; Thu, 14 Oct 2021 09:33:09 +0000 Received: from DM6NAM11FT047.eop-nam11.prod.protection.outlook.com (2603:10b6:3:7b:cafe::c6) by DM5PR13CA0032.outlook.office365.com (2603:10b6:3:7b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.8 via Frontend Transport; Thu, 14 Oct 2021 09:33:09 +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 DM6NAM11FT047.mail.protection.outlook.com (10.13.172.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4608.15 via Frontend Transport; Thu, 14 Oct 2021 09:33:08 +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.8; Thu, 14 Oct 2021 04:33:05 -0500 From: Zoran Zaric To: Subject: [PATCH v3 11/28] Add is_implicit_ptr_at method to dwarf_location Date: Thu, 14 Oct 2021 10:32:18 +0100 Message-ID: <20211014093235.69756-12-zoran.zaric@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211014093235.69756-1-zoran.zaric@amd.com> References: <20211014093235.69756-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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4c39bfc0-eb3a-42a6-d5f7-08d98ef5a22d X-MS-TrafficTypeDiagnostic: BYAPR12MB3046: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 09uyf/8ImRkui1rM9LqUZBfHbU2ea4Da8d1DLWJ/RZa7M8QSGb/uKHyUYKc7h4ofW6XEG4OZFlQ72I1VbII6Xv5WmxR095v4q271E5gBvoawXXvjZI2Z1M7dXGdcAiTw26sXr8bhXAlVrpti8boJhFLSn+GysY8J5oiJ3+tzx89y8Kq7j5AzLtoKmqmIJivXUabTqLe21RQCpWqln20gqXyu45JnAK5+YEISZHF9QSWmfbFct3nbgGUQKHq+ybctI+uxssFjofGmI2WLGkV7heVU+n9e3h2opjLinmH5NDvOl4KrwcA5yKfnp6oQxwf48ee66Ir9OCKkfTUcdGfBGhG5QV+FZB4YNhpLqNUCytdxhMu3gA0wzDwBrtROq4Xx61SHtGh9tdybSMOqpUe8/cWdM6wgKgfrdHTeAQYllCZeOOJh2wJNC3Hvx4n1Rx9/6xjugoVLykXOlWWJBrseoyblZYC/Spopo+agumPK4s+QIDp2G34WCbkH1fEXC+GczlEB5yIX+n9qRwrCH3jWrbJ1w+8tCAda9kK6GsY2zYHXrGbGxisu2wMcTEdl4S+ZssJdGaPZy9fcHVGCx4zUIhUQNcmvXep3IH5OPWGWFvB/AYS/iolyXuVcq+39+jxb9ZXqdNSGg/L7eHUu3Y9AIvpMrnKp1yXZPqjhn8rCsrVw64r6MgngqZnWn9VXF8WtOiNjGHOk33LrjV1//umJyFQKkEKbVvjP5E03BTmjQxY= 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)(2616005)(426003)(8676002)(26005)(16526019)(36756003)(83380400001)(5660300002)(336012)(70206006)(6916009)(316002)(81166007)(6666004)(356005)(508600001)(8936002)(70586007)(4326008)(186003)(86362001)(47076005)(44832011)(82310400003)(1076003)(36860700001)(2906002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2021 09:33:08.7881 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4c39bfc0-eb3a-42a6-d5f7-08d98ef5a22d 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: DM6NAM11FT047.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3046 X-Spam-Status: No, score=-11.8 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.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: Thu, 14 Oct 2021 09:33:12 -0000 From: Zoran Zaric Another expectation of the existing function callback interface of the computed struct value is to check if a specific part (on a given offset of a given length) of an underlying location description is an implicit pointer location description. To satisfy this expectation a new is_implicit_ptr_at has been added. gdb/ChangeLog: * dwarf2/expr.c (dwarf_location::is_implicit_ptr_at): New method. (dwarf_implicit_pointer::is_implicit_ptr_at): New method. (dwarf_composite::is_implicit_ptr_at): New method. --- gdb/dwarf2/expr.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index bf8be951673..aa36a992e09 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -466,6 +466,14 @@ class dwarf_location : public dwarf_entry LONGEST bits_to_skip, size_t bit_size, size_t location_bit_limit) const; + /* Check if a given DWARF location description contains an implicit + pointer location description of a BIT_LENGTH size on a given + BIT_OFFSET offset. */ + virtual bool is_implicit_ptr_at (LONGEST bit_offset, int bit_length) const + { + return false; + } + protected: /* Architecture of the location. */ gdbarch *m_arch; @@ -1090,6 +1098,11 @@ class dwarf_implicit_pointer final : public dwarf_location size_t location_bit_limit) const override {} + bool is_implicit_ptr_at (LONGEST bit_offset, int bit_length) const override + { + return true; + } + private: /* Per object file data of the implicit pointer. */ dwarf2_per_objfile *m_per_objfile; @@ -1176,6 +1189,8 @@ class dwarf_composite final : public dwarf_location LONGEST bits_to_skip, size_t bit_size, size_t location_bit_limit) const override; + bool is_implicit_ptr_at (LONGEST bit_offset, int bit_length) const override; + private: /* Composite piece that contains a piece location description and it's size. */ @@ -1372,6 +1387,43 @@ dwarf_composite::write_to_gdb_value (frame_info *frame, struct value *value, } } +bool +dwarf_composite::is_implicit_ptr_at (LONGEST bit_offset, int bit_length) const +{ + /* Advance to the first non-skipped piece. */ + unsigned int pieces_num = m_pieces.size (); + LONGEST total_bit_offset = bit_offset; + LONGEST total_bit_length = bit_length; + + total_bit_offset += HOST_CHAR_BIT * m_offset + m_bit_suboffset; + + for (unsigned int i = 0; i < pieces_num && total_bit_length != 0; i++) + { + const piece &piece = m_pieces[i]; + ULONGEST read_bit_length = piece.size; + + if (total_bit_offset >= read_bit_length) + { + total_bit_offset -= read_bit_length; + continue; + } + + read_bit_length -= total_bit_offset; + + if (total_bit_length < read_bit_length) + read_bit_length = total_bit_length; + + if (piece.location->is_implicit_ptr_at (total_bit_offset, + read_bit_length)) + return true; + + total_bit_offset = 0; + total_bit_length -= read_bit_length; + } + + return false; +} + struct piece_closure { /* Reference count. */ -- 2.17.1