From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id gA7pGYD+PGA3JAAAWB0awg (envelope-from ) for ; Mon, 01 Mar 2021 09:47:28 -0500 Received: by simark.ca (Postfix, from userid 112) id A37961F0C1; Mon, 1 Mar 2021 09:47:26 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,RDNS_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id B0EEB1EF7C for ; Mon, 1 Mar 2021 09:47:21 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C81E5393BC19; Mon, 1 Mar 2021 14:47:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C81E5393BC19 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614610039; bh=8pa6in36uvA5Xtgtt/RkGB9lFE+tEUr3VcB8PnovCek=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=H50XsgMXSbSIGTM/ecHtFdF5xfvpeNRHOiLeGurn84R8nKKrMUMgQy8wnMvUq4tHK xqoZnzQWbCN0iukDnKYo8UjOxozCPfrRQv57KWBK3orq2kwhHciMvtkMR7u89RZye0 9DGPBzx+/+1wDBAMCkcdY8PBAf+n9Ws1xZ0yUoy4= Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2075.outbound.protection.outlook.com [40.107.244.75]) by sourceware.org (Postfix) with ESMTPS id DF5D0393A43D for ; Mon, 1 Mar 2021 14:47:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DF5D0393A43D ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FUWbA/9DFQNcE/wZ7wYW/1E83VdiQS8rugtQKXmIyJ5tww+IAOVGvCCwew9lj41ZuHOGOvU9uz1TJqXbzB/dU77gR7VldZz62iAsUKedFH3BJ4nxDpymG0Z3AdMPQuxwtAj0nvkjXHRJNtSNS+4ylBf9q+8FwHrIAJ7kTB6NRBVjY37ia1+moOQoO3vkQlMGgN2Krzcg32iNyBgY/3iu4NSve0YL2giWAkyvxRF8vmVpN4wcH471MhfkapoQ1zwuhCz55u0xKNb0gx3bAE8M85/wnj0fA7EQ4jvrCoZhdoH2ZWr8IctvDk6cYguS7lRPLhd1tTTgxXqYu7ydVeHSNQ== 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-SenderADCheck; bh=8pa6in36uvA5Xtgtt/RkGB9lFE+tEUr3VcB8PnovCek=; b=Uoa5ily30xnad8Shy3GR3xDefe/2ajJ39SxaBs/qhrJ5+1qfyLiFOqR9Fx5wndtjFRdqAcVPZ7JCjI2TYc2zeYR5EoLK0vn2B3/Q72jLkXMk/fLM8gtJhAnwS0N4ZC0cK5q2eFb6F6xM4cObqvHThPrgHu7H3DSKdsmvo51BIKQk9scUKGWBX9/DIaQmuJnQeIGlxpa8BleQVzDUHRn+i9amwOz6039rZVHCR1st9sF9/Cj/DiQbhrobaKanPYR3nTypxttc6m0vqNQoNpkzo/7Oq5TyVD4hTAcH+QYIxBivi8i8wSnafRyAL+vpzg1/1uXYI1RsJSKZhF7IqGyB3A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none Received: from DM6PR12MB2762.namprd12.prod.outlook.com (2603:10b6:5:45::15) by DM6PR12MB3676.namprd12.prod.outlook.com (2603:10b6:5:1c7::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.19; Mon, 1 Mar 2021 14:47:08 +0000 Received: from DM6PR12MB2762.namprd12.prod.outlook.com ([fe80::31d8:f503:f7b2:f44]) by DM6PR12MB2762.namprd12.prod.outlook.com ([fe80::31d8:f503:f7b2:f44%3]) with mapi id 15.20.3868.033; Mon, 1 Mar 2021 14:47:08 +0000 To: gdb-patches@sourceware.org Subject: [PATCH 24/43] Add write method to location description classes Date: Mon, 1 Mar 2021 14:46:01 +0000 Message-Id: <20210301144620.103016-25-Zoran.Zaric@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210301144620.103016-1-Zoran.Zaric@amd.com> References: <20210301144620.103016-1-Zoran.Zaric@amd.com> Content-Type: text/plain X-Originating-IP: [2a00:23c7:5a85:6801:b4ed:fe7b:8064:d4d] X-ClientProxiedBy: AM0PR04CA0073.eurprd04.prod.outlook.com (2603:10a6:208:be::14) To DM6PR12MB2762.namprd12.prod.outlook.com (2603:10b6:5:45::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a00:23c7:5a85:6801:b4ed:fe7b:8064:d4d) by AM0PR04CA0073.eurprd04.prod.outlook.com (2603:10a6:208:be::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.19 via Frontend Transport; Mon, 1 Mar 2021 14:47:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 5809b737-4d36-4060-6b8e-08d8dcc0e21f X-MS-TrafficTypeDiagnostic: DM6PR12MB3676: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Rzt0uEKdpPIghFvKcrwMvm5POLzhlFT35paGfZLvr3N42NKfT+HgBfVl9QOz7gz6rGdbEEE1Af87K3cgSYP3vzbpy1+tvUW7qDEuWbLrS/MHb2DWMxoXpkpHXPlMw5wqxvqJBvpnlWopGt+oczlVy3EKvRhvQIKJ/VI4inl2YtGun7VvvBP/nw4iGmkALgWcnqtWMzFEaC9rAhVfT7IDhMc23EU2fem7jJnbhkuyLMVnmx7HGpwMUkrNdcex4/jasPn/XgQwh7x8/Sm5anZD6hXBAGG1fT4c4BLdR3Z5gLk84U2sVCfr6cc3eHhb2wd8rdMjTECTSWtcu7xT2pggsJA4WCdwdMQbKUfylCZC3EajqXW4XMmJ6oqsh95TsmpBnUjs+6tTyNnE6yPft0siq8yyPAgnzdtbxoKYRJrrq74zeqNZf5i4rBi98UHUpoDu+nDYk/649R/LxX4/OT22LEDBQLsE8ZIBo2QIBd9jZQ/VsbYzOW6rCO46w8lsoy0aCEHK6H51ALcUZqFH7TGxtWlIkS3X88zpVQgLhPqenZrpkxG2UsuwXQSYbZC943EgxeWXu1CwtFlkRezPlFHnww== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR12MB2762.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(366004)(396003)(346002)(136003)(39860400002)(6666004)(16526019)(1076003)(83380400001)(2616005)(69590400012)(2906002)(186003)(36756003)(66946007)(316002)(66476007)(8936002)(52116002)(86362001)(6506007)(478600001)(5660300002)(4326008)(6486002)(8676002)(30864003)(6916009)(6512007)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?tX1A8+NXQSCA+0q/aiXqdypnPjtxAwNzJEAOFjMHrKnwYl+t8dVoMzk9wa9T?= =?us-ascii?Q?QIrC6dNXr56xw+++Y5/BrtH8IBtr98bwDddhhFo51FYAe7ADQUDXiood5BU/?= =?us-ascii?Q?Xsnizu3D/2E1iJadAUUJFZiyyDzCfv3G5uYgMXw+UYhvgwbvf90wCR0jRzH2?= =?us-ascii?Q?CHC/cSbhW5ErIFI1N/teQE8kQgYe6Nmwd6+gVpt/NOH9IO0erB39VdjPI01h?= =?us-ascii?Q?yTmjg+PoEdVqEmNI7hNTCGNCefGggW2Fu2PyGPqQW/7lOBPsauZHduWzeFr+?= =?us-ascii?Q?nPCdV0LzK9N3V2nArSw3K2oo+QwVog6vWliKgX1htEKw7McH+/X3EwvzLnFp?= =?us-ascii?Q?9BaK3ewwH4HjkgsLCnpAUSq0BkjdPG+8VJR3cUxQN4/ahtlanFAkChWg0F1v?= =?us-ascii?Q?4Av/WIkDrmyuP2th/zK351I3JgXUDQLC4NHTCr09tBTITVzT2yD/93rR7XBR?= =?us-ascii?Q?lLoTGgQMbRI209nWoZ2hvz38yA+2W1cWCQ94yyN+r/uRfPJRpv1CXGrvdc+w?= =?us-ascii?Q?UToVwb7TNYJ5rHOVZzqzGTZHZ+0qFDgYWja/ZKW6GYF+wdu2dD5Ckd0MNTm1?= =?us-ascii?Q?yvHfWj6rg5wmsu+3BW8V8vYylRwOk/SFGeGUqB+6jDx0nfDHaJTjtM1cPVSB?= =?us-ascii?Q?zy3NKUhQS1o7ARrv5bqnJayphHathyrLHutzeM6aoKJzlSNKHpnkEm9EM3tQ?= =?us-ascii?Q?rRn8qlhmT2VE/l934BT6HNExjDkPUWYNIocLdpgDN+m9qlIOdZkB4n5/IMDG?= =?us-ascii?Q?FGSvQobCvDjzCHHQmlTgAE5hUr4zO5T8VvpN6UXy9A3Swo1AG4svSmtLvo6x?= =?us-ascii?Q?oY6ssUBYvDnF1MIPZmb3WLNzB/+nSyh7gAKGE5HhQ1sKi1VHnSqIlTnX6rsU?= =?us-ascii?Q?596qlWhN5E4A+3kbO1x2x8kF9Y7cX1tFoRwRbApgWhBS8WZ0KD2jcLlYi6nQ?= =?us-ascii?Q?FShk0j3fuRPNErgGHPgVja27oNeCoWTWMYIvzyuy2ot20GJ+9ILA0QFNYmxI?= =?us-ascii?Q?g9rn1Wnd08wNoQ0dfpOdmMHm2fTDPB3A6A/jDlB947745MSVhMXKE3T9AQhw?= =?us-ascii?Q?mY+aP8NjhzfDKwzLpJeaOxVDLGuT86zVc72ROPLV9BZDfjk47Tyg+DVKViIv?= =?us-ascii?Q?+NhosY7UlX/JhZpAz37DIz0J4jXgeFKbNpWKE0u8QzV8fKVCklRussAV9PNc?= =?us-ascii?Q?/PeuOBNOmuOswaGVtz029jhlVeHjQU3KynCtCUikXR7qU7qD/xcaTrC5q+d8?= =?us-ascii?Q?7YjYZdW+1RNnUHfDoLa3onQdvkxUScXiSUkuRLa7MuAZHbmN6Gr/lm/5JcHO?= =?us-ascii?Q?I6/AGiULRt9hNdE8rzmNgiVxlhIZgEbkKEA6Vw/UNzuzU6EXQxIOQH0n4Mq5?= =?us-ascii?Q?+kK1dEyIw4KXy4Xo2OG+x8pUStYO?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5809b737-4d36-4060-6b8e-08d8dcc0e21f X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB2762.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2021 14:47:06.0255 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9Nh4bjDx5+89wy6ZzwmeAoVsIDbIrHA4GPMWUZoyUqqzGbN5DphHx7DSXfSVeoL68me6FZ/UcQ8g0ylP7yCqDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3676 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: , From: Zoran Zaric via Gdb-patches Reply-To: Zoran Zaric Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" After adding the interface for reading from the location, it also makes sense to add the interface for writing. To be clear, DWARF standard doesn't have a concept of writting to a location, but because of the way how callback functions are used to interact with the opeque implementation of the computed struct value objects, the choice was to either use the existing DWARF entry classes or to invent another way of representing the complexity behind those computed objects. Adding a write method seems to be a simpler option of the two. gdb/ChangeLog: * dwarf2/expr.c (dwarf_location::write): New method. (dwarf_undefined::write): New method. (dwarf_memory::write): New method. (dwarf_register::write): New method. (dwarf_implicit::write): New method. (dwarf_implicit_pointer::write): New method. (dwarf_composite::write): New method. --- gdb/dwarf2/expr.c | 211 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 211 insertions(+) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 35b2efa6cb5..ef7adb1f959 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -421,6 +421,28 @@ class dwarf_location : public dwarf_entry bool big_endian, int *optimized, int *unavailable) const = 0; + /* Write contents to a described location. + + The write operation is performed in the context of a FRAME. + BIT_SIZE is the number of bits written. The data written is + copied from the caller-managed BUF buffer. BIG_ENDIAN defines an + endianness of the target. BITS_TO_SKIP is a bit offset into the + location and BUF_BIT_OFFSET is buffer BUF's bit offset. + 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 written without a FRAME + context. + + If the location is optimized out or unavailable, the OPTIMIZED and + UNAVAILABLE outputs are set. */ + virtual void write (struct frame_info *frame, const gdb_byte *buf, + int buf_bit_offset, size_t bit_size, + LONGEST bits_to_skip, size_t location_bit_limit, + bool big_endian, int *optimized, + int *unavailable) const = 0; + protected: /* Architecture of the location. */ struct gdbarch *m_arch; @@ -535,6 +557,15 @@ class dwarf_undefined : public dwarf_location *unavailable = 0; *optimized = 1; } + + void write (struct frame_info *frame, const gdb_byte *buf, + int buf_bit_offset, size_t bit_size, LONGEST bits_to_skip, + size_t location_bit_limit, bool big_endian, + int *optimized, int *unavailable) const override + { + *unavailable = 0; + *optimized = 1; + } }; class dwarf_memory : public dwarf_location @@ -558,6 +589,11 @@ class dwarf_memory : public dwarf_location size_t location_bit_limit, bool big_endian, int *optimized, int *unavailable) const override; + void write (struct frame_info *frame, const gdb_byte *buf, + int buf_bit_offset, size_t bit_size, LONGEST bits_to_skip, + size_t location_bit_limit, bool big_endian, + int *optimized, int *unavailable) const override; + private: /* True if the location belongs to a stack memory region. */ bool m_stack; @@ -609,6 +645,62 @@ dwarf_memory::read (struct frame_info *frame, gdb_byte *buf, } } +void +dwarf_memory::write (struct frame_info *frame, const gdb_byte *buf, + int buf_bit_offset, size_t bit_size, + LONGEST bits_to_skip, size_t location_bit_limit, + bool big_endian, int *optimized, int *unavailable) const +{ + LONGEST total_bits_to_skip = bits_to_skip; + CORE_ADDR start_address + = m_offset + (m_bit_suboffset + total_bits_to_skip) / HOST_CHAR_BIT; + gdb::byte_vector temp_buf; + + total_bits_to_skip += m_bit_suboffset; + *optimized = 0; + + if (total_bits_to_skip % HOST_CHAR_BIT == 0 + && bit_size % HOST_CHAR_BIT == 0 + && buf_bit_offset % HOST_CHAR_BIT == 0) + { + /* Everything is byte-aligned; no buffer needed. */ + write_to_memory (start_address, buf + buf_bit_offset / HOST_CHAR_BIT, + bit_size / HOST_CHAR_BIT, m_stack, unavailable); + } + else + { + LONGEST this_size = bits_to_bytes (total_bits_to_skip, bit_size); + temp_buf.resize (this_size); + + if (total_bits_to_skip % HOST_CHAR_BIT != 0 + || bit_size % HOST_CHAR_BIT != 0) + { + if (this_size <= HOST_CHAR_BIT) + /* Perform a single read for small sizes. */ + read_from_memory (start_address, temp_buf.data (), + this_size, m_stack, unavailable); + else + { + /* Only the first and last bytes can possibly have + any bits reused. */ + read_from_memory (start_address, temp_buf.data (), + 1, m_stack, unavailable); + + if (!*unavailable) + read_from_memory (start_address + this_size - 1, + &temp_buf[this_size - 1], 1, + m_stack, unavailable); + } + } + + copy_bitwise (temp_buf.data (), total_bits_to_skip % HOST_CHAR_BIT, + buf, buf_bit_offset, bit_size, big_endian); + + write_to_memory (start_address, temp_buf.data (), this_size, + m_stack, unavailable); + } +} + /* Register location description entry. */ class dwarf_register : public dwarf_location @@ -624,6 +716,11 @@ class dwarf_register : public dwarf_location size_t bit_size, LONGEST bits_to_skip, size_t location_bit_limit, bool big_endian, int *optimized, int *unavailable) const override; + void write (struct frame_info *frame, const gdb_byte *buf, + int buf_bit_offset, size_t bit_size, LONGEST bits_to_skip, + size_t location_bit_limit, bool big_endian, + int *optimized, int *unavailable) const override; + private: /* DWARF register number. */ unsigned int m_regnum; @@ -669,6 +766,52 @@ dwarf_register::read (struct frame_info *frame, gdb_byte *buf, total_bits_to_skip % HOST_CHAR_BIT, bit_size, big_endian); } +void +dwarf_register::write (struct frame_info *frame, const gdb_byte *buf, + int buf_bit_offset, size_t bit_size, + LONGEST bits_to_skip, size_t location_bit_limit, + bool big_endian, int *optimized, int *unavailable) const +{ + LONGEST total_bits_to_skip = bits_to_skip; + size_t write_bit_limit = location_bit_limit; + int gdb_regnum = dwarf_reg_to_regnum_or_error (m_arch, m_regnum); + ULONGEST reg_bits = HOST_CHAR_BIT * register_size (m_arch, gdb_regnum); + gdb::byte_vector temp_buf; + + if (frame == NULL) + internal_error (__FILE__, __LINE__, _("invalid frame information")); + + if (big_endian) + { + if (!write_bit_limit || reg_bits <= write_bit_limit) + write_bit_limit = bit_size; + + total_bits_to_skip += reg_bits - (m_offset * HOST_CHAR_BIT + + m_bit_suboffset + write_bit_limit); + } + else + total_bits_to_skip += m_offset * HOST_CHAR_BIT + m_bit_suboffset; + + LONGEST this_size = bits_to_bytes (total_bits_to_skip, bit_size); + temp_buf.resize (this_size); + + if (total_bits_to_skip % HOST_CHAR_BIT != 0 + || bit_size % HOST_CHAR_BIT != 0) + { + /* Contents is copied non-byte-aligned into the register. + Need some bits from original register value. */ + read_from_register (frame, gdb_regnum, + total_bits_to_skip / HOST_CHAR_BIT, + temp_buf, optimized, unavailable); + } + + copy_bitwise (temp_buf.data (), total_bits_to_skip % HOST_CHAR_BIT, buf, + buf_bit_offset, bit_size, big_endian); + + write_to_register (frame, gdb_regnum, total_bits_to_skip / HOST_CHAR_BIT, + temp_buf, optimized, unavailable); +} + /* Implicit location description entry. Describes a location description not found on the target but instead saved in a gdb-allocated buffer. */ @@ -692,6 +835,15 @@ class dwarf_implicit : public dwarf_location size_t bit_size, LONGEST bits_to_skip, size_t location_bit_limit, bool big_endian, int *optimized, int *unavailable) const override; + void write (struct frame_info *frame, const gdb_byte *buf, + int buf_bit_offset, size_t bit_size, + LONGEST bits_to_skip, size_t location_bit_limit, + bool big_endian, int* optimized, int* unavailable) const override + { + *optimized = 1; + *unavailable = 0; + } + private: /* Implicit location contents as a stream of bytes in target byte-order. */ gdb::unique_xmalloc_ptr m_contents; @@ -761,6 +913,15 @@ class dwarf_implicit_pointer : public dwarf_location size_t bit_size, LONGEST bits_to_skip, size_t location_bit_limit, bool big_endian, int *optimized, int *unavailable) const override; + void write (struct frame_info *frame, const gdb_byte *buf, + int buf_bit_offset, size_t bit_size, LONGEST bits_to_skip, + size_t location_bit_limit, bool big_endian, + int* optimized, int* unavailable) const override + { + *optimized = 1; + *unavailable = 0; + } + private: /* Per object file data of the implicit pointer. */ dwarf2_per_objfile *m_per_objfile; @@ -833,6 +994,11 @@ class dwarf_composite : public dwarf_location size_t bit_size, LONGEST bits_to_skip, size_t location_bit_limit, bool big_endian, int *optimized, int *unavailable) const override; + void write (struct frame_info *frame, const gdb_byte *buf, + int buf_bit_offset, size_t bit_size, LONGEST bits_to_skip, + size_t location_bit_limit, bool big_endian, + int *optimized, int *unavailable) const override; + private: /* Composite piece that contains a piece location description and it's size. */ @@ -899,6 +1065,51 @@ dwarf_composite::read (struct frame_info *frame, gdb_byte *buf, } } +void +dwarf_composite::write (struct frame_info *frame, const gdb_byte *buf, + int buf_bit_offset, size_t bit_size, + LONGEST bits_to_skip, size_t location_bit_limit, + bool big_endian, int *optimized, + int *unavailable) const +{ + LONGEST total_bits_to_skip = bits_to_skip; + unsigned int pieces_num = m_pieces.size (); + unsigned int i; + + total_bits_to_skip += m_offset * HOST_CHAR_BIT + m_bit_suboffset; + + /* Skip pieces covered by the write offset. */ + for (i = 0; i < pieces_num; i++) + { + LONGEST piece_bit_size = m_pieces[i].m_size; + + if (total_bits_to_skip < piece_bit_size) + break; + + total_bits_to_skip -= piece_bit_size; + } + + for (; i < pieces_num; i++) + { + LONGEST piece_bit_size = m_pieces[i].m_size; + LONGEST actual_bit_size = piece_bit_size; + + if (actual_bit_size > bit_size) + actual_bit_size = bit_size; + + m_pieces[i].m_location->write (frame, buf, buf_bit_offset, + actual_bit_size, total_bits_to_skip, + piece_bit_size, big_endian, + optimized, unavailable); + + if (bit_size == actual_bit_size || *optimized || *unavailable) + break; + + buf_bit_offset += actual_bit_size; + bit_size -= actual_bit_size; + } +} + struct piece_closure { /* Reference count. */ -- 2.17.1