From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2040.outbound.protection.outlook.com [40.107.94.40]) by sourceware.org (Postfix) with ESMTPS id 2B4CB3857C42 for ; Thu, 14 Oct 2021 09:33:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2B4CB3857C42 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YTc3mHWMu1onSmL3/kRmVhHZwDv+lwZ5cJd5mGOjXvV71f1o13/N4Jrl93lmb/Wxn9stbgnX3GqpbvQIDNhhtQfqGCmg6gLd760qzeiBvLs13ZODQgV8HlWgil/7Mv4QL/rXiyAA1btIxCJiGB7QZ27SU0WWaQjFoGXMqZXuG0xJ1B18v1hSQlv3RS3kCZ5yMsEm8YaxZvOJv2+D3Qf4UH3zIHT3PkAqp0fbKgDn0Bq3WlKsjOVL2qPcGJ4K2r4djNt+tPZ0TGLilIoVT7ig5M+p+VrgdqHNTPNhzGFOE3l9stFCb3YFHZ3BmZLH8+LxVMoIEuRU4OwX45szyXHZqQ== 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=9cXI5t8cFjo5L2UwFKmUrXMYU3TDGglYczzepsoLpbM=; b=bEwuodmnQnpN/+botWBP1gNYW5nfR7DuRiKsvkHyBqucmACo/RaejKBiKJ9799Hq4FLOpF0ZmQe3QDmTdgC4axlvRm4BsatV/3muoIYoEcTtHHAQpU/kKbTRiERS20/y+yDiYtrTzdzvdY4XtJLjK5qadLqq0P7XT0PyJNS9qsq76qr8+VFx9QXvKCqIPkKIBwsOwsJWiVe9couKPfE4rqGEjGJaPpeLVnyRdS6N0h/g5DBNbdY4/FKTitsQTqejtEQrJSM3elV9oD4C38tWe0p3HyuJ/Xf2DKcGgfCAz65c0+1JQ2tMCk34FX78QvJk+YyLl8vvK8/70hnRCyjbPw== 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 DM5PR13CA0043.namprd13.prod.outlook.com (2603:10b6:3:7b::29) by MN2PR12MB3565.namprd12.prod.outlook.com (2603:10b6:208:c2::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.16; Thu, 14 Oct 2021 09:33:11 +0000 Received: from DM6NAM11FT047.eop-nam11.prod.protection.outlook.com (2603:10b6:3:7b:cafe::11) by DM5PR13CA0043.outlook.office365.com (2603:10b6:3:7b::29) 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:11 +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:10 +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:07 -0500 From: Zoran Zaric To: Subject: [PATCH v3 12/28] Add indirect_implicit_ptr to dwarf_location class Date: Thu, 14 Oct 2021 10:32:19 +0100 Message-ID: <20211014093235.69756-13-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: 564331f9-14b4-41a7-e4cf-08d98ef5a354 X-MS-TrafficTypeDiagnostic: MN2PR12MB3565: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZaJVkEFAg7S8eGywVeFKq1PFlpEH68saRrjkbI+IZmopJU1yEVS1+6Brue8f+s4lHnBIEnR0xUKx9Blvb3Vj7jc2Gd8052fB0Z/kG3LNszhFUPSQlhkqXPsCP8aWAo6BQ32kMNQ+ck4gM6FN1odz7pa0XYVnoZnouYzdoH7ZXItlM2YMLD7JBpUZBKAp8SBwIsHUjJSm8pjZkpSkKhiZLGIJgTKEfeOpJGu455bpN3Uxg7nANFbV0ruAiXppf6pXua17CX52+u7owLcWUGoV2xf8R2WYiu4I0d61GUwOJw5k2vIJAVFBzLSISjnC36EHqpWAF2WolDBALgZ8lj7uNfYm2kEWti9zDvHAOYjp14B6f3Uwws/KdFbN8koblQjYZxCIdV+61LzQPvK1Acnp+qs063OXwXuvLv3ro1XslIRugyhjVFxfK+otdlmcNmt+DaZ50GGSvr2ikuRxYKZpIg1zBiQQnQYkOlPTwhHq2O6vp6NW9QxqI+sET1/tF/MtdFpa1GSzgAQpoA3swscfjbECBl1QX6gRE0irz2e9sxZFTCggtg1Tacwi9J1OAaychYlxU/GMBCCUA6JadYQ8vwTR6hNk4rQQvxGHT75EtrsLsvqaWGFd9it9HkBSWvPS21xvTDqKQTnrtg3RLvWndaLlUwqcVsDiwEwnE9LeOnw7k11IGZsfKLX8T2vJTly08cGWZ743/PwLrdFB270F5GNby1d7l01QwGyzqi8d72Y= 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)(70586007)(26005)(5660300002)(6666004)(8676002)(81166007)(16526019)(186003)(86362001)(2906002)(70206006)(47076005)(82310400003)(426003)(36756003)(4326008)(336012)(44832011)(2616005)(6916009)(8936002)(1076003)(83380400001)(508600001)(316002)(356005)(36860700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2021 09:33:10.7208 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 564331f9-14b4-41a7-e4cf-08d98ef5a354 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: MN2PR12MB3565 X-Spam-Status: No, score=-11.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.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:15 -0000 From: Zoran Zaric Similarly to the is_implicit_ptr_at method, the existing function callback interface of the computed struct value, requiers a way to apply indirection to an implicit pointer on a given offset of a given length of an underlying location description. This is different then reading from a struct value object (previously described write_to_gdb_value method) in a way that the result of this operation is expected to be a struct value of a pointed source level variable instead of reading the value of that variable. In the same way this is also different operation then the deref method because the deref returns a read value of a given type from that location description. gdb/ChangeLog: * dwarf2/expr.c (dwarf_location::indirect_implicit_ptr): New method. (dwarf_implicit_pointer::indirect_implicit_ptr): New method. (dwarf_composite::indirect_implicit_ptr): New method. --- gdb/dwarf2/expr.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index aa36a992e09..af84710b054 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -474,6 +474,24 @@ class dwarf_location : public dwarf_entry return false; } + /* Recursive indirecting of the implicit pointer location description + if that location is or encapsulates an implicit pointer. The + operation is performed in a given FRAME context, using the TYPE as + the type of the pointer. Where POINTER_OFFSET is an offset + applied to that implicit pointer location description before the + operation. BIT_OFFSET is a bit offset applied to the location and + BIT_LENGTH is a bit length of the read. + + Indirecting is only performed on the implicit pointer location + description parts of the location. */ + virtual value *indirect_implicit_ptr (frame_info *frame, struct type *type, + LONGEST pointer_offset = 0, + LONGEST bit_offset = 0, + int bit_length = 0) const + { + return nullptr; + } + protected: /* Architecture of the location. */ gdbarch *m_arch; @@ -1103,6 +1121,11 @@ class dwarf_implicit_pointer final : public dwarf_location return true; } + value *indirect_implicit_ptr (frame_info *frame, struct type *type, + LONGEST pointer_offset = 0, + LONGEST bit_offset = 0, + int bit_length = 0) const override; + private: /* Per object file data of the implicit pointer. */ dwarf2_per_objfile *m_per_objfile; @@ -1155,6 +1178,17 @@ dwarf_implicit_pointer::read (frame_info *frame, gdb_byte *buf, } } +value * +dwarf_implicit_pointer::indirect_implicit_ptr (frame_info *frame, + struct type *type, + LONGEST pointer_offset, + LONGEST bit_offset, + int bit_length) const +{ + return indirect_synthetic_pointer (m_die_offset, m_offset + pointer_offset, + m_per_cu, m_per_objfile, frame, type); +} + /* Composite location description entry. */ class dwarf_composite final : public dwarf_location @@ -1191,6 +1225,11 @@ class dwarf_composite final : public dwarf_location bool is_implicit_ptr_at (LONGEST bit_offset, int bit_length) const override; + value *indirect_implicit_ptr (frame_info *frame, struct type *type, + LONGEST pointer_offset = 0, + LONGEST bit_offset = 0, + int bit_length = 0) const override; + private: /* Composite piece that contains a piece location description and it's size. */ @@ -1424,6 +1463,40 @@ dwarf_composite::is_implicit_ptr_at (LONGEST bit_offset, int bit_length) const return false; } +value * +dwarf_composite::indirect_implicit_ptr (frame_info *frame, struct type *type, + LONGEST pointer_offset, + LONGEST bit_offset, + int bit_length) const +{ + LONGEST total_bit_offset = HOST_CHAR_BIT * m_offset + + m_bit_suboffset + bit_offset; + + /* Advance to the first non-skipped piece. */ + for (const piece &piece : m_pieces) + { + 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 (bit_length < read_bit_length) + read_bit_length = bit_length; + + return piece.location->indirect_implicit_ptr (frame, type, + pointer_offset, + total_bit_offset, + read_bit_length); + } + + return nullptr; +} + struct piece_closure { /* Reference count. */ -- 2.17.1