mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-02-05 12:53:16 +08:00
b78b3a297b
Having pagination enabled when handling an inferior event gives the user an option to quit, which causes early exit in GDB's flow and may lead to half-baked state. For instance, here is a case where we quit in the middle of handling an inferior exit: $ gdb ./a.out Reading symbols from ./a.out... (gdb) set height 2 (gdb) run Starting program: ./a.out --Type <RET> for more, q to quit, c to continue without paging--q Quit Couldn't get registers: No such process. (gdb) set height unlimited Couldn't get registers: No such process. (gdb) info threads Id Target Id Frame * 1 process 27098 Couldn't get registers: No such process. Couldn't get registers: No such process. (gdb) Or suppose having a multi-threaded program like below: static void * fun (void *dummy) { int a = 1; /* break-here */ return NULL; } int main (void) { pthread_t thread; pthread_create (&thread, NULL, fun, NULL); pthread_join (thread, NULL); return 0; } If we define a breakpoint at line "break-here", we expect only Thread 2 to hit it. $ gdb ./a.out Reading symbols from ./a.out... (gdb) break 7 Breakpoint 1 at 0x1182: file mt.c, line 7. (gdb) set height 2 (gdb) run Starting program: ./a.out [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [New Thread 0x7ffff77c4700 (LWP 23048)] --Type <RET> for more, q to quit, c to continue without paging--q Quit (gdb) set height unlimited (gdb) info thread Id Target Id Frame * 1 Thread 0x7ffff7fe3740 (LWP 23044) "a.out" 0x00007ffff7bbed2d in ... 2 Thread 0x7ffff77c4700 (LWP 23048) "a.out" fun (dummy=0x0) at mt.c:7 (gdb) The prompt for continuation was triggered because Thread 2 hit the breakpoint. (If we had hit 'c', we were going to see that stop event, but we didn't.) The context did not switch to Thread 2. GDB also did not execute several other things it would normally do in infrun.c:normal_stop after outputting "[Switching to Thread ...]" (but it seems harmless in this case). If we 'continue' at this state, both threads run until termination, and we don't see the breakpoint hit event ever. Here is another related and more complicated scenario that leads to a GDB crash. Create two inferiors, one sitting on top of a native target, and the other on a remote target, so that we have a multi-target setting, like so: (gdb) i inferiors Num Description Connection Executable 1 process 13786 1 (native) a.out * 2 process 13806 2 (remote ...) target:a.out Next, resume both inferiors to run until termination: (gdb) set schedule-multiple on (gdb) set height 2 (gdb) continue Continuing. --Type <RET> for more, q to quit, c to continue without paging--[Inferior 2 (process 13806) exited normally] terminate called after throwing an instance of 'gdb_exception_error' Aborted Here, GDB first received a termination event from Inferior 1. GDB attempted to print this event, triggering a "prompt for continue", and GDB started polling for events, hoping to get an input from the user. However, the exit event from Inferior 2 was received instead. So, GDB started processing an exit event while being in the middle of processing another exit event. It was not ready for this situation and eventually crashed. To address these cases, temporarily disable pagination in fetch_inferior_event. This doesn't affect commands like 'info threads', 'backtrace', or 'thread apply'. Regression-tested on X86_64 Linux. gdb/ChangeLog: 2020-10-30 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * infrun.c (fetch_inferior_event): Temporarily disable pagination. gdb/testsuite/ChangeLog: 2020-10-30 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * gdb.base/paginate-after-ctrl-c-running.exp: Update with no pagination behavior. * gdb.base/paginate-bg-execution.exp: Ditto. * gdb.base/paginate-inferior-exit.exp: Ditto. * gdb.base/double-prompt-target-event-error.c: Remove. * gdb.base/double-prompt-target-event-error.exp: Remove. |
||
---|---|---|
bfd | ||
binutils | ||
config | ||
contrib | ||
cpu | ||
elfcpp | ||
etc | ||
gas | ||
gdb | ||
gdbserver | ||
gdbsupport | ||
gnulib | ||
gold | ||
gprof | ||
include | ||
intl | ||
ld | ||
libctf | ||
libdecnumber | ||
libiberty | ||
opcodes | ||
readline | ||
sim | ||
texinfo | ||
zlib | ||
.cvsignore | ||
.gitattributes | ||
.gitignore | ||
ar-lib | ||
ChangeLog | ||
compile | ||
config-ml.in | ||
config.guess | ||
config.rpath | ||
config.sub | ||
configure | ||
configure.ac | ||
COPYING | ||
COPYING3 | ||
COPYING3.LIB | ||
COPYING.LIB | ||
COPYING.LIBGLOSS | ||
COPYING.NEWLIB | ||
depcomp | ||
djunpack.bat | ||
install-sh | ||
libtool.m4 | ||
lt~obsolete.m4 | ||
ltgcc.m4 | ||
ltmain.sh | ||
ltoptions.m4 | ||
ltsugar.m4 | ||
ltversion.m4 | ||
MAINTAINERS | ||
Makefile.def | ||
Makefile.in | ||
Makefile.tpl | ||
makefile.vms | ||
missing | ||
mkdep | ||
mkinstalldirs | ||
move-if-change | ||
multilib.am | ||
README | ||
README-maintainer-mode | ||
setup.com | ||
src-release.sh | ||
symlink-tree | ||
test-driver | ||
ylwrap |
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.