forked from bminor/binutils-gdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 b1b6014 Author: Pedro Alves <[email protected]> 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 <[email protected]> * 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 <[email protected]> * gdb-safe-ctype.h: New.
- Loading branch information
Showing
4 changed files
with
88 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
2020-05-23 Pedro Alves <[email protected]> | ||
|
||
* 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. | ||
|
||
2020-05-22 Simon Marchi <[email protected]> | ||
|
||
* gdbtypes.h (struct type) <field>: New method. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
2020-05-23 Pedro Alves <[email protected]> | ||
|
||
* gdb-safe-ctype.h: New. | ||
|
||
2020-05-16 Tankut Baris Aktemur <[email protected]> | ||
|
||
* linux-ia64-low.cc (ia64_target::sw_breakpoint_from_kind): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |