From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2077.outbound.protection.outlook.com [40.107.236.77]) by sourceware.org (Postfix) with ESMTPS id 95BFB385841D for ; Fri, 5 Nov 2021 11:39:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 95BFB385841D ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=liBzll7cv9Dxvc3eD4lgtzLDEk1GCaC8ubzftw6/kNlX7j9RRBUbn3Tch6UeHeLbgloAIkY26yS4BhgVhNCtfnjV+Phgve2KRFcuQDND/p16I/O6czaoCQ4jDPQcO5Q8CcJQs3UbE8m1TLP0nP2vNuEFj6+U4QjDZ5FCb/31cJkc/B/+IdK+On8vmUpcCV3Pug+uKNSavv69Pufg31SAEAYvQ5st7M1TfT0+wVXQABZvqfJbef4KVhvv2WI3anLgmLNYYi61QEnfPYCVnsHCgDticR0OtMEwvENwwDvty5bCbHNBYRFj7KR1QxvYupb1pBN+sF4NU6rXkZU/czIkOQ== 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=2eVhuDcM5XbgM/ffCz0Af2ajUamknI15JRr9whXnuFs=; b=CBLsKJdrV7T+931uc0orc5O87VIDDc+Z/JEI7VCYkpEJGoTwJWC4HP3R/vauBBM7g5m4eu/A3MYp2d5FjdP/KiAVwy1Roew52MDSAjVr2BqqO/BwWC1sPnpau1cCT9BsVRewcci345ahB0+KD2VV+B8GL0zhLrx+yIrJQXCuj8ZGIVW7KmKGzd3mFsj8RwMf1j4J45sh96pHKHFgehH2HgOi56zglMo6M9xUhsfM2tn9ONH74lbGlz37ytLothZt10rzrpDbQdO4uDrEJbDqftepR3M/raAKybH3peMfl4+RXxyJjkG9Q1G5zodfJFY7Oi12ul0+bDVbM2blkFFofA== 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 MW4PR04CA0159.namprd04.prod.outlook.com (2603:10b6:303:85::14) by MW2PR12MB2490.namprd12.prod.outlook.com (2603:10b6:907:9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.17; Fri, 5 Nov 2021 11:39:20 +0000 Received: from CO1NAM11FT047.eop-nam11.prod.protection.outlook.com (2603:10b6:303:85:cafe::f8) by MW4PR04CA0159.outlook.office365.com (2603:10b6:303:85::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11 via Frontend Transport; Fri, 5 Nov 2021 11:39:20 +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 CO1NAM11FT047.mail.protection.outlook.com (10.13.174.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4669.10 via Frontend Transport; Fri, 5 Nov 2021 11:39:20 +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.15; Fri, 5 Nov 2021 06:39:16 -0500 From: Zoran Zaric To: Subject: [PATCH v4 12/28] Add indirect_implicit_ptr to dwarf_location class Date: Fri, 5 Nov 2021 11:38:33 +0000 Message-ID: <20211105113849.118800-13-zoran.zaric@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211105113849.118800-1-zoran.zaric@amd.com> References: <20211105113849.118800-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: 9128aa45-afa8-4bad-42b9-08d9a050e856 X-MS-TrafficTypeDiagnostic: MW2PR12MB2490: 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: Z4w19NJSGmsS87TisXj4Xljy277OL54AEugJ1mnF+mGka2Z38FxCKi/XLv2GnPfND2L0s8qxhJr3nzGT6IoMrh4UrGzjXdADlEtY3kkoCT7z2AF8OgRRg3rDf+r630uYhitCP85wbU2TAnTyOKVRkC0ryPkYrAwNSceWk/eq7R1oG3GILyz+pe0rvLza1Xfv2Hh7WyUM2eV9FmAHwGsTFzxZzb1m8K37I/tglGPcep8W3obEYN85PSkrhhn38SwqpgCSDyz/sQguBca6O8GMyi049Hk8/hfGfOsUpw6/C6IRoI5JVZiUNJADDNm0NZMFzGTcGRyVIcnvOuTfn/LQr4b1j2DpKW0JORvKM9PneIUHkEPP01goR0rsc5G+fO6NcZs+dpm6nzr9mCy1Hhkt+x//cAxj95B+bNdhEUfDaQvh0jhkvXXx86dDC6EpuXELULnBLNWda7z4zEp/aHTyIcmyW/s9nzgQI9uY/EQxrTM3n+pwx5sQ13x5K2vH+8D8UJH7qvVi2FCFFdC7IBxulMDpFxEwjcKmZufr+VjPqUEjde3SMrVZRXWIEqbi1xbqyfwIwGsjo2cE/4y0ppnElmyHsYhkop7k+1uyV4WsLCvsC1+RWmO2cP9Mbf9XHWV4LMj5HAYfYRIaqMdZqRpdD9c1cpgQAiC2W5qY2UOuZi0yNKM6eJr02ymlgcsCIOjkXxHQiO8aI7ZSa5VGaU7DJ6+/bLyOATSSMggMn10pt34= 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)(26005)(6916009)(44832011)(36756003)(426003)(2906002)(336012)(86362001)(36860700001)(186003)(2616005)(70586007)(508600001)(5660300002)(316002)(81166007)(6666004)(8936002)(4326008)(82310400003)(8676002)(1076003)(47076005)(356005)(83380400001)(70206006)(16526019)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2021 11:39:20.3731 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9128aa45-afa8-4bad-42b9-08d9a050e856 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: CO1NAM11FT047.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR12MB2490 X-Spam-Status: No, score=-12.4 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: Fri, 05 Nov 2021 11:39:27 -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 than 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 than 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 a933ca2797d..185324f1d2d 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -465,6 +465,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; @@ -1101,6 +1119,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; @@ -1153,6 +1176,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 @@ -1189,6 +1223,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. */ @@ -1422,6 +1461,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