From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2043.outbound.protection.outlook.com [40.107.212.43]) by sourceware.org (Postfix) with ESMTPS id A0C7F3857C5E for ; Fri, 5 Nov 2021 11:39:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A0C7F3857C5E ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RF1fja4vW2/JvAVF64zK88EP70lIVGEmKDwNOx/5Aex7bTgTm+rMGjSjcr3v7r4a6bIiEGDOMdGieovQIoe/OxUD/z7/ZZ2eye7++lQvUIyA6WBFw1GwoL7mx8JgxIpMAVjvNReHdTVxf0w6tYbMeMrYwMV+0cQzxcliOn9SwBu6HNHb5GhvY8uhZPmrSY71NqyrqMueJozKDjS5YfGoiM7OWjlIUCsgXXEbEoD2iUwCENWmlcYsC8buBS+cA9jC+9Q0oYXoaw84MVWxEENovQiRaHvS9UFqht3bRMB6XoKTDJmoKSlTE5NJw9sCNrk3jRTkbPNc71LbphjB33CHyA== 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=qyZMuNq56UyvJBOCP03oac/inZKHZ8aCP5PCTK5DSxc=; b=g/sS1Dbyi+RalYN+6Ah8gLm3oNSK70Mo2F0bff8Vh9zB+tDPr6uuOGSfByugAJC10CLeGQ5f1NFymC4kCg/8Qdl5FSyXdq7gEtGtEXpZwoaoAhWIYUKxiYGDdy9olVbE8pG5dUtxn+JiJxsRNzw+ksqpUXfnuep+QOFw7uK+LoWMIoUkzpXfNtXTahvXlOm3cOvzB1/AjA55Ka8tB/D5gEQM94RkM+UQqi1Iwsv7Q/tNqc4KBF8UOUh6ouTbG6cWoUmX10uWqmf+TRUU5VqalKPFwmPLkbm81wFVeKMAnTEdvMIX3U1jNbCe51RgjknjRT+WAsjiFneGqDQFgdHqaA== 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 MW2PR16CA0036.namprd16.prod.outlook.com (2603:10b6:907::49) by DM6PR12MB3354.namprd12.prod.outlook.com (2603:10b6:5:11f::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.17; Fri, 5 Nov 2021 11:39:22 +0000 Received: from CO1NAM11FT042.eop-nam11.prod.protection.outlook.com (2603:10b6:907:0:cafe::7a) by MW2PR16CA0036.outlook.office365.com (2603:10b6:907::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Fri, 5 Nov 2021 11:39:22 +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 CO1NAM11FT042.mail.protection.outlook.com (10.13.174.250) 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:20 +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:17 -0500 From: Zoran Zaric To: Subject: [PATCH v4 13/28] Add is_optimized_out to dwarf_location class Date: Fri, 5 Nov 2021 11:38:34 +0000 Message-ID: <20211105113849.118800-14-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: 5d343e40-13de-4b35-877d-08d9a050e86b X-MS-TrafficTypeDiagnostic: DM6PR12MB3354: 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: rDu+D7n4d9JzHsNfIAQ0wl919hmfkCZ0VFsKmvHT7yTQS50/SqteBI3C6U0Yj0cEZhRjybZ0dQWWSVceuTkNok8MIaNStoIs7PqJa50ZzPMIMEw+yB7DTW2VvJOtuJsaZyk0T7zVd2+3JKFG93DrMKwo2PkEn2ZfAGHjBaxWM3Xbh1mQWmmAyHwbi4M72YdBlkAF4J81lKlsvBhXrgPTC/VBfVvMhRii+FPXcQqYv+21nY9NkcU6iqejrdKE7BdYQgchQbsPCr0kRhpdUCs3u3naeDpj9eoPjavzPWvRSLpESFLstmr7wAJwfq1S4UwEzibK6jWEW8XZkfL8cgRtYOaoukCtJDJuddJiX5yPgPP89pQLUS6mhIicjKY5NVgKsK9a+ehqeMOnUks0gADH7RBif5wvNwQ+pqIwPiD6eUCTILqZQegoGh2ZN78LC4IZPeqDPzHnesT8KqZRlgFxeezx5LkjB9DyXvq9gE+UaIlZ3rHS6TR71NaA2FaFFXW0EmYPYPiJ3IcHUi4LBW5catgfvjFn/XQbcAYQDCsy/UYosoA1hz3P7zv4awobwcWwgS+C6IAAiPWsx9Zf3w+rFcLYdaQKo6Zv0WmgzK4JULuPAcin35Oe/P7eBxIZGtTOb5YClVv78Le9c4Rm9gFv3fIYXBgahDJAlkO7Zy773Lb5oYHGexaZmJzGfIvXnWvYQEVPoI39T4uq35ragiKXJXu3kmNpYjeWlGHMIE44Y4U= 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)(426003)(336012)(8676002)(1076003)(6666004)(36860700001)(2906002)(47076005)(316002)(86362001)(2616005)(82310400003)(8936002)(186003)(4326008)(16526019)(26005)(356005)(5660300002)(6916009)(44832011)(70206006)(83380400001)(81166007)(70586007)(36756003)(508600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2021 11:39:20.5185 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5d343e40-13de-4b35-877d-08d9a050e86b 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: CO1NAM11FT042.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3354 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, 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: Fri, 05 Nov 2021 11:39:26 -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 185324f1d2d..a16c53377b7 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -483,6 +483,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; @@ -662,6 +677,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 @@ -902,6 +924,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; @@ -995,6 +1021,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. */ @@ -1023,6 +1067,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; @@ -1228,6 +1279,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. */ @@ -1495,6 +1550,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