From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from progateway7-pub.mail.pro1.eigbox.com (gproxy5-pub.mail.unifiedlayer.com [67.222.38.55]) by sourceware.org (Postfix) with ESMTPS id B34F63858D3C for ; Wed, 20 Apr 2022 04:29:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B34F63858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id E0FAA10047817 for ; Wed, 20 Apr 2022 04:29:08 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id h1xkndHcm53CXh1xknL40f; Wed, 20 Apr 2022 04:29:08 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=OPfiYQWB c=1 sm=1 tr=0 ts=625f8c14 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=z0gMJWrwH1QA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=mDV3o1hIAAAA:8 a=x8ksNq88E6SrOw4axggA:9 a=_FVE-zBwftR9WsbkzFJk:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=AfbPL4aD7VkCYTOM8leW/4a39YuQ0NtsR4BcxGjj3IU=; b=aFepgLYs/85IB/m3DZqONt3RiF DTkPloidGNXkggoWAlzFx046mZvW1MHtfqklkI4ZoZqXMjpCctMfB1FkCv/d6cJY0zRa2bJu5Qx0E J5q+x0ZqsVWAf8Sqoqlb1Ruep; Received: from 71-211-154-204.hlrn.qwest.net ([71.211.154.204]:45552 helo=prentzel.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nh1xk-002pFS-6i; Tue, 19 Apr 2022 22:29:08 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/9] Move mapped_index_base to new header file Date: Tue, 19 Apr 2022 22:28:58 -0600 Message-Id: <20220420042906.1973648-2-tom@tromey.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420042906.1973648-1-tom@tromey.com> References: <20220420042906.1973648-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.154.204 X-Source-L: No X-Exim-ID: 1nh1xk-002pFS-6i X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-154-204.hlrn.qwest.net (prentzel.Home) [71.211.154.204]:45552 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3029.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: Wed, 20 Apr 2022 04:29:11 -0000 This moves mapped_index_base and the helper struct name_component to a new header file in gdb/dwarf2/. --- gdb/dwarf2/mapped-index.h | 97 +++++++++++++++++++++++++++++++++++++++ gdb/dwarf2/read.c | 72 ----------------------------- gdb/dwarf2/read.h | 1 + 3 files changed, 98 insertions(+), 72 deletions(-) create mode 100644 gdb/dwarf2/mapped-index.h diff --git a/gdb/dwarf2/mapped-index.h b/gdb/dwarf2/mapped-index.h new file mode 100644 index 00000000000..c2ff27ac4f5 --- /dev/null +++ b/gdb/dwarf2/mapped-index.h @@ -0,0 +1,97 @@ +/* Base class for mapped indices + + Copyright (C) 2021 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef GDB_DWARF2_MAPPED_INDEX_H +#define GDB_DWARF2_MAPPED_INDEX_H + +#include "language.h" + +/* An index into a (C++) symbol name component in a symbol name as + recorded in the mapped_index's symbol table. For each C++ symbol + in the symbol table, we record one entry for the start of each + component in the symbol in a table of name components, and then + sort the table, in order to be able to binary search symbol names, + ignoring leading namespaces, both completion and regular look up. + For example, for symbol "A::B::C", we'll have an entry that points + to "A::B::C", another that points to "B::C", and another for "C". + Note that function symbols in GDB index have no parameter + information, just the function/method names. You can convert a + name_component to a "const char *" using the + 'mapped_index::symbol_name_at(offset_type)' method. */ + +struct name_component +{ + /* Offset in the symbol name where the component starts. Stored as + a (32-bit) offset instead of a pointer to save memory and improve + locality on 64-bit architectures. */ + offset_type name_offset; + + /* The symbol's index in the symbol and constant pool tables of a + mapped_index. */ + offset_type idx; +}; + +/* Base class containing bits shared by both .gdb_index and + .debug_name indexes. */ + +struct mapped_index_base +{ + mapped_index_base () = default; + DISABLE_COPY_AND_ASSIGN (mapped_index_base); + + /* The name_component table (a sorted vector). See name_component's + description above. */ + std::vector name_components; + + /* How NAME_COMPONENTS is sorted. */ + enum case_sensitivity name_components_casing; + + /* Return the number of names in the symbol table. */ + virtual size_t symbol_name_count () const = 0; + + /* Get the name of the symbol at IDX in the symbol table. */ + virtual const char *symbol_name_at + (offset_type idx, dwarf2_per_objfile *per_objfile) const = 0; + + /* Return whether the name at IDX in the symbol table should be + ignored. */ + virtual bool symbol_name_slot_invalid (offset_type idx) const + { + return false; + } + + /* Build the symbol name component sorted vector, if we haven't + yet. */ + void build_name_components (dwarf2_per_objfile *per_objfile); + + /* Returns the lower (inclusive) and upper (exclusive) bounds of the + possible matches for LN_NO_PARAMS in the name component + vector. */ + std::pair::const_iterator, + std::vector::const_iterator> + find_name_components_bounds (const lookup_name_info &ln_no_params, + enum language lang, + dwarf2_per_objfile *per_objfile) const; + + /* Prevent deleting/destroying via a base class pointer. */ +protected: + ~mapped_index_base() = default; +}; + +#endif /* GDB_DWARF2_MAPPED_INDEX_H */ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 6dcd446e5f4..3f44c72565b 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -156,78 +156,6 @@ static int dwarf2_loclist_block_index; /* Size of .debug_rnglists section header for 64-bit DWARF format. */ #define RNGLIST_HEADER_SIZE64 20 -/* An index into a (C++) symbol name component in a symbol name as - recorded in the mapped_index's symbol table. For each C++ symbol - in the symbol table, we record one entry for the start of each - component in the symbol in a table of name components, and then - sort the table, in order to be able to binary search symbol names, - ignoring leading namespaces, both completion and regular look up. - For example, for symbol "A::B::C", we'll have an entry that points - to "A::B::C", another that points to "B::C", and another for "C". - Note that function symbols in GDB index have no parameter - information, just the function/method names. You can convert a - name_component to a "const char *" using the - 'mapped_index::symbol_name_at(offset_type)' method. */ - -struct name_component -{ - /* Offset in the symbol name where the component starts. Stored as - a (32-bit) offset instead of a pointer to save memory and improve - locality on 64-bit architectures. */ - offset_type name_offset; - - /* The symbol's index in the symbol and constant pool tables of a - mapped_index. */ - offset_type idx; -}; - -/* Base class containing bits shared by both .gdb_index and - .debug_name indexes. */ - -struct mapped_index_base -{ - mapped_index_base () = default; - DISABLE_COPY_AND_ASSIGN (mapped_index_base); - - /* The name_component table (a sorted vector). See name_component's - description above. */ - std::vector name_components; - - /* How NAME_COMPONENTS is sorted. */ - enum case_sensitivity name_components_casing; - - /* Return the number of names in the symbol table. */ - virtual size_t symbol_name_count () const = 0; - - /* Get the name of the symbol at IDX in the symbol table. */ - virtual const char *symbol_name_at - (offset_type idx, dwarf2_per_objfile *per_objfile) const = 0; - - /* Return whether the name at IDX in the symbol table should be - ignored. */ - virtual bool symbol_name_slot_invalid (offset_type idx) const - { - return false; - } - - /* Build the symbol name component sorted vector, if we haven't - yet. */ - void build_name_components (dwarf2_per_objfile *per_objfile); - - /* Returns the lower (inclusive) and upper (exclusive) bounds of the - possible matches for LN_NO_PARAMS in the name component - vector. */ - std::pair::const_iterator, - std::vector::const_iterator> - find_name_components_bounds (const lookup_name_info &ln_no_params, - enum language lang, - dwarf2_per_objfile *per_objfile) const; - - /* Prevent deleting/destroying via a base class pointer. */ -protected: - ~mapped_index_base() = default; -}; - /* This is a view into the index that converts from bytes to an offset_type, and allows indexing. Unaligned bytes are specifically allowed here, and handled via unpacking. */ diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index be3b9d19601..f3b09c63b64 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -26,6 +26,7 @@ #include "dwarf2/cooked-index.h" #include "dwarf2/file-and-dir.h" #include "dwarf2/index-cache.h" +#include "dwarf2/mapped-index.h" #include "dwarf2/section.h" #include "filename-seen-cache.h" #include "gdbsupport/gdb_obstack.h" -- 2.34.1