From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2059.outbound.protection.outlook.com [40.107.243.59]) by sourceware.org (Postfix) with ESMTPS id C0E013858436 for ; Fri, 5 Nov 2021 11:39:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C0E013858436 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IliSPLG63ACQlxgOYP+sF/Ek6Rn7MwD9h2BZxYHOFp2vYQ/nrjwhzskYr2uB6LO0WmhdLPXNbxJVkHVNXLDQesLKmqlRWHRtxvsQT1qQnbCPWypph2np1hj+JRVL78Jz32eiSwcbK/zjFB3zlEG8x8m7AESmIAvfxBCrFvcjYmwPKJqsrxf0jYCLH921h0zIUg/DTDDykctAXiEJjM5RgV2WkhH2RWV7KRoUbN1sVbELLxHcgssEdFnxYHQi/8RAGuUi/sckRrsEptuZsZcUVIgEI9pYg9H7FSyc8n3iS4rKxz419d0SOBDFG2zH7Go0LGz9hosjz1TH0vhDso3u6Q== 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=3pfWULSLFFRnwVA41j/5wNXIIe2ip/7AzoaWNqJWLiY=; b=YS/6oJp2SxP2YQ2dRWpmxV7F+tXgCPodi88kQl/bxlhGkiX7AcD0VqygRixKphBtRR43XCjAPZgx2wOmHxLsSWXXMt9lApj2c4lsWOZ4gNG1YojRMO0pnkTcvQW0UdWeoeDx65zpqGJlchSIZmavuR0CUsJ6bKZQFbHxaqEwo4gzIlwcPzhbv/7A4M/qQH5BQz5y3+6+6+H1mPel8/fixTB7bJa+RoaXhI7W/9F/WfBbw/5Jy7L9koEOhUVFYioxC+bnTj2FPLycCLO7dy/afibViReQpK6WuOeuv2SnN+EtbitD8LoPYZBAguRloEBrFduwObT8HbpjDLltWK7guQ== 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 MW4PR04CA0177.namprd04.prod.outlook.com (2603:10b6:303:85::32) by BY5PR12MB4887.namprd12.prod.outlook.com (2603:10b6:a03:1c6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11; Fri, 5 Nov 2021 11:39:19 +0000 Received: from CO1NAM11FT047.eop-nam11.prod.protection.outlook.com (2603:10b6:303:85:cafe::cc) by MW4PR04CA0177.outlook.office365.com (2603:10b6:303:85::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Fri, 5 Nov 2021 11:39:19 +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:18 +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:14 -0500 From: Zoran Zaric To: Subject: [PATCH v4 10/28] Add write_to_gdb_value method to dwarf_location Date: Fri, 5 Nov 2021 11:38:31 +0000 Message-ID: <20211105113849.118800-11-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: 293d9d6b-2212-496b-94d4-08d9a050e74e X-MS-TrafficTypeDiagnostic: BY5PR12MB4887: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2733; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bV/IeTFWwsjieKZQih6/XJPYAQ/6IpbshaMMjg1MGutgnxCPV03kEXBt/RTl98D5R9mxfouWnAQ6NZLgQdWaHzDUEW9QBVeSVNW7D09mb02/jtaB2d+5qxyZHOkkkbkvukigSM+6EMIpQgN7gNObmz6uyVnY/nUOUdU1NybXL0Pz1lcTC3TNyHcK5xziYWpL6xzlF1SfXKQtnX0gKPdX2dTzY1YzAB5kt+gIhESsrUVI8KBAS/mNmz2O38Bpnzl+u7e4OIboYafk2VlSLf5Fhm+4K2rSp+IeKYp2DnbDQ6JRB0d6PNmBXGX2wxXdJv35AW7MzUB2KXZo0Ztho4oeAdMT+u+qDtLJVDtBlsIrhhlHE/S69NmHJJuiSjO7Cbo2KGCpmUS9nkl5jZdExIEde+6ScMgBRRq1rEx7A7Ch8ZiGHPoJAmgTs0pTq3qj7jyvIcdYyENg/81VTvSGFddeVDBXmSq1z3se+NZOPrI3szyC5rBNmcOVenn4KiU1HxuVeKT7WxVj8fBzUF3yvp1Y2g0G3rfCGuCEaj1X61n7Lx4hfv5UUTHFRjeGcn3P87jHQGFddcdC/m2i53KG0uTTkzAesh5NlepVt01PVzKpha0oii3YKVGsWiL5ikFWkMnMy6Uf8ty5G9GHbwZwSTUSZ1CoNRm2/55rWlfkoIAc+GZN+IE9aTASX0FMwOxLghfgnWSzKIqCTL+yIT22bAWBFlFvsKS2SzNLACnicu1i/WQ= 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)(44832011)(8676002)(36860700001)(6666004)(6916009)(8936002)(336012)(5660300002)(70206006)(426003)(83380400001)(16526019)(2906002)(86362001)(47076005)(26005)(356005)(508600001)(82310400003)(4326008)(186003)(36756003)(316002)(1076003)(2616005)(81166007)(70586007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2021 11:39:18.6441 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 293d9d6b-2212-496b-94d4-08d9a050e74e 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: BY5PR12MB4887 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:22 -0000 From: Zoran Zaric Similar story behind the previous read_from_gdb_value method applies to the new write_to_gdb_value. In the same way, reading the data from a location described and writing that data to a struct value object, can be different from just generic read the data from a buffer (location description read method). To make this distinction clear, a new write_to_gdb_value method is added to classes that derive from location description class. gdb/ChangeLog: * dwarf2/expr.c (dwarf_location::write_to_gdb_value): New method. (dwarf_composite::write_to_gdb_value): New method. --- gdb/dwarf2/expr.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index e79d57fbfd4..b2fb0099b0e 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -441,6 +441,22 @@ class dwarf_location : public dwarf_entry LONGEST bits_to_skip, size_t bit_size, size_t location_bit_limit) const; +/* Write data to the VALUE contents from the location specified by the + location description. + + The write operation is performed in the context of a FRAME. + BIT_SIZE is the number of bits to read. VALUE_BIT_OFFSET is a bit + offset into a VALUE content and BITS_TO_SKIP is a bit offset into + the location. LOCATION_BIT_LIMIT is a maximum number of bits that + location can hold, where value zero signifies that there is no such + restriction. + + Note that some location types can be read without a FRAME context. */ + virtual void write_to_gdb_value (frame_info *frame, struct value *value, + int value_bit_offset, + LONGEST bits_to_skip, size_t bit_size, + size_t location_bit_limit) const; + protected: /* Architecture of the location. */ gdbarch *m_arch; @@ -483,6 +499,25 @@ dwarf_location::read_from_gdb_value (frame_info *frame, struct value *value, "is unavailable")); } +void +dwarf_location::write_to_gdb_value (frame_info *frame, struct value *value, + int value_bit_offset, + LONGEST bits_to_skip, size_t bit_size, + size_t location_bit_limit) const +{ + int optimized, unavailable; + bool big_endian = type_byte_order (value_type (value)) == BFD_ENDIAN_BIG; + + this->read (frame, value_contents_raw (value).data (), value_bit_offset, + bit_size, bits_to_skip, location_bit_limit, + big_endian, &optimized, &unavailable); + + if (optimized) + mark_value_bits_optimized_out (value, value_bit_offset, bit_size); + if (unavailable) + mark_value_bits_unavailable (value, value_bit_offset, bit_size); +} + /* Value entry found on a DWARF expression evaluation stack. */ class dwarf_value final : public dwarf_entry @@ -1047,6 +1082,12 @@ class dwarf_implicit_pointer final : public dwarf_location mark_value_bits_optimized_out (value, bits_to_skip, bit_size); } + void write_to_gdb_value (frame_info *frame, struct value *value, + int value_bit_offset, + LONGEST bits_to_skip, size_t bit_size, + size_t location_bit_limit) const override + {} + private: /* Per object file data of the implicit pointer. */ dwarf2_per_objfile *m_per_objfile; @@ -1128,6 +1169,11 @@ class dwarf_composite final : public dwarf_location LONGEST bits_to_skip, size_t bit_size, size_t location_bit_limit) const override; + void write_to_gdb_value (frame_info *frame, struct value *value, + int value_bit_offset, + LONGEST bits_to_skip, size_t bit_size, + size_t location_bit_limit) const override; + private: /* Composite piece that contains a piece location description and it's size. */ @@ -1281,6 +1327,49 @@ dwarf_composite::read_from_gdb_value (frame_info *frame, struct value *value, } } +void +dwarf_composite::write_to_gdb_value (frame_info *frame, struct value *value, + int value_bit_offset, + LONGEST bits_to_skip, size_t bit_size, + size_t location_bit_limit) const +{ + ULONGEST total_bits_to_skip + = bits_to_skip + HOST_CHAR_BIT * m_offset + m_bit_suboffset; + ULONGEST remaining_bit_size = bit_size; + ULONGEST bit_offset = value_bit_offset; + unsigned int pieces_num = m_pieces.size (); + unsigned int i; + + /* Advance to the first non-skipped piece. */ + for (i = 0; i < pieces_num; i++) + { + ULONGEST piece_bit_size = m_pieces[i].size; + + if (total_bits_to_skip < piece_bit_size) + break; + + total_bits_to_skip -= piece_bit_size; + } + + for (; i < pieces_num; i++) + { + const dwarf_location &location = *m_pieces[i].location; + ULONGEST piece_bit_size = m_pieces[i].size; + size_t this_bit_size = piece_bit_size - total_bits_to_skip; + + if (this_bit_size > remaining_bit_size) + this_bit_size = remaining_bit_size; + + location.write_to_gdb_value (frame, value, bit_offset, + total_bits_to_skip, this_bit_size, + piece_bit_size); + + bit_offset += this_bit_size; + remaining_bit_size -= this_bit_size; + total_bits_to_skip = 0; + } +} + struct piece_closure { /* Reference count. */ -- 2.17.1