From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2048.outbound.protection.outlook.com [40.107.243.48]) by sourceware.org (Postfix) with ESMTPS id C5FCE3857C56 for ; Thu, 14 Oct 2021 09:33:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C5FCE3857C56 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AN4WbXdYZrha0qvAaLnhx7mVrQTyvTwTnko1Fe1Kr4m397B50WDzWhTtMMD9DPoJQT3KWQqomiOywornS+7mIikJ2uQh8oErtE+TmHNWPHMgOYcGHCchkeUyXx5CAxAHVyGGSDr1s8uqYySuwnLiHMLxRGcXeJatHiwSr76CwLHrlcVCMciUw5Q4rWy9kL6p5NO7xBHiQaagF3oOvjsJFiFIlzM1ZxZrpw+8PGcgBDeioUSerXH4MKCn+C3rh+AeKGloEElLUN5oH8tp0hsSUmef0VPyC/iJGRrHW4xKkPJXg1XiiPqXb/tLh5o45pCttN/YY8QNHKbiPmqXEILTkQ== 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=sKwSbOPIpmNTwvYc7FxQrQ95IxfEYChAaH0nn3kuXW0=; b=cJvMIJef7ArTzgG29OH3s1CHjjEn6bwPHkj5gQtpqaS/2k3HyQv+bOTlyVj0fCWrFnRNA/k0JfrWVTSxsMteUlSoeMqICYbWIK1iGMq3QZW3S2tlw/GG0kOg8KFKuX0+Pp8JBtAU0rXH1BXz8ufSAvq4w/IQ1v5CnoMx0Ydu26/J+yrjnO0hsrIhxcgGLvsCZNeDgq6Knfnn+NIdbpQX5eZWSWlvUk6IgwFPPDwyKn1Mg379UhxciCjMwAK6E8tfArLLAm8dm/TWvNR95n8Tx6OkCtR+ZOWvnyijYKryRzuawCw7/6gZXvUUH+fUA6yMnt5e23gNi6i1kFPFtxmNrA== 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 DM5PR13CA0029.namprd13.prod.outlook.com (2603:10b6:3:7b::15) by DM6PR12MB4987.namprd12.prod.outlook.com (2603:10b6:5:163::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.25; Thu, 14 Oct 2021 09:33:08 +0000 Received: from DM6NAM11FT047.eop-nam11.prod.protection.outlook.com (2603:10b6:3:7b:cafe::f8) by DM5PR13CA0029.outlook.office365.com (2603:10b6:3:7b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.4 via Frontend Transport; Thu, 14 Oct 2021 09:33:08 +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:07 +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:04 -0500 From: Zoran Zaric To: Subject: [PATCH v3 10/28] Add write_to_gdb_value method to dwarf_location Date: Thu, 14 Oct 2021 10:32:17 +0100 Message-ID: <20211014093235.69756-11-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: c5e904d1-280d-40ba-f49c-08d98ef5a198 X-MS-TrafficTypeDiagnostic: DM6PR12MB4987: 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: 24Y8Gy+QaSNGSC1KpJ2D/iYOuLmbAiUxUhTEdeNe/Gu6Y/Lo9Oa4s5mTvuCRST3PaZaqKO7wf+sr5zpt88f4aqySnyWG+Hp8VlmRfI7If+AJ0WzeMwN/BidxHMtQ/ekTwzzlpj3dSHcPMaE2NsHlmxXF8pBJcv+iw1NifVSrAYmF8SCFRzePCgbcAWODHlFW5UhNBnIur28DEhgflSrlpgI8lX9kWMhqa7bMjDjabummwQjs00NgbgcFowIxxAMkT/qFognz52FqIppD1ot4rwHUlcBGk4FkwN8qWK1khYoQYikOSZlFFtYlpV6OmT0n/egFZG0du4ggUgR7XmABOta9aPnvxBwmWN1xr8jcv6U7EB/67EMf5W/0qJQxcJ2+YU6U3Y9hbrXvVH71OP/ZqmCeftpzqZTuc6pWTYnuviulGT4w4AfBxQ3/AQK3eBf8tdzvnrpPge6ybdJPL6ycqMt3uMoy276uwprTjx1qNA2THwwObCgZXxw/cWakr9i6fblRbosWTuKMnVwPbXPVAE1ZH2+eupWX2PkIf72EO2BXOTxyC+8ugW27UfFsIOROVwbJQ1NvBpLEjYiykJ7DYgyFFw0yZjsHekRS/XWj2GmhhaLZawakg9sJ7sMrxJFIEFE1FLhkdliyV4L13zkXS83R++zAVSCEJahspIQRYhXWOAML4ravrqJNrO/MnJah7u/rfwzHVgpomSZ6Dz0N8tEN+jJDmh364Px3sB5QnLY= 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)(16526019)(26005)(8676002)(70586007)(8936002)(83380400001)(47076005)(4326008)(5660300002)(2906002)(82310400003)(186003)(508600001)(70206006)(81166007)(2616005)(336012)(356005)(44832011)(36756003)(1076003)(86362001)(6916009)(36860700001)(426003)(6666004)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2021 09:33:07.8124 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c5e904d1-280d-40ba-f49c-08d98ef5a198 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: DM6PR12MB4987 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 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 03c3d7306e2..bf8be951673 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -450,6 +450,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; @@ -492,6 +508,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), 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 : public dwarf_entry @@ -1049,6 +1084,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; @@ -1130,6 +1171,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. */ @@ -1283,6 +1329,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