Commit Graph

808 Commits

Author SHA1 Message Date
Tom Tromey 919adfe840 Move gdbserver to top level
This patch moves gdbserver to the top level.

This patch is as close to a pure move as possible -- gdbserver still
builds its own variant of gnulib and gdbsupport.  Changing this will
be done in a separate patch.

[v2] Note that, per Simon's review comment, this patch changes the
tree so that gdbserver is not built for or1k or score.  This makes
sense, because there is apparently not actually a gdbserver port here.

[v3] This version of the patch also splits out some configury into a
new file, gdbserver/configure.host, so that the top-level configure
script can simply rely on it in order to decide whether gdbserver
should be built.

[v4] This version adds documentation and removes some unnecessary
top-level dependencies.

[v5] Update docs to mention "make all-gdbserver" and change how
top-level configure decides whether to build gdbserver, switching to a
single, shared script.

Tested by the buildbot.

ChangeLog
2020-02-07  Tom Tromey  <tom@tromey.com>
	    Pedro Alves  <palves@redhat.com>

	* src-release.sh (GDB_SUPPORT_DIRS): Add gdbserver.
	* gdbserver: New directory, moved from gdb/gdbserver.
	* configure.ac (host_tools): Add gdbserver.
	Only build gdbserver on certain systems.
	* Makefile.in, configure: Rebuild.
	* Makefile.def (host_modules, dependencies): Add gdbserver.
	* MAINTAINERS: Add gdbserver.

gdb/ChangeLog
2020-02-07  Tom Tromey  <tom@tromey.com>

	* README: Update gdbserver documentation.
	* gdbserver: Move to top level.
	* configure.tgt (build_gdbserver): Remove.
	* configure.ac: Remove --enable-gdbserver.
	* configure: Rebuild.
	* Makefile.in (distclean): Don't mention gdbserver.

Change-Id: I826b7565b54604711dc7a11edea0499cd51ff39e
2020-02-07 08:42:25 -07:00
Tom Tromey 05ea2a0510 Move many configure checks to common.m4
This moves many needed configure checks from gdb and gdbserver into
common.m4.  This helps gdbsupport, nat, and target be self-contained.

The result is a bit spaghetti-ish, because gdbsupport uses another m4
file from gdb/.  The resulting code is somewhat non-obvious.  However,
these problems already exist, so it's not really that much worse than
what is already done.

gdb/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* configure.ac: Move many checks to ../gdbsupport/common.m4.

gdb/gdbserver/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* configure.ac: Remove any checks that were added to common.m4.
	* acinclude.m4: Include lib-ld.m4, lib-prefix.m4, and
	lib-link.m4.

gdbsupport/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* configure, Makefile.in, aclocal.m4, common.m4, config.in:
	Rebuild.
	* common.m4 (GDB_AC_COMMON): Move many checks from
	gdb/configure.ac.
	* acinclude.m4: Include bfd.m4, ptrace.m4.

Change-Id: I931eaa94065df268b30a2f1354390710df89c7f8
2020-01-14 16:25:03 -07:00
Tom Tromey 01027315f5 Move gdbsupport to the top level
This patch moves the gdbsupport directory to the top level.  This is
the next step in the ongoing project to move gdbserver to the top
level.

The bulk of this patch was created by "git mv gdb/gdbsupport gdbsupport".

This patch then adds a build system to gdbsupport and wires it into
the top level.  Then it changes gdb to use the top-level build.

gdbserver, on the other hand, is not yet changed.  It still does its
own build of gdbsupport.

ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* src-release.sh (GDB_SUPPORT_DIRS): Add gdbsupport.
	* MAINTAINERS: Add gdbsupport.
	* configure: Rebuild.
	* configure.ac (configdirs): Add gdbsupport.
	* gdbsupport: New directory, move from gdb/gdbsupport.
	* Makefile.def (host_modules, dependencies): Add gnulib.
	* Makefile.in: Rebuild.

gdb/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* nat/x86-linux-dregs.c: Include configh.h.
	* nat/linux-ptrace.c: Include configh.h.
	* nat/linux-btrace.c: Include configh.h.
	* defs.h: Include config.h, bfd.h.
	* configure.ac: Don't source common.host.
	(CONFIG_OBS, CONFIG_SRCS): Remove gdbsupport files.
	* configure: Rebuild.
	* acinclude.m4: Update path.
	* Makefile.in (SUPPORT, LIBSUPPORT, INCSUPPORT): New variables.
	(CONFIG_SRC_SUBDIR): Remove gdbsupport.
	(INTERNAL_CFLAGS_BASE): Add INCSUPPORT.
	(CLIBS): Add LIBSUPPORT.
	(CDEPS): Likewise.
	(COMMON_SFILES): Remove gdbsupport files.
	(HFILES_NO_SRCDIR): Likewise.
	(stamp-version): Update path to create-version.sh.
	(ALLDEPFILES): Remove gdbsupport files.

gdb/gdbserver/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* server.h: Include config.h.
	* gdbreplay.c: Include config.h.
	* configure: Rebuild.
	* configure.ac: Don't source common.host.
	* acinclude.m4: Update path.
	* Makefile.in (INCSUPPORT): New variable.
	(INCLUDE_CFLAGS): Add INCSUPPORT.
	(SFILES): Update paths.
	(version-generated.c): Update path to create-version.sh.
	(gdbsupport/%-ipa.o, gdbsupport/%.o): Update paths.

gdbsupport/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* common-defs.h: Add GDBSERVER case.  Update includes.
	* acinclude.m4, aclocal.m4, config.in, configure, configure.ac,
	Makefile.am, Makefile.in, README: New files.
	* Moved from ../gdb/gdbsupport/

Change-Id: I07632e7798635c1bab389bf885971e584fb4bb78
2020-01-14 16:25:02 -07:00
Tom Tromey b2ceabe8f0 Consolidate definition of USE_WIN32API
I noticed that USE_WIN32API is defined separately by gdbserver and
gdb.  However, because it is used by code in gdbsupport, it should be
defined by common.m4.  This approach ensures that the code will
continue to work when it is moved to the top level.

gdb/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* gdbsupport/common.m4 (GDB_AC_COMMON): Define WIN32APILIBS and
	USE_WIN32API when needed.
	* configure.ac (USE_WIN32API): Don't define.
	(WIN32LIBS): Use WIN32APILIBS.
	* configure: Rebuild.

gdb/gdbserver/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* configure.ac (LIBS): Use WIN32APILIBS.
	(USE_WIN32API): Don't define.
	* configure: Rebuild.

Change-Id: I40d524d5445ebfb452b36f4d0e102f0b1e1089df
2020-01-14 16:25:02 -07:00
Tom Tromey 25c51f71d5 Fix indentation in common.m4
Simon pointed out that the indentation in common.m4 is off.  This
patch fixes the problem.

gdb/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* gdbsupport/common.m4 (GDB_AC_COMMON): Fix indentation.

gdb/gdbserver/ChangeLog
2020-01-14  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

Change-Id: I6a629bd5873cca95ba3e17656f0d0ce583a08361
2020-01-14 16:16:39 -07:00
Simon Marchi bb564c588d Enable -Wmissing-declarations diagnostic
Now that most warnings of this kind are fixed, we can enable
-Wmissing-declarations.  I say "most", because it is likely that there
are some more in some configurations I am not able to build, but they
should be pretty easy to fix.

gdb/ChangeLog:

	* warning.m4: Add -Wmissing-declarations to build_warnings.
	* configure: Re-generate.

gdb/gdbserver/ChangeLog:

	* configure: Re-generate.

Change-Id: Iae9b59f22eb5dd1965d09f34c5c9e212cddf67ba
2020-01-13 14:06:09 -05:00
Christian Biesinger 0ad6b8ee70 Consistently quote variables used with "test"
This ensures that empty variables and variables with spaces are handled
correctly.

Code was inconsistent on whether the constant string (e.g. yes/no)
should also be quoted; I tried to be consistent with surrounding code.

This fixes the error Eli reported during configure with mingw (though that
was not fatal).

gdb/ChangeLog:

2019-12-19  Christian Biesinger  <cbiesinger@google.com>

	* configure: Regenerate.
	* configure.ac: Quote variable arguments of test.
	* gdbsupport/common.m4: Likewise.

gdb/gdbserver/ChangeLog:

2019-12-19  Christian Biesinger  <cbiesinger@google.com>

	* configure: Regenerate.
	* configure.ac: Quote variable arguments of test.

Change-Id: I220e78b52c7db88b9dd058eda604635b03464fac
2019-12-19 13:30:50 -06:00
Christian Biesinger ab7d13f070 Replace the remaining uses of strerror with safe_strerror
To do that, this patch makes IPA compile safe-strerror as well. Because
it doesn't use Gnulib, it calls the Glibc version of strerror_r directly.

Consequently this patch also removes the configure checks for strerror.

gdb/ChangeLog:

2019-12-10  Christian Biesinger  <cbiesinger@google.com>

	* config.in: Regenerate.
	* configure: Regenerate.
	* gdbsupport/agent.c (gdb_connect_sync_socket): Call
	safe_strerror instead of strerror.
	* gdbsupport/common.m4: Don't check for strerror.
	* gdbsupport/safe-strerror.c: Support both the glibc version
	of strerror_r and the XSI version.

gdb/gdbserver/ChangeLog:

2019-12-10  Christian Biesinger  <cbiesinger@google.com>

	* Makefile.in: Add safe-strerror.c to gdbreplay and IPA, and change
	UNDO_GNULIB_CFLAGS to undo strerror_r instead of strerror.
	* config.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Don't check for strerror.
	* linux-i386-ipa.c (initialize_fast_tracepoint_trampoline_buffer):
	Call safe_strerror instead of strerror.
	* server.h (strerror): Remove this now-unnecessary declaration.
	* tracepoint.c (init_named_socket): Call safe_strerror instead of
	strerror.
	(gdb_agent_helper_thread): Likewise.
	* utils.c (perror_with_name): Likewise.

Change-Id: I74848f072dcde75cb55c435ef9398dc8f958cd73
2019-12-10 13:23:01 -06:00
Tom Tromey 4da8c3a8a5 Set names of worker threads
This adds some configury so that gdb can set the names of worker
threads.  This makes them show up more nicely when debugging gdb
itself.

2019-11-26  Tom Tromey  <tom@tromey.com>

	* gdbsupport/thread-pool.c (thread_pool::set_thread_count): Set
	name of worker thread.
	* gdbsupport/common.m4 (GDB_AC_COMMON): Check for
	pthread_setname_np.
	* configure, config.in: Rebuild.

gdb/gdbserver/ChangeLog
2019-11-26  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

Change-Id: I60473d65ae9ae14d8c56ddde39684240c16aaf35
2019-11-26 14:02:58 -07:00
Tom Tromey 21987b9c06 Add RAII class for blocking gdb signals
This adds configury support and an RAII class that can be used to
temporarily block signals that are used by gdb.  (This class is not
used in this patch, but it split out for easier review.)

The idea of this patch is that these signals should only be delivered
to the main thread.  So, when creating a background thread, they are
temporarily blocked; the blocked state is inherited by the new thread.

The sigprocmask man page says:

    The use of sigprocmask() is unspecified in a multithreaded
    process; see pthread_sigmask(3).

This patch changes gdb to use pthread_sigmask when appropriate, by
introducing a convenience define.

I've updated gdbserver as well, because I had to touch gdbsupport, and
because the threading patches will make it link against the thread
library.

I chose not to touch the NTO code, because I don't know anything about
that platform and because I cannot test it.

Finally, this modifies an existing spot in the Guile layer to use the
new facility.

gdb/ChangeLog
2019-11-26  Tom Tromey  <tom@tromey.com>

	* gdbsupport/signals-state-save-restore.c (original_signal_mask):
	Remove comment.
	(save_original_signals_state, restore_original_signals_state): Use
	gdb_sigmask.
	* linux-nat.c (block_child_signals, restore_child_signals_mask)
	(_initialize_linux_nat): Use gdb_sigmask.
	* guile/guile.c (_initialize_guile): Use block_signals.
	* Makefile.in (HFILES_NO_SRCDIR): Add gdb-sigmask.h.
	* gdbsupport/gdb-sigmask.h: New file.
	* event-top.c (async_sigtstp_handler): Use gdb_sigmask.
	* cp-support.c (gdb_demangle): Use gdb_sigmask.
	* gdbsupport/common.m4 (GDB_AC_COMMON): Check for
	pthread_sigmask.
	* configure, config.in: Rebuild.
	* gdbsupport/block-signals.h: New file.

gdb/gdbserver/ChangeLog
2019-11-26  Tom Tromey  <tom@tromey.com>

	* remote-utils.c (block_unblock_async_io): Use gdb_sigmask.
	* linux-low.c (linux_wait_for_event_filtered, linux_async): Use
	gdb_sigmask.
	* configure, config.in: Rebuild.

Change-Id: If3f37dc57dd859c226e9e4d79458a0514746e8c6
2019-11-26 14:02:57 -07:00
Tom Tromey 5e03027845 Add configure check for std::thread
This adds a configure check for std::thread.  This is needed because
std::thread is not available on some systems, like some versions of
mingw and DJGPP.

This also adds configury to make sure that a threaded gdb links
against the correct threading library (-lpthread or the like), and
passes the right flags (e.g., -pthread) to the compilations.

Note that this also links gdbserver against the thread library.  This
is not strictly necessary at this point in the series, but a later
patch will change gdbsupport to use pthread_sigmask, at which point
this will be needed.

gdb/ChangeLog
2019-11-26  Tom Tromey  <tom@tromey.com>

	* acinclude.m4: Include ax_pthread.m4.
	* Makefile.in (PTHREAD_CFLAGS, PTHREAD_LIBS): New variables.
	(INTERNAL_CFLAGS_BASE): Use PTHREAD_CFLAGS.
	(CLIBS): Use PTHREAD_LIBS.
	(aclocal_m4_deps): Add ax_pthread.m4.
	* config.in, configure: Rebuild.
	* gdbsupport/common.m4 (GDB_AC_COMMON): Check for std::thread.

gdb/gdbserver/ChangeLog
2019-11-26  Tom Tromey  <tom@tromey.com>

	* Makefile.in (PTHREAD_CFLAGS, PTHREAD_LIBS): New variables.
	(INTERNAL_CFLAGS_BASE): Use PTHREAD_CFLAGS.
	(GDBSERVER_LIBS): Use PTHREAD_LIBS.
	* acinclude.m4: Include ax_pthread.m4.
	* config.in, configure: Rebuild.

Change-Id: I00ec55db6077f2615421a93461fc3be57e916aa0
2019-11-26 14:02:57 -07:00
Christian Biesinger cd850b40cc Use gnulib's strerror_r on MinGW
There is no need to keep mingw-strerror around; we can just always use
the code from posix-strerror. The main reason we had that code, it
seems, is to handle winsock error codes, but gnulib's version
handles those.

Unfortunately the code can't be moved into common-utils.c because
libinproctrace.so uses common-utils but not gnulib.

gdb/ChangeLog:

2019-11-15  Christian Biesinger  <cbiesinger@google.com>

	* Makefile.in: Replace {posix,mingw}-strerror.c with safe-strerror.c.
	* configure: Regenerate.
	* configure.ac: Don't source common.host.
	* gdbsupport/common.host: Remove.
	* gdbsupport/mingw-strerror.c: Remove.
	* gdbsupport/posix-strerror.c: Rename to...
	* gdbsupport/safe-strerror.c: ...this.

gdb/gdbserver/ChangeLog:

2019-11-15  Christian Biesinger  <cbiesinger@google.com>

	* Makefile.in: Add safe-strerror.c.
	* configure: Regenerate.
	* configure.ac: Don't source common.host.

Change-Id: I9e6d8a752fc398784201f370cafee65e0ea05474
2019-11-15 13:31:36 -08:00
Christian Biesinger 5abebf3c3f Import the strerror_r-posix module and use it in GDB.
Makes sure to assign the return value of strerror_r to an int,
so that we get a compile error if we accidentally get the
wrong version.

gdb/ChangeLog:

2019-11-15  Christian Biesinger  <cbiesinger@google.com>

	* config.in: Regenerate.
	* configure: Regenerate.
	* gdbsupport/common.m4: No longer check for strerror_r.
	* gdbsupport/posix-strerror.c (safe_strerror): Always call the
	POSIX version of strerror_r, now that gnulib provides it if
	necessary.

gdb/gdbserver/ChangeLog:

2019-11-15  Christian Biesinger  <cbiesinger@google.com>

	* config.in: Regenerate.
	* configure: Regenerate.

gnulib/ChangeLog:

2019-11-15  Christian Biesinger  <cbiesinger@google.com>

	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* config.in: Regenerate.
	* configure: Regenerate.
	* import/Makefile.am: Update.
	* import/Makefile.in: Regenerate.
	* import/extra/config.rpath: New file.
	* import/glthread/lock.c: New file.
	* import/glthread/lock.h: New file.
	* import/glthread/threadlib.c: New file.
	* import/m4/gnulib-cache.m4: Update.
	* import/m4/gnulib-comp.m4: Update.
	* import/m4/lib-ld.m4: New file.
	* import/m4/lib-link.m4: New file.
	* import/m4/lib-prefix.m4: New file.
	* import/m4/lock.m4: New file.
	* import/m4/strerror_r.m4: New file.
	* import/m4/threadlib.m4: New file.
	* import/strerror_r.c: New file.
	* update-gnulib.sh: Import strerror_r-posix.

Change-Id: I5cfeb12a5203a4cd94a78581541e6085a68685c3
2019-11-15 11:12:24 -08:00
Christian Biesinger e48f6033b0 Move check for strerror_r to common.m4 where it belongs
gdb/ChangeLog:

2019-11-01  Christian Biesinger  <cbiesinger@google.com>

	* configure: Regenerate.
	* configure.ac: Remove check for strerror_r.
	* gdbsupport/common.m4: Check for strerror_r.

gdb/gdbserver/ChangeLog:

2019-11-01  Christian Biesinger  <cbiesinger@google.com>

	* configure: Regenerate.
	* configure.ac: Remove check for strerror_r.

Change-Id: Ibc290c3f84b1db23e998cffdbe2c1f97651d2a8d
2019-11-01 10:13:44 -05:00
Christian Biesinger b231e86ac9 Use strerror_r in safe_strerror if available
Also stores the result in a thread-local static variable and
changes the return value to a const char*.

This is already important because Guile creates threads and
Python can create threads, but with the patch series here:
https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/176
GDB itself will create threads, too.

gdb/ChangeLog:

2019-10-31  Christian Biesinger  <cbiesinger@google.com>

	* configure: Regenerate.
	* configure.ac: Check for strerror_r.
	* gdbsupport/common-utils.h (safe_strerror): Change return value
	to const char * and document that this function is now threadsafe.
	* gdbsupport/posix-strerror.c (safe_strerror): Make buf
	thread_local and call strerror_r, if available.
	* utils.c (perror_string): Update.
	(print_sys_errmsg): Update.

Change-Id: I81048fbaf148035c221c528727f7efe58ba528eb
2019-10-31 15:14:14 -05:00
Christian Biesinger ed2a222951 Load system gdbinit files from a directory
Adds a configure option --with-system-gdbinit-dir to specify a directory
in which to look for gdbinit files.  All files in this directory are
loaded on startup (subject to -n/-nx as usual) as long as the extension
matches a known and enabled scripting language (.gdb/.py/.scm).

This also changes get_ext_lang_of_file to support ".gdb" files, similar
to get_ext_lang_defn's handling of EXT_LANG_GDB.

gdb/ChangeLog:

2019-10-29  Christian Biesinger  <cbiesinger@google.com>

	* NEWS: Mention new --with-system-gdbinit-dir option.
	* config.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Add new option --with-system-gdbinit-dir.
	* extension.c (get_ext_lang_of_file): Return extension_language_gdb
	for a ".gdb" suffix.
	* main.c (get_init_files): Change system_gdbinit argument to
	a vector and return the files in SYSTEM_GDBINIT_DIR in
	addition to SYSTEM_GDBINIT.
	(captured_main_1): Update.
	(print_gdb_help): Update.
	* top.c (print_gdb_configuration): Also print the value of
	SYSTEM_GDBINIT_DIR.

gdb/doc/ChangeLog:

2019-10-29  Christian Biesinger  <cbiesinger@google.com>

	* Makefile.in: Also set SYSTEM_GDBINIT_DIR for the info manual
	generation.
	* gdb.texinfo (many sections): Document new --with-system-gdbinit-dir
	option.

Change-Id: If233859ecc21bc6421d589b37cd658a3c7d030f2
2019-10-29 13:43:04 -05:00
Christian Biesinger cbb5a2ea49 Remove python_has_threads check in configure.ac
The only use of python_has_threads has been removed in
commit 404f29021a

gdb/ChangeLog:

2019-10-24  Christian Biesinger  <cbiesinger@google.com>

	* configure: Rebuild.
	* configure.ac: Remove code that sets python_has_threads.

Change-Id: I75f1b873562bc2abc6f2db17699a3e82fcfd2de3
2019-10-24 14:14:07 -05:00
Christian Biesinger 71737c435d Simplify Python checks in configure.ac
The version checking code is not necessary. It is only used to define
HAVE_LIBPYTHON2_6 or HAVE_LIBPYTHON2_7, which is not used anywhere.

If a version check is desired, the PY_{MAJOR,MINOR}_VERSION macro from
the Python headers can be (and is) used, which does not require updating
configure.ac whenever a new Python version is released.

gdb/ChangeLog:

2019-10-24  Christian Biesinger  <cbiesinger@google.com>

	* config.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Remove the code that uses sed to get the python
	version and defines HAVE_LIBPYTHON2_6 / HAVE_LIBPYTHON2_7.

Change-Id: I07073870d9040c2bc8519882c8b3c1368edd4513
2019-10-24 13:47:37 -05:00
Tom Tromey c12d372d26 Check for sigprocmask in common.m4
I noticed that gdbsupport uses HAVE_SIGPROCMASK, but common.m4 does
not check for it.  This means that gdbserver may not compile some
gdbsupport code properly.  This patch fixes this error.

gdb/ChangeLog
2019-10-23  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* configure.ac: Don't check for sigprocmask.
	* gdbsupport/common.m4 (GDB_AC_COMMON): Check for sigprocmask.

gdb/gdbserver/ChangeLog
2019-10-23  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

Change-Id: I2c0a4dd2c376507b9483b38707a242382faa8163
2019-10-23 09:06:21 -06:00
Christian Biesinger ccb1ba6229 Use libxxhash for hashing, if present
XXHash is faster than htab_hash_string:
------------------------------------------------------------
Benchmark                     Time           CPU Iterations
------------------------------------------------------------
BM_xxh3                      11 ns         11 ns   65887249
BM_xxh32                     19 ns         19 ns   36511877
BM_xxh64                     16 ns         16 ns   42964585
BM_hash_string              182 ns        182 ns    3853125
BM_iterative_hash            77 ns         77 ns    9087638

Unfortunately, XXH3 is still experimental (see
https://github.com/Cyan4973/xxHash#user-content-new-experimental-hash-algorithm)

However, regular XXH64 is still a lot faster than
htab_hash_string per my benchmark above. I used the
following string for the benchmark:
static constexpr char str[] = "_ZZZL13make_gdb_typeP7gdbarchP10tdesc_typeEN16gdb_type_creator19make_gdb_type_flagsEPK22tdesc_type_with_fieldsE19__PRETTY_FUNCTION__";

htab_hash_string is currently 4.35% + 7.98% (rehashing) of gdb
startup when attaching to Chrome's content_shell.

An additional 5.21% is spent in msymbol_hash, which does not use
this hash function. Unfortunately, since it has to lowercase the
string, it can't use this hash function.
BM_msymbol_hash                52 ns         52 ns   13281495

It may be worth investigating if strlen+XXHash is still faster than
htab_hash_string, which would make it easier to use in more places.

Debian ships xxhash as libxxhash{0,-dev}. Fedora ships it as xxhash-devel.

gdb/ChangeLog:

2019-10-22  Christian Biesinger  <cbiesinger@google.com>

	* Makefile.in: Link with libxxhash.
	* config.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Search for libxxhash.
	* utils.c (fast_hash): Use xxhash if present.

Change-Id: Icab218388b9f829522ed3977f04301ae6d4fc4ca
2019-10-22 11:47:24 -05:00
Tom Tromey a0a461e5b4 Fix creation of nm.h when configure is changed
My earlier patch -- commit c5adaa192 ("Fix creation of stamp-h by
gdb's configure script") -- broke the creation of nm.h.  In
particular, configure removes nm.h, so if you touch configure and
rebuild, nothing will re-create the link, breaking the build.

This patch fixes the bug, and also updates configure.ac to use
AC_CONFIG_LINKS, rather than the obsolete AC_LINK_FILES.

Finally, I noticed that gcore is in generated_files in the
Makefile.in.  I think this is incorrect, as generated_files is only
needed for files that can be the target of a #include.  So, this patch
removes it.

gdb/ChangeLog
2019-10-21  Tom Tromey  <tom@tromey.com>

	* configure.ac (nm.h): Conditionally create nm.h link.  Subst
	NM_H.   Use AC_CONFIG_LINKS.
	* configure: Rebuild.
	* Makefile.in (NM_H): New variable.
	(generated_files): Add NM_H.  Remove gcore.
	(nm.h, stamp-nmh): New targets.

Change-Id: I8dd539785d52455e85389425e4bb996c8a127a0e
2019-10-21 07:45:30 -06:00
Tom Tromey c5adaa1921 Fix creation of stamp-h by gdb's configure script
I happened to notice that "make" would always print:

    CONFIG_HEADERS=config.h:config.in \
      CONFIG_COMMANDS="default depdir" \
      CONFIG_FILES= \
      CONFIG_LINKS= \
      /bin/sh config.status
    config.status: creating config.h
    config.status: config.h is unchanged

on every rebuild.  This seems to have changed due to an autoconf
upgrade at some point in the past.  In the autoconf gdb uses now, it
works to use AC_CONFIG_HEADERS and then create the stamp file via the
"commands" argument.

This patch also fixes up Makefile.in to use the new-style
config.status invocation.  It's no longer necessary to pass the output
file names via environment variables.

gdb/ChangeLog
2019-10-17  Tom Tromey  <tromey@adacore.com>

	* configure: Rebuild.
	* configure.ac: Use AC_CONFIG_HEADERS.  Create stamp-h there, not
	in AC_CONFIG_FILES invocation.
	* Makefile.in (Makefile, data-directory/Makefile, stamp-h): Use
	new-style config.status invocation.

gdb/gdbserver/ChangeLog
2019-10-17  Tom Tromey  <tromey@adacore.com>

	* configure: Rebuild.
	* configure.ac: Use AC_CONFIG_HEADERS.  Create stamp-h there, not
	in AC_CONFIG_FILES invocation.
	* Makefile.in (stamp-h, Makefile): Use new-style config.status
	invocation.

Change-Id: Ia0530d1c5b9756812d29ddb8dc1062326155e61e
2019-10-17 13:21:24 -06:00
Sergio Durigan Junior 2d41fa1165 Move gdb-dlfcn.[ch] to gdbsupport/
I need to use 'gdb_dlopen' inside 'gdbsupport/', but it's not yet
supported there.  This commit moves 'gdb-dlfcn.[ch]' to 'gdbsupport/',
which makes it available also on gdbserver.

gdb/ChangeLog:
2019-08-23  Sergio Durigan Junior  <sergiodj@redhat.com>

	* configure.ac: Don't check for 'dlfcn.h' (moved to
	gdbsupport/common.m4).
	* Makefile.in (COMMON_SFILES): Move 'gdb-dlfcn.c' to
	'gdbsupport/'.
	(HFILES_NO_SRCDIR): Likewise, for 'gdb-dlfcn.h'.
	* compile/compile-c-support.c: Include
	'gdbsupport/gdb-dlfcn.h'.
	* gdbsupport/common.m4: Check for 'dlfcn.h'.
	* gdb-dlfcn.c: Move to...
	* gdbsupport/gdb-dlfcn.c: ... here.
	* gdb-dlfcn.h: Move to...
	* gdbsupport/gdb-dlfcn.h: ... here.

gdb/gdbserver/ChangeLog:
2019-08-23  Sergio Durigan Junior  <sergiodj@redhat.com>

	* Makefile.in (SFILES): Add 'gdbsupport/gdb-dlfcn.c'.
	(OBS): Add 'gdbsupport/gdb-dlfcn.o'.
	* config.in: Regenerate.
	* configure: Regenerate.
2019-08-23 13:13:18 -04:00
Tom Tromey d806ea2d0e Add Rust support to source highlighting
Currently, no release of GNU Source Highlight supports Rust.  However,
I've checked in a patch to do so there, and I plan to make a new
release sometime this summer.

This patch prepares gdb for that by adding support for Rust to the
source highlighting code.

Because Source Highlight will throw an exception if the language is
unrecognized, this also changes gdb to ignore exceptions here.  This
will cause gdb to fall back to un-highlighted source text.

This updates gdb's configure script to reject the combination of
Source Highlight and -static-libstdc++.  This is done because it's not
possible to use -static-libstdc++ and then catch exceptions from a
shared library.

Tested with the current and development versions of Source Highlight.

gdb/ChangeLog
2019-08-19  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* configure.ac: Disallow the combination of -static-libstdc++ and
	source highlight.
	* source-cache.c (get_language_name): Handle rust.
	(source_cache::get_source_lines): Ignore highlighting exceptions.
2019-08-19 10:17:27 -06:00
Tom Tromey 86c6b807f5 Require readline 7 or newer
This changes gdb to require readline 7 or newer at build time.

gdb/ChangeLog
2019-08-12  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* configure.ac: Check for readline 7.
	* NEWS: Mention readline 7 requirement.
	* README: Update.

gdb/doc/ChangeLog
2019-08-12  Tom Tromey  <tom@tromey.com>

	* gdb.texinfo (Configure Options): Document minimum version of
	readline.
2019-08-12 10:57:56 -06:00
Frank Ch. Eigler 404f29021a [PR build/24886] disable glibc mcheck support
This patch drops gdb's configury support for glibc's mcheck function.
It has been observed to cause false abort()s, because it is
thread-unsafe yet interposes every malloc/free operation.  So if any
library transitively used by gdb also uses threads, then these
functions can easily corrupt their own checking data.  These days, gcc
ASAN and valgrind provide high quality checking, and mcheck is
apparently itself being slowly deprecated.

So, let's stop linking to it.  Attached patch drops the
autoconf/Makefile machinery for both gdb and gdbserver.  No
testsuite-visible impact.  IMHO not worth mentioning in NEWS.

See also: https://sourceware.org/bugzilla/show_bug.cgi?id=9939

gdb/ChangeLog

        PR build/24886
        * configure.ac: Drop enable-libmcheck support.
        * configure, config.in: Rebuild.
        * libmcheck.m4: Remove.
        * acinclude.m4: Don't include it.
        * Makefile.in: Don't distribute it.
        * top.c (print_gdb_configuration): Don't mention it.

gdb/gdbserver/ChangeLog

        PR build/24886
        * configure.ac: Drop enable-libmcheck support.
        * configure, config.in: Rebuild.
        * acinclude.m4: Don't include it.
2019-08-06 15:09:53 -04:00
Tom Tromey 268a13a5a3 Rename common to gdbsupport
This is the next patch in the ongoing series to move gdbsever to the
top level.

This patch just renames the "common" directory.  The idea is to do
this move in two parts: first rename the directory (this patch), then
move the directory to the top.  This approach makes the patches a bit
more tractable.

I chose the name "gdbsupport" for the directory.  However, as this
patch was largely written by sed, we could pick a new name without too
much difficulty.

Tested by the buildbot.

gdb/ChangeLog
2019-07-09  Tom Tromey  <tom@tromey.com>

	* contrib/ari/gdb_ari.sh: Change common to gdbsupport.
	* configure: Rebuild.
	* configure.ac: Change common to gdbsupport.
	* gdbsupport: Rename from common.
	* acinclude.m4: Change common to gdbsupport.
	* Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES)
	(HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to
	gdbsupport.
	* aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c,
	amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c,
	amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c,
	amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c,
	amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c,
	arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c,
	arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c,
	arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c,
	arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c,
	auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h,
	btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c,
	charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c,
	cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c,
	coff-pe-read.c, command.h, compile/compile-c-support.c,
	compile/compile-c.h, compile/compile-cplus-symbols.c,
	compile/compile-cplus-types.c, compile/compile-cplus.h,
	compile/compile-loc2c.c, compile/compile.c, completer.c,
	completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c,
	cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c,
	darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c,
	disasm.h, dtrace-probe.c, dwarf-index-cache.c,
	dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c,
	dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c,
	event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c,
	features/aarch64-core.c, features/aarch64-fpu.c,
	features/aarch64-pauth.c, features/aarch64-sve.c,
	features/i386/32bit-avx.c, features/i386/32bit-avx512.c,
	features/i386/32bit-core.c, features/i386/32bit-linux.c,
	features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c,
	features/i386/32bit-segments.c, features/i386/32bit-sse.c,
	features/i386/64bit-avx.c, features/i386/64bit-avx512.c,
	features/i386/64bit-core.c, features/i386/64bit-linux.c,
	features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c,
	features/i386/64bit-segments.c, features/i386/64bit-sse.c,
	features/i386/x32-core.c, features/riscv/32bit-cpu.c,
	features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c,
	features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c,
	features/riscv/64bit-fpu.c, features/tic6x-c6xp.c,
	features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h,
	findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h,
	gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c,
	gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c,
	go32-nat.c, guile/guile.c, guile/scm-ports.c,
	guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c,
	i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c,
	i386-linux-tdep.c, i386-tdep.c, i387-tdep.c,
	ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c,
	inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h,
	inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h,
	inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c,
	linux-tdep.c, linux-thread-db.c, location.c, machoread.c,
	macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h,
	mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c,
	mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h,
	minsyms.c, mips-linux-tdep.c, namespace.h,
	nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h,
	nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c,
	nat/amd64-linux-siginfo.c, nat/fork-inferior.c,
	nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c,
	nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c,
	nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h,
	nat/linux-waitpid.c, nat/mips-linux-watch.c,
	nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c,
	nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c,
	nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h,
	obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c,
	parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c,
	procfs.c, producer.c, progspace.h, psymtab.h,
	python/py-framefilter.c, python/py-inferior.c, python/py-ref.h,
	python/py-type.c, python/python.c, record-btrace.c, record-full.c,
	record.c, record.h, regcache-dump.c, regcache.c, regcache.h,
	remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c,
	riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c,
	selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c,
	ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c,
	source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c,
	stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h,
	symtab.c, symtab.h, target-descriptions.c, target-descriptions.h,
	target-memory.c, target.c, target.h, target/waitstatus.c,
	target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c,
	top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c,
	tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h,
	unittests/array-view-selftests.c,
	unittests/child-path-selftests.c, unittests/cli-utils-selftests.c,
	unittests/common-utils-selftests.c,
	unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c,
	unittests/format_pieces-selftests.c,
	unittests/function-view-selftests.c,
	unittests/lookup_name_info-selftests.c,
	unittests/memory-map-selftests.c, unittests/memrange-selftests.c,
	unittests/mkdir-recursive-selftests.c,
	unittests/observable-selftests.c,
	unittests/offset-type-selftests.c, unittests/optional-selftests.c,
	unittests/parse-connection-spec-selftests.c,
	unittests/ptid-selftests.c, unittests/rsp-low-selftests.c,
	unittests/scoped_fd-selftests.c,
	unittests/scoped_mmap-selftests.c,
	unittests/scoped_restore-selftests.c,
	unittests/string_view-selftests.c, unittests/style-selftests.c,
	unittests/tracepoint-selftests.c, unittests/unpack-selftests.c,
	unittests/utils-selftests.c, unittests/xml-utils-selftests.c,
	utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c,
	value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c,
	xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c,
	xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport.

gdb/gdbserver/ChangeLog
2019-07-09  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* configure.ac: Change common to gdbsupport.
	* acinclude.m4: Change common to gdbsupport.
	* Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS)
	(version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change
	common to gdbsupport.
	* ax.c, event-loop.c, fork-child.c, gdb_proc_service.h,
	gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c,
	inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c,
	linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c,
	linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c,
	linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h,
	nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c,
	server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h,
	thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change
	common to gdbsupport.
2019-07-09 07:45:38 -06:00
Tom Tromey 73cc72729a Move gnulib to top level
This patch moves the gdb/gnulib subdirectory to the top level.

It adjusts the top-level build system to build gnulib when necessary,
and changes gdb to use this.  However, gdbserver still builds its own
copy of gnulib, just from the new source location.

A small hack was needed to ensure that gnulib is only built when gdb
is enabled.  The Makefile only provides an ordering -- the directory
must be mentioned in configdirs to actually be compiled at all.

Most of the patch is just a "git mv" of gnulib, though a few minor
path adjustments were needed in some files there.

Tested by the buildbot.

ChangeLog
2019-06-14  Tom Tromey  <tom@tromey.com>

	* MAINTAINERS: Add gnulib.
	* gnulib: New directory, move from gdb/gnulib.
	* configure.ac (host_libs): Add gnulib.
	* configure: Rebuild.
	* Makefile.def (host_modules, dependencies): Add gnulib.
	* Makefile.in: Rebuild.

gdb/ChangeLog
2019-06-14  Tom Tromey  <tom@tromey.com>

	* gnulib: Move directory to top-level.
	* configure.ac: Don't configure gnulib.
	* configure: Rebuild.
	* common/common-defs.h: Use new path to gnulib.
	* Makefile.in (GNULIB_BUILDDIR): Now ../gnulib.
	(GNULIB_H): Remove.
	(INCGNU): Look in new gnulib location.
	(HFILES_NO_SRCDIR): Remove gnulib files.
	(SUBDIR, REQUIRED_SUBDIRS): Remove gnulib.
	(generated_files): Remove GNULIB_H.
	($(LIBGNU), all-lib): Remove targets.
	(distclean): Don't mention GNULIB_BUILDDIR.
	($(GNULIB_BUILDDIR)/Makefile): Remove target.

gdb/gdbserver/ChangeLog
2019-06-14  Tom Tromey  <tom@tromey.com>

	* configure.ac: Use new path to gnulib.
	* configure: Rebuild.
	* Makefile.in (INCGNU, $(GNULIB_BUILDDIR)/Makefile): Use new path
	to gnulib.

gnulib/ChangeLog
2019-06-14  Tom Tromey  <tom@tromey.com>

	* update-gnulib.sh: Adjust paths.
	* Makefile.in: Adjust paths.
	* configure.ac: Adjust paths.  Use ACX_LARGEFILE.
	* configure: Rebuild.
2019-06-14 12:40:02 -06:00
Tom Tromey 33a6bc350f Add new GCC 9 warnings to warnings.m4
GCC 9 has a few new warnings that aren't enabled in the gdb build by
default: -Wdeprecated-copy, -Wdeprecated-copy-dtor, and
-Wredundant-move.  This patch enables them all.

Tested by rebuilding with a new GCC (git master) on x86-64 Fedora 29.

gdb/ChangeLog
2019-05-29  Tom Tromey  <tromey@adacore.com>

	* inflow.c (struct terminal_info): Add default operator=.
	* configure: Rebuild.
	* warning.m4 (AM_GDB_WARNINGS): Add -Wdeprecated-copy,
	-Wdeprecated-copy-dtor, -Wredundant-move.

gdb/gdbserver/ChangeLog
2019-05-29  Tom Tromey  <tromey@adacore.com>

	* configure: Rebuild.
2019-05-29 08:56:23 -06:00
Sergei Trofimovich 189b8c2e10 gdb/configure.ac: add --enable-source-highlight
Allow disabling source-highlight dependency autodetection even
it exists in the system. More details on problem of automatic
dependencies:
https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Automagic_dependencies

Noticed by Jeroen Roovers in https://bugs.gentoo.org/680238

	* configure.ac: add --enable-source-highlight switch.
	* configure: Regenerate.
	* top.c (print_gdb_version): plumb --enable-source-highlight
	status to "show configuration".

gdb/ChangeLog
2019-04-19  Sergei Trofimovich <siarheit@google.com>

	* configure.ac: add --enable-source-highlight switch.
	* configure: Regenerate.
	* top.c (print_gdb_version): plumb --enable-source-highlight
	status to "show configuration".
2019-04-19 14:05:47 -06:00
Tom Tromey 6c28e44a35 Remove Python 2.4 and 2.5 support
This removes all the remainings spots I could find that work around
issues in Python 2.4 and 2.5.

I don't have a good way to test that Python 2.6 still works.

Tested by the buildbot.

gdb/ChangeLog
2019-02-27  Tom Tromey  <tromey@adacore.com>

	* config.in, configure: Rebuild.
	* configure.ac (HAVE_LIBPYTHON2_4, HAVE_LIBPYTHON2_5): Never
	define.
	* python/py-value.c: Remove Python 2.4 workaround.
	* python/py-utils.c (gdb_pymodule_addobject): Remove Python 2.4
	workaround.
	* python/py-type.c (convert_field, gdbpy_initialize_types): Remove
	Python 2.4 workaround.
	* python/python-internal.h: Remove Python 2.4 comment.
	(Py_ssize_t): Don't define.
	(PyVarObject_HEAD_INIT, Py_TYPE): Don't define.
	(gdb_Py_DECREF): Remove Python 2.4 workaround.
	(gdb_PyObject_GetAttrString, PyObject_GetAttrString): Remove.
	(gdb_PyObject_HasAttrString, PyObject_HasAttrString): Remove.
	* python/python.c (do_start_initialization): Remove Python 2.4
	workaround.
	* python/py-prettyprint.c (class dummy_python_frame): Remove.
	(print_children): Remove Python 2.4 workaround.
	* python/py-inferior.c (buffer_procs): Remove Python 2.4
	workaround.
	(CHARBUFFERPROC_NAME): Remove.
	* python/py-breakpoint.c (gdbpy_initialize_breakpoints): Remove
	Python 2.4 workaround.

gdb/testsuite/ChangeLog
2019-02-27  Tom Tromey  <tromey@adacore.com>

	* lib/gdb.exp (skip_python_tests_prompt): Don't check for Python
	2.4.
	* gdb.python/py-finish-breakpoint.exp: Remove Python 2.4
	workaround.

gdb/ChangeLog
2019-02-27  Tom Tromey  <tromey@adacore.com>

	* config.in, configure: Rebuild.
	* configure.ac (HAVE_LIBPYTHON2_4, HAVE_LIBPYTHON2_5): Never
	define.
	* python/py-value.c: Remove Python 2.4 workaround.
	* python/py-utils.c (gdb_pymodule_addobject): Remove Python 2.4
	workaround.
	* python/py-type.c (convert_field, gdbpy_initialize_types): Remove
	Python 2.4 workaround.
	* python/python-internal.h: Remove Python 2.4 comment.
	(Py_ssize_t): Don't define.
	(PyVarObject_HEAD_INIT, Py_TYPE): Don't define.
	(gdb_Py_DECREF): Remove Python 2.4 workaround.
	(gdb_PyObject_GetAttrString, PyObject_GetAttrString): Remove.
	(gdb_PyObject_HasAttrString, PyObject_HasAttrString): Remove.
	* python/python.c (do_start_initialization): Remove Python 2.4
	workaround.
	* python/py-prettyprint.c (class dummy_python_frame): Remove.
	(print_children): Remove Python 2.4 workaround.
	* python/py-inferior.c (buffer_procs): Remove Python 2.4
	workaround.
	(CHARBUFFERPROC_NAME): Remove.
	* python/py-breakpoint.c (gdbpy_initialize_breakpoints): Remove
	Python 2.4 workaround.
2019-02-27 11:43:06 -07:00
Tom Tromey 62f29fda90 Highlight source code using GNU Source Highlight
This changes gdb to highlight source using GNU Source Highlight, if it
is available.

This affects the output of the "list" command and also the TUI source
window.

No new test because I didn't see a way to make it work when Source
Highlight is not found.

gdb/ChangeLog
2018-12-28  Tom Tromey  <tom@tromey.com>

	* utils.h (can_emit_style_escape): Declare.
	* utils.c (can_emit_style_escape): No longer static.
	* cli/cli-style.c (set_style_enabled): New function.
	(_initialize_cli_style): Use it.
	* tui/tui-winsource.c (tui_show_source_line): Use tui_puts.
	(tui_alloc_source_buffer): Change how source lines are allocated.
	* tui/tui-source.c (copy_source_line): New function.
	(tui_set_source_content): Use source cache.
	* tui/tui-io.h (tui_puts): Update.
	* tui/tui-io.c (tui_puts_internal): Add window parameter.
	(tui_puts): Likewise.
	(tui_redisplay_readline): Update.
	* tui/tui-data.c (free_content_elements): Change how source window
	contents are freed.
	* source.c (forget_cached_source_info): Clear the source cache.
	(print_source_lines_base): Use the source cache.
	* source-cache.h: New file.
	* source-cache.c: New file.
	* configure.ac: Check for GNU Source Highlight library.
	* configure: Update.
	* config.in: Update.
	* Makefile.in (SRCHIGH_LIBS, SRCHIGH_CFLAGS): New variables.
	(INTERNAL_CFLAGS_BASE): Add SRCHIGH_CFLAGS.
	(CLIBS): Add SRCHIGH_LIBS.
	(COMMON_SFILES): Add source-cache.c.
	(HFILES_NO_SRCDIR): Add source-cache.h.
2018-12-28 12:49:54 -07:00
Tom Tromey 1d1d0bf76f Make ANSI terminal escape sequences work in TUI
PR tui/14126 notes that ANSI terminal escape sequences don't affect
the colors shown in the TUI.  A simple way to see this is to try the
extended-prompt example from the gdb manual.

Curses does not pass escape sequences through to the terminal.
Instead, it replaces non-printable characters with a visible
representation, for example "^[" for the ESC character.

This patch fixes the problem by adding a simple ANSI terminal sequence
parser to gdb.  These sequences are decoded and those that are
recognized are turned into the appropriate curses calls.

The curses approach to color handling is unusual and so there are some
oddities in the implementation.

Standard curses has no notion of the default colors of the terminal.
So, if you set the foreground color, it is not possible to reset it --
you have to pick some other color.  ncurses provides an extension to
handle this, so this patch updates configure and uses it when
available.

Second, in curses, colors always come in pairs: you cannot set just
the foreground.  This patch handles this by tracking actually-used
pairs of colors and keeping a table of these for reuse.

Third, there are a limited number of such pairs available.  In this
patch, if you try to use too many color combinations, gdb will just
ignore some color changes.

Finally, in addition to limiting the number of color pairs, curses
also limits the number of colors.  This means that, when using
extended 8- or 24-bit color sequences, it may be possible to exhaust
the curses color table.

I am very sour on the curses design now.

I do not know how to write a test for this, so I did not.

gdb/ChangeLog
2018-12-28  Tom Tromey  <tom@tromey.com>

	PR tui/14126:
	* tui/tui.c (tui_enable): Call start_color and
	use_default_colors.
	* tui/tui-io.c (struct color_pair): New.
	(color_pair_map, last_color_pair, last_style): New globals.
	(tui_setup_io): Clean up color map when shutting down.
	(curses_colors): New constant.
	(get_color_pair, apply_ansi_escape): New functions.
	(tui_write): Rewrite.
	(tui_puts_internal): New function, from tui_puts.  Add "height"
	parameter.
	(tui_puts): Use tui_puts_internal.
	(tui_redisplay_readline): Use tui_puts_internal.
	(_initialize_tui_io): New function.
	(color_map): New globals.
	(get_color): New function.
	* configure.ac: Check for use_default_colors.
	* config.in, configure: Rebuild.
2018-12-28 12:49:53 -07:00
Simon Marchi 2578ecb1b5 Look for tgetent in libtinfow
On some systems where ncurses is only available in the "wide" version
(compiled with --with-widec), there might be no libtinfo.so, only a
libtinfow.so.  Look for libtinfow in addition to libtinfo.

gdb/ChangeLog:

YYYY-MM-DD  Simon Marchi  <simon.marchi@ericsson.com>
        Дилян Палаузов  <dilyan.palauzov@aegee.org>

    PR gdb/23950
    * configure.ac: Search for tgetent in libtinfow.
    * configure: Re-generate.
2018-12-08 19:36:19 -05:00
John Baldwin 2861ee4fde Use separate sed expressions to escape auto-load directories.
Not all sed implementations support alternation via \| in the default
regular expressions.  Instead, resort to separate sed expressions via
-e for $debugdir and $datadir.  This fixes the default setting of the
auto-load directories on FreeBSD.  Previously on FreeBSD the sed
invocation was a no-op causing the debugdir and datadir values to be
expanded yielding an autoload path of ':${prefix}/share/gdb'.

gdb/ChangeLog:

	* configure: Re-generate.
	* configure.ac: Use separate sed expressions to escape variables
	in auto-load directories.
2018-12-05 10:51:16 -08:00
Hafiz Abid Qadeer 5d762de01c Fix a typo in iconv.m4.
config/
2018-11-09  Hafiz Abid Qadeer  <abidh@codesourcery.com>

	* iconv.m4 (AM_ICONV_LINK): Don't overwrite CPPFLAGS.
	Append $INCICONV to it.

gdb/
2018-11-09  Hafiz Abid Qadeer  <abidh@codesourcery.com>

	* configure: Regenerate.

binutils/
2018-11-09  Hafiz Abid Qadeer  <abidh@codesourcery.com>

	* configure: Regenerate.

intl/
2018-11-09  Hafiz Abid Qadeer  <abidh@codesourcery.com>

	* configure: Regenerate.
2018-11-09 16:08:10 +00:00
Simon Marchi e8d8cce69b Import mkdtemp gnulib module, fix mingw build
Building with mingw currently fails:

  CXX    unittests/mkdir-recursive-selftests.o
/home/emaisin/src/binutils-gdb/gdb/unittests/mkdir-recursive-selftests.c: In function ‘void selftests::mkdir_recursive::test()’:
/home/emaisin/src/binutils-gdb/gdb/unittests/mkdir-recursive-selftests.c:49:20: error: ‘mkdtemp’ was not declared in this scope
   if (mkdtemp (base) == NULL)
                    ^
Commit

    e418a61a67 ("Move mkdir_recursive to common/filestuff.c")

moved this code, but also removed the HAVE_MKDTEMP guard which prevented
the mkdtemp call to be compiled on mingw.

We can either put back the HAVE_MKDTEMP ifdef, or import the gnulib
mkdtemp module, which provides the function for mingw.  Since the
mkdir_recursive is susceptible to be used on mingw at some point, I
think it would be nice to have it tested on mingw, so I did the latter.

Once built, I tested it on Windows (copied the resulting gdb.exe on a
Windows machine, ran it, and ran "maint selftest mkdir_recursive").  It
failed, because the temporary directory is hardcoded to "/tmp/...".  I
therefore added and used a new get_standard_temp_dir function, which
returns an appropriate temporary directory for the host platform.

gdb/ChangeLog:

	* common/pathstuff.c (get_standard_temp_dir): New.
	* common/pathstuff.h (get_standard_temp_dir): New.
	* config.in: Re-generate.
	* configure: Re-generate.
	* configure.ac: Don't check for mkdtemp.
	* gnulib/aclocal-m4-deps.mk: Re-generate.
	* gnulib/aclocal.m4: Re-generate.
	* gnulib/config.in: Re-generate.
	* gnulib/configure: Re-generate.
	* gnulib/import/Makefile.am: Re-generate.
	* gnulib/import/Makefile.in: Re-generate.
	* gnulib/import/m4/gnulib-cache.m4: Re-generate.
	* gnulib/import/m4/gnulib-comp.m4: Re-generate.
	* gnulib/import/m4/mkdtemp.m4: New file.
	* gnulib/import/mkdtemp.c: New file.
	* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES):
	Add mkdtemp module.
	* unittests/mkdir-recursive-selftests.c (test): Use
	get_standard_temp_dir.
	(_initialize_mkdir_recursive_selftests): Remove HAVE_MKDTEMP
	ifdef.
	* compile/compile.c (get_compile_file_tempdir): Likewise.
2018-11-01 15:41:43 -04:00
Simon Marchi 7f53228719 Revert "GDB: Only build for "unix:" connections if AF_LOCAL is supported."
This reverts commit 98a17ece01.
2018-10-29 13:22:42 -04:00
John Darrington 98a17ece01 GDB: Only build for "unix:" connections if AF_LOCAL is supported.
Commit f19c7ff839 added a new member to the
prefixes array which included a use of the symbol AF_LOCAL.   Unfortunately,
not all systems declare this symbol.    This change only compiles the "unix:"
member if the system knows about AF_LOCAL.

gdb/ChangeLog:

* configure.ac: New test HAVE_AF_LOCAL
* common/netstuff.c (parse_connection_spec) [prefixes]: Only compile "unix:"
   if HAVE_AF_LOCAL is true.
* configure: regenerate.
* config.in: regenerate.
2018-10-29 08:07:32 +01:00
Sergio Durigan Junior 8ecfd7bd4a Add parameter to allow enabling/disabling selftests via configure
This is a follow-up of:

  https://sourceware.org/ml/gdb-patches/2018-08/msg00347.html

Instead of going throttle and always enabling our selftests (even in
non-development builds), this patch is a bit more conservative and
introduces a configure option ("--enable-unit-tests") that allows the
user to choose whether she wants unit tests in the build or not.  Note
that the current behaviour is retained: if no option is provided, GDB
will have selftests included in a development build, and will *not*
have selftests included in a non-development build.

The rationale for having this option is still the same: due to the
many racy testcases and random failures we see when running the GDB
testsuite, it is unfortunately not possible to perform a full test
when one is building a downstream package.  As the Fedora GDB
maintainer and one of the Debian GDB uploaders, I feel like this
situation could be improved by, at least, executing our selftests
after the package has been built.

This patch introduces no regressions to our build.

OK?

gdb/ChangeLog:
2018-10-10  Sergio Durigan Junior  <sergiodj@redhat.com>
	    Simon Marchi <simark@simark.ca>

	* README (`configure' options): Add documentation for new
	"--enable-unit-tests" option.
	* acinclude.m4: Include "selftest.m4".
	* configure: Regenerate.
	* configure.ac: Use "GDB_AC_SELFTEST".
	* maint.c (maintenance_selftest): Update message informing
	that selftests have been disabled.
	(maintenance_info_selftests): Likewise.
	* selftest.m4: New file.

gdb/gdbserver/ChangeLog:
2018-10-10  Sergio Durigan Junior  <sergiodj@redhat.com>
	    Simon Marchi <simark@simark.ca>

	* acinclude.m4: Include "../selftest.m4".
	* configure: Regenerate.
	* configure.ac: Use "GDB_AC_SELFTEST".
	* configure.srv: Use "$enable_unittests" instead of
	"$development" when checking whether unit tests have been
	enabled.
	* server.c (captured_main): Update message informing that
	selftests have been disabled.

gdb/testsuite/ChangeLog:
2018-10-10  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdb.gdb/unittest.exp: Update expected message informing that
	selftests have been disabled.
	* gdb.server/unittest.exp: Likewise.

squash! Add parameter to allow enabling/disabling selftests via configure
2018-10-10 16:23:56 -04:00
Tom Tromey eff98030f9 Disable the undefined behavior sanitizer by default
There have been a few undefined behavior failures reported, and Pedro
suggested that the sanitizer be disabled by default.  This patch
implements this.

gdb/ChangeLog
2018-10-09  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* sanitize.m4 (AM_GDB_UBSAN): Default to no.
	* NEWS: Update --enable-ubsan documentation.

gdb/doc/ChangeLog
2018-10-09  Tom Tromey  <tom@tromey.com>

	* gdb.texinfo (Configure Options): Update --enable-ubsan
	documentation.
2018-10-09 11:51:33 -06:00
Tom Tromey 96643e35c0 Add -Wshadow=local
This adds -Wshadow=local to configure.

gdb/ChangeLog
2018-10-04  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* warning.m4 (AM_GDB_WARNINGS): Add -Wshadow=local.

gdb/gdbserver/ChangeLog
2018-10-04  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
2018-10-04 22:51:49 -06:00
Tom Tromey f35d5adea1 Add --enable-ubsan
This adds --enable-ubsan to gdb's configure.  By default it is enabled
in development mode, and disabled otherwise.  This passes both
-fsanitize=undefined and -fno-sanitize-recover=undefined to
compilations, so that undefined behavior violations will be sure to
cause test failures.

gdb/ChangeLog
2018-10-03  Tom Tromey  <tom@tromey.com>

	* README: Mention --enable-ubsan.
	* NEWS: Mention --enable-ubsan.
	* acinclude.m4: Include sanitize.m4.
	* configure: Rebuild.
	* configure.ac: Call AM_GDB_UBSAN.
	* sanitize.m4: New file.

gdb/doc/ChangeLog
2018-10-03  Tom Tromey  <tom@tromey.com>

	* gdb.texinfo (Configure Options): Document --enable-ubsan.
2018-10-03 15:19:06 -06:00
John Darrington c1168a2f66 Allow remote debugging over a Unix local domain socket.
Extend the "target remote" and "target extended-remote" commands
such that if the filename provided is a Unix local domain (AF_UNIX)
socket, then it'll be treated as such, instead of trying to open
it as if it were a character device.

gdb/ChangeLog:
	* NEWS: Mention changed commands.
	* ser-uds.c: New file.
	* configure.ac (SER_HARDWIRE): Add ser-uds.o.
	* configure: Regenerate.
	* Makefile.in: Add new file.
	* serial.c (serial_open): Check if filename is a socket
	  and lookup the appropriate interface accordingly.

gdb/doc/ChangeLog:
	* gdb.texinfo (Remote Connection Commands): Describe
	  the changes to target remote and target extended-remote
	  relating to Unix domain sockets.
2018-10-02 16:10:57 +02:00
Gary Benson 12b164e9a9 Remove ancient workaround
This commit removes a workaround for a bug in glibc 2.1.3, which
was released 2000-02-24 and superseded 2000-11-09.

gdb/ChangeLog:

	* gdb_proc_service.h (gdb_prfpregset_t): Remove typedef.
	* proc-service.c (ps_lgetfpregs, ps_lsetfpregs): Use
	prfpregset_t instead of gdb_prfpregset_t.
	* configure.ac (PRFPREGSET_T_BROKEN): Remove check.
	* configure, config.in: Rebuild.
2018-10-01 10:37:39 +01:00
Gary Benson 43b7e92b0c Add workaround from gdbserver's gdb_proc_service.h to GDB
This commit adds a workaround from gdbserver's gdb_proc_service.h
to GDB's.  It doesn't seem to have been needed on any glibc as far
back as 2001, but it's possibly required for other C libraries so
I've retained it.

gdb/ChangeLog:

	* configure.ac: Check if sys/procfs.h defines elf_fpregset_t.
	(AC_CHECK_HEADERS): Check for linux/elf.h.
	* configure, config.in: Rebuild.
	* gdb_proc_service.h: Include linux/elf.h if sys/procfs.h
	doesn't define elf_fpregset_t.
2018-10-01 10:37:39 +01:00
Tom Tromey ae292b3afc Do not pass -DNDEBUG to Python compilations in development mode
The Python CFLAGS include -DNDEBUG.  This was apparently done
intentionally -- setting the flags is done manually because, according
to a comment, python-config passes too many things to the compiler
(which is true).

Per PR python/20445, this patch changes configure so that -DNDEBUG is
only used by release builds.  This probably doesn't have very much
effect in practice, but I did see that some Python headers use assert,
so perhaps it will give some safety.

Tested by rebuilding and re-running gdb.python/*.exp on x86-64 Fedora 28.

gdb/ChangeLog
2018-09-17  Tom Tromey  <tom@tromey.com>

	PR python/20445:
	* configure: Rebuild.
	* configure.ac: Conditionally use -DNDEBUG for Python.
2018-09-17 13:51:38 -06:00
Tom Tromey da658607ed Check for gmp when checking for mpfr
There was a report on irc that the gdb check for mpfr failed when only
static libraries are available.  The issue is that mpfr depends on
gmp, but this is not handled explicitly by gdb.

Ideally upstream would switch to pkg-config.  Or even more ideally, we
would incorporate pkg-config into the compiler and not mess with any
of this.

Meanwhile, this changes gdb's configure to add gmp to the link line
when checking for mpfr.

gdb/ChangeLog
2018-09-17  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* configure.ac: Use gmp as a library dependency when checking for
	mpfr.
2018-09-17 13:51:38 -06:00
Tom Tromey f1628857d7 Make -Wformat-nonliteral work with gcc
After looking into why the build failed for Simon but not for me, we
found that the underlying cause was due to how gcc treats
-Wformat-nonliteral.  gcc requires -Wformat to be given first; but
warning.m4 was not doing this, so -Wformat-nonliteral was not being
used.

This patch changes warning.m4 to account gcc's requirement.

This then showed that the target-float.c build change in the earlier
Makefile patch was also incorrect.  Simon didn't see this in his
build, but gcc now points it out.  So, this patch fixes this problem
as well.

2018-09-05  Tom Tromey  <tom@tromey.com>

	* warning.m4 (AM_GDB_WARNINGS): Add -Wformat when testing
	-Wformat-nonliteral.
	* target-float.c (host_float_ops<T>::to_string)
	(host_float_ops<T>::from_string): Use
	DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL.
	* configure: Rebuild.

gdb/gdbserver/ChangeLog
2018-09-05  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
2018-09-05 21:47:33 -06:00
Tom Tromey d53d543682 Remove --enable-multi-ice
gdb's configure script accepts --enable-multi-ice, but the code this
refers to is long gone.  This patch removes the option entirely.

gdb/ChangeLog
2018-09-04  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
	* configure.ac: Remove multi-ice code.
2018-09-04 10:45:55 -06:00