From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2058.outbound.protection.outlook.com [40.107.94.58]) by sourceware.org (Postfix) with ESMTPS id DE6223858411 for ; Fri, 5 Nov 2021 11:39:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DE6223858411 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IJHo6G/XF6AsuoCX4SMOo38uAeYNwlEr3KhHY2mKNMlwvvo9rdAz6LybbZ6obcz4EyAUooe8wrI3/DWib+HFR9gO1+A5yKwR+pY3g+Qoh0iN5UmzUhiHm2rAIEFsfZB7e6RKc9/LswLCgU+lslNnvb+542XYeV7uH167hjGtwlg2lCpq4XpYO1noH/sqmoSRoRQ7XdEXRoJEHAIehNSTHougO9igsPIsa8qx7hXFlm2LLlIL0xkCYFwliT92lvmS0klrdZdzXKZnulNpKvmN1IvUsDceEgGOd7FunDz1nFmyKhVBBzg0VN/w4cR/6tDH3Uc78pNyrBlfgXooALUPOQ== 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=idcI1rxDJFTJkXt9dBnzu112c5Bo5lyMRCK5/eL2ta4=; b=mSY2+Up6OanSoH9hGNaMbhcNyskbA/+C9FfTgSIMK9yGw21s8ePWibeMYlaBx03bDHHI1zX7t9LHom2vdIPRJwjkSH9FJnnXwuWudgxvIzM3VfuEphhDaMbiOTlUVIQ9cgQEo32fmWUMUdm0f9715b3KcnsOEL+P0psL5kKwk+aRyCrKbUAQhor64qF+ZXXDfJVN5UgCTRYr0WwooTyiQ+oyBvIxckLnzDdD0q/X0tUINfytw0TmsV3lPg50suX3XKUN2QBwziI7MkxQWfqHp9csp/4CFhZz0oyqvQ04TMTB/G/RzdBZT0Vto7j4LBlPqm547CzAVlCQZWfVD9dziQ== 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 MW4PR04CA0171.namprd04.prod.outlook.com (2603:10b6:303:85::26) by MWHPR1201MB0207.namprd12.prod.outlook.com (2603:10b6:301:4d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.11; Fri, 5 Nov 2021 11:39:20 +0000 Received: from CO1NAM11FT047.eop-nam11.prod.protection.outlook.com (2603:10b6:303:85:cafe::d7) by MW4PR04CA0171.outlook.office365.com (2603:10b6:303:85::26) 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:20 +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:19 +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:15 -0500 From: Zoran Zaric To: Subject: [PATCH v4 11/28] Add is_implicit_ptr_at method to dwarf_location Date: Fri, 5 Nov 2021 11:38:32 +0000 Message-ID: <20211105113849.118800-12-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: 81a96b13-d82f-4cc8-5cb8-08d9a050e7d0 X-MS-TrafficTypeDiagnostic: MWHPR1201MB0207: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CdHf5xlMbilA9BqhvHxBVZPmsG6thbINupgc/VovpqlefhG6r9kDxcuJMmcq5TseYJqSad6MXM3HutBoG/O03zt3GBlGSDJ75Cj5vhSDvcQVPZL/aW0oR9xR4QxWJfyUpz4VVS9Ih3ZEPhq4tOStL9gWgRjIFb6HVAPVW1R53IsYEiLzHhII14hWGJUkSEZ3D+q2e2yb4ZfZJJOi4miRCQ2oPByT/JwdznT2wx+o1XOyk5Le1mCjXPovZJEdEPdlntKERFe5jeLXlcJMZAypTI/vi7Ou2hStkLmvS1dWQXlwdoUKPclalPw0Ad6dxyejYHbXgeSK1Ux3r3021QGTVuj1rfZdUSuZCHXIIQB3pJy7Zfv/wLHUzDnbbzZgBxUZs4mEaYanbIpJYZkQjnb78K4fwhrhRZikfH/BI0pxUDqoYdO+8dGEnnQYjBSCIhqJ//C6Y0i3pE7WpJw1isBtckGsAaBozTetYM1T2t30fWg2kQKKHmRg6RyZ01aJsM4K7t6ABe4B+ine51m//z2othkGPdWHroFDtgyrY8LycEycz52fPHlOnyJowAskhnralzFNOud9srcneZAOx03RhxOEuV8BVPigpAdgVQZQ2FQnAfsOh4kZ3pjLpKCO/6NjuU7/t1YBb3x5CdJHcmUeAvImMM2eHnI3AVJ/5N0xFpl6djyyUGj6Gf/FHNcXUVmChg9bgnmG93AufNqiDy2yWUQRvz2nvDq3a9GwfAfBaLE= 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)(6666004)(86362001)(44832011)(83380400001)(316002)(82310400003)(508600001)(70586007)(8676002)(36756003)(4326008)(81166007)(2616005)(1076003)(26005)(36860700001)(426003)(6916009)(336012)(5660300002)(16526019)(8936002)(356005)(70206006)(186003)(2906002)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2021 11:39:19.4966 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 81a96b13-d82f-4cc8-5cb8-08d9a050e7d0 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: MWHPR1201MB0207 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:25 -0000 From: Zoran Zaric Another expectation of the existing function callback interface of the computed struct value is to check if a specific part (on a given offset of a given length) of an underlying location description is an implicit pointer location description. To satisfy this expectation a new is_implicit_ptr_at has been added. gdb/ChangeLog: * dwarf2/expr.c (dwarf_location::is_implicit_ptr_at): New method. (dwarf_implicit_pointer::is_implicit_ptr_at): New method. (dwarf_composite::is_implicit_ptr_at): New method. --- gdb/dwarf2/expr.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index b2fb0099b0e..a933ca2797d 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -457,6 +457,14 @@ class dwarf_location : public dwarf_entry LONGEST bits_to_skip, size_t bit_size, size_t location_bit_limit) const; + /* Check if a given DWARF location description contains an implicit + pointer location description of a BIT_LENGTH size on a given + BIT_OFFSET offset. */ + virtual bool is_implicit_ptr_at (LONGEST bit_offset, int bit_length) const + { + return false; + } + protected: /* Architecture of the location. */ gdbarch *m_arch; @@ -1088,6 +1096,11 @@ class dwarf_implicit_pointer final : public dwarf_location size_t location_bit_limit) const override {} + bool is_implicit_ptr_at (LONGEST bit_offset, int bit_length) const override + { + return true; + } + private: /* Per object file data of the implicit pointer. */ dwarf2_per_objfile *m_per_objfile; @@ -1174,6 +1187,8 @@ class dwarf_composite final : public dwarf_location LONGEST bits_to_skip, size_t bit_size, size_t location_bit_limit) const override; + bool is_implicit_ptr_at (LONGEST bit_offset, int bit_length) const override; + private: /* Composite piece that contains a piece location description and it's size. */ @@ -1370,6 +1385,43 @@ dwarf_composite::write_to_gdb_value (frame_info *frame, struct value *value, } } +bool +dwarf_composite::is_implicit_ptr_at (LONGEST bit_offset, int bit_length) const +{ + /* Advance to the first non-skipped piece. */ + unsigned int pieces_num = m_pieces.size (); + LONGEST total_bit_offset = bit_offset; + LONGEST total_bit_length = bit_length; + + total_bit_offset += HOST_CHAR_BIT * m_offset + m_bit_suboffset; + + for (unsigned int i = 0; i < pieces_num && total_bit_length != 0; i++) + { + const piece &piece = m_pieces[i]; + ULONGEST read_bit_length = piece.size; + + if (total_bit_offset >= read_bit_length) + { + total_bit_offset -= read_bit_length; + continue; + } + + read_bit_length -= total_bit_offset; + + if (total_bit_length < read_bit_length) + read_bit_length = total_bit_length; + + if (piece.location->is_implicit_ptr_at (total_bit_offset, + read_bit_length)) + return true; + + total_bit_offset = 0; + total_bit_length -= read_bit_length; + } + + return false; +} + struct piece_closure { /* Reference count. */ -- 2.17.1