Binutils with MCST patches
Go to file
Joel Brobecker 80d82c1964 [LynxOS] GDBserver crash debugging threaded program
This crash is observable by debugging a threaded program on LynxOS.
On the GDB side, this is what we would see:

    % gdb q
    (gdb) target remote machine:4444
    (gdb) break q.adb:6
    (gdb) cont
    [gdb hits breakpoint]
    (gdb) cont
    Remote connection closed    <<<--- expected: [Inferior 1 (Remote target) exited normally]

On the gdbserver side, which was launched as usual:

    % gdbserver --once :4444 q
    Segmentation fault (core dumped)

Ooops!

The problem happens while GDB is trying to handle the thread termination
event of the thread that hit the breakpoint. It started happening after
the following change was made:

    commit 96e7a1eb6d
    Date:   Fri Oct 16 11:08:38 2015 -0400
    Subject: gdbserver: Reset current_thread when the thread is removed.

    Reset current_thread and make sure 'remove_process' is used
    after all associated threads have been removed first.

More precisely:

  . GDBserver receives the execution-resume order;

  . lynx-low resumes it succesfully, and then relies on lynx_wait_1
    to wait for the next event;

  . We quickly receive one, which lynx_wait_1 analyzes to be
    a "thread exit" event, and therefore does...

          case SIGTHREADEXIT:
            remove_thread (find_thread_ptid (new_ptid));
            lynx_continue (new_ptid);
            goto retry;

    => remove_thread causes current_thread to be set to NULL...
       (that's the recent change mentioned above)

    => ... which causes problems during lynx_continue, because
       it calls lynx_resume, which calls regcache_invalidate,
       which unfortunately assumes that CURRENT_THREAD is not NULL:

        void
        regcache_invalidate (void)
        {
          /* Only update the threads of the current process.  */
SEGV!-->  int pid = ptid_get_pid (current_thread->entry.id);

          find_inferior (&all_threads, regcache_invalidate_one, &pid);
        }

Since the problem at hand is caused by trying to figure out which
inferior to reset the regcache for, and since lynx_resume actually
had that info, this patch fixes the problem by introducing a new
routine called regcache_invalidate_pid, which invalidates the cache
of the given pid; and then modifies lynx_resume use that new routine
rather than relying on regcache_invalidate to invalidate the regcache
of the expected inferior.

gdb/gdbserver/ChangeLog:

        * regcache.h (regcache_invalidate_pid): Add declaration.
        * regcache.c (regcache_invalidate_pid): New function, extracted
        from regcache_invalidate.
        (regcache_invalidate): Reimplement using regcache_invalidate_pid.
        Add trivial documentation comment.
        * lynx-low.c: Use regcache_invalidate_pid instead of
        regcache_invalidate.
2015-11-23 09:56:23 -08:00
bfd Automatic date update in version.in 2015-11-23 00:00:08 +00:00
binutils Fix building objcopy under mingw64 by replacing uses of strndup with xstrndup. 2015-11-20 14:08:29 +00:00
config Missing parts of fixes for in-tree libiconv 2015-08-24 10:57:03 +01:00
cpu Remove leading/trailing white spaces in ChangeLog 2015-07-24 04:16:47 -07:00
elfcpp Add assembler, disassembler and linker support for power9. 2015-11-11 19:52:52 -06:00
etc PR external/{16327,16328}: Remove etc/configure.texi and etc/standards.texi. 2014-06-27 11:33:25 +02:00
gas MIPS/GAS/testsuite: Tighten negative-match NaN tests 2015-11-20 16:17:53 +00:00
gdb [LynxOS] GDBserver crash debugging threaded program 2015-11-23 09:56:23 -08:00
gold [GOLD] PowerPC TOC16 and GOT16 relocs are relative 2015-11-19 17:01:04 +10:30
gprof Bump version to 2.26.51 2015-11-14 16:24:39 -08:00
include [AArch64] Add support for ARMv8.1 Virtulization Host Extensions. 2015-11-20 16:09:34 +00:00
intl Regen intl/configure 2015-08-31 12:53:36 +09:30
ld MIPS/LD: Fix little-endian `mti' and `img' ELF emulations 2015-11-20 16:16:40 +00:00
libdecnumber Remove leading/trailing white spaces in ChangeLog 2015-07-24 04:16:47 -07:00
libiberty Configury changes for obstack optimization 2015-11-09 15:21:50 +10:30
opcodes opcodes: handle mach-o for thumb/arm disambiguation. 2015-11-23 15:50:29 +01:00
readline Revert "Sync readline/ to version 7.0 alpha" 2015-07-25 15:57:00 -04:00
sim sim: common: set up CPPFLAGS/CXXFLAGS/LDFLAGS from configure [PR sim/18762] 2015-11-22 02:23:25 -05:00
texinfo
zlib Remove leading/trailing white spaces in ChangeLog 2015-07-24 04:16:47 -07:00
.cvsignore
.gitattributes Add a .gitattributes file for use with git-merge-changelog 2014-07-25 18:07:23 -04:00
.gitignore Sync the root .gitignore file with GCC's. 2013-01-11 15:17:35 +00:00
COPYING
COPYING.LIB
COPYING.LIBGLOSS
COPYING.NEWLIB 2013-10-01 Jeff Johnston <jjohnstn@redhat.com> 2013-10-01 18:14:04 +00:00
COPYING3
COPYING3.LIB
ChangeLog binutils: add support for arm-*-darwin and aarch64-*-darwin. 2015-11-20 14:53:06 +01:00
MAINTAINERS Update description of ownership of files in include/ 2014-11-04 16:14:14 -08:00
Makefile.def Resync files in the binutils repository that are maintained in the gcc repository. 2015-09-30 17:55:16 +01:00
Makefile.in Resync files in the binutils repository that are maintained in the gcc repository. 2015-09-30 17:55:16 +01:00
Makefile.tpl Sync Makefile.tpl with GCC 2015-07-14 09:52:36 -07:00
README
README-maintainer-mode
compile Update from upstream Automake 2014-11-16 13:43:48 +01:00
config-ml.in Sync toplevel files with GCC 2015-07-27 07:49:05 -07:00
config.guess Sync config.sub and config.guess with GCC 2015-08-07 07:51:39 -07:00
config.rpath
config.sub Sync config.sub and config.guess with GCC 2015-08-07 07:51:39 -07:00
configure binutils: add support for arm-*-darwin and aarch64-*-darwin. 2015-11-20 14:53:06 +01:00
configure.ac binutils: add support for arm-*-darwin and aarch64-*-darwin. 2015-11-20 14:53:06 +01:00
depcomp Update from upstream Automake 2014-11-16 13:43:48 +01:00
djunpack.bat
install-sh Update from upstream Automake 2014-11-16 13:43:48 +01:00
libtool.m4 Update libtool.m4 from GCC trunk 2014-11-24 09:14:09 -08:00
ltgcc.m4
ltmain.sh PR target/59788 2014-02-06 11:01:57 +01:00
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
makefile.vms
missing Update from upstream Automake 2014-11-16 13:43:48 +01:00
mkdep
mkinstalldirs Update from upstream Automake 2014-11-16 13:43:48 +01:00
move-if-change Update `move-if-change' from gnulib 2014-11-16 17:04:02 +01:00
setup.com
src-release.sh Adjust src-release.sh for sim using the gdb create-version.sh. 2015-04-15 04:08:51 +02:00
symlink-tree
ylwrap Update from upstream Automake 2014-11-16 13:43:48 +01:00

README

		   README for GNU development tools

This directory contains various GNU compilers, assemblers, linkers, 
debuggers, etc., plus their support routines, definitions, and documentation.

If you are receiving this as part of a GDB release, see the file gdb/README.
If with a binutils release, see binutils/README;  if with a libg++ release,
see libg++/README, etc.  That'll give you info about this
package -- supported targets, how to use it, how to report bugs, etc.

It is now possible to automatically configure and build a variety of
tools with one command.  To build all of the tools contained herein,
run the ``configure'' script here, e.g.:

	./configure 
	make

To install them (by default in /usr/local/bin, /usr/local/lib, etc),
then do:
	make install

(If the configure script can't determine your type of computer, give it
the name as an argument, for instance ``./configure sun4''.  You can
use the script ``config.sub'' to test whether a name is recognized; if
it is, config.sub translates it to a triplet specifying CPU, vendor,
and OS.)

If you have more than one compiler on your system, it is often best to
explicitly set CC in the environment before running configure, and to
also set CC when running make.  For example (assuming sh/bash/ksh):

	CC=gcc ./configure
	make

A similar example using csh:

	setenv CC gcc
	./configure
	make

Much of the code and documentation enclosed is copyright by
the Free Software Foundation, Inc.  See the file COPYING or
COPYING.LIB in the various directories, for a description of the
GNU General Public License terms under which you can copy the files.

REPORTING BUGS: Again, see gdb/README, binutils/README, etc., for info
on where and how to report problems.