This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Use TOLOWER in SYMBOL_HASH_NEXT
- From: Pedro Alves <palves at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 25 Nov 2017 00:34:28 -0000
- Subject: [binutils-gdb] Use TOLOWER in SYMBOL_HASH_NEXT
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=deeeba559bd0c18e06dba19f44571ee8a218fcdb
commit deeeba559bd0c18e06dba19f44571ee8a218fcdb
Author: Pedro Alves <palves@redhat.com>
Date: Sat Nov 25 00:33:05 2017 +0000
Use TOLOWER in SYMBOL_HASH_NEXT
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
<https://sourceware.org/ml/gdb/2017-11/msg00021.html>.
gdb/ChangeLog:
2017-11-25 Pedro Alves <palves@redhat.com>
* dictionary.c: Include "safe-ctype.h".
* minsyms.c: Include "safe-ctype.h".
* minsyms.c (SYMBOL_HASH_NEXT): Use TOLOWER instead of tolower.
Diff:
---
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 <palves@redhat.com>
+
+ * 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 <palves@redhat.com>
* completer.c (complete_line_internal_1): Skip spaces until the
diff --git a/gdb/dictionary.c b/gdb/dictionary.c
index fb30753..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 <algorithm>
+#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)