aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2024-01-10 11:27:34 +0100
committerTom de Vries <tdevries@suse.de>2024-01-10 11:27:34 +0100
commit83094d3de44846071cc2e3e42366ea782b3e4027 (patch)
treed10feb9093dbd48a21980dbcde833db2a3b42b93 /gdb
parentcdf2a0febd8a20ef74e782bdf4493536535d33a8 (diff)
downloadgdb-83094d3de44846071cc2e3e42366ea782b3e4027.zip
gdb-83094d3de44846071cc2e3e42366ea782b3e4027.tar.gz
gdb-83094d3de44846071cc2e3e42366ea782b3e4027.tar.bz2
[gdb] Fix assertion failure for checkpoint delete 0
When doing "checkpoint delete 0" we run into an assertion failure: ... +delete checkpoint 0 inferior.c:406: internal-error: find_inferior_pid: Assertion `pid != 0' failed. ... Fix this by handling the "pptid == null_ptid" case in delete_checkpoint_command. Tested on x86_64-linux. Approved-By: Kevin Buettner <kevinb@redhat.com> PR gdb/31209 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31209
Diffstat (limited to 'gdb')
-rw-r--r--gdb/linux-fork.c11
-rw-r--r--gdb/testsuite/gdb.base/checkpoint.exp14
2 files changed, 25 insertions, 0 deletions
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 659264a..64b83e7 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -537,6 +537,17 @@ Please switch to another checkpoint before deleting the current one"));
delete_fork (ptid);
+ if (pptid == null_ptid)
+ {
+ int status;
+ /* Wait to collect the inferior's exit status. Do not check whether
+ this succeeds though, since we may be dealing with a process that we
+ attached to. Such a process will only report its exit status to its
+ original parent. */
+ waitpid (ptid.pid (), &status, 0);
+ return;
+ }
+
/* If fi->parent_ptid is not a part of lwp but it's a part of checkpoint
list, waitpid the ptid.
If fi->parent_ptid is a part of lwp and it is stopped, waitpid the
diff --git a/gdb/testsuite/gdb.base/checkpoint.exp b/gdb/testsuite/gdb.base/checkpoint.exp
index 9ba5b3e..96976bb 100644
--- a/gdb/testsuite/gdb.base/checkpoint.exp
+++ b/gdb/testsuite/gdb.base/checkpoint.exp
@@ -336,3 +336,17 @@ verbose "Timeout now $timeout sec."
#
# Finished: cleanup
#
+
+#
+# Now let's try to delete checkpoint 0.
+#
+
+with_test_prefix "delete checkpoint 0" {
+ clean_restart $binfile
+ runto_main
+
+ gdb_test "checkpoint" "checkpoint 1: fork returned pid $decimal\\."
+ gdb_test "restart 1" "Switching to .*"
+ gdb_test "delete checkpoint 0" "Killed process $decimal"
+ gdb_test "info checkpoints" [string_to_regexp "No checkpoints."]
+}