From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2055.outbound.protection.outlook.com [40.107.220.55]) by sourceware.org (Postfix) with ESMTPS id 6C046385803B for ; Fri, 5 Nov 2021 11:39:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6C046385803B ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XgeUUfmAhNI61kFSkv0xbH/F5vDijQM2ra4c9JeLyLY9gpHOvEnc+hJgSJRfOb4RNVi2Ln2cpKdRKIcv1nwq21szJQdt4ngJrtlrgCtMgv113Hfi948wayyNmULVZOPfjSWgNeCw3cbqCUUfw3xiBBHecgLSreOyY8WTdpqdBetWCxsG3u1NuiFeUfzl7Y/rSJOL4Cc5e1uA35nM908TG4yRMt4eY+NOCiQoTo5cYj0SLL/PYCVhSKmxwbbS04FSNmx4GxyGQNXV6EnC4u9KqHLq4DbFf8vBgemiwD/KselO2CWUFZLFeYFh+/ImHtJi6y43ip6e3JkKMuNyOCBhwA== 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=ob2gHczecX8FQnN0IWrAN4LMgr7EWCh9i48FDjWN9pg=; b=K11V11qau1OocQldXRn/OGpVbbkbb1/Ig6lDcqqdxg+RGLw5YC/8EXMjQbpWcqFhTqAvmN28wqmlsOx6kpCfrFHg2qrHO/OnXldDaPJKOzevktAxQ4BpgHXs69uxpQMlj4MTDdMUId+6L0jw6+2a63mQehizas/2s5p7Ls9LWMFypTMTWZb+LTKAla+ToyVqAk0encWThcXU61S61fZoIXvgrgB6WaX2bV0hSnvdwu60ncV4jEcV3Mnps6PAYfBsdc0GkIqR5nSFSPQsUfv3mT5DVpUxiZ/+IvRV+Pa8TK8/bFe7iCU5RZh/OtRMDkyqig0Gb+njbEk+uoAAysEC8A== 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 MW4PR04CA0152.namprd04.prod.outlook.com (2603:10b6:303:85::7) by CH2PR12MB4199.namprd12.prod.outlook.com (2603:10b6:610:a7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10; Fri, 5 Nov 2021 11:39:18 +0000 Received: from CO1NAM11FT047.eop-nam11.prod.protection.outlook.com (2603:10b6:303:85:cafe::24) by MW4PR04CA0152.outlook.office365.com (2603:10b6:303:85::7) 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:18 +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:17 +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:13 -0500 From: Zoran Zaric To: Subject: [PATCH v4 09/28] Add read_from_gdb_value method to dwarf_location Date: Fri, 5 Nov 2021 11:38:30 +0000 Message-ID: <20211105113849.118800-10-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: 502327f0-4dd4-4682-f524-08d9a050e6ba X-MS-TrafficTypeDiagnostic: CH2PR12MB4199: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WhZVKvONTYEEcP/8DBDVf+A/0aW+6bezifD47/63buynfHBWVBf9zVLXY+Izlp51TiOVYUXSoXtQ8xgw2E8OYZriN3yebE74oYND13v3PZZc78NfL2Hl0IbiPj0e4sPrtlkbUBl6D8OAlbfgVbo8mHoMrZbkvN4IBfBaMmQvgut6HzDOGXejfJvwYJKLF7bj5/+4+CqK01DO54t4Hvk8bf6onvnCq8XGCzUjUEp/lR0DnJVJAAy3de26jg3NNWuGG9e5hPJMvA/Fxtne3694e5azwW2T3h92/0axHaJi1//MPPgYLY0eqgGBYwqHXZcFxhBIOLFszVtsTFY3/tJT4P0wrhOLRIUjZwfRfRnMUmBXSpYakRJ6KyxEOQUNAwSm3i/vaNB623J5AJspoeh6vl+elIiFuagyT6/jIfq5t3SPcjuupsv1lvL9Vr7dLC7UgCNeo/buIJSyVo0fMDoeWg9KpYB1vvuWSD8a9a4scrj9jpFApOLbkOd+PJomyvSrh56mplUF2+n8VDe4Ion7F1rNHR3542xuI4kXJbqa9gteePkLcbM3L8omKiMp8CoSJOPV5CB7+FPVxwzGtEqlu8LcSxqMzUGMHSjHPVd6/EmMJIiUZ/cVMFwS0uSB7YddHLJF8ZwzfX025yKDE+Igu9C3yh2xGbMjYe1RvY+FAKfFUDp9FYXXqzuuVhdpFaLT1fIhTKPa4PXfKPyX9ucf+80mFONizbEWzmYXRNpeV5A= 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)(356005)(8676002)(26005)(70206006)(16526019)(186003)(81166007)(83380400001)(508600001)(8936002)(6666004)(1076003)(47076005)(4326008)(36860700001)(2616005)(336012)(426003)(5660300002)(316002)(82310400003)(44832011)(36756003)(70586007)(6916009)(2906002)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2021 11:39:17.6776 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 502327f0-4dd4-4682-f524-08d9a050e6ba 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: CH2PR12MB4199 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 The few 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 | 99 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index 87a8b87eee7..e79d57fbfd4 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -425,6 +425,22 @@ class dwarf_location : public dwarf_entry (frame_info *frame, const 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 (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; @@ -442,6 +458,31 @@ class dwarf_location : public dwarf_entry using dwarf_location_up = std::unique_ptr; +void +dwarf_location::read_from_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->write (frame, value_contents (value).data (), 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 final : public dwarf_entry @@ -996,6 +1037,16 @@ class dwarf_implicit_pointer final : 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 (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 + { + 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; @@ -1072,6 +1123,11 @@ class dwarf_composite final : public dwarf_location size_t location_bit_limit, bool big_endian, int *optimized, int *unavailable) const override; + void read_from_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. */ @@ -1182,6 +1238,49 @@ dwarf_composite::write (frame_info *frame, const gdb_byte *buf, } } +void +dwarf_composite::read_from_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.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