From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2056.outbound.protection.outlook.com [40.107.243.56]) by sourceware.org (Postfix) with ESMTPS id 95917385802E for ; Thu, 14 Oct 2021 09:33:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 95917385802E ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oDr3PfXRuO9ZdPZr2W4wTlH77EFpMAhjrwHCyE3q2GOzNgarEEaP5JYb8n0ZUIlBd5FtCszdJhnZx7Pam3xmRwULgwnyhSLH0+iBI/c7Mxi914bdj4IXO6EcsrtmaLK69QWSJ09ZgTa94/3qvTntsFjU0WQKk62Dz1VU+/L0+Z8UoovsVSutzlyoo/IQ76Hrc4T9prxfUEcrSrK5IXgZXqqZytkG2iqrOW1vgDGzlzMIFKIm6P5oQada/0Yz2KIP57SbaiomD+F3hjU0QNvvqZNEhtINDo/+8+1VrWM0JsiWlrkfAVEFGZ2K168N7hXoZ1m+0o6cjT67FhXcFfxX9Q== 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=YDSMfPrlrYGn5msWUMLByuYIb2lmmtuqYTV+LlLnMus=; b=JTugfF1lDU1jT4j+MAhc6O10WZKAMRFjKWuxTZFMjFUombIUvrl/ZvYNnQa0nZVpDtmQlFjfYMOgWZcD25SANH8pAdyDeQek8jQiuFdEumwQsfk7xaoHQ2CEcSav8AbEaKZPuJQcuDwn4TfrewH5LccnNKvdYhwETUX3W2ZE709KLhanGXS9L8+rL5fMeWh1XT14RsuXUAHUX5C4ppGSgpFAtDepUdqi/Z0HXa0NJidlOXxsDMwaNzrsy5v4LEpOxPA9FNjJddkdiltH0RZ/QvDWTBPFGN7djxxEP87IkZqIYibXGkTWV7UuKfuZ1ucqDTYG7AkpX5HEAncSssGidQ== 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 DM5PR13CA0025.namprd13.prod.outlook.com (2603:10b6:3:7b::11) by DM6PR12MB3034.namprd12.prod.outlook.com (2603:10b6:5:3e::17) 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:12 +0000 Received: from DM6NAM11FT047.eop-nam11.prod.protection.outlook.com (2603:10b6:3:7b:cafe::bc) by DM5PR13CA0025.outlook.office365.com (2603:10b6:3:7b::11) 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:12 +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:11 +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:08 -0500 From: Zoran Zaric To: Subject: [PATCH v3 13/28] Add is_optimized_out to dwarf_location class Date: Thu, 14 Oct 2021 10:32:20 +0100 Message-ID: <20211014093235.69756-14-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: c05c27f5-f699-46bd-df34-08d98ef5a3d0 X-MS-TrafficTypeDiagnostic: DM6PR12MB3034: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1QVNGh+988TH1ffq9j7A2ENxNNQJkpLoXAvy9l4yGCc9jgjAgFJdGGtijUb8JhRYYU0vUi89QzLoevs4zEtqzw7k15Py96+9ph3MyS60c9b1lFgVUO30bXZimGUJE2GUtegdUok89LHIgT0UXzFmc6SgO76JeussdYJTeAGaQ3+b68aXgG4GyEPR6sOz1B86ipSEPQDPj393O7mJs4FeVrbFhTRfshfMILADx7wduLL33dA/nBukCzP922CAW+bxx50AXzWZaNeFjpEv+rIKyBbn5jrUxQ6/KQEJRRZXqpPnCvP4+7mNaBsCC0a7NYPHk4URgKT0P0aRewRHYyVoQ2GUmkUM5CCXdeKG/Cb+SeqHTyDEW1dAx3aHk1vROCd5XlNYOxw9ohCSUb+OBX6HghwXNYY4/IID3oOV/bzTdDOXkRxap/j3m4fBLnEmjDn50FQZ9BBbed6aT9Q5Dsw9Dm5KLtMhpPS5BV9zOmJWZa3Eg1nyzKDl+mq1vDwFtLTijpV2Ye33iGeYlUGYMe0LNwINxwIAXRS6dvnGI8y92T119k/rLm1JDXwJ5O2F0x2spXykn75VupG46/nk0puVEoaq9E5I4+bVixqCAfFlt7KsODYVtMzSZPQ1xHcooQlXmwlRwMt3mkORkMaY87M7P7ebGsTIecl/K7XLN2yx65TgHPFtlTg2oskwPrjS47iPLaAG8nVT7wfugRlzzviWBw2FGHTSieiIxPDc64EVB1w= 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)(46966006)(36840700001)(316002)(8676002)(16526019)(4326008)(86362001)(2616005)(5660300002)(47076005)(356005)(82310400003)(70586007)(36860700001)(44832011)(6666004)(83380400001)(81166007)(508600001)(1076003)(6916009)(336012)(186003)(8936002)(36756003)(70206006)(426003)(2906002)(26005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2021 09:33:11.5333 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c05c27f5-f699-46bd-df34-08d98ef5a3d0 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: DM6PR12MB3034 X-Spam-Status: No, score=-11.9 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, T_FILL_THIS_FORM_SHORT 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:15 -0000 Similarly to the is_implicit_ptr_at method, the existing function callback interface of the computed struct value, requiers a way to check if the underlying location description describes any part as optimized out. gdb/ChangeLog: * dwarf2/expr.c (dwarf_location::is_optimized_out): New method. (dwarf_implicit::is_optimized_out): New method. (dwarf_register::is_optimized_out): New method. (dwarf_composite::is_optimized_out): New method. --- gdb/dwarf2/expr.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index af84710b054..1b6622d5f59 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -492,6 +492,21 @@ class dwarf_location : public dwarf_entry return nullptr; } + /* Check if location description resolves into optimized out. + + The check operation is performed in the context of a FRAME. + BIG_ENDIAN defines the endianness of the target, BIT_SIZE is the + number of bits to read 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. */ + virtual bool is_optimized_out (frame_info *frame, bool big_endian, + LONGEST bits_to_skip, size_t bit_size, + size_t location_bit_limit) const + { + return false; + } + protected: /* Architecture of the location. */ gdbarch *m_arch; @@ -666,6 +681,13 @@ class dwarf_undefined final : public dwarf_location *unavailable = 0; *optimized = 1; } + + bool is_optimized_out (frame_info *frame, bool big_endian, + LONGEST bits_to_skip, size_t bit_size, + size_t location_bit_limit) const override + { + return true; + } }; class dwarf_memory final : public dwarf_location @@ -904,6 +926,10 @@ class dwarf_register final : public dwarf_location size_t location_bit_limit, bool big_endian, int *optimized, int *unavailable) const override; + bool is_optimized_out (frame_info *frame, bool big_endian, + LONGEST bits_to_skip, size_t bit_size, + size_t location_bit_limit) const override; + private: /* DWARF register number. */ unsigned int m_regnum; @@ -997,6 +1023,24 @@ dwarf_register::write (frame_info *frame, const gdb_byte *buf, temp_buf, optimized, unavailable); } +bool +dwarf_register::is_optimized_out (frame_info *frame, bool big_endian, + LONGEST bits_to_skip, size_t bit_size, + size_t location_bit_limit) const +{ + int optimized, unavailable; + gdb::byte_vector temp_buf (bit_size); + + this->read (frame, temp_buf.data (), 0, bit_size, + bits_to_skip, location_bit_limit, + big_endian, &optimized, &unavailable); + + if (optimized) + return true; + + return false; +} + /* Implicit location description entry. Describes a location description not found on the target but instead saved in a gdb-allocated buffer. */ @@ -1025,6 +1069,13 @@ class dwarf_implicit final : public dwarf_location *unavailable = 0; } + bool is_optimized_out (frame_info *frame, bool big_endian, + LONGEST bits_to_skip, size_t bit_size, + size_t location_bit_limit) const override + { + return true; + } + private: /* Implicit location contents as a stream of bytes in target byte-order. */ gdb::byte_vector m_contents; @@ -1230,6 +1281,10 @@ class dwarf_composite final : public dwarf_location LONGEST bit_offset = 0, int bit_length = 0) const override; + bool is_optimized_out (frame_info *frame, bool big_endian, + 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. */ @@ -1497,6 +1552,48 @@ dwarf_composite::indirect_implicit_ptr (frame_info *frame, struct type *type, return nullptr; } +bool +dwarf_composite::is_optimized_out (frame_info *frame, bool big_endian, + 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; + 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; + + if (location.is_optimized_out (frame, big_endian, total_bits_to_skip, + this_bit_size, piece_bit_size)) + return true; + + remaining_bit_size -= this_bit_size; + total_bits_to_skip = 0; + } + + return false; +} + struct piece_closure { /* Reference count. */ -- 2.17.1