binutils-gdb/gdb/testsuite/gdb.base/dprintf-detach.c

34 lines
895 B
C
Raw Normal View History

Only leave dprintf inserted if it is marked as persistent (PR breakpoints/17012) On Linux native, if dprintfs are inserted when detaching, they are left in the inferior which causes it to crash from a SIGTRAP. It also happens with dprintfs on remote targets, when set disconnected-dprintf is off. The rationale of the line modified by the patch was to leave dprintfs inserted in order to support disconnected dprintfs. However, not all dprintfs are persistent. Also, there's no reason other kinds of breakpoints can't be persistent either. So this replaces the bp_dprintf check with a check on whether the location is persistent. bl->target_info.persist will be 1 only if disconnected-dprintf is on and we are debugging a remote target. On native, it will always be 0, regardless of the value of disconnected-dprintf. This makes sense, since disconnected dprintfs are not supported by the native target. One issue about the test is that it does not pass when using --target_board=native-extended-gdbserver, partly due to bug 17302 [1]. One quick hack I tried for this was to add a useless "next" between the call to getpid() and detach, which avoids the bug. There is still one case where the test fails, and that is with: - breakpoint always-inserted on - dprintf-style agent - disconnected-dprintf on What happens is that my detach does not actually detach the process, because some persistent commands (the disconnected dprintf) is present. However since gdbserver is ran with --once, when gdb disconnects, gdbserver goes down and takes with it all the processes it spawned and that are still under its control (which includes my test process). When the test checks if the test process is still alive, it obvisouly fails. Investigating about that led me to ask a question on the ML [2] about the behavior of detach. Until the remote case is sorted out, the problematic test is marked as KFAIL. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=17302 [2] https://sourceware.org/ml/gdb/2014-08/msg00115.html gdb/Changelog: PR breakpoints/17012 * breakpoint.c (remove_breakpoints_pid): Skip removing breakpoint if it is marked as persistent. gdb/testsuite/ChangeLog: PR breakpoints/17012 * gdb.base/dprintf-detach.c: New file. * gdb.base/dprintf-detach.exp: New file.
2014-12-10 22:10:05 +01:00
/* This testcase is part of GDB, the GNU debugger.
Copyright 2014-2018 Free Software Foundation, Inc.
Only leave dprintf inserted if it is marked as persistent (PR breakpoints/17012) On Linux native, if dprintfs are inserted when detaching, they are left in the inferior which causes it to crash from a SIGTRAP. It also happens with dprintfs on remote targets, when set disconnected-dprintf is off. The rationale of the line modified by the patch was to leave dprintfs inserted in order to support disconnected dprintfs. However, not all dprintfs are persistent. Also, there's no reason other kinds of breakpoints can't be persistent either. So this replaces the bp_dprintf check with a check on whether the location is persistent. bl->target_info.persist will be 1 only if disconnected-dprintf is on and we are debugging a remote target. On native, it will always be 0, regardless of the value of disconnected-dprintf. This makes sense, since disconnected dprintfs are not supported by the native target. One issue about the test is that it does not pass when using --target_board=native-extended-gdbserver, partly due to bug 17302 [1]. One quick hack I tried for this was to add a useless "next" between the call to getpid() and detach, which avoids the bug. There is still one case where the test fails, and that is with: - breakpoint always-inserted on - dprintf-style agent - disconnected-dprintf on What happens is that my detach does not actually detach the process, because some persistent commands (the disconnected dprintf) is present. However since gdbserver is ran with --once, when gdb disconnects, gdbserver goes down and takes with it all the processes it spawned and that are still under its control (which includes my test process). When the test checks if the test process is still alive, it obvisouly fails. Investigating about that led me to ask a question on the ML [2] about the behavior of detach. Until the remote case is sorted out, the problematic test is marked as KFAIL. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=17302 [2] https://sourceware.org/ml/gdb/2014-08/msg00115.html gdb/Changelog: PR breakpoints/17012 * breakpoint.c (remove_breakpoints_pid): Skip removing breakpoint if it is marked as persistent. gdb/testsuite/ChangeLog: PR breakpoints/17012 * gdb.base/dprintf-detach.c: New file. * gdb.base/dprintf-detach.exp: New file.
2014-12-10 22:10:05 +01: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>
static void
function (void)
{
sleep (1);
}
int
main (void)
{
int i;
for (i = 0; i < 30; i++)
function ();
}