binutils-gdb/gdb/testsuite/gdb.server/extended-remote-restart.c

61 lines
1.1 KiB
C
Raw Normal View History

gdb: Fix assert for extended-remote target (PR gdb/18050) Consider the following GDB session: (gdb) target extended-remote :2347 (gdb) file /path/to/exe (gdb) set remote exec-file /path/to/exe (gdb) set detach-on-fork off (gdb) break breakpt (gdb) run # ... hits breakpoint (gdb) info inferiors Num Description Executable * 1 process 17001 /path/to/exe 2 process 17002 /path/to/exe (gdb) kill (gdb) info inferiors Num Description Executable * 1 <null> /path/to/exe 2 process 17002 /path/to/exe (gdb) target extended-remote :2348 ../../src/gdb/thread.c:660: internal-error: thread_info* any_thread_of_process(int): Assertion `pid != 0' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Or, from bug PR gdb/18050: (gdb) start (gdb) add-inferior -exec /path/to/exe (gdb) target extended-remote :2347 ../../src/gdb/thread.c:660: internal-error: thread_info* any_thread_of_process(int): Assertion `pid != 0' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. The issue is calling target.c:dispose_inferior with a killed inferior in the inferior list. This assertion is fixed in this commit. The new test for this issue only runs on platforms that support 'detach-on-fork', and when using '--target_board=native-extended-gdbserver'. gdb/ChangeLog: PR gdb/18050: * target.c (dispose_inferior): Don't dispose of inferiors that are already killed. gdb/testsuite/ChangeLog: PR gdb/18050: * gdb.server/extended-remote-restart.c: New file. * gdb.server/extended-remote-restart.exp: New file.
2018-06-22 21:39:26 +02:00
/* This testcase is part of GDB, the GNU debugger.
Copyright 2018-2019 Free Software Foundation, Inc.
gdb: Fix assert for extended-remote target (PR gdb/18050) Consider the following GDB session: (gdb) target extended-remote :2347 (gdb) file /path/to/exe (gdb) set remote exec-file /path/to/exe (gdb) set detach-on-fork off (gdb) break breakpt (gdb) run # ... hits breakpoint (gdb) info inferiors Num Description Executable * 1 process 17001 /path/to/exe 2 process 17002 /path/to/exe (gdb) kill (gdb) info inferiors Num Description Executable * 1 <null> /path/to/exe 2 process 17002 /path/to/exe (gdb) target extended-remote :2348 ../../src/gdb/thread.c:660: internal-error: thread_info* any_thread_of_process(int): Assertion `pid != 0' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Or, from bug PR gdb/18050: (gdb) start (gdb) add-inferior -exec /path/to/exe (gdb) target extended-remote :2347 ../../src/gdb/thread.c:660: internal-error: thread_info* any_thread_of_process(int): Assertion `pid != 0' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. The issue is calling target.c:dispose_inferior with a killed inferior in the inferior list. This assertion is fixed in this commit. The new test for this issue only runs on platforms that support 'detach-on-fork', and when using '--target_board=native-extended-gdbserver'. gdb/ChangeLog: PR gdb/18050: * target.c (dispose_inferior): Don't dispose of inferiors that are already killed. gdb/testsuite/ChangeLog: PR gdb/18050: * gdb.server/extended-remote-restart.c: New file. * gdb.server/extended-remote-restart.exp: New file.
2018-06-22 21:39:26 +02:00
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <unistd.h>
#include <stdlib.h>
static void
breakpt ()
{
asm ("" ::: "memory");
}
static void
go_child ()
{
breakpt ();
while (1)
sleep (1);
}
static void
go_parent ()
{
breakpt ();
while (1)
sleep (1);
}
int
main ()
{
pid_t pid;
pid = fork ();
if (pid == -1)
abort ();
if (pid == 0)
go_child ();
else
go_parent ();
exit (EXIT_SUCCESS);
}