From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 0BC0D393BC03 for ; Mon, 1 Mar 2021 14:47:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0BC0D393BC03 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RUBes3i6JjJoJWD3OZlJZn8n6y8fW3jco9fS6Hp0XO4vfPaVA7Jf+odpUsN/KYZ40b6J2BHf74jP1BBmPtNt9Nam3vaDfunTx1IRfh7GkZGdNpWTak69x4JMIALYz3tlF/dmpW4QMJ3cHxTUyWlK8X9yeKe4OP8ZEQYOU+sVZdrBr3ZFQ9lIiPn+5cYIcTzU0txV6Rphmqj0FI0X8qLu+76S5tZ4znk5d6ZHgdyVYS9+OuYlaBU0M2i5oumq3o7fTMJbXLztakfjuuoMe3oFzfaUKsmHHnI7ft2b18LFHBLRpc9jl7ImM0Wa0hbUSbDe28IYiSDN1YJTXdmc1zuYHA== 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=H2LzqeSgUzdNBCD7ITTzeTf3mmi0L38r6pTMCP72QhQ=; b=AkdK1XCagdr/4PbHgiancDTYhTb7ufCY9IXXmZ+TO73/IOOTxGYUcclwiG9gPIZSEiaX0bXm4tWrEW8X7Ohl35FiJhqPdM9tlNs3lgBy7za3/L7rcdwtBClkYxywMNZb8H74lFiqXNDHrL4Y4mzcYNuPjMSBazFvwUuvbUOFBuYlMJN3/5jDENMYU5SCv8QEKJe7uDvUy469WKp/ddOwVkTsQyVOB8Nz5T3IscE7t6deB7xzoQkSx081mZtonx2jD10rgmxkvszhXq7IW+I4M9unO0i95VVwnrULYO+r/dygQNpcjXNmFh/xRdwOCPDFw8PCGaKqsK4ZgevWFrnXDA== 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:09 +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:09 +0000 From: Zoran Zaric To: gdb-patches@sourceware.org Subject: [PATCH 26/43] Add read_from_gdb_value method to dwarf_location Date: Mon, 1 Mar 2021 14:46:03 +0000 Message-Id: <20210301144620.103016-27-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:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f721d1ad-d80b-41d2-0ac1-08d8dcc0e3e4 X-MS-TrafficTypeDiagnostic: DM6PR12MB3676: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YAhElvAEByp93lfnlq0gefiaTQQQYME3e4ALYjZePzH8wxlqduUwavSRCUrgUyN9wKZ+sGnVOV5yx/aNNmDQ7BkwRyqC0OZOVegQs5/q0ZOeVlJloRdVDPshOqEnkqzHbCl3N9sHR8XRFfeB4PIJagRM3paXQy5aIH7s4pkL1ZLNegay7CWssh03bNs3+zlJf43D8NdKgf8MQF/O3Ss0gyUSLUhKuGS0hJds8EqRmQl3hbMBVLULbERgZIzXkMu8BEKcHbBBw8XghT2z6MsyHvnJ+ktBbFD3JbBLXSvMsypAf/ew6Xx/ayNtcxxDofvK9tRMnO0VkNHvZuVInHatApfSV9QqR+5XZid9vf1gO72JhO3K078L58pTOjQaGPqllZYYLeDEUJPbXwomMFcEXv0Xa1K+U5ogf6pucBeTLBUaEqidc1tVhzeYzwBghL9JYcaaGY5Pi//dWVs7V0dlRoUwZaezdu2J2Vy4gp2/ZFmEEdH1bTpC92+QhXToWZyxpDYpWgVvIYRodsTms18RbjcVRqv3n5oEMKiWuRH4O0N30u+Dwq3kQm39xTl7ddXdtsWcGJgXLnGZk78dWEB0kA== 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)(6916009)(6512007)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?ibs2yvo5fF4oJJwoqVQ43INbzHnRbXkmTg6Ylc0w9epclXQsUx/vxVH+I9Rr?= =?us-ascii?Q?Wog5TAwDsWYdAwEGqjUHaPb9iJHXJvNrKEt/4YILkzsw9hZfJOzmeRoTwpsG?= =?us-ascii?Q?MRMYmFd2Yk0fET1C9qJGbIMrKpUQP9IX66W6ub64vuGkGuL0b49//Y4m+xLe?= =?us-ascii?Q?uVGylZWmjbAMumx+2O1vG4WwukUuarwDIWuNlxsdDMd/nCFpNT7RbywjHJg5?= =?us-ascii?Q?JyYWW+jM9Dd0ujFSBG5ZmBh0LWcIf28NusO8tvle3Op6rxLv1zUXkDl9qAYS?= =?us-ascii?Q?UZKIVEmDS+4VzZ6TH7viNBpIbdi1R4Jzq0CMMNkyqQzwM8xg3pmMVY/ork2R?= =?us-ascii?Q?Fq3tFR1qrm0G8+nOBXmE2gKOn9GKVHJJnZHztva0ic+UlrQtrOjmkDselCCj?= =?us-ascii?Q?x2iN/S+i7jz0KdjQHXw6fhIUdT3OGfqYhCBehKPgAguluNTJ7hRtXeyow5a0?= =?us-ascii?Q?OZwLg9CWY298hNwi5ZOOJPO92iY582DYFRtedawCQQaOB6C3RMqqitbgeCZq?= =?us-ascii?Q?Qe+pvVonC17qdIbm3BHW48GZ9ndUfGF/zqFUXd8xcggD3B3LAchzBRJbT8jr?= =?us-ascii?Q?EZik1URFg1TxuSG61JFbXCyiFtJs15xlO+bYjgw/GAq0QSJmaDk0HtCp6OCt?= =?us-ascii?Q?cH3QOJ+VvKfEeeEfjXvjNHryEm72Y1O6K8cycC3KRNfhmb4G31WFgJA1ezvC?= =?us-ascii?Q?gbkFJ3TNTU/O++0FvgD6DBpF9H8SrNjLihHExeiSVX+BDUKvD/ZyqczDJJlR?= =?us-ascii?Q?wloXd/CQ+B9b3uYCIJPrnIkGH0CJ5YtxK0T7sZKm1QAhDl+b4QO7qkpad7Nr?= =?us-ascii?Q?RBnFuklG1J/1aIWyULsYihncj7TuBGK2N1XaonwndpJ0qj9KXv5WqGYpRA4Z?= =?us-ascii?Q?LTX4VAsidOc+XlNYvjN1qg2Fw9QHedGTFXqv/aGxCEx5VnelQ++hqU9xos5Z?= =?us-ascii?Q?wLUPakYoOyWEVUR6Zdq+9myNP7PxABiHVc1621a5Cs0Ls0fb16knLG3ax1Qq?= =?us-ascii?Q?fv0XkvymsJKU6x9B1ZSPlIWUP7NMXvec/kZmnsNy0xUWTNH7Mo2V1u0cJVhQ?= =?us-ascii?Q?kCcJRsZQF48t7PL9Mw0Dud93EykKPUpAziBq5IeFvqXUVFvbKzzOcxtZj+DP?= =?us-ascii?Q?IFfnyGedCIyCsx+h6Pjw7ISycYOmghvli0NtAAjaB4pR9UkcZFW2fx5pHv0j?= =?us-ascii?Q?K/sdgik52iqVMDAVMyYLO9czuuZwmmsJpwl3+zAZ/Wl7FBhYKO4Fp4s3HDmj?= =?us-ascii?Q?Udhg4lVYoEwnt9LmZ/3caAfYWI/esgVJYnHMvmlONXuH3UU6vReT+PjwUA0t?= =?us-ascii?Q?hNVABLml7M6A+XjYNJY/SEgpitUdwmm6MI2tsmfu5cFzLGmbBG9PAVPqrTtB?= =?us-ascii?Q?1bKIb1/fFEFwIY+b4aKzPSOhBagn?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: f721d1ad-d80b-41d2-0ac1-08d8dcc0e3e4 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:09.1138 (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: 8BF6ApS6Gkugl37t5o+AtRYYk3Hdaa/i9Zhe1uRG/txbpaKJUqtmI16+3/BT6c8uMCtXkm13sY8AatFza7PGnw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3676 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Mon, 01 Mar 2021 14:47:20 -0000 The next 4 patches are addressing the expectations of the existing function calback interface of the computed struct value objects. As mentioned in the previous patches the location description and the interaction with that location are opaque to the struct value object, but currently that interaction is influenced by the data contained inside of that object and outside of the location description class. Also, the struct value evaluation involves more then just writing or reading the object contents buffer, in certain cases it is also expected to throw an exception or mark different parts of the object with additional information (optimized out bitmap for example). As a result, reading the data from a struct value object and writing that data into the location described, can be different then just generic writing the data from a buffer (dwarf_location write method). To make this distinction clear a new read_from_gdb_value method is added to classes that derive from location description class. gdb/ChangeLog: * dwarf2/expr.c (dwarf_location::read_from_gdb_value): New method. (dwarf_composite::read_from_gdb_value): New method. --- gdb/dwarf2/expr.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index ff9c88087d8..10386cca858 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -455,6 +455,23 @@ class dwarf_location : public dwarf_entry (struct frame_info *frame, const struct property_addr_info *addr_info, struct type *type, size_t size = 0) const; +/* Read data from the VALUE contents to the location specified by the + location description. + + The read 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 read_from_gdb_value (struct frame_info *frame, + struct value *value, + int value_bit_offset, + LONGEST bits_to_skip, size_t bit_size, + size_t location_bit_limit); + protected: /* Architecture of the location. */ struct gdbarch *m_arch; @@ -507,6 +524,32 @@ dwarf_location::deref (struct frame_info *frame, return std::make_shared (read_buf.data (), type); } +void +dwarf_location::read_from_gdb_value (struct frame_info *frame, + struct value *value, + int value_bit_offset, + LONGEST bits_to_skip, size_t bit_size, + size_t location_bit_limit) +{ + int optimized, unavailable; + bool big_endian = type_byte_order (value_type (value)) == BFD_ENDIAN_BIG; + + this->write (frame, value_contents (value), value_bit_offset, + bit_size, bits_to_skip, location_bit_limit, + big_endian, &optimized, &unavailable); + + if (optimized) + throw_error (OPTIMIZED_OUT_ERROR, + _("Can't do read-modify-write to " + "update bitfield; containing word " + "has been optimized out")); + if (unavailable) + throw_error (NOT_AVAILABLE_ERROR, + _("Can't do read-modify-write to " + "update bitfield; containing word " + "is unavailable")); +} + /* Value entry found on a DWARF expression evaluation stack. */ class dwarf_value : public dwarf_entry @@ -1041,6 +1084,16 @@ class dwarf_implicit_pointer : public dwarf_location *unavailable = 0; } + /* Reading from and writing to an implicit pointer is not meaningful, + so we just skip them here. */ + void read_from_gdb_value (struct frame_info *frame, + struct value *value, int value_bit_offset, + LONGEST bits_to_skip, size_t bit_size, + size_t location_bit_limit) override + { + mark_value_bits_optimized_out (value, bits_to_skip, bit_size); + } + private: /* Per object file data of the implicit pointer. */ dwarf2_per_objfile *m_per_objfile; @@ -1118,6 +1171,11 @@ class dwarf_composite : public dwarf_location size_t location_bit_limit, bool big_endian, int *optimized, int *unavailable) const override; + void read_from_gdb_value (struct frame_info *frame, + struct value *value, int value_bit_offset, + LONGEST bits_to_skip, size_t bit_size, + size_t location_bit_limit) override; + private: /* Composite piece that contains a piece location description and it's size. */ @@ -1229,6 +1287,50 @@ dwarf_composite::write (struct frame_info *frame, const gdb_byte *buf, } } +void +dwarf_composite::read_from_gdb_value (struct frame_info *frame, + struct value *value, + int value_bit_offset, + LONGEST bits_to_skip, size_t bit_size, + size_t location_bit_limit) +{ + 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].m_size; + + if (total_bits_to_skip < piece_bit_size) + break; + + total_bits_to_skip -= piece_bit_size; + } + + for (; i < pieces_num; i++) + { + auto location = m_pieces[i].m_location; + ULONGEST piece_bit_size = m_pieces[i].m_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->read_from_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