From patchwork Sat Nov 25 00:35:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 24523 Received: (qmail 42448 invoked by alias); 25 Nov 2017 00:35:57 -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 42434 invoked by uid 89); 25 Nov 2017 00:35:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, KB_WAM_FROM_NAME_SINGLEWORD, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:3566 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; Sat, 25 Nov 2017 00:35:55 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6B65781E01 for ; Sat, 25 Nov 2017 00:35:54 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 500C35FFE6; Sat, 25 Nov 2017 00:35:53 +0000 (UTC) Subject: [pushed] Re: [PATCH 38/40] Use TOLOWER in SYMBOL_HASH_NEXT To: Keith Seitz , gdb-patches@sourceware.org References: <1496406158-12663-1-git-send-email-palves@redhat.com> <1496406158-12663-39-git-send-email-palves@redhat.com> <3439ec61-0b2d-5d32-db2a-07b9b726b767@redhat.com> From: Pedro Alves Message-ID: Date: Sat, 25 Nov 2017 00:35:52 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <3439ec61-0b2d-5d32-db2a-07b9b726b767@redhat.com> On 08/09/2017 08:24 PM, Keith Seitz wrote: > On 06/02/2017 05:22 AM, Pedro Alves wrote: >> gdb/ChangeLog: >> yyyy-mm-dd Pedro Alves >> >> * dictionary.c: Include "safe-ctype.h". >> * minsyms.c: Include "safe-ctype.h". >> * minsyms.c (SYMBOL_HASH_NEXT): Use TOLOWER instead of tolower. > > Looks good! Since this improves performance a little bit, I guess I could say it stands on is own, so I went ahead and pushed it in already, as below. From deeeba559bd0c18e06dba19f44571ee8a218fcdb Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Sat, 25 Nov 2017 00:33:05 +0000 Subject: [PATCH] Use TOLOWER in SYMBOL_HASH_NEXT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The support for setting breakpoint in functions with ABI tags patch will add a use of SYMBOL_HASH_NEXT in cp-support.c, which fails to compile with: src/gdb/cp-support.c:38:0: src/gdb/cp-support.c: In function ‘unsigned int cp_search_name_hash(const char*)’: src/gdb/../include/safe-ctype.h:148:20: error: ‘do_not_use_tolower_with_safe_ctype’ was not declared in this scope #define tolower(c) do_not_use_tolower_with_safe_ctype ^ src/gdb/minsyms.h:174:18: note: in expansion of macro ‘tolower’ ((hash) * 67 + tolower ((unsigned char) (c)) - 113) ^ src/gdb/cp-support.c:1677:14: note: in expansion of macro ‘SYMBOL_HASH_NEXT’ hash = SYMBOL_HASH_NEXT (hash, *string); ^ This fixes the problem before it happens. I was somewhat worried about whether this might have an impact with languages that are case insensitive, but I convinced myself that it doesn't. As bonus, this improves GDB's minsym interning performance a bit (3%-10%). See . gdb/ChangeLog: 2017-11-25 Pedro Alves * dictionary.c: Include "safe-ctype.h". * minsyms.c: Include "safe-ctype.h". * minsyms.c (SYMBOL_HASH_NEXT): Use TOLOWER instead of tolower. --- gdb/ChangeLog | 6 ++++++ gdb/dictionary.c | 1 + gdb/minsyms.c | 1 + gdb/minsyms.h | 2 +- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4e0b45e..61db1b1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2017-11-25 Pedro Alves + + * dictionary.c: Include "safe-ctype.h". + * minsyms.c: Include "safe-ctype.h". + * minsyms.c (SYMBOL_HASH_NEXT): Use TOLOWER instead of tolower. + 2017-11-25 Pedro Alves * completer.c (complete_line_internal_1): Skip spaces until the diff --git a/gdb/dictionary.c b/gdb/dictionary.c index fb307538..7d26efb 100644 --- a/gdb/dictionary.c +++ b/gdb/dictionary.c @@ -26,6 +26,7 @@ #include "symtab.h" #include "buildsym.h" #include "dictionary.h" +#include "safe-ctype.h" /* This file implements dictionaries, which are tables that associate symbols to names. They are represented by an opaque type 'struct diff --git a/gdb/minsyms.c b/gdb/minsyms.c index a0d3bd5..4898da1 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -52,6 +52,7 @@ #include "cli/cli-utils.h" #include "symbol.h" #include +#include "safe-ctype.h" /* See minsyms.h. */ diff --git a/gdb/minsyms.h b/gdb/minsyms.h index f326be9..5c0dde4 100644 --- a/gdb/minsyms.h +++ b/gdb/minsyms.h @@ -177,7 +177,7 @@ unsigned int msymbol_hash_iw (const char *); requirements. */ #define SYMBOL_HASH_NEXT(hash, c) \ - ((hash) * 67 + tolower ((unsigned char) (c)) - 113) + ((hash) * 67 + TOLOWER ((unsigned char) (c)) - 113)