From patchwork Tue Oct 22 17:55:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 35229 Received: (qmail 88759 invoked by alias); 22 Oct 2019 17:55:17 -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 88734 invoked by uid 89); 22 Oct 2019 17:55:17 -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 autolearn=ham version=3.3.1 spammy= X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 22 Oct 2019 17:55:15 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 4E002204A3; Tue, 22 Oct 2019 13:55:13 -0400 (EDT) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id 6E55D204A9; Tue, 22 Oct 2019 13:55:04 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 4CFB22192E; Tue, 22 Oct 2019 13:55:04 -0400 (EDT) X-Gerrit-PatchSet: 6 Date: Tue, 22 Oct 2019 13:55:04 -0400 From: "Sourceware to Gerrit sync (Code Review)" To: Christian Biesinger , gdb-patches@sourceware.org Cc: Tom Tromey , Simon Marchi Auto-Submitted: auto-generated X-Gerrit-MessageType: merged Subject: [pushed] Store the mangled name as a string_view X-Gerrit-Change-Id: I24711ae2bcaa9e79ca89a6f8fda385d400419175 X-Gerrit-Change-Number: 37 X-Gerrit-ChangeURL: X-Gerrit-Commit: 7bb43059820c5febb4509b15202a93efde442bc6 In-Reply-To: References: Reply-To: noreply@gnutoolchain-gerrit.osci.io, simon.marchi@polymtl.ca, tromey@sourceware.org, cbiesinger@google.com, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3 Message-Id: <20191022175504.4CFB22192E@gnutoolchain-gerrit.osci.io> Sourceware to Gerrit sync has submitted this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/37 ...................................................................... Store the mangled name as a string_view This should be a bit faster (because we can compare the size first), but it is also a dependency for the next patch. (3.47% of gdb startup time is spent in eq_demangled_name_entry when attaching to Chrome's content_shell binary) gdb/ChangeLog: 2019-10-22 Christian Biesinger * symtab.c (struct demangled_name_entry): Change type of mangled to gdb::string_view. Also adds a constructor that takes the mangled name. (hash_demangled_name_entry): Update. (eq_demangled_name_entry): Update. (free_demangled_name_entry): New function to call the destructor now that this is not a POD anymore. (create_demangled_names_hash): Pass free_demangled_name_entry to htab_create_alloc. (symbol_set_names): Update. Change-Id: I24711ae2bcaa9e79ca89a6f8fda385d400419175 --- M gdb/ChangeLog M gdb/symtab.c 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a70f3e1..d271330 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +2019-10-22 Christian Biesinger + + * symtab.c (struct demangled_name_entry): Change type of mangled + to gdb::string_view. Also adds a constructor that takes the + mangled name. + (hash_demangled_name_entry): Update. + (eq_demangled_name_entry): Update. + (free_demangled_name_entry): New function to call the destructor + now that this is not a POD anymore. + (create_demangled_names_hash): Pass free_demangled_name_entry to + htab_create_alloc. + (symbol_set_names): Update. + 2019-10-21 Ali Tamur * dwarf2read.c (dir_index): Change type. diff --git a/gdb/symtab.c b/gdb/symtab.c index fc736fd..567d09d 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -68,6 +68,7 @@ #include "filename-seen-cache.h" #include "arch-utils.h" #include +#include "gdbsupport/gdb_string_view.h" #include "gdbsupport/pathstuff.h" /* Forward declarations for local functions. */ @@ -713,7 +714,7 @@ /* Objects of this type are stored in the demangled name hash table. */ struct demangled_name_entry { - const char *mangled; + gdb::string_view mangled; ENUM_BITFIELD(language) language : LANGUAGE_BITS; char demangled[1]; }; @@ -726,7 +727,7 @@ const struct demangled_name_entry *e = (const struct demangled_name_entry *) data; - return htab_hash_string (e->mangled); + return iterative_hash (e->mangled.data (), e->mangled.length (), 0); } /* Equality function for the demangled name hash. */ @@ -739,7 +740,7 @@ const struct demangled_name_entry *db = (const struct demangled_name_entry *) b; - return strcmp (da->mangled, db->mangled) == 0; + return da->mangled == db->mangled; } /* Create the hash table used for demangled names. Each hash entry is @@ -855,7 +856,7 @@ else linkage_name_copy = linkage_name; - entry.mangled = linkage_name_copy; + entry.mangled = gdb::string_view (linkage_name_copy, len); slot = ((struct demangled_name_entry **) htab_find_slot (per_bfd->demangled_names_hash.get (), &entry, INSERT)); @@ -888,7 +889,7 @@ obstack_alloc (&per_bfd->storage_obstack, offsetof (struct demangled_name_entry, demangled) + demangled_len + 1)); - (*slot)->mangled = linkage_name; + (*slot)->mangled = gdb::string_view (linkage_name, len); } else { @@ -904,7 +905,7 @@ + len + demangled_len + 2)); mangled_ptr = &((*slot)->demangled[demangled_len + 1]); strcpy (mangled_ptr, linkage_name_copy); - (*slot)->mangled = mangled_ptr; + (*slot)->mangled = gdb::string_view (mangled_ptr, len); } (*slot)->language = gsymbol->language; @@ -917,7 +918,7 @@ || gsymbol->language == language_auto) gsymbol->language = (*slot)->language; - gsymbol->name = (*slot)->mangled; + gsymbol->name = (*slot)->mangled.data (); if ((*slot)->demangled[0] != '\0') symbol_set_demangled_name (gsymbol, (*slot)->demangled, &per_bfd->storage_obstack);