diff options
author | Pedro Alves <palves@redhat.com> | 2020-05-23 12:46:37 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2020-05-23 12:46:37 +0100 |
commit | 51e2cfa2dc2dd600727c91701c747c28fa67a5df (patch) | |
tree | 5b3affafd078666406b81aab732e84be1cd58c36 /gdbsupport | |
parent | c892b44730bb1a66d614fd47fabe47555ca83b3b (diff) | |
download | gdb-51e2cfa2dc2dd600727c91701c747c28fa67a5df.zip gdb-51e2cfa2dc2dd600727c91701c747c28fa67a5df.tar.gz gdb-51e2cfa2dc2dd600727c91701c747c28fa67a5df.tar.bz2 |
Use safe-ctype.h (ISSPACE etc.) in symbol parsing & comparison
This patch avoids depending on the current locale when parsing &
comparing symbol names, by using libiberty's safe-ctype.h uppercase
TOLOWER, ISXDIGIT, etc. macros instead of the standard ctype.h
tolower, isxdigit, etc. macros/functions.
This commit:
commit b1b60145aedb8adcb0b9dcf43a5ae735c2f03b51
Author: Pedro Alves <palves@redhat.com>
AuthorDate: Tue May 22 17:35:38 2018 +0100
Support UTF-8 identifiers in C/C++ expressions (PR gdb/22973)
did something similar, except in the expression parser.
This can improve GDB's symbol loading performance significantly.
Currently strcmp_iw_ordered can show up high on profiles (called from
sort_pst_symbols -> std::sort) because of the isspace and tolower
functions. Hannes mentions seeing it as high as in ~24% of the
profiling samples on Windows
(https://sourceware.org/pipermail/gdb-patches/2020-May/168858.html).
I tested GDB's performance (built with "-g -O2") loading a "-g -O0"
build of gdb.
I ran GDB 10 times like:
/bin/time -f %e \
./gdb/gdb --data-directory ./gdb/data-directory -nx \
-batch /tmp/gdb-g-O0
Then I computed the mean time.
The baseline mean time was
gdb 2.515
This patch brings the number down to
gdb 2.096
Which is an around 16% improvement.
gdb/ChangeLog:
2020-05-23 Pedro Alves <palves@redhat.com>
* utils.c: Include "gdbsupport/gdb-safe-ctype.h".
(parse_escape): Use ISDIGIT instead of isdigit.
(puts_debug): Use gdb_isprint instead of isprint.
(fprintf_symbol_filtered): Use ISALNUM instead of isalnum.
(cp_skip_operator_token, skip_ws, strncmp_iw_with_mode): Use
ISSPACE instead of isspace.
(strncmp_iw_with_mode): Use TOLOWER instead of tolower and ISSPACE
instead of isspace.
(strcmp_iw_ordered): Use ISSPACE instead of isspace.
(string_to_core_addr): Use TOLOWER instead of tolower, ISXDIGIT
instead of isxdigit and ISDIGIT instead of isdigit.
gdbsupport/ChangeLog:
2020-05-23 Pedro Alves <palves@redhat.com>
* gdb-safe-ctype.h: New.
Diffstat (limited to 'gdbsupport')
-rw-r--r-- | gdbsupport/gdb-safe-ctype.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/gdbsupport/gdb-safe-ctype.h b/gdbsupport/gdb-safe-ctype.h new file mode 100644 index 0000000..b8e3bb4 --- /dev/null +++ b/gdbsupport/gdb-safe-ctype.h @@ -0,0 +1,46 @@ +/* Wrapper around libiberty's safe-ctype.h for GDB, the GNU debugger. + + Copyright (C) 2019-2020 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 <http://www.gnu.org/licenses/>. */ + +#ifndef GDB_SAFE_CTYPE_H +#define GDB_SAFE_CTYPE_H + +/* After safe-ctype.h is included, we can no longer use the host's + ctype routines. Trying to do so results in compile errors. Code + that uses safe-ctype.h that wants to refer to the locale-dependent + ctype functions must call these wrapper versions instead. */ + +static inline int +gdb_isprint (int ch) +{ + return isprint (ch); +} + +/* readline.h defines these symbols too, but we want libiberty's + versions. */ +#undef ISALPHA +#undef ISALNUM +#undef ISDIGIT +#undef ISLOWER +#undef ISPRINT +#undef ISUPPER +#undef ISXDIGIT + +#include "safe-ctype.h" + +#endif |