From patchwork Fri Nov 9 02:28:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Seitz X-Patchwork-Id: 30087 Received: (qmail 86069 invoked by alias); 9 Nov 2018 02:28:54 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 86018 invoked by uid 89); 9 Nov 2018 02:28:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=23712, keith, expandable, Keith X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 09 Nov 2018 02:28:51 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 10AA02D803 for ; Fri, 9 Nov 2018 02:28:50 +0000 (UTC) Received: from theo.uglyboxes.com.com (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA8AE5D783 for ; Fri, 9 Nov 2018 02:28:49 +0000 (UTC) From: Keith Seitz To: gdb-patches@sourceware.org Subject: [PATCH 3/5] gdb/23712: Cleanup/Remove temporary dictionary functions Date: Thu, 8 Nov 2018 18:28:45 -0800 Message-Id: <20181109022847.32049-3-keiths@redhat.com> In-Reply-To: <20181109022847.32049-1-keiths@redhat.com> References: <20181109022847.32049-1-keiths@redhat.com> X-IsSubscribed: yes Now that multidictionary's are being used, there is no longer any need to retain the four temporary functions introduced in the beginning of this series. This patch removes them. As an additional cleanup, since the single-language dictionaries are no longer used outside dictionary.c, make all of those functions static. gdb/ChangeLog: PR gdb/23712 * dictionary.c (pending_to_vector): Remove. (dict_create_hashed_1, dict_create_linear_1, dict_add_pending_1): Remove _1 suffix, replacing functions of the same name. Update all callers. (dict_create_hashed, dict_create_hashed_expandable) (dict_create_linear, dict_create_linear_expandable, dict_free) (dict_add_symbol, dict_add_pending, dict_size, dict_empty): Make functions static. --- gdb/ChangeLog | 12 ++++++ gdb/dictionary.c | 97 ++++++++++++------------------------------------ 2 files changed, 35 insertions(+), 74 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 27e08d30cf..32c58ed1e1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +YYYY-MM-DD Keith Seitz + + PR gdb/23712 + * dictionary.c (pending_to_vector): Remove. + (dict_create_hashed_1, dict_create_linear_1, dict_add_pending_1): + Remove _1 suffix, replacing functions of the same name. Update + all callers. + (dict_create_hashed, dict_create_hashed_expandable) + (dict_create_linear, dict_create_linear_expandable, dict_free) + (dict_add_symbol, dict_add_pending, dict_size, dict_empty): + Make functions static. + YYYY-MM-DD Keith Seitz PR gdb/23712 diff --git a/gdb/dictionary.c b/gdb/dictionary.c index 83d8126682..2aedc480e9 100644 --- a/gdb/dictionary.c +++ b/gdb/dictionary.c @@ -342,31 +342,14 @@ static void insert_symbol_hashed (struct dictionary *dict, static void expand_hashtable (struct dictionary *dict); -/* A function to convert a linked list into a vector. */ - -static std::vector -pending_to_vector (const struct pending *symbol_list) -{ - std::vector symlist; - - for (const struct pending *list_counter = symbol_list; - list_counter != nullptr; list_counter = list_counter->next) - { - for (int i = list_counter->nsyms - 1; i >= 0; --i) - symlist.push_back (list_counter->symbol[i]); - } - - return symlist; -} - /* The creation functions. */ -/* A function to transition dict_create_hashed to new API. */ +/* Create a hashed dictionary of a given language. */ static struct dictionary * -dict_create_hashed_1 (struct obstack *obstack, - enum language language, - const std::vector &symbol_list) +dict_create_hashed (struct obstack *obstack, + enum language language, + const std::vector &symbol_list) { /* Allocate the dictionary. */ struct dictionary *retval = XOBNEW (obstack, struct dictionary); @@ -388,21 +371,9 @@ dict_create_hashed_1 (struct obstack *obstack, return retval; } -/* See dictionary.h. */ - -struct dictionary * -dict_create_hashed (struct obstack *obstack, - enum language language, - const struct pending *symbol_list) -{ - std::vector symlist = pending_to_vector (symbol_list); - - return dict_create_hashed_1 (obstack, language, symlist); -} +/* Create an expandable hashed dictionary of a given language. */ -/* See dictionary.h. */ - -extern struct dictionary * +static struct dictionary * dict_create_hashed_expandable (enum language language) { struct dictionary *retval = XNEW (struct dictionary); @@ -417,12 +388,12 @@ dict_create_hashed_expandable (enum language language) return retval; } -/* A function to transition dict_create_linear to new API. */ +/* Create a linear dictionary of a given language. */ static struct dictionary * -dict_create_linear_1 (struct obstack *obstack, - enum language language, - const std::vector &symbol_list) +dict_create_linear (struct obstack *obstack, + enum language language, + const std::vector &symbol_list) { struct dictionary *retval = XOBNEW (obstack, struct dictionary); DICT_VECTOR (retval) = &dict_linear_vector; @@ -442,21 +413,9 @@ dict_create_linear_1 (struct obstack *obstack, return retval; } -/* See dictionary.h. */ - -struct dictionary * -dict_create_linear (struct obstack *obstack, - enum language language, - const struct pending *symbol_list) -{ - std::vector symlist = pending_to_vector (symbol_list); - - return dict_create_linear_1 (obstack, language, symlist); -} - -/* See dictionary.h. */ +/* Create an expandable linear dictionary of a given language. */ -struct dictionary * +static struct dictionary * dict_create_linear_expandable (enum language language) { struct dictionary *retval = XNEW (struct dictionary); @@ -476,7 +435,7 @@ dict_create_linear_expandable (enum language language) /* Free the memory used by a dictionary that's not on an obstack. (If any.) */ -void +static void dict_free (struct dictionary *dict) { (DICT_VECTOR (dict))->free (dict); @@ -484,34 +443,24 @@ dict_free (struct dictionary *dict) /* Add SYM to DICT. DICT had better be expandable. */ -void +static void dict_add_symbol (struct dictionary *dict, struct symbol *sym) { (DICT_VECTOR (dict))->add_symbol (dict, sym); } -/* A function to transition dict_add_pending to new API. */ +/* Utility to add a list of symbols to a dictionary. + DICT must be an expandable dictionary. */ static void -dict_add_pending_1 (struct dictionary *dict, - const std::vector &symbol_list) +dict_add_pending (struct dictionary *dict, + const std::vector &symbol_list) { /* Preserve ordering by reversing the list. */ for (auto sym = symbol_list.rbegin (); sym != symbol_list.rend (); ++sym) dict_add_symbol (dict, *sym); } -/* Utility to add a list of symbols to a dictionary. - DICT must be an expandable dictionary. */ - -void -dict_add_pending (struct dictionary *dict, const struct pending *symbol_list) -{ - std::vector symlist = pending_to_vector (symbol_list); - - dict_add_pending_1 (dict, symlist); -} - /* Initialize ITERATOR to point at the first symbol in DICT, and return that first symbol, or NULL if DICT is empty. */ @@ -548,7 +497,7 @@ dict_iter_match_next (const lookup_name_info &name, ->iter_match_next (name, iterator); } -int +static int dict_size (const struct dictionary *dict) { return (DICT_VECTOR (dict))->size (dict); @@ -560,7 +509,7 @@ dict_size (const struct dictionary *dict) /* Test to see if DICT is empty. */ -int +static int dict_empty (struct dictionary *dict) { struct dict_iterator iter; @@ -1019,7 +968,7 @@ mdict_create_hashed (struct obstack *obstack, std::vector symlist = pair.second; retval->dictionaries[idx++] - = dict_create_hashed_1 (obstack, language, symlist); + = dict_create_hashed (obstack, language, symlist); } return retval; @@ -1064,7 +1013,7 @@ mdict_create_linear (struct obstack *obstack, std::vector symlist = pair.second; retval->dictionaries[idx++] - = dict_create_linear_1 (obstack, language, symlist); + = dict_create_linear (obstack, language, symlist); } return retval; @@ -1210,7 +1159,7 @@ mdict_add_pending (struct multidictionary *mdict, dict = create_new_language_dictionary (mdict, language); } - dict_add_pending_1 (dict, symlist); + dict_add_pending (dict, symlist); } }