Go to file
Tom de Vries 4ece39c56c [gdb/testsuite] Extend gdb.base/kill-during-detach.exp
I ran into the following FAIL:
...
(gdb) python kill_and_detach()^M
Traceback (most recent call last):^M
  File "<string>", line 1, in <module>^M
  File "<string>", line 7, in kill_and_detach^M
gdb.error: Selected thread is running.^M
Error while executing Python code.^M
(gdb) FAIL: gdb.base/kill-during-detach.exp: exit_p=true: checkpoint_p=true: \
  python kill_and_detach()
...

The FAIL happens as follows:
- gdb is debugging a process A
- a checkpoint is created, in other words, fork is called in the inferior,
  after which we have:
  - checkpoint 0 (the fork parent, process A), and
  - checkpoint 1 (the fork child, process B).
- during checkpoint creation, lseek is called in the inferior (process A) for
  all file descriptors, and it returns != -1 for at least one file descriptor.
- the process A continues in the background
- gdb detaches, from process A
- gdb switches to process B, in other words, it restarts checkpoint 1
- while restarting checkpoint 1, gdb tries to call lseek in the inferior
  (process B), but this fails because gdb incorrectly thinks that inferior B
  is running.

This happens because linux_nat_switch_fork patches the pid of process B into
the current inferior and current thread which where originally representing
process A.  So, because process A was running in the background, the
thread_info fields executing and resumed are set accordingly, but they are not
correct for process B.

There's a line in fork_load_infrun_state that fixes up the thread_info field
stop_pc, so fix this by adding similar fixups for the executing and resumed
fields alongside.

The FAIL did not always reproduce, so extend the test-case to reliably
trigger this scenario.

Tested on x86_64-linux.

Approved-By: Kevin Buettner <kevinb@redhat.com>

PR gdb/31203
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31203
2024-01-11 10:12:48 +01:00
bfd Automatic date update in version.in 2024-01-11 00:00:28 +00:00
binutils MAINTAINERS: Update my email address 2024-01-08 18:55:03 +00:00
config libiberty: Disable hwcaps for sha1.o 2023-11-30 10:14:30 +01:00
contrib
cpu sim: cris: change temp var name slightly to avoid shadowing 2024-01-06 23:30:43 -05:00
elfcpp Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
etc Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
gas LoongArch: Discard extra spaces in objdump output 2024-01-11 14:08:24 +08:00
gdb [gdb/testsuite] Extend gdb.base/kill-during-detach.exp 2024-01-11 10:12:48 +01:00
gdbserver gdbsupport: tighten up libiberty code a bit with dnl 2024-01-10 19:53:14 -05:00
gdbsupport gdbsupport: tighten up libiberty code a bit with dnl 2024-01-10 19:53:14 -05:00
gnulib gnulib: mark configure +x 2023-11-28 12:55:29 -05:00
gold Enforce C++11 as a minimum for building gold [PR30867] 2024-01-05 13:00:11 +10:30
gprof Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
gprofng gprofng: add an examples directory 2024-01-10 09:44:52 -08:00
include gas: aarch64: Add system registers for Debug and PMU extensions 2024-01-10 11:10:07 +00:00
ld LoongArch: ld: Adjusted some code order in relax.exp. 2024-01-11 14:37:26 +08:00
libbacktrace
libctf Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
libdecnumber
libiberty Synchronize sourceware version of the libiberty sources with the master gcc versions. 2024-01-09 12:34:00 +00:00
libsframe Update year range in copyright notice of binutils files 2024-01-04 22:58:12 +10:30
opcodes LoongArch: Discard extra spaces in objdump output 2024-01-11 14:08:24 +08:00
readline
sim sim: ppc: return register error when unhandled 2024-01-11 00:49:56 -05:00
texinfo
zlib
.cvsignore
.editorconfig
.gitattributes
.gitignore Finalized intl-update patches 2023-11-15 12:53:04 +00:00
ar-lib
ChangeLog Finalized intl-update patches 2023-11-15 12:53:04 +00:00
compile
config-ml.in
config.guess Synchronize config.sub and config.guess with their upstream master versions. 2024-01-04 12:00:34 +00:00
config.rpath
config.sub Synchronize config.sub and config.guess with their upstream master versions. 2024-01-04 12:00:34 +00:00
configure Sync top level configure and makefiles 2024-01-10 12:03:03 +00:00
configure.ac Sync top level configure and makefiles 2024-01-10 12:03:03 +00:00
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 Sync top level configure and makefiles 2024-01-10 12:03:03 +00:00
Makefile.in Sync top level configure and makefiles 2024-01-10 12:03:03 +00:00
Makefile.tpl Sync top level configure and makefiles 2024-01-10 12:03:03 +00:00
makefile.vms
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
README-maintainer-mode
SECURITY.txt
setup.com
src-release.sh Finalized intl-update patches 2023-11-15 12:53:04 +00:00
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.