[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
This commit is contained in:
Tom de Vries 2024-01-10 11:27:34 +01:00
parent cdf2a0febd
commit 83094d3de4
2 changed files with 25 additions and 0 deletions

View File

@ -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

View File

@ -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."]
}