binutils-gdb/gdbsupport
Pedro Alves 51e2cfa2dc 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 b1b60145ae
 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.
2020-05-23 12:46:37 +01:00
..
.dir-locals.el gdbserver/gdbsupport: Add .dir-locals.el file 2020-03-06 11:29:46 +00:00
.gitattributes gdb, gdbserver, gdbsupport: add .gitattributes files 2020-03-05 15:59:22 +01:00
ChangeLog Disable record btrace bts support for AMD processors 2020-05-14 17:56:33 -07:00
Makefile.am Move event-loop.[ch] to gdbsupport/ 2020-04-13 14:10:04 -06:00
Makefile.in Move event-loop.[ch] to gdbsupport/ 2020-04-13 14:10:04 -06:00
README
acinclude.m4 Move gdb/selftest.m4 to gdbsupport/selftest.m4 2020-03-12 14:19:38 -04:00
aclocal.m4
agent.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
agent.h
alt-stack.h
array-view.h
ax.def
block-signals.h
break-common.h
btrace-common.cc Don't pass NULL to memcpy in gdb 2020-03-31 07:29:53 -06:00
btrace-common.h Disable record btrace bts support for AMD processors 2020-05-14 17:56:33 -07:00
buffer.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
buffer.h
byte-vector.h
check-defines.el Add gdbsupport check-defines script 2020-01-14 16:25:04 -07:00
cleanups.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
cleanups.h
common-debug.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
common-debug.h
common-defs.h gdbsupport: include cstdlib in common-defs.h 2020-04-27 09:28:03 -04:00
common-exceptions.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
common-exceptions.h
common-gdbthread.h
common-inferior.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
common-inferior.h
common-regcache.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
common-regcache.h gdb: protect some 'regcache_read_pc' calls 2020-05-14 13:59:53 +02:00
common-types.h Change gdbsupport not to rely on BFD 2020-03-12 13:32:16 -06:00
common-utils.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
common-utils.h
common.m4 Move event-loop configury to common.m4 2020-04-13 14:10:03 -06:00
config.in Move event-loop configury to common.m4 2020-04-13 14:10:03 -06:00
configure Move event-loop configury to common.m4 2020-04-13 14:10:03 -06:00
configure.ac Move sourcing of development.sh to GDB_AC_COMMON 2020-03-12 14:18:00 -04:00
create-version.sh gdbsupport: Resolve shellcheck issues in create-version.sh script 2020-03-27 13:52:00 +00:00
def-vector.h
default-init-alloc.h
enum-flags.h
environ.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
environ.h
errors.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
errors.h Introduce and use flush_streams 2020-04-13 14:10:04 -06:00
event-loop.cc Move gdb_notifier comment 2020-04-13 14:10:04 -06:00
event-loop.h Move event-loop.[ch] to gdbsupport/ 2020-04-13 14:10:04 -06:00
fileio.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
fileio.h
filestuff.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
filestuff.h
filtered-iterator.h
format.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
format.h
forward-scope-exit.h
function-view.h
gdb-dlfcn.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
gdb-dlfcn.h Fix comment for 'gdb_dlopen' 2020-02-28 11:04:28 -05:00
gdb-safe-ctype.h Use safe-ctype.h (ISSPACE etc.) in symbol parsing & comparison 2020-05-23 12:46:37 +01:00
gdb-sigmask.h Fix typo (thead -> thread) 2020-04-28 11:38:26 +02:00
gdb_assert.h
gdb_binary_search.h Fix two typos in gdb_binary_search.h 2020-03-08 11:05:43 -06:00
gdb_locale.h
gdb_optional.h
gdb_proc_service.h Ensure proc-service symbols have default visibility (PR build/24805) 2020-01-16 19:14:14 +00:00
gdb_ref_ptr.h Mark move constructors as "noexcept" 2020-04-20 11:45:06 -06:00
gdb_select.h Move gdb_select.h to gdbsupport/ 2020-04-13 14:10:03 -06:00
gdb_setjmp.h
gdb_signals.h
gdb_splay_tree.h
gdb_string_view.h
gdb_string_view.tcc
gdb_sys_time.h
gdb_tilde_expand.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
gdb_tilde_expand.h
gdb_unique_ptr.h
gdb_unlinker.h
gdb_vecs.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
gdb_vecs.h
gdb_wait.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
gdb_wait.h
hash_enum.h
host-defs.h
job-control.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
job-control.h
netstuff.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
netstuff.h
new-op.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
next-iterator.h
observable.h
offset-type.h
parallel-for.h
pathstuff.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
pathstuff.h
poison.h
preprocessor.h
print-utils.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
print-utils.h
ptid.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
ptid.h
refcounted-object.h
rsp-low.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
rsp-low.h
run-time-clock.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
run-time-clock.h
safe-iterator.h
safe-strerror.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
scope-exit.h
scoped_fd.h Mark move constructors as "noexcept" 2020-04-20 11:45:06 -06:00
scoped_mmap.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
scoped_mmap.h Mark move constructors as "noexcept" 2020-04-20 11:45:06 -06:00
scoped_restore.h
selftest.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
selftest.h
selftest.m4 Move gdb/selftest.m4 to gdbsupport/selftest.m4 2020-03-12 14:19:38 -04:00
signals-state-save-restore.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
signals-state-save-restore.h
signals.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
symbol.h
tdesc.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
tdesc.h
thread-pool.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
thread-pool.h
traits.h
underlying.h
valid-expr.h
version.h
warning.m4 gdb: enable -Wmissing-prototypes warning 2020-03-11 15:15:12 -04:00
x86-xstate.h
xml-utils.cc gdbsupport: rename source files to .cc 2020-02-13 16:27:03 -05:00
xml-utils.h

README

This is a helper library that is used by gdb and gdbserver.

To send patches, follow the gdb patch submission instructions in
../gdb/CONTRIBUTE.  For maintainers, see ../gdb/MAINTAINERS.