- Fix detaching from a threaded formerly stopped process with non-primary
thread currently active (general BZ 233852). - Enable back again the testcases named `attachstop.exp' (no such exist now). - Rename the testcase `gdb.threads/attachstop' to `gdb.threads/attachstop-mt'. - Test ia64 memory leaks of the code using libunwind. - Testcase delay increase (for BZ 247354). - Test gcore memory and time requirements for large inferiors.
This commit is contained in:
parent
d50521fae0
commit
3f52bbd141
143
gdb-6.5-gcore-buffer-limit-test.patch
Normal file
143
gdb-6.5-gcore-buffer-limit-test.patch
Normal file
@ -0,0 +1,143 @@
|
||||
diff -u -X /home/jkratoch/.diffi.list -ruNp gdb-6.5/gdb/testsuite/gdb.base/gcore-excessive-memory.c gdb-6.5-unknown/gdb/testsuite/gdb.base/gcore-excessive-memory.c
|
||||
--- gdb-6.5/gdb/testsuite/gdb.base/gcore-excessive-memory.c 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ gdb-6.5-unknown/gdb/testsuite/gdb.base/gcore-excessive-memory.c 2008-01-08 11:25:45.000000000 +0100
|
||||
@@ -0,0 +1,37 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2008 Free Software Foundation, Inc.
|
||||
+
|
||||
+ 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 2 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, write to the Free Software
|
||||
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+ Please email any bugs, comments, and/or additions to this file to:
|
||||
+ bug-gdb@prep.ai.mit.edu */
|
||||
+
|
||||
+#include <unistd.h>
|
||||
+#include <stdlib.h>
|
||||
+
|
||||
+#define MEGS 64
|
||||
+
|
||||
+int main()
|
||||
+{
|
||||
+ void *mem;
|
||||
+
|
||||
+ mem = malloc (MEGS * 1024ULL * 1024ULL);
|
||||
+
|
||||
+ for (;;)
|
||||
+ sleep (1);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
diff -u -X /home/jkratoch/.diffi.list -ruNp gdb-6.5/gdb/testsuite/gdb.base/gcore-excessive-memory.exp gdb-6.5-unknown/gdb/testsuite/gdb.base/gcore-excessive-memory.exp
|
||||
--- gdb-6.5/gdb/testsuite/gdb.base/gcore-excessive-memory.exp 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ gdb-6.5-unknown/gdb/testsuite/gdb.base/gcore-excessive-memory.exp 2008-01-08 11:47:32.000000000 +0100
|
||||
@@ -0,0 +1,98 @@
|
||||
+# Copyright 2008 Free Software Foundation, Inc.
|
||||
+
|
||||
+# 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 2 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, write to the Free Software
|
||||
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+if $tracelevel then {
|
||||
+ strace $tracelevel
|
||||
+}
|
||||
+
|
||||
+set prms_id 0
|
||||
+set bug_id 0
|
||||
+
|
||||
+set testfile gcore-excessive-memory
|
||||
+set srcfile ${testfile}.c
|
||||
+set shfile ${objdir}/${subdir}/${testfile}-gdb.sh
|
||||
+set corefile ${objdir}/${subdir}/${testfile}.core
|
||||
+set binfile ${objdir}/${subdir}/${testfile}
|
||||
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
||||
+ untested "Couldn't compile test program"
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+set f [open "|getconf PAGESIZE" "r"]
|
||||
+gets $f pagesize
|
||||
+close $f
|
||||
+
|
||||
+set pid_of_bin [eval exec $binfile &]
|
||||
+sleep 2
|
||||
+
|
||||
+# Get things started.
|
||||
+
|
||||
+gdb_exit
|
||||
+gdb_start
|
||||
+gdb_reinitialize_dir $srcdir/$subdir
|
||||
+gdb_load ${binfile}
|
||||
+
|
||||
+set pid_of_gdb [exp_pid -i [board_info host fileid]]
|
||||
+
|
||||
+gdb_test "attach $pid_of_bin" "Attaching to .*" "attach"
|
||||
+gdb_test "up 99" "in main .*" "verify we can get to main"
|
||||
+
|
||||
+proc memory_v_pages_get {} {
|
||||
+ global pid_of_gdb pagesize
|
||||
+ set fd [open "/proc/$pid_of_gdb/statm"]
|
||||
+ gets $fd line
|
||||
+ close $fd
|
||||
+ # number of pages of virtual memory
|
||||
+ scan $line "%d" drs
|
||||
+ return $drs
|
||||
+}
|
||||
+
|
||||
+set pages_found [memory_v_pages_get]
|
||||
+
|
||||
+# It must be definitely less than `MEGS' of `gcore-excessive-memory.c'.
|
||||
+set mb_gcore_reserve 4
|
||||
+verbose -log "pages_found = $pages_found, mb_gcore_reserve = $mb_gcore_reserve"
|
||||
+set kb_found [expr $pages_found * $pagesize / 1024]
|
||||
+set kb_permit [expr $kb_found + 1 * 1024 + $mb_gcore_reserve * 1024]
|
||||
+verbose -log "kb_found = $kb_found, kb_permit = $kb_permit"
|
||||
+
|
||||
+# Create the ulimit wrapper.
|
||||
+set f [open $shfile "w"]
|
||||
+puts $f "#! /bin/sh"
|
||||
+puts $f "ulimit -v $kb_permit"
|
||||
+puts $f "exec $GDB \"\$@\""
|
||||
+close $f
|
||||
+remote_exec host "chmod +x $shfile"
|
||||
+
|
||||
+gdb_exit
|
||||
+set GDBold $GDB
|
||||
+set GDB "$shfile"
|
||||
+gdb_start
|
||||
+set GDB $GDBold
|
||||
+
|
||||
+gdb_reinitialize_dir $srcdir/$subdir
|
||||
+gdb_load ${binfile}
|
||||
+
|
||||
+set pid_of_gdb [exp_pid -i [board_info host fileid]]
|
||||
+
|
||||
+gdb_test "attach $pid_of_bin" "Attaching to .*" "attach"
|
||||
+gdb_test "up 99" "in main .*" "verify we can get to main"
|
||||
+
|
||||
+verbose -log "kb_found before gcore = [expr [memory_v_pages_get] * $pagesize / 1024]"
|
||||
+
|
||||
+gdb_test "gcore $corefile" "Saved corefile \[^\n\r\]*" "Save the core file"
|
||||
+
|
||||
+verbose -log "kb_found after gcore = [expr [memory_v_pages_get] * $pagesize / 1024]"
|
127
gdb-6.5-ia64-libunwind-leak-test.patch
Normal file
127
gdb-6.5-ia64-libunwind-leak-test.patch
Normal file
@ -0,0 +1,127 @@
|
||||
diff -u -rup gdb-6.3-orig/gdb/testsuite/gdb.base/unwind-leak.c gdb-6.3/gdb/testsuite/gdb.base/unwind-leak.c
|
||||
--- gdb-6.3-orig/gdb/testsuite/gdb.base/unwind-leak.c 2007-12-19 15:12:55.000000000 -0500
|
||||
+++ gdb-6.3/gdb/testsuite/gdb.base/unwind-leak.c 2007-12-19 13:55:22.000000000 -0500
|
||||
@@ -0,0 +1,29 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2007 Free Software Foundation, Inc.
|
||||
+
|
||||
+ 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 2 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, write to the Free Software
|
||||
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+ Please email any bugs, comments, and/or additions to this file to:
|
||||
+ bug-gdb@prep.ai.mit.edu */
|
||||
+
|
||||
+#include <unistd.h>
|
||||
+
|
||||
+int main()
|
||||
+{
|
||||
+ for (;;)
|
||||
+ alarm (0);
|
||||
+ return 0;
|
||||
+}
|
||||
diff -u -rup gdb-6.3-orig/gdb/testsuite/gdb.base/unwind-leak.exp gdb-6.3/gdb/testsuite/gdb.base/unwind-leak.exp
|
||||
--- gdb-6.3-orig/gdb/testsuite/gdb.base/unwind-leak.exp 2007-12-19 15:12:53.000000000 -0500
|
||||
+++ gdb-6.3/gdb/testsuite/gdb.base/unwind-leak.exp 2007-12-19 15:11:35.000000000 -0500
|
||||
@@ -0,0 +1,90 @@
|
||||
+# Copyright 2007 Free Software Foundation, Inc.
|
||||
+
|
||||
+# 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 2 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, write to the Free Software
|
||||
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+if $tracelevel then {
|
||||
+ strace $tracelevel
|
||||
+}
|
||||
+
|
||||
+set prms_id 0
|
||||
+set bug_id 0
|
||||
+
|
||||
+set testfile unwind-leak
|
||||
+set srcfile ${testfile}.c
|
||||
+set shfile ${objdir}/${subdir}/${testfile}-gdb.sh
|
||||
+set binfile ${objdir}/${subdir}/${testfile}
|
||||
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
||||
+ untested "Couldn't compile test program"
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+# Get things started.
|
||||
+
|
||||
+gdb_exit
|
||||
+gdb_start
|
||||
+gdb_reinitialize_dir $srcdir/$subdir
|
||||
+gdb_load ${binfile}
|
||||
+
|
||||
+set pid [exp_pid -i [board_info host fileid]]
|
||||
+
|
||||
+# For C programs, "start" should stop in main().
|
||||
+
|
||||
+gdb_test "start" \
|
||||
+ "main \\(\\) at .*$srcfile.*" \
|
||||
+ "start"
|
||||
+
|
||||
+set loc [gdb_get_line_number "alarm"]
|
||||
+gdb_breakpoint $loc
|
||||
+
|
||||
+proc memory_get {} {
|
||||
+ global pid
|
||||
+ set fd [open "/proc/$pid/statm"]
|
||||
+ gets $fd line
|
||||
+ close $fd
|
||||
+ # number of pages of data/stack
|
||||
+ scan $line "%*d%*d%*d%*d%*d%d" drs
|
||||
+ return $drs
|
||||
+}
|
||||
+
|
||||
+set cycles 100
|
||||
+# For 100 cycles it was 1308: from = 363 KB, to = 1671 KB
|
||||
+set permit_kb 100
|
||||
+verbose -log "cycles = $cycles, permit_kb = $permit_kb"
|
||||
+
|
||||
+set fail 0
|
||||
+set test "breakpoint stop/continue cycles"
|
||||
+for {set i $cycles} {$i > 0} {set i [expr {$i - 1}]} {
|
||||
+ gdb_test_multiple "continue" $test {
|
||||
+ -re "Breakpoint 2, main .*alarm .*.*${gdb_prompt} $" {
|
||||
+ }
|
||||
+ -re "Segmentation fault" {
|
||||
+ fail $test
|
||||
+ set i 0
|
||||
+ set fail 1
|
||||
+ }
|
||||
+ }
|
||||
+ if ![info exists from] {
|
||||
+ set from [memory_get]
|
||||
+ }
|
||||
+}
|
||||
+set to [memory_get]
|
||||
+if {!$fail} {
|
||||
+ verbose -log "from = $from KB, to = $to KB"
|
||||
+ if {$from > 0 && $to > 10 && $to < $from + $permit_kb} {
|
||||
+ pass $test
|
||||
+ } else {
|
||||
+ fail $test
|
||||
+ }
|
||||
+}
|
@ -1,934 +0,0 @@
|
||||
2007-07-01 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* linux-nat.h (struct lwp_info): New field WAS_STOPPED.
|
||||
* linux-nat.c (STRINGIFY, STRINGIFY_ARG): New macros.
|
||||
(kill_lwp): New declaration.
|
||||
(linux_ptrace_post_attach, pid_is_stopped): New function.
|
||||
(linux_child_follow_fork): New comment about WAS_STOPPED.
|
||||
(lin_lwp_attach_lwp): Variable PID removed. Part replaced by a call to
|
||||
LINUX_PTRACE_POST_ATTACH.
|
||||
(linux_nat_attach): Likewise.
|
||||
(linux_nat_detach): Optionally stop the detached process.
|
||||
(linux_nat_resume): Clear WAS_STOPPED if appropriate.
|
||||
* NEWS: Document the new behaviour.
|
||||
|
||||
2007-06-30 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* gdb.threads/attach-into-signal.c, gdb.threads/attach-into-signal.exp,
|
||||
gdb.threads/attach-stopped.c, gdb.threads/attach-stopped.exp: New files.
|
||||
|
||||
2007-06-30 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* gdb.texinfo (Attach): Document the ATTACH and DETACH commands for
|
||||
stopped processes. Document the messages on the seen pending signals.
|
||||
|
||||
[ Backport for GDB-6.6. ]
|
||||
|
||||
--- ./gdb/NEWS 21 Jun 2007 15:18:50 -0000 1.232
|
||||
+++ ./gdb/NEWS 30 Jun 2007 16:27:37 -0000
|
||||
@@ -44,6 +44,9 @@ segment base addresses (rather than offs
|
||||
* The /i format now outputs any trailing branch delay slot instructions
|
||||
immediately following the last instruction within the count specified.
|
||||
|
||||
+* On GNU/Linux, stopped processes may get attached to now. Signals being
|
||||
+delivered at the time of the attach command no longer get lost.
|
||||
+
|
||||
* New commands
|
||||
|
||||
set remoteflow
|
||||
--- gdb-6.6/gdb/linux-nat.c-orig-orig 2007-09-16 20:57:13.000000000 +0200
|
||||
+++ gdb-6.6/gdb/linux-nat.c 2007-09-16 21:02:28.000000000 +0200
|
||||
@@ -87,6 +87,12 @@
|
||||
#define __WALL 0x40000000 /* Wait for any child. */
|
||||
#endif
|
||||
|
||||
+#define STRINGIFY_ARG(x) #x
|
||||
+#define STRINGIFY(x) STRINGIFY_ARG (x)
|
||||
+
|
||||
+static int linux_ptrace_post_attach (struct lwp_info *lp);
|
||||
+static int kill_lwp (int lwpid, int signo);
|
||||
+
|
||||
/* The single-threaded native GNU/Linux target_ops. We save a pointer for
|
||||
the use of the multi-threaded target. */
|
||||
static struct target_ops *linux_ops;
|
||||
@@ -533,6 +539,11 @@ child_follow_fork (struct target_ops *op
|
||||
}
|
||||
else
|
||||
{
|
||||
+ /* We should check LP->WAS_STOPPED and detach it stopped accordingly.
|
||||
+ In this point of code it cannot be 1 as we would not get FORK
|
||||
+ executed without CONTINUE first which resets LP->WAS_STOPPED.
|
||||
+ We would have to first TARGET_STOP and WAITPID it as with running
|
||||
+ inferior PTRACE_DETACH, SIGSTOP will ignore the signal. */
|
||||
target_detach (NULL, 0);
|
||||
}
|
||||
|
||||
@@ -992,7 +1003,6 @@ lin_lwp_attach_lwp (ptid_t ptid, int ver
|
||||
to happen. */
|
||||
if (GET_LWP (ptid) != GET_PID (ptid) && lp == NULL)
|
||||
{
|
||||
- pid_t pid;
|
||||
int status;
|
||||
|
||||
if (ptrace (PTRACE_ATTACH, GET_LWP (ptid), 0, 0) < 0)
|
||||
@@ -1002,37 +1012,16 @@ lin_lwp_attach_lwp (ptid_t ptid, int ver
|
||||
if (lp == NULL)
|
||||
lp = add_lwp (ptid);
|
||||
|
||||
- if (debug_linux_nat)
|
||||
- fprintf_unfiltered (gdb_stdlog,
|
||||
- "LLAL: PTRACE_ATTACH %s, 0, 0 (OK)\n",
|
||||
- target_pid_to_str (ptid));
|
||||
-
|
||||
- pid = my_waitpid (GET_LWP (ptid), &status, 0);
|
||||
- if (pid == -1 && errno == ECHILD)
|
||||
- {
|
||||
- /* Try again with __WCLONE to check cloned processes. */
|
||||
- pid = my_waitpid (GET_LWP (ptid), &status, __WCLONE);
|
||||
- if (pid == -1 && errno == ECHILD)
|
||||
- error (_("Can't attach %s (%s) - possible SELinux denial,"
|
||||
- " check your /var/log/messages for `avc: denied'"),
|
||||
- target_pid_to_str (ptid), safe_strerror (errno));
|
||||
- lp->cloned = 1;
|
||||
+ status = linux_ptrace_post_attach (lp);
|
||||
+ if (status != 0)
|
||||
+ {
|
||||
+ error (_("Thread %s exited: %s"), target_pid_to_str (ptid),
|
||||
+ status_to_str (status));
|
||||
}
|
||||
|
||||
- gdb_assert (pid == GET_LWP (ptid)
|
||||
- && WIFSTOPPED (status) && WSTOPSIG (status));
|
||||
-
|
||||
- target_post_attach (pid);
|
||||
+ target_post_attach (GET_LWP (ptid));
|
||||
|
||||
lp->stopped = 1;
|
||||
-
|
||||
- if (debug_linux_nat)
|
||||
- {
|
||||
- fprintf_unfiltered (gdb_stdlog,
|
||||
- "LLAL: waitpid %s received %s\n",
|
||||
- target_pid_to_str (ptid),
|
||||
- status_to_str (status));
|
||||
- }
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1061,11 +1049,172 @@ lin_lwp_attach_lwp (ptid_t ptid, int ver
|
||||
return 0;
|
||||
}
|
||||
|
||||
+/* Detect `T (stopped)' in `/proc/PID/status'.
|
||||
+ Other states including `T (tracing stop)' are reported as false. */
|
||||
+
|
||||
+static int
|
||||
+pid_is_stopped (pid_t pid)
|
||||
+{
|
||||
+ FILE *status_file;
|
||||
+ char buf[100];
|
||||
+ int retval = 0;
|
||||
+
|
||||
+ snprintf (buf, sizeof (buf), "/proc/%d/status", (int) pid);
|
||||
+ status_file = fopen (buf, "r");
|
||||
+ if (status_file != NULL)
|
||||
+ {
|
||||
+ int have_state = 0;
|
||||
+
|
||||
+ while (fgets (buf, sizeof (buf), status_file))
|
||||
+ {
|
||||
+ if (strncmp (buf, "State:", 6) == 0)
|
||||
+ {
|
||||
+ have_state = 1;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ if (have_state && strstr (buf, "T (stopped)") != NULL)
|
||||
+ retval = 1;
|
||||
+ fclose (status_file);
|
||||
+ }
|
||||
+ return retval;
|
||||
+}
|
||||
+
|
||||
+/* Handle the processing after PTRACE_ATTACH, the first WAITPID -> SIGSTOP.
|
||||
+ Returns STATUS if the thread has exited, 0 otherwise.
|
||||
+ Sets LP->WAS_STOPPED if the process was originally stopped.
|
||||
+ Sets LP->CLONED if the given LWP is not the thread leader.
|
||||
+
|
||||
+ Scenario for a standard unstopped inferior:
|
||||
+ * `S (sleeping)' or `R (running)' or similiar states.
|
||||
+ * PTRACE_ATTACH is called.
|
||||
+ * `S (sleeping)' (or similiar) for some while.
|
||||
+ * `T (tracing stop)'.
|
||||
+ * WAITPID succeeds here returning SIGSTOP (signalled by PTRACE_ATTACH).
|
||||
+
|
||||
+ Scenario for a formerly stopped inferior:
|
||||
+ * `T (stopped)'.
|
||||
+ * PTRACE_ATTACH is called.
|
||||
+ * `T (stopped)' would stay indefinitely
|
||||
+ Note since this moment the `TracerPid' field gets filled
|
||||
+ (by PTRACE_ATTACH), it is no longer just the common `T (stopped)' state.
|
||||
+ * If no one did WAITPID since sending SIGSTOP our WAITPID would return
|
||||
+ SIGSTOP. The state still would not turn to `T (tracing stop)'.
|
||||
+ * Usually its original parent (before PTRACE_ATTACH was applied) already
|
||||
+ did WAITPID. The original parent already received our SIGSTOP
|
||||
+ sinalled by our PTRACE_ATTACH.
|
||||
+ In this case our own WAITPID would hang. Therefore...
|
||||
+ * ... we do artificial: tkill (SIGCONT);
|
||||
+ `PTRACE_CONT, SIGSTOP' does not work in 100% cases as sometimes SIGSTOP
|
||||
+ gets remembered by kernel during the first PTRACE_CONT later and we get
|
||||
+ spurious SIGSTOP event. Expecting the signal may get delivered to
|
||||
+ a different task of the thread group.
|
||||
+ `kill_lwp (SIGSTOP)' has no effect in this moment (it is already stopped).
|
||||
+ * WAITPID returns the artifical SIGCONT.
|
||||
+ (The possibly pending SIGSTOP gets vanished by specifically SIGCONT.)
|
||||
+ * State turns `T (tracing stop)'.
|
||||
+ In this moment everything is almost fine but we need a workaround as final
|
||||
+ `PTRACE_DETACH, SIGSTOP' would leave the process unstopped otherwise:
|
||||
+ * tkill (SIGSTOP);
|
||||
+ * `PTRACE_CONT, 0'
|
||||
+ * WAITPID returns the artifical SIGSTOP.
|
||||
+
|
||||
+ With the pending (unwaited for) SIGSTOP the artifical signal effects are:
|
||||
+ kill (SIGSTOP)
|
||||
+ PTRACE_ATTACH
|
||||
+ /-tkill (SIGCONT), WAITPID: SIGCONT, WAITPID: hang !
|
||||
+ //-tkill (SIGCONT), WAITPID: SIGCONT, PTRACE_CONT (SIG_0), WAITPID: wait (OK)
|
||||
+ \\-tkill (SIGALRM), WAITPID: SIGSTOP, WAITPID: hang !
|
||||
+ \-tkill (SIGALRM), WAITPID: SIGSTOP, PTRACE_CONT (SIG_0), WAITPID: SIGALRM !
|
||||
+ Therefore we signal artifical SIGCONT and stop waiting after its reception.
|
||||
+
|
||||
+ For the detection whether the process was formerly stopped we need to
|
||||
+ read `/proc/PID/status'. `PTRACE_CONT, SIGSTOP' returns ESRCH
|
||||
+ for `S (sleeping)' and succeeds for `T (stopped)' but it unfortunately
|
||||
+ succeeds even for `T (tracing stop)'. Depending on PTRACE_CONT, SIGSTOP
|
||||
+ success value for formerly stopped processes would mean a race condition
|
||||
+ as we would get false stopped processes detection if we get too slow.
|
||||
+
|
||||
+ `waitid (..., WSTOPPED)' hangs the same way as WAITPID.
|
||||
+
|
||||
+ Signals get queued for WAITPID. PTRACE_ATTACH (or TKILL) enqueues SIGSTOP
|
||||
+ there but WAITPID may return an already pending signal.
|
||||
+ Redeliver it by PTRACE_CONT, SIGxxx as otherwise it would get lost.
|
||||
+ Similiar processing is being done in this file by WAIT_LWP. */
|
||||
+
|
||||
+static int
|
||||
+linux_ptrace_post_attach (struct lwp_info *lp)
|
||||
+{
|
||||
+ ptid_t ptid = lp->ptid;
|
||||
+ unsigned long sig;
|
||||
+
|
||||
+ if (debug_linux_nat)
|
||||
+ fprintf_unfiltered (gdb_stdlog,
|
||||
+ "LLAL: PTRACE_ATTACH %s, 0, 0 (OK)\n",
|
||||
+ target_pid_to_str (ptid));
|
||||
+
|
||||
+ lp->was_stopped = pid_is_stopped (GET_LWP (ptid));
|
||||
+ if (lp->was_stopped)
|
||||
+ {
|
||||
+ if (kill_lwp (GET_LWP (ptid), SIGCONT) != 0)
|
||||
+ perror_with_name (("kill_lwp (SIGCONT)"));
|
||||
+ }
|
||||
+
|
||||
+ for (;;)
|
||||
+ {
|
||||
+ pid_t pid;
|
||||
+ int status;
|
||||
+
|
||||
+ pid = my_waitpid (GET_LWP (ptid), &status, 0);
|
||||
+ if (pid == -1 && errno == ECHILD)
|
||||
+ {
|
||||
+ /* Try again with __WCLONE to check cloned processes. */
|
||||
+ pid = my_waitpid (GET_LWP (ptid), &status, __WCLONE);
|
||||
+ lp->cloned = 1;
|
||||
+ }
|
||||
+ gdb_assert (pid == GET_LWP (ptid));
|
||||
+
|
||||
+ if (debug_linux_nat)
|
||||
+ {
|
||||
+ fprintf_unfiltered (gdb_stdlog,
|
||||
+ "LLAL: waitpid %s received %s\n",
|
||||
+ target_pid_to_str (ptid),
|
||||
+ status_to_str (status));
|
||||
+ }
|
||||
+
|
||||
+ /* Check if the thread has exited. */
|
||||
+ if (WIFEXITED (status) || WIFSIGNALED (status))
|
||||
+ return status;
|
||||
+ gdb_assert (WIFSTOPPED (status));
|
||||
+ sig = WSTOPSIG (status);
|
||||
+ gdb_assert (sig != 0);
|
||||
+ if (sig == SIGSTOP)
|
||||
+ break;
|
||||
+
|
||||
+ /* As the second signal for stopped processes we send SIGSTOP. */
|
||||
+ if (lp->was_stopped && sig == SIGCONT)
|
||||
+ sig = SIGSTOP;
|
||||
+
|
||||
+ printf_unfiltered (_("Redelivering pending %s.\n"),
|
||||
+ target_signal_to_string (target_signal_from_host (sig)));
|
||||
+ if (sig == SIGSTOP)
|
||||
+ {
|
||||
+ if (kill_lwp (GET_LWP (ptid), sig) != 0)
|
||||
+ perror_with_name (("kill_lwp"));
|
||||
+ /* We now must resume the inferior to get SIGSTOP delivered. */
|
||||
+ sig = 0;
|
||||
+ }
|
||||
+ if (ptrace (PTRACE_CONT, GET_LWP (ptid), NULL, (void *) sig) != 0)
|
||||
+ perror_with_name (("ptrace"));
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static void
|
||||
linux_nat_attach (char *args, int from_tty)
|
||||
{
|
||||
struct lwp_info *lp;
|
||||
- pid_t pid;
|
||||
int status;
|
||||
|
||||
/* FIXME: We should probably accept a list of process id's, and
|
||||
@@ -1076,21 +1225,12 @@ linux_nat_attach (char *args, int from_t
|
||||
inferior_ptid = BUILD_LWP (GET_PID (inferior_ptid), GET_PID (inferior_ptid));
|
||||
lp = add_lwp (inferior_ptid);
|
||||
|
||||
- /* Make sure the initial process is stopped. The user-level threads
|
||||
- layer might want to poke around in the inferior, and that won't
|
||||
- work if things haven't stabilized yet. */
|
||||
- pid = my_waitpid (GET_PID (inferior_ptid), &status, 0);
|
||||
- if (pid == -1 && errno == ECHILD)
|
||||
- {
|
||||
- warning (_("%s is a cloned process"), target_pid_to_str (inferior_ptid));
|
||||
-
|
||||
- /* Try again with __WCLONE to check cloned processes. */
|
||||
- pid = my_waitpid (GET_PID (inferior_ptid), &status, __WCLONE);
|
||||
- lp->cloned = 1;
|
||||
- }
|
||||
-
|
||||
- gdb_assert (pid == GET_PID (inferior_ptid)
|
||||
- && WIFSTOPPED (status) && WSTOPSIG (status) == SIGSTOP);
|
||||
+ status = linux_ptrace_post_attach (lp);
|
||||
+ if (status != 0)
|
||||
+ error (_("Program %s exited: %s\n"), target_pid_to_str (inferior_ptid),
|
||||
+ status_to_str (status));
|
||||
+ if (lp->cloned)
|
||||
+ warning (_("%s is a cloned process"), target_pid_to_str (inferior_ptid));
|
||||
|
||||
lp->stopped = 1;
|
||||
|
||||
@@ -1099,8 +1239,8 @@ linux_nat_attach (char *args, int from_t
|
||||
lp->resumed = 1;
|
||||
if (debug_linux_nat)
|
||||
{
|
||||
- fprintf_unfiltered (gdb_stdlog,
|
||||
- "LLA: waitpid %ld, faking SIGSTOP\n", (long) pid);
|
||||
+ fprintf_unfiltered (gdb_stdlog, "LLA: waitpid %d, faking SIGSTOP\n",
|
||||
+ GET_PID (inferior_ptid));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1173,6 +1313,9 @@ linux_nat_detach (char *args, int from_t
|
||||
|
||||
trap_ptid = null_ptid;
|
||||
|
||||
+ if (lwp_list->was_stopped)
|
||||
+ args = STRINGIFY (SIGSTOP);
|
||||
+
|
||||
/* Destroy LWP info; it's no longer valid. */
|
||||
init_lwp_list ();
|
||||
|
||||
@@ -1310,6 +1453,12 @@ linux_nat_resume (ptid_t ptid, int step_
|
||||
lp->stopped = 0;
|
||||
}
|
||||
|
||||
+ /* At this point, we are going to resume the inferior and if we
|
||||
+ have attached to a stopped process, we no longer should leave
|
||||
+ it as stopped if the user detaches. */
|
||||
+ if (!step && lp != NULL)
|
||||
+ lp->was_stopped = 0;
|
||||
+
|
||||
if (resume_all)
|
||||
iterate_over_lwps (resume_callback, NULL);
|
||||
|
||||
--- ./gdb/linux-nat.h 10 May 2007 21:36:00 -0000 1.18
|
||||
+++ ./gdb/linux-nat.h 29 Jun 2007 22:06:05 -0000
|
||||
@@ -42,6 +42,9 @@ struct lwp_info
|
||||
/* Non-zero if this LWP is stopped. */
|
||||
int stopped;
|
||||
|
||||
+ /* Non-zero if this LWP was stopped by SIGSTOP before attaching. */
|
||||
+ int was_stopped;
|
||||
+
|
||||
/* Non-zero if this LWP will be/has been resumed. Note that an LWP
|
||||
can be marked both as stopped and resumed at the same time. This
|
||||
happens if we try to resume an LWP that has a wait status
|
||||
--- /dev/null 1 Jan 1970 00:00:00 -0000
|
||||
+++ ./gdb/testsuite/gdb.threads/attach-into-signal.c 29 Jun 2007 22:06:05 -0000
|
||||
@@ -0,0 +1,70 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2007 Free Software Foundation, Inc.
|
||||
+
|
||||
+ 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 2 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, write to the Free Software
|
||||
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
+
|
||||
+#include <signal.h>
|
||||
+#include <unistd.h>
|
||||
+#include <string.h>
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#ifdef USE_THREADS
|
||||
+#include <pthread.h>
|
||||
+#endif
|
||||
+
|
||||
+void action(int sig, siginfo_t * info, void *uc)
|
||||
+{
|
||||
+ raise (SIGALRM);
|
||||
+}
|
||||
+
|
||||
+static void *func (void *arg)
|
||||
+{
|
||||
+ struct sigaction act;
|
||||
+
|
||||
+ memset (&act, 0, sizeof(struct sigaction));
|
||||
+ act.sa_sigaction = action;
|
||||
+ act.sa_flags = SA_RESTART;
|
||||
+ sigaction (SIGALRM, &act, 0);
|
||||
+
|
||||
+ raise (SIGALRM);
|
||||
+
|
||||
+ /* It is an upstream kernel bug (2.6.22-rc4-git7.x86_64, PREEMPT, SMP).
|
||||
+ We never get here without ptrace(2) but we get while under ptrace(2). */
|
||||
+ for (;;)
|
||||
+ pause ();
|
||||
+
|
||||
+ abort ();
|
||||
+ /* NOTREACHED */
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+int main ()
|
||||
+{
|
||||
+
|
||||
+#ifndef USE_THREADS
|
||||
+
|
||||
+ func (NULL);
|
||||
+
|
||||
+#else
|
||||
+
|
||||
+ pthread_t th;
|
||||
+ pthread_create (&th, NULL, func, NULL);
|
||||
+ pthread_join (th, NULL);
|
||||
+
|
||||
+#endif
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
--- /dev/null 1 Jan 1970 00:00:00 -0000
|
||||
+++ ./gdb/testsuite/gdb.threads/attach-into-signal.exp 29 Jun 2007 22:06:06 -0000
|
||||
@@ -0,0 +1,179 @@
|
||||
+# Copyright 2007
|
||||
+
|
||||
+# 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 2 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, write to the Free Software
|
||||
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+# This test was created by modifying attach-stopped.exp.
|
||||
+# This file was created by Jan Kratochvil <jan.kratochvil@redhat.com>.
|
||||
+
|
||||
+if $tracelevel then {
|
||||
+ strace $tracelevel
|
||||
+}
|
||||
+
|
||||
+set prms_id 0
|
||||
+set bug_id 0
|
||||
+
|
||||
+set testfile "attach-into-signal"
|
||||
+set srcfile ${testfile}.c
|
||||
+set binfile ${objdir}/${subdir}/${testfile}
|
||||
+set escapedbinfile [string_to_regexp ${objdir}/${subdir}/${testfile}]
|
||||
+
|
||||
+remote_exec build "rm -f ${binfile}"
|
||||
+# For debugging this test
|
||||
+#
|
||||
+#log_user 1
|
||||
+
|
||||
+proc corefunc { threadtype } {
|
||||
+ global srcfile
|
||||
+ global binfile
|
||||
+ global escapedbinfile
|
||||
+ global srcdir
|
||||
+ global subdir
|
||||
+ global gdb_prompt
|
||||
+
|
||||
+ if [get_compiler_info ${binfile}] {
|
||||
+ return -1
|
||||
+ }
|
||||
+
|
||||
+ # Start the program running and then wait for a bit, to be sure
|
||||
+ # that it can be attached to.
|
||||
+ # Statistically there is a better chance without giving process a nice.
|
||||
+
|
||||
+ set testpid [eval exec $binfile &]
|
||||
+ exec sleep 2
|
||||
+
|
||||
+ # Run 2 passes of the test.
|
||||
+ # The C file inferior stops pending its signals if a single one is lost,
|
||||
+ # we test successful redelivery of the caught signal by the 2nd pass.
|
||||
+
|
||||
+ # linux-2.6.20.4.x86_64 had maximal attempt # 20 in 4 test runs.
|
||||
+ set attempts 100
|
||||
+ set attempt 1
|
||||
+ set passes 1
|
||||
+ while { $passes < 3 && $attempt <= $attempts } {
|
||||
+
|
||||
+ # Start with clean gdb
|
||||
+ gdb_exit
|
||||
+
|
||||
+ set stoppedtry 0
|
||||
+ while { $stoppedtry < 10 } {
|
||||
+ if [catch {open /proc/${testpid}/status r} fileid] {
|
||||
+ set stoppedtry 10
|
||||
+ break
|
||||
+ }
|
||||
+ gets $fileid line1;
|
||||
+ gets $fileid line2;
|
||||
+ close $fileid;
|
||||
+
|
||||
+ if {![string match "*(stopped)*" $line2]} {
|
||||
+ # No PASS message as we may be looping in multiple attempts.
|
||||
+ break
|
||||
+ }
|
||||
+ sleep 1
|
||||
+ set stoppedtry [expr $stoppedtry + 1]
|
||||
+ }
|
||||
+ if { $stoppedtry >= 10 } {
|
||||
+ verbose -log $line2
|
||||
+ set test "$threadtype: process is still running on the attempt # $attempt of $attempts"
|
||||
+ break
|
||||
+ }
|
||||
+
|
||||
+ gdb_start
|
||||
+ gdb_reinitialize_dir $srcdir/$subdir
|
||||
+ gdb_load ${binfile}
|
||||
+
|
||||
+ # No PASS message as we may be looping in multiple attempts.
|
||||
+ gdb_test "set debug lin-lwp 1" "" ""
|
||||
+
|
||||
+ set test "$threadtype: set file (pass $passes), before attach1 to stopped process"
|
||||
+ if {[gdb_test_multiple "file $binfile" $test {
|
||||
+ -re "Load new symbol table from.*y or n. $" {
|
||||
+ # No PASS message as we may be looping in multiple attempts.
|
||||
+ gdb_test "y" "Reading symbols from $escapedbinfile\.\.\.*done." ""
|
||||
+ }
|
||||
+ -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $" {
|
||||
+ # No PASS message as we may be looping in multiple attempts.
|
||||
+ }
|
||||
+ }] != 0 } {
|
||||
+ break
|
||||
+ }
|
||||
+
|
||||
+ # Main test:
|
||||
+ set test "$threadtype: attach (pass $passes), pending signal catch"
|
||||
+ if {[gdb_test_multiple "attach $testpid" $test {
|
||||
+ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*Redelivering pending Alarm clock..*$gdb_prompt $" {
|
||||
+ # nonthreaded:
|
||||
+ pass $test
|
||||
+ verbose -log "$test succeeded on the attempt # $attempt of $attempts"
|
||||
+ set passes [expr $passes + 1]
|
||||
+ }
|
||||
+ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" {
|
||||
+ # nonthreaded:
|
||||
+ # We just lack the luck, we should try it again.
|
||||
+ set attempt [expr $attempt + 1]
|
||||
+ }
|
||||
+ -re "Attaching to process $testpid.*Redelivering pending Alarm clock..*$gdb_prompt $" {
|
||||
+ # threaded:
|
||||
+ pass $test
|
||||
+ verbose -log "$test succeeded on the attempt # $attempt of $attempts"
|
||||
+ set passes [expr $passes + 1]
|
||||
+ }
|
||||
+ -re "Attaching to process $testpid.*$gdb_prompt $" {
|
||||
+ # threaded:
|
||||
+ # We just lack the luck, we should try it again.
|
||||
+ set attempt [expr $attempt - 1]
|
||||
+ }
|
||||
+ }] != 0 } {
|
||||
+ break
|
||||
+ }
|
||||
+ }
|
||||
+ if {$passes < 3} {
|
||||
+ if {$attempt > $attempts} {
|
||||
+ unresolved $test
|
||||
+ } else {
|
||||
+ fail $test
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ # Exit and detach the process.
|
||||
+
|
||||
+ gdb_exit
|
||||
+
|
||||
+ # Make sure we don't leave a process around to confuse
|
||||
+ # the next test run (and prevent the compile by keeping
|
||||
+ # the text file busy), in case the "set should_exit" didn't
|
||||
+ # work.
|
||||
+
|
||||
+ # Continue the program - some Linux kernels need it before -9 if the
|
||||
+ # process is stopped.
|
||||
+ remote_exec build "kill -s CONT ${testpid}"
|
||||
+
|
||||
+ remote_exec build "kill -9 ${testpid}"
|
||||
+}
|
||||
+
|
||||
+# build the test case first without threads
|
||||
+#
|
||||
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
||||
+ gdb_suppress_entire_file "Testcase nonthraded compile failed, so all tests in this file will automatically fail."
|
||||
+}
|
||||
+
|
||||
+corefunc nonthreaded
|
||||
+
|
||||
+# build the test case also with threads
|
||||
+#
|
||||
+if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DUSE_THREADS}] != "" } {
|
||||
+ gdb_suppress_entire_file "Testcase threaded compile failed, so all tests in this file will automatically fail."
|
||||
+}
|
||||
+
|
||||
+corefunc threaded
|
||||
--- /dev/null 1 Jan 1970 00:00:00 -0000
|
||||
+++ ./gdb/testsuite/gdb.threads/attach-stopped.c 29 Jun 2007 22:06:06 -0000
|
||||
@@ -0,0 +1,51 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2005-2007 Free Software Foundation, Inc.
|
||||
+
|
||||
+ 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 2 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, write to the Free Software
|
||||
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
+
|
||||
+/* This program is intended to be started outside of gdb, then
|
||||
+ manually stopped via a signal. */
|
||||
+
|
||||
+#include <stddef.h>
|
||||
+#include <unistd.h>
|
||||
+#ifdef USE_THREADS
|
||||
+#include <pthread.h>
|
||||
+#endif
|
||||
+
|
||||
+static void *func (void *arg)
|
||||
+{
|
||||
+ sleep (10000); /* Ridiculous time, but we will eventually kill it. */
|
||||
+ sleep (10000); /* Second sleep. */
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+int main ()
|
||||
+{
|
||||
+
|
||||
+#ifndef USE_THREADS
|
||||
+
|
||||
+ func (NULL);
|
||||
+
|
||||
+#else
|
||||
+
|
||||
+ pthread_t th;
|
||||
+ pthread_create (&th, NULL, func, NULL);
|
||||
+ pthread_join (th, NULL);
|
||||
+
|
||||
+#endif
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
--- /dev/null 1 Jan 1970 00:00:00 -0000
|
||||
+++ ./gdb/testsuite/gdb.threads/attach-stopped.exp 29 Jun 2007 22:06:06 -0000
|
||||
@@ -0,0 +1,219 @@
|
||||
+# Copyright 2005-2007
|
||||
+
|
||||
+# 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 2 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, write to the Free Software
|
||||
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+# This test was created by modifying attach.exp.
|
||||
+# This file was created by Jeff Johnston <jjohnstn@redhat.com>.
|
||||
+# This file was updated by Jan Kratochvil <jan.kratochvil@redhat.com>.
|
||||
+
|
||||
+if $tracelevel then {
|
||||
+ strace $tracelevel
|
||||
+}
|
||||
+
|
||||
+set prms_id 0
|
||||
+set bug_id 0
|
||||
+
|
||||
+# This test only works on Linux
|
||||
+if { ![istarget "*-*-linux-gnu*"] } {
|
||||
+ return 0
|
||||
+}
|
||||
+
|
||||
+set testfile "attach-stopped"
|
||||
+set srcfile ${testfile}.c
|
||||
+set binfile ${objdir}/${subdir}/${testfile}
|
||||
+set escapedbinfile [string_to_regexp ${objdir}/${subdir}/${testfile}]
|
||||
+
|
||||
+#execute_anywhere "rm -f ${binfile}"
|
||||
+remote_exec build "rm -f ${binfile}"
|
||||
+# For debugging this test
|
||||
+#
|
||||
+#log_user 1
|
||||
+
|
||||
+proc corefunc { threadtype } {
|
||||
+ global srcfile
|
||||
+ global binfile
|
||||
+ global escapedbinfile
|
||||
+ global srcdir
|
||||
+ global subdir
|
||||
+ global gdb_prompt
|
||||
+
|
||||
+ if [get_compiler_info ${binfile}] {
|
||||
+ return -1
|
||||
+ }
|
||||
+
|
||||
+ # Start the program running and then wait for a bit, to be sure
|
||||
+ # that it can be attached to.
|
||||
+
|
||||
+ set testpid [eval exec $binfile &]
|
||||
+
|
||||
+ # Avoid some race:
|
||||
+ sleep 2
|
||||
+
|
||||
+ # Stop the program
|
||||
+ remote_exec build "kill -s STOP ${testpid}"
|
||||
+
|
||||
+ # Start with clean gdb
|
||||
+ gdb_exit
|
||||
+ gdb_start
|
||||
+ gdb_reinitialize_dir $srcdir/$subdir
|
||||
+ gdb_load ${binfile}
|
||||
+
|
||||
+ # Verify that we can attach to the process by first giving its
|
||||
+ # executable name via the file command, and using attach with the
|
||||
+ # process ID.
|
||||
+
|
||||
+ set test "$threadtype: set file, before attach1 to stopped process"
|
||||
+ gdb_test_multiple "file $binfile" "$test" {
|
||||
+ -re "Load new symbol table from.*y or n. $" {
|
||||
+ gdb_test "y" "Reading symbols from $escapedbinfile\.\.\.*done." \
|
||||
+ "$test (re-read)"
|
||||
+ }
|
||||
+ -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $" {
|
||||
+ pass "$test"
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ set test "$threadtype: attach1 to stopped, after setting file"
|
||||
+ gdb_test_multiple "attach $testpid" "$test" {
|
||||
+ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" {
|
||||
+ pass "$test"
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if {[string equal $threadtype threaded]} {
|
||||
+ gdb_test "thread apply all bt" ".*sleep.*clone.*" "$threadtype: attach1 to stopped bt"
|
||||
+ } else {
|
||||
+ gdb_test "bt" ".*sleep.*main.*" "$threadtype: attach1 to stopped bt"
|
||||
+ }
|
||||
+
|
||||
+ # Exit and detach the process.
|
||||
+
|
||||
+ gdb_exit
|
||||
+
|
||||
+ # Avoid some race:
|
||||
+ sleep 2
|
||||
+
|
||||
+ if [catch {open /proc/${testpid}/status r} fileid] {
|
||||
+ set line2 "NOTFOUND"
|
||||
+ } else {
|
||||
+ gets $fileid line1;
|
||||
+ gets $fileid line2;
|
||||
+ close $fileid;
|
||||
+ }
|
||||
+
|
||||
+ set test "$threadtype: attach1, exit leaves process stopped"
|
||||
+ if {[string match "*(stopped)*" $line2]} {
|
||||
+ pass $test
|
||||
+ } else {
|
||||
+ fail $test
|
||||
+ }
|
||||
+
|
||||
+ # At this point, the process should still be stopped
|
||||
+
|
||||
+ gdb_start
|
||||
+ gdb_reinitialize_dir $srcdir/$subdir
|
||||
+ gdb_load ${binfile}
|
||||
+
|
||||
+ # Verify that we can attach to the process just by giving the
|
||||
+ # process ID.
|
||||
+
|
||||
+ set test "$threadtype: attach2 to stopped, after setting file"
|
||||
+ gdb_test_multiple "attach $testpid" "$test" {
|
||||
+ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" {
|
||||
+ pass "$test"
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if {[string equal $threadtype threaded]} {
|
||||
+ gdb_test "thread apply all bt" ".*sleep.*clone.*" "$threadtype: attach2 to stopped bt"
|
||||
+ } else {
|
||||
+ gdb_test "bt" ".*sleep.*main.*" "$threadtype: attach2 to stopped bt"
|
||||
+ }
|
||||
+ gdb_breakpoint [gdb_get_line_number "$threadtype: Second sleep"]
|
||||
+ set test "$threadtype: attach2 continue"
|
||||
+ send_gdb "continue\n"
|
||||
+ gdb_expect {
|
||||
+ -re "Continuing"
|
||||
+ { pass "continue ($test)" }
|
||||
+ timeout
|
||||
+ { fail "continue ($test) (timeout)" }
|
||||
+ }
|
||||
+
|
||||
+ # For this to work we must be sure to consume the "Continuing."
|
||||
+ # message first, or GDB's signal handler may not be in place.
|
||||
+ after 1000 {send_gdb "\003"}
|
||||
+ set test "$threadtype: attach2 stop interrupt"
|
||||
+ gdb_expect 10 {
|
||||
+ -re "Program received signal SIGINT.*$gdb_prompt $"
|
||||
+ {
|
||||
+ pass $test
|
||||
+ }
|
||||
+ -re "Breakpoint \[0-9\].*$srcfile.*$gdb_prompt $"
|
||||
+ {
|
||||
+ pass $test
|
||||
+ }
|
||||
+ timeout
|
||||
+ {
|
||||
+ fail $test
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ gdb_exit
|
||||
+
|
||||
+ # Avoid some race:
|
||||
+ sleep 2
|
||||
+
|
||||
+ # At this point, the process should be sleeping
|
||||
+
|
||||
+ if [catch {open /proc/${testpid}/status r} fileid2] {
|
||||
+ set line2 "NOTFOUND"
|
||||
+ } else {
|
||||
+ gets $fileid2 line1;
|
||||
+ gets $fileid2 line2;
|
||||
+ close $fileid2;
|
||||
+ }
|
||||
+
|
||||
+ set test "$threadtype: attach2, exit leaves process sleeping"
|
||||
+ if {[string match "*(sleeping)*" $line2]} {
|
||||
+ pass $test
|
||||
+ } else {
|
||||
+ fail $test
|
||||
+ }
|
||||
+
|
||||
+ # Make sure we don't leave a process around to confuse
|
||||
+ # the next test run (and prevent the compile by keeping
|
||||
+ # the text file busy), in case the "set should_exit" didn't
|
||||
+ # work.
|
||||
+
|
||||
+ remote_exec build "kill -9 ${testpid}"
|
||||
+}
|
||||
+
|
||||
+# build the test case first without threads
|
||||
+#
|
||||
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
||||
+ gdb_suppress_entire_file "Testcase nonthraded compile failed, so all tests in this file will automatically fail."
|
||||
+}
|
||||
+
|
||||
+corefunc nonthreaded
|
||||
+
|
||||
+# build the test case first without threads
|
||||
+#
|
||||
+if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DUSE_THREADS}] != "" } {
|
||||
+ gdb_suppress_entire_file "Testcase threaded compile failed, so all tests in this file will automatically fail."
|
||||
+}
|
||||
+
|
||||
+corefunc threaded
|
||||
+
|
||||
+return 0
|
||||
--- ./gdb/doc/gdb.texinfo 1 Jul 2007 09:13:05 -0000 1.418
|
||||
+++ ./gdb/doc/gdb.texinfo 1 Jul 2007 09:55:14 -0000
|
||||
@@ -2167,16 +2167,29 @@ can step and continue; you can modify st
|
||||
process continue running, you may use the @code{continue} command after
|
||||
attaching @value{GDBN} to the process.
|
||||
|
||||
+For a process already being stopped before the @code{attach} command executed
|
||||
+you get the informational message below. Other signals may be occasionally
|
||||
+shown if they were being delivered right the time the @code{attach} command
|
||||
+executed. Such process is left still stopped after the @code{detach} command
|
||||
+as long as you have not used the @code{continue} command (or similiar one)
|
||||
+during your debugging session.
|
||||
+
|
||||
+@smallexample
|
||||
+Attaching to program: /bin/sleep, process 16289
|
||||
+Redelivering pending Stopped (signal).
|
||||
+@end smallexample
|
||||
+
|
||||
@table @code
|
||||
@kindex detach
|
||||
@item detach
|
||||
When you have finished debugging the attached process, you can use the
|
||||
-@code{detach} command to release it from @value{GDBN} control. Detaching
|
||||
-the process continues its execution. After the @code{detach} command,
|
||||
-that process and @value{GDBN} become completely independent once more, and you
|
||||
-are ready to @code{attach} another process or start one with @code{run}.
|
||||
-@code{detach} does not repeat if you press @key{RET} again after
|
||||
-executing the command.
|
||||
+@code{detach} command to release it from @value{GDBN} control. Detaching the
|
||||
+process continues its execution unless it was already stopped before the
|
||||
+attachment and a @code{continue} type command has not been executed. After the
|
||||
+@code{detach} command, that process and @value{GDBN} become completely
|
||||
+independent once more, and you are ready to @code{attach} another process or
|
||||
+start one with @code{run}. @code{detach} does not repeat if you press
|
||||
+@key{RET} again after executing the command.
|
||||
@end table
|
||||
|
||||
If you exit @value{GDBN} while you have an attached process, you detach
|
@ -112,7 +112,7 @@
|
||||
+}
|
||||
+
|
||||
+# Prevent races.
|
||||
+sleep 2
|
||||
+sleep 8
|
||||
+
|
||||
+stop_process "Threads could be stopped"
|
||||
+
|
||||
|
421
gdb-6.7-bz233852-attach-signalled-fix.patch
Normal file
421
gdb-6.7-bz233852-attach-signalled-fix.patch
Normal file
@ -0,0 +1,421 @@
|
||||
2008-01-09 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
Support attaching to stopped processes/threads and/or with pending
|
||||
signals. This ChangeLog entry is OBSOLETE:
|
||||
* linux-nat.c (STRINGIFY, STRINGIFY_ARG): New macros.
|
||||
(kill_lwp): New declaration.
|
||||
(linux_ptrace_post_attach, pid_is_stopped): New function.
|
||||
(linux_child_follow_fork): New comment about WAS_STOPPED.
|
||||
(lin_lwp_attach_lwp): Variable PID removed. Part replaced by a call to
|
||||
LINUX_PTRACE_POST_ATTACH.
|
||||
(linux_nat_attach): Likewise.
|
||||
(linux_nat_detach): Optionally stop the detached process.
|
||||
(linux_nat_resume): Clear WAS_STOPPED if appropriate.
|
||||
* NEWS: Document the new behaviour.
|
||||
|
||||
2007-06-30 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* gdb.texinfo (Attach): Document the ATTACH and DETACH commands for
|
||||
stopped processes. Document the messages on the seen pending signals.
|
||||
|
||||
diff -u -X /home/short/.diffi.list -ruNp gdb-6.5-unpatched/gdb/NEWS gdb-6.5/gdb/NEWS
|
||||
--- gdb-6.5-unpatched/gdb/NEWS 2008-01-09 18:26:07.000000000 +0100
|
||||
+++ gdb-6.5/gdb/NEWS 2008-01-09 15:26:30.000000000 +0100
|
||||
@@ -9,6 +9,9 @@ Renesas M32C/M16C m32c-elf
|
||||
|
||||
Morpho Technologies ms1 ms1-elf
|
||||
|
||||
+* On GNU/Linux, stopped processes may get attached to now. Signals being
|
||||
+delivered at the time of the attach command no longer get lost.
|
||||
+
|
||||
* New commands
|
||||
|
||||
init-if-undefined Initialize a convenience variable, but
|
||||
--- gdb-6.7.1/gdb/linux-nat.c.orig 2008-01-09 23:54:42.000000000 +0100
|
||||
+++ gdb-6.7.1/gdb/linux-nat.c 2008-01-10 00:08:07.000000000 +0100
|
||||
@@ -85,11 +85,20 @@
|
||||
#define __WALL 0x40000000 /* Wait for any child. */
|
||||
#endif
|
||||
|
||||
+#define STRINGIFY_ARG(x) #x
|
||||
+#define STRINGIFY(x) STRINGIFY_ARG (x)
|
||||
+
|
||||
+static int linux_ptrace_post_attach (struct lwp_info *lp);
|
||||
+static int kill_lwp (int lwpid, int signo);
|
||||
+
|
||||
/* The single-threaded native GNU/Linux target_ops. We save a pointer for
|
||||
the use of the multi-threaded target. */
|
||||
static struct target_ops *linux_ops;
|
||||
static struct target_ops linux_ops_saved;
|
||||
|
||||
+/* PID of the inferior stopped by SIGSTOP before attaching (or zero). */
|
||||
+static pid_t pid_was_stopped;
|
||||
+
|
||||
/* The saved to_xfer_partial method, inherited from inf-ptrace.c.
|
||||
Called by our to_xfer_partial. */
|
||||
static LONGEST (*super_xfer_partial) (struct target_ops *,
|
||||
@@ -540,6 +549,11 @@ linux_child_follow_fork (struct target_o
|
||||
}
|
||||
else
|
||||
{
|
||||
+ /* We should check PID_WAS_STOPPED and detach it stopped accordingly.
|
||||
+ In this point of code it cannot be 1 as we would not get FORK
|
||||
+ executed without CONTINUE first which resets PID_WAS_STOPPED.
|
||||
+ We would have to first TARGET_STOP and WAITPID it as with running
|
||||
+ inferior PTRACE_DETACH, SIGSTOP will ignore the signal. */
|
||||
target_detach (NULL, 0);
|
||||
}
|
||||
|
||||
@@ -940,7 +954,6 @@ lin_lwp_attach_lwp (ptid_t ptid, int ver
|
||||
to happen. */
|
||||
if (GET_LWP (ptid) != GET_PID (ptid) && lp == NULL)
|
||||
{
|
||||
- pid_t pid;
|
||||
int status;
|
||||
|
||||
if (ptrace (PTRACE_ATTACH, GET_LWP (ptid), 0, 0) < 0)
|
||||
@@ -958,10 +971,156 @@ lin_lwp_attach_lwp (ptid_t ptid, int ver
|
||||
if (lp == NULL)
|
||||
lp = add_lwp (ptid);
|
||||
|
||||
- if (debug_linux_nat)
|
||||
- fprintf_unfiltered (gdb_stdlog,
|
||||
- "LLAL: PTRACE_ATTACH %s, 0, 0 (OK)\n",
|
||||
- target_pid_to_str (ptid));
|
||||
+ status = linux_ptrace_post_attach (lp);
|
||||
+ if (status != 0)
|
||||
+ {
|
||||
+ error (_("Thread %s exited: %s"), target_pid_to_str (ptid),
|
||||
+ status_to_str (status));
|
||||
+ }
|
||||
+
|
||||
+ target_post_attach (GET_LWP (ptid));
|
||||
+
|
||||
+ lp->stopped = 1;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ /* We assume that the LWP representing the original process is
|
||||
+ already stopped. Mark it as stopped in the data structure
|
||||
+ that the GNU/linux ptrace layer uses to keep track of
|
||||
+ threads. Note that this won't have already been done since
|
||||
+ the main thread will have, we assume, been stopped by an
|
||||
+ attach from a different layer. */
|
||||
+ if (lp == NULL)
|
||||
+ lp = add_lwp (ptid);
|
||||
+ lp->stopped = 1;
|
||||
+ }
|
||||
+
|
||||
+ if (verbose)
|
||||
+ printf_filtered (_("[New %s]\n"), target_pid_to_str (ptid));
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+/* Detect `T (stopped)' in `/proc/PID/status'.
|
||||
+ Other states including `T (tracing stop)' are reported as false. */
|
||||
+
|
||||
+static int
|
||||
+pid_is_stopped (pid_t pid)
|
||||
+{
|
||||
+ FILE *status_file;
|
||||
+ char buf[100];
|
||||
+ int retval = 0;
|
||||
+
|
||||
+ snprintf (buf, sizeof (buf), "/proc/%d/status", (int) pid);
|
||||
+ status_file = fopen (buf, "r");
|
||||
+ if (status_file != NULL)
|
||||
+ {
|
||||
+ int have_state = 0;
|
||||
+
|
||||
+ while (fgets (buf, sizeof (buf), status_file))
|
||||
+ {
|
||||
+ if (strncmp (buf, "State:", 6) == 0)
|
||||
+ {
|
||||
+ have_state = 1;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ if (have_state && strstr (buf, "T (stopped)") != NULL)
|
||||
+ retval = 1;
|
||||
+ fclose (status_file);
|
||||
+ }
|
||||
+ return retval;
|
||||
+}
|
||||
+
|
||||
+/* Handle the processing after PTRACE_ATTACH, the first WAITPID -> SIGSTOP.
|
||||
+ Returns STATUS if the thread has exited, 0 otherwise.
|
||||
+ Sets PID_WAS_STOPPED if the process was originally stopped.
|
||||
+ Sets LP->CLONED if the given LWP is not the thread leader.
|
||||
+
|
||||
+ Scenario for a standard unstopped inferior:
|
||||
+ * `S (sleeping)' or `R (running)' or similiar states.
|
||||
+ * PTRACE_ATTACH is called.
|
||||
+ * `S (sleeping)' (or similiar) for some while.
|
||||
+ * `T (tracing stop)'.
|
||||
+ * WAITPID succeeds here returning SIGSTOP (signalled by PTRACE_ATTACH).
|
||||
+
|
||||
+ Scenario for a formerly stopped inferior:
|
||||
+ * `T (stopped)'.
|
||||
+ * PTRACE_ATTACH is called.
|
||||
+ * `T (stopped)' would stay indefinitely
|
||||
+ Note since this moment the `TracerPid' field gets filled
|
||||
+ (by PTRACE_ATTACH), it is no longer just the common `T (stopped)' state.
|
||||
+ * If no one did WAITPID since sending SIGSTOP our WAITPID would return
|
||||
+ SIGSTOP. The state still would not turn to `T (tracing stop)'.
|
||||
+ * Usually its original parent (before PTRACE_ATTACH was applied) already
|
||||
+ did WAITPID. The original parent already received our SIGSTOP
|
||||
+ sinalled by our PTRACE_ATTACH.
|
||||
+ In this case our own WAITPID would hang. Therefore...
|
||||
+ * ... we do artificial: tkill (SIGCONT);
|
||||
+ `PTRACE_CONT, SIGSTOP' does not work in 100% cases as sometimes SIGSTOP
|
||||
+ gets remembered by kernel during the first PTRACE_CONT later and we get
|
||||
+ spurious SIGSTOP event. Expecting the signal may get delivered to
|
||||
+ a different task of the thread group.
|
||||
+ `kill_lwp (SIGSTOP)' has no effect in this moment (it is already stopped).
|
||||
+ * WAITPID returns the artifical SIGCONT.
|
||||
+ (The possibly pending SIGSTOP gets vanished by specifically SIGCONT.)
|
||||
+ * State turns `T (tracing stop)'.
|
||||
+ In this moment everything is almost fine but we need a workaround as final
|
||||
+ `PTRACE_DETACH, SIGSTOP' would leave the process unstopped otherwise:
|
||||
+ * tkill (SIGSTOP);
|
||||
+ * `PTRACE_CONT, 0'
|
||||
+ * WAITPID returns the artifical SIGSTOP.
|
||||
+
|
||||
+ With the pending (unwaited for) SIGSTOP the artifical signal effects are:
|
||||
+ kill (SIGSTOP)
|
||||
+ PTRACE_ATTACH
|
||||
+ /-tkill (SIGCONT), WAITPID: SIGCONT, WAITPID: hang !
|
||||
+ //-tkill (SIGCONT), WAITPID: SIGCONT, PTRACE_CONT (SIG_0), WAITPID: wait (OK)
|
||||
+ \\-tkill (SIGALRM), WAITPID: SIGSTOP, WAITPID: hang !
|
||||
+ \-tkill (SIGALRM), WAITPID: SIGSTOP, PTRACE_CONT (SIG_0), WAITPID: SIGALRM !
|
||||
+ Therefore we signal artifical SIGCONT and stop waiting after its reception.
|
||||
+
|
||||
+ For the detection whether the process was formerly stopped we need to
|
||||
+ read `/proc/PID/status'. `PTRACE_CONT, SIGSTOP' returns ESRCH
|
||||
+ for `S (sleeping)' and succeeds for `T (stopped)' but it unfortunately
|
||||
+ succeeds even for `T (tracing stop)'. Depending on PTRACE_CONT, SIGSTOP
|
||||
+ success value for formerly stopped processes would mean a race condition
|
||||
+ as we would get false stopped processes detection if we get too slow.
|
||||
+
|
||||
+ `waitid (..., WSTOPPED)' hangs the same way as WAITPID.
|
||||
+
|
||||
+ Signals get queued for WAITPID. PTRACE_ATTACH (or TKILL) enqueues SIGSTOP
|
||||
+ there but WAITPID may return an already pending signal.
|
||||
+ Redeliver it by PTRACE_CONT, SIGxxx as otherwise it would get lost.
|
||||
+ Similiar processing is being done in this file by WAIT_LWP. */
|
||||
+
|
||||
+static int
|
||||
+linux_ptrace_post_attach (struct lwp_info *lp)
|
||||
+{
|
||||
+ ptid_t ptid = lp->ptid;
|
||||
+ unsigned long sig;
|
||||
+ int this_thread_was_stopped;
|
||||
+
|
||||
+ if (debug_linux_nat)
|
||||
+ fprintf_unfiltered (gdb_stdlog,
|
||||
+ "LLAL: PTRACE_ATTACH %s, 0, 0 (OK)\n",
|
||||
+ target_pid_to_str (ptid));
|
||||
+
|
||||
+ /* This code should not be run for the threads being attached after the first
|
||||
+ thread (process) as we would get later spurious SIGCONT otherwise. */
|
||||
+
|
||||
+ this_thread_was_stopped = pid_is_stopped (GET_LWP (ptid));
|
||||
+ if (this_thread_was_stopped)
|
||||
+ {
|
||||
+ pid_was_stopped = GET_PID (ptid);
|
||||
+ if (kill_lwp (GET_LWP (ptid), SIGCONT) != 0)
|
||||
+ perror_with_name (("kill_lwp (SIGCONT)"));
|
||||
+ }
|
||||
+
|
||||
+ for (;;)
|
||||
+ {
|
||||
+ pid_t pid;
|
||||
+ int status;
|
||||
|
||||
pid = my_waitpid (GET_LWP (ptid), &status, 0);
|
||||
if (pid == -1 && errno == ECHILD)
|
||||
@@ -974,13 +1133,7 @@ lin_lwp_attach_lwp (ptid_t ptid, int ver
|
||||
target_pid_to_str (ptid), safe_strerror (errno));
|
||||
lp->cloned = 1;
|
||||
}
|
||||
-
|
||||
- gdb_assert (pid == GET_LWP (ptid)
|
||||
- && WIFSTOPPED (status) && WSTOPSIG (status));
|
||||
-
|
||||
- target_post_attach (pid);
|
||||
-
|
||||
- lp->stopped = 1;
|
||||
+ gdb_assert (pid == GET_LWP (ptid));
|
||||
|
||||
if (debug_linux_nat)
|
||||
{
|
||||
@@ -989,22 +1142,32 @@ lin_lwp_attach_lwp (ptid_t ptid, int ver
|
||||
target_pid_to_str (ptid),
|
||||
status_to_str (status));
|
||||
}
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- /* We assume that the LWP representing the original process is
|
||||
- already stopped. Mark it as stopped in the data structure
|
||||
- that the GNU/linux ptrace layer uses to keep track of
|
||||
- threads. Note that this won't have already been done since
|
||||
- the main thread will have, we assume, been stopped by an
|
||||
- attach from a different layer. */
|
||||
- if (lp == NULL)
|
||||
- lp = add_lwp (ptid);
|
||||
- lp->stopped = 1;
|
||||
- }
|
||||
|
||||
- if (verbose)
|
||||
- printf_filtered (_("[New %s]\n"), target_pid_to_str (ptid));
|
||||
+ /* Check if the thread has exited. */
|
||||
+ if (WIFEXITED (status) || WIFSIGNALED (status))
|
||||
+ return status;
|
||||
+ gdb_assert (WIFSTOPPED (status));
|
||||
+ sig = WSTOPSIG (status);
|
||||
+ gdb_assert (sig != 0);
|
||||
+ if (sig == SIGSTOP)
|
||||
+ break;
|
||||
+
|
||||
+ /* As the second signal for stopped processes we send SIGSTOP. */
|
||||
+ if (this_thread_was_stopped && sig == SIGCONT)
|
||||
+ sig = SIGSTOP;
|
||||
+
|
||||
+ printf_unfiltered (_("Redelivering pending %s.\n"),
|
||||
+ target_signal_to_string (target_signal_from_host (sig)));
|
||||
+ if (sig == SIGSTOP)
|
||||
+ {
|
||||
+ if (kill_lwp (GET_LWP (ptid), sig) != 0)
|
||||
+ perror_with_name (("kill_lwp"));
|
||||
+ /* We now must resume the inferior to get SIGSTOP delivered. */
|
||||
+ sig = 0;
|
||||
+ }
|
||||
+ if (ptrace (PTRACE_CONT, GET_LWP (ptid), NULL, (void *) sig) != 0)
|
||||
+ perror_with_name (("ptrace"));
|
||||
+ }
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1013,7 +1176,6 @@ static void
|
||||
linux_nat_attach (char *args, int from_tty)
|
||||
{
|
||||
struct lwp_info *lp;
|
||||
- pid_t pid;
|
||||
int status;
|
||||
|
||||
/* FIXME: We should probably accept a list of process id's, and
|
||||
@@ -1024,21 +1186,12 @@ linux_nat_attach (char *args, int from_t
|
||||
inferior_ptid = BUILD_LWP (GET_PID (inferior_ptid), GET_PID (inferior_ptid));
|
||||
lp = add_lwp (inferior_ptid);
|
||||
|
||||
- /* Make sure the initial process is stopped. The user-level threads
|
||||
- layer might want to poke around in the inferior, and that won't
|
||||
- work if things haven't stabilized yet. */
|
||||
- pid = my_waitpid (GET_PID (inferior_ptid), &status, 0);
|
||||
- if (pid == -1 && errno == ECHILD)
|
||||
- {
|
||||
- warning (_("%s is a cloned process"), target_pid_to_str (inferior_ptid));
|
||||
-
|
||||
- /* Try again with __WCLONE to check cloned processes. */
|
||||
- pid = my_waitpid (GET_PID (inferior_ptid), &status, __WCLONE);
|
||||
- lp->cloned = 1;
|
||||
- }
|
||||
-
|
||||
- gdb_assert (pid == GET_PID (inferior_ptid)
|
||||
- && WIFSTOPPED (status) && WSTOPSIG (status) == SIGSTOP);
|
||||
+ status = linux_ptrace_post_attach (lp);
|
||||
+ if (status != 0)
|
||||
+ error (_("Program %s exited: %s\n"), target_pid_to_str (inferior_ptid),
|
||||
+ status_to_str (status));
|
||||
+ if (lp->cloned)
|
||||
+ warning (_("%s is a cloned process"), target_pid_to_str (inferior_ptid));
|
||||
|
||||
lp->stopped = 1;
|
||||
|
||||
@@ -1047,8 +1200,8 @@ linux_nat_attach (char *args, int from_t
|
||||
lp->resumed = 1;
|
||||
if (debug_linux_nat)
|
||||
{
|
||||
- fprintf_unfiltered (gdb_stdlog,
|
||||
- "LLA: waitpid %ld, faking SIGSTOP\n", (long) pid);
|
||||
+ fprintf_unfiltered (gdb_stdlog, "LLA: waitpid %d, faking SIGSTOP\n",
|
||||
+ GET_PID (inferior_ptid));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1093,6 +1246,9 @@ detach_callback (struct lwp_info *lp, vo
|
||||
overall process id just yet. */
|
||||
if (GET_LWP (lp->ptid) != GET_PID (lp->ptid))
|
||||
{
|
||||
+ /* None of these threads should be stopped for PID_WAS_STOPPED. Only the
|
||||
+ last thread (process) will be stopped by LINUX_NAT_DETACH. */
|
||||
+
|
||||
errno = 0;
|
||||
if (ptrace (PTRACE_DETACH, GET_LWP (lp->ptid), 0,
|
||||
WSTOPSIG (lp->status)) < 0)
|
||||
@@ -1121,6 +1277,9 @@ linux_nat_detach (char *args, int from_t
|
||||
|
||||
trap_ptid = null_ptid;
|
||||
|
||||
+ if (pid_was_stopped == GET_PID (lwp_list->ptid))
|
||||
+ args = STRINGIFY (SIGSTOP);
|
||||
+
|
||||
/* Destroy LWP info; it's no longer valid. */
|
||||
init_lwp_list ();
|
||||
|
||||
@@ -1258,6 +1417,14 @@ linux_nat_resume (ptid_t ptid, int step_
|
||||
lp->stopped = 0;
|
||||
}
|
||||
|
||||
+ /* At this point, we are going to resume the inferior and if we
|
||||
+ have attached to a stopped process, we no longer should leave
|
||||
+ it as stopped if the user detaches. PTID variable has PID set to LWP
|
||||
+ while we need to check the real PID here. */
|
||||
+
|
||||
+ if (!step && lp && pid_was_stopped == GET_PID (lp->ptid))
|
||||
+ pid_was_stopped = 0;
|
||||
+
|
||||
if (resume_all)
|
||||
iterate_over_lwps (resume_callback, NULL);
|
||||
|
||||
diff -u -X /home/short/.diffi.list -ruNp gdb-6.5-unpatched/gdb/doc/gdb.texinfo gdb-6.5/gdb/doc/gdb.texinfo
|
||||
--- gdb-6.5-unpatched/gdb/doc/gdb.texinfo 2008-01-09 18:26:07.000000000 +0100
|
||||
+++ gdb-6.5/gdb/doc/gdb.texinfo 2008-01-09 15:26:30.000000000 +0100
|
||||
@@ -2190,16 +2190,29 @@ can step and continue; you can modify st
|
||||
process continue running, you may use the @code{continue} command after
|
||||
attaching @value{GDBN} to the process.
|
||||
|
||||
+For a process already being stopped before the @code{attach} command executed
|
||||
+you get the informational message below. Other signals may be occasionally
|
||||
+shown if they were being delivered right the time the @code{attach} command
|
||||
+executed. Such process is left still stopped after the @code{detach} command
|
||||
+as long as you have not used the @code{continue} command (or similiar one)
|
||||
+during your debugging session.
|
||||
+
|
||||
+@smallexample
|
||||
+Attaching to program: /bin/sleep, process 16289
|
||||
+Redelivering pending Stopped (signal).
|
||||
+@end smallexample
|
||||
+
|
||||
@table @code
|
||||
@kindex detach
|
||||
@item detach
|
||||
When you have finished debugging the attached process, you can use the
|
||||
-@code{detach} command to release it from @value{GDBN} control. Detaching
|
||||
-the process continues its execution. After the @code{detach} command,
|
||||
-that process and @value{GDBN} become completely independent once more, and you
|
||||
-are ready to @code{attach} another process or start one with @code{run}.
|
||||
-@code{detach} does not repeat if you press @key{RET} again after
|
||||
-executing the command.
|
||||
+@code{detach} command to release it from @value{GDBN} control. Detaching the
|
||||
+process continues its execution unless it was already stopped before the
|
||||
+attachment and a @code{continue} type command has not been executed. After the
|
||||
+@code{detach} command, that process and @value{GDBN} become completely
|
||||
+independent once more, and you are ready to @code{attach} another process or
|
||||
+start one with @code{run}. @code{detach} does not repeat if you press
|
||||
+@key{RET} again after executing the command.
|
||||
@end table
|
||||
|
||||
If you exit @value{GDBN} or use the @code{run} command while you have an
|
887
gdb-6.7-bz233852-attach-signalled-test.patch
Normal file
887
gdb-6.7-bz233852-attach-signalled-test.patch
Normal file
@ -0,0 +1,887 @@
|
||||
2008-01-09 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* gdb.threads/attach-into-signal.c, gdb.threads/attach-into-signal.exp,
|
||||
gdb.threads/attach-stopped.c, gdb.threads/attach-stopped.exp: New files.
|
||||
|
||||
Formerly gdb-6.3-bz202705-attach-stop-20051011-race-fix-test.patch:
|
||||
gdb.threads/attachstop-mt.exp, gdb.threads/attachstop-mt.c
|
||||
|
||||
diff -u -X /home/short/.diffi.list -ruNp gdb-6.5-unpatched/gdb/testsuite/gdb.threads/attach-into-signal.c gdb-6.5/gdb/testsuite/gdb.threads/attach-into-signal.c
|
||||
--- gdb-6.5-unpatched/gdb/testsuite/gdb.threads/attach-into-signal.c 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ gdb-6.5/gdb/testsuite/gdb.threads/attach-into-signal.c 2008-01-09 15:26:30.000000000 +0100
|
||||
@@ -0,0 +1,70 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2007 Free Software Foundation, Inc.
|
||||
+
|
||||
+ 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 2 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, write to the Free Software
|
||||
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
+
|
||||
+#include <signal.h>
|
||||
+#include <unistd.h>
|
||||
+#include <string.h>
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#ifdef USE_THREADS
|
||||
+#include <pthread.h>
|
||||
+#endif
|
||||
+
|
||||
+void action(int sig, siginfo_t * info, void *uc)
|
||||
+{
|
||||
+ raise (SIGALRM);
|
||||
+}
|
||||
+
|
||||
+static void *func (void *arg)
|
||||
+{
|
||||
+ struct sigaction act;
|
||||
+
|
||||
+ memset (&act, 0, sizeof(struct sigaction));
|
||||
+ act.sa_sigaction = action;
|
||||
+ act.sa_flags = SA_RESTART;
|
||||
+ sigaction (SIGALRM, &act, 0);
|
||||
+
|
||||
+ raise (SIGALRM);
|
||||
+
|
||||
+ /* This should be NOTREACHED but sometimes it is reached - Bug 427860.
|
||||
+ We never get here without ptrace(2). It may also be a kernel bug. */
|
||||
+ for (;;)
|
||||
+ pause ();
|
||||
+
|
||||
+ abort ();
|
||||
+ /* NOTREACHED */
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+int main ()
|
||||
+{
|
||||
+
|
||||
+#ifndef USE_THREADS
|
||||
+
|
||||
+ func (NULL);
|
||||
+
|
||||
+#else
|
||||
+
|
||||
+ pthread_t th;
|
||||
+ pthread_create (&th, NULL, func, NULL);
|
||||
+ pthread_join (th, NULL);
|
||||
+
|
||||
+#endif
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
diff -u -X /home/short/.diffi.list -ruNp gdb-6.5-unpatched/gdb/testsuite/gdb.threads/attach-into-signal.exp gdb-6.5/gdb/testsuite/gdb.threads/attach-into-signal.exp
|
||||
--- gdb-6.5-unpatched/gdb/testsuite/gdb.threads/attach-into-signal.exp 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ gdb-6.5/gdb/testsuite/gdb.threads/attach-into-signal.exp 2008-01-09 15:26:30.000000000 +0100
|
||||
@@ -0,0 +1,179 @@
|
||||
+# Copyright 2007
|
||||
+
|
||||
+# 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 2 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, write to the Free Software
|
||||
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+# This test was created by modifying attach-stopped.exp.
|
||||
+# This file was created by Jan Kratochvil <jan.kratochvil@redhat.com>.
|
||||
+
|
||||
+if $tracelevel then {
|
||||
+ strace $tracelevel
|
||||
+}
|
||||
+
|
||||
+set prms_id 0
|
||||
+set bug_id 0
|
||||
+
|
||||
+set testfile "attach-into-signal"
|
||||
+set srcfile ${testfile}.c
|
||||
+set binfile ${objdir}/${subdir}/${testfile}
|
||||
+set escapedbinfile [string_to_regexp ${objdir}/${subdir}/${testfile}]
|
||||
+
|
||||
+remote_exec build "rm -f ${binfile}"
|
||||
+# For debugging this test
|
||||
+#
|
||||
+#log_user 1
|
||||
+
|
||||
+proc corefunc { threadtype } {
|
||||
+ global srcfile
|
||||
+ global binfile
|
||||
+ global escapedbinfile
|
||||
+ global srcdir
|
||||
+ global subdir
|
||||
+ global gdb_prompt
|
||||
+
|
||||
+ if [get_compiler_info ${binfile}] {
|
||||
+ return -1
|
||||
+ }
|
||||
+
|
||||
+ # Start the program running and then wait for a bit, to be sure
|
||||
+ # that it can be attached to.
|
||||
+ # Statistically there is a better chance without giving process a nice.
|
||||
+
|
||||
+ set testpid [eval exec $binfile &]
|
||||
+ exec sleep 2
|
||||
+
|
||||
+ # Run 2 passes of the test.
|
||||
+ # The C file inferior stops pending its signals if a single one is lost,
|
||||
+ # we test successful redelivery of the caught signal by the 2nd pass.
|
||||
+
|
||||
+ # linux-2.6.20.4.x86_64 had maximal attempt # 20 in 4 test runs.
|
||||
+ set attempts 100
|
||||
+ set attempt 1
|
||||
+ set passes 1
|
||||
+ while { $passes < 3 && $attempt <= $attempts } {
|
||||
+
|
||||
+ # Start with clean gdb
|
||||
+ gdb_exit
|
||||
+
|
||||
+ set stoppedtry 0
|
||||
+ while { $stoppedtry < 10 } {
|
||||
+ if [catch {open /proc/${testpid}/status r} fileid] {
|
||||
+ set stoppedtry 10
|
||||
+ break
|
||||
+ }
|
||||
+ gets $fileid line1;
|
||||
+ gets $fileid line2;
|
||||
+ close $fileid;
|
||||
+
|
||||
+ if {![string match "*(stopped)*" $line2]} {
|
||||
+ # No PASS message as we may be looping in multiple attempts.
|
||||
+ break
|
||||
+ }
|
||||
+ sleep 1
|
||||
+ set stoppedtry [expr $stoppedtry + 1]
|
||||
+ }
|
||||
+ if { $stoppedtry >= 10 } {
|
||||
+ verbose -log $line2
|
||||
+ set test "$threadtype: process is still running on the attempt # $attempt of $attempts"
|
||||
+ break
|
||||
+ }
|
||||
+
|
||||
+ gdb_start
|
||||
+ gdb_reinitialize_dir $srcdir/$subdir
|
||||
+ gdb_load ${binfile}
|
||||
+
|
||||
+ # No PASS message as we may be looping in multiple attempts.
|
||||
+ gdb_test "set debug lin-lwp 1" "" ""
|
||||
+
|
||||
+ set test "$threadtype: set file (pass $passes), before attach1 to stopped process"
|
||||
+ if {[gdb_test_multiple "file $binfile" $test {
|
||||
+ -re "Load new symbol table from.*y or n. $" {
|
||||
+ # No PASS message as we may be looping in multiple attempts.
|
||||
+ gdb_test "y" "Reading symbols from $escapedbinfile\.\.\.*done." ""
|
||||
+ }
|
||||
+ -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $" {
|
||||
+ # No PASS message as we may be looping in multiple attempts.
|
||||
+ }
|
||||
+ }] != 0 } {
|
||||
+ break
|
||||
+ }
|
||||
+
|
||||
+ # Main test:
|
||||
+ set test "$threadtype: attach (pass $passes), pending signal catch"
|
||||
+ if {[gdb_test_multiple "attach $testpid" $test {
|
||||
+ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*Redelivering pending Alarm clock..*$gdb_prompt $" {
|
||||
+ # nonthreaded:
|
||||
+ pass $test
|
||||
+ verbose -log "$test succeeded on the attempt # $attempt of $attempts"
|
||||
+ set passes [expr $passes + 1]
|
||||
+ }
|
||||
+ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" {
|
||||
+ # nonthreaded:
|
||||
+ # We just lack the luck, we should try it again.
|
||||
+ set attempt [expr $attempt + 1]
|
||||
+ }
|
||||
+ -re "Attaching to process $testpid.*Redelivering pending Alarm clock..*$gdb_prompt $" {
|
||||
+ # threaded:
|
||||
+ pass $test
|
||||
+ verbose -log "$test succeeded on the attempt # $attempt of $attempts"
|
||||
+ set passes [expr $passes + 1]
|
||||
+ }
|
||||
+ -re "Attaching to process $testpid.*$gdb_prompt $" {
|
||||
+ # threaded:
|
||||
+ # We just lack the luck, we should try it again.
|
||||
+ set attempt [expr $attempt - 1]
|
||||
+ }
|
||||
+ }] != 0 } {
|
||||
+ break
|
||||
+ }
|
||||
+ }
|
||||
+ if {$passes < 3} {
|
||||
+ if {$attempt > $attempts} {
|
||||
+ unresolved $test
|
||||
+ } else {
|
||||
+ fail $test
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ # Exit and detach the process.
|
||||
+
|
||||
+ gdb_exit
|
||||
+
|
||||
+ # Make sure we don't leave a process around to confuse
|
||||
+ # the next test run (and prevent the compile by keeping
|
||||
+ # the text file busy), in case the "set should_exit" didn't
|
||||
+ # work.
|
||||
+
|
||||
+ # Continue the program - some Linux kernels need it before -9 if the
|
||||
+ # process is stopped.
|
||||
+ remote_exec build "kill -s CONT ${testpid}"
|
||||
+
|
||||
+ remote_exec build "kill -9 ${testpid}"
|
||||
+}
|
||||
+
|
||||
+# build the test case first without threads
|
||||
+#
|
||||
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
||||
+ gdb_suppress_entire_file "Testcase nonthraded compile failed, so all tests in this file will automatically fail."
|
||||
+}
|
||||
+
|
||||
+corefunc nonthreaded
|
||||
+
|
||||
+# build the test case also with threads
|
||||
+#
|
||||
+if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DUSE_THREADS}] != "" } {
|
||||
+ gdb_suppress_entire_file "Testcase threaded compile failed, so all tests in this file will automatically fail."
|
||||
+}
|
||||
+
|
||||
+corefunc threaded
|
||||
diff -u -X /home/short/.diffi.list -ruNp gdb-6.5-unpatched/gdb/testsuite/gdb.threads/attach-stopped.c gdb-6.5/gdb/testsuite/gdb.threads/attach-stopped.c
|
||||
--- gdb-6.5-unpatched/gdb/testsuite/gdb.threads/attach-stopped.c 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ gdb-6.5/gdb/testsuite/gdb.threads/attach-stopped.c 2008-01-09 15:26:30.000000000 +0100
|
||||
@@ -0,0 +1,51 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2005-2007 Free Software Foundation, Inc.
|
||||
+
|
||||
+ 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 2 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, write to the Free Software
|
||||
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
+
|
||||
+/* This program is intended to be started outside of gdb, then
|
||||
+ manually stopped via a signal. */
|
||||
+
|
||||
+#include <stddef.h>
|
||||
+#include <unistd.h>
|
||||
+#ifdef USE_THREADS
|
||||
+#include <pthread.h>
|
||||
+#endif
|
||||
+
|
||||
+static void *func (void *arg)
|
||||
+{
|
||||
+ sleep (10000); /* Ridiculous time, but we will eventually kill it. */
|
||||
+ sleep (10000); /* Second sleep. */
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+int main ()
|
||||
+{
|
||||
+
|
||||
+#ifndef USE_THREADS
|
||||
+
|
||||
+ func (NULL);
|
||||
+
|
||||
+#else
|
||||
+
|
||||
+ pthread_t th;
|
||||
+ pthread_create (&th, NULL, func, NULL);
|
||||
+ pthread_join (th, NULL);
|
||||
+
|
||||
+#endif
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
diff -u -X /home/short/.diffi.list -ruNp gdb-6.5-unpatched/gdb/testsuite/gdb.threads/attach-stopped.exp gdb-6.5/gdb/testsuite/gdb.threads/attach-stopped.exp
|
||||
--- gdb-6.5-unpatched/gdb/testsuite/gdb.threads/attach-stopped.exp 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ gdb-6.5/gdb/testsuite/gdb.threads/attach-stopped.exp 2008-01-09 15:26:30.000000000 +0100
|
||||
@@ -0,0 +1,221 @@
|
||||
+# Copyright 2005-2007
|
||||
+
|
||||
+# 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 2 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, write to the Free Software
|
||||
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+# This test was created by modifying attach.exp.
|
||||
+# This file was created by Jeff Johnston <jjohnstn@redhat.com>.
|
||||
+# This file was updated by Jan Kratochvil <jan.kratochvil@redhat.com>.
|
||||
+
|
||||
+if $tracelevel then {
|
||||
+ strace $tracelevel
|
||||
+}
|
||||
+
|
||||
+set prms_id 0
|
||||
+set bug_id 0
|
||||
+
|
||||
+# This test only works on Linux
|
||||
+if { ![istarget "*-*-linux-gnu*"] } {
|
||||
+ return 0
|
||||
+}
|
||||
+
|
||||
+set testfile "attach-stopped"
|
||||
+set srcfile ${testfile}.c
|
||||
+set binfile ${objdir}/${subdir}/${testfile}
|
||||
+set escapedbinfile [string_to_regexp ${objdir}/${subdir}/${testfile}]
|
||||
+
|
||||
+#execute_anywhere "rm -f ${binfile}"
|
||||
+remote_exec build "rm -f ${binfile}"
|
||||
+# For debugging this test
|
||||
+#
|
||||
+#log_user 1
|
||||
+
|
||||
+proc corefunc { threadtype } {
|
||||
+ global srcfile
|
||||
+ global binfile
|
||||
+ global escapedbinfile
|
||||
+ global srcdir
|
||||
+ global subdir
|
||||
+ global gdb_prompt
|
||||
+
|
||||
+ if [get_compiler_info ${binfile}] {
|
||||
+ return -1
|
||||
+ }
|
||||
+
|
||||
+ # Start the program running and then wait for a bit, to be sure
|
||||
+ # that it can be attached to.
|
||||
+
|
||||
+ set testpid [eval exec $binfile &]
|
||||
+
|
||||
+ # Avoid some race:
|
||||
+ sleep 2
|
||||
+
|
||||
+ # Stop the program
|
||||
+ remote_exec build "kill -s STOP ${testpid}"
|
||||
+
|
||||
+ # Start with clean gdb
|
||||
+ gdb_exit
|
||||
+ gdb_start
|
||||
+ gdb_reinitialize_dir $srcdir/$subdir
|
||||
+ gdb_load ${binfile}
|
||||
+
|
||||
+ # Verify that we can attach to the process by first giving its
|
||||
+ # executable name via the file command, and using attach with the
|
||||
+ # process ID.
|
||||
+
|
||||
+ set test "$threadtype: set file, before attach1 to stopped process"
|
||||
+ gdb_test_multiple "file $binfile" "$test" {
|
||||
+ -re "Load new symbol table from.*y or n. $" {
|
||||
+ gdb_test "y" "Reading symbols from $escapedbinfile\.\.\.*done." \
|
||||
+ "$test (re-read)"
|
||||
+ }
|
||||
+ -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $" {
|
||||
+ pass "$test"
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ set test "$threadtype: attach1 to stopped, after setting file"
|
||||
+ gdb_test_multiple "attach $testpid" "$test" {
|
||||
+ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" {
|
||||
+ pass "$test"
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ # ".*sleep.*clone.*" would fail on s390x as bt stops at START_THREAD there.
|
||||
+ if {[string equal $threadtype threaded]} {
|
||||
+ gdb_test "thread apply all bt" ".*sleep.*start_thread.*" "$threadtype: attach1 to stopped bt"
|
||||
+ } else {
|
||||
+ gdb_test "bt" ".*sleep.*main.*" "$threadtype: attach1 to stopped bt"
|
||||
+ }
|
||||
+
|
||||
+ # Exit and detach the process.
|
||||
+
|
||||
+ gdb_exit
|
||||
+
|
||||
+ # Avoid some race:
|
||||
+ sleep 2
|
||||
+
|
||||
+ if [catch {open /proc/${testpid}/status r} fileid] {
|
||||
+ set line2 "NOTFOUND"
|
||||
+ } else {
|
||||
+ gets $fileid line1;
|
||||
+ gets $fileid line2;
|
||||
+ close $fileid;
|
||||
+ }
|
||||
+
|
||||
+ set test "$threadtype: attach1, exit leaves process stopped"
|
||||
+ if {[string match "*(stopped)*" $line2]} {
|
||||
+ pass $test
|
||||
+ } else {
|
||||
+ fail $test
|
||||
+ }
|
||||
+
|
||||
+ # At this point, the process should still be stopped
|
||||
+
|
||||
+ gdb_start
|
||||
+ gdb_reinitialize_dir $srcdir/$subdir
|
||||
+ gdb_load ${binfile}
|
||||
+
|
||||
+ # Verify that we can attach to the process just by giving the
|
||||
+ # process ID.
|
||||
+
|
||||
+ set test "$threadtype: attach2 to stopped, after setting file"
|
||||
+ gdb_test_multiple "attach $testpid" "$test" {
|
||||
+ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" {
|
||||
+ pass "$test"
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ # ".*sleep.*clone.*" would fail on s390x as bt stops at START_THREAD there.
|
||||
+ if {[string equal $threadtype threaded]} {
|
||||
+ gdb_test "thread apply all bt" ".*sleep.*start_thread.*" "$threadtype: attach2 to stopped bt"
|
||||
+ } else {
|
||||
+ gdb_test "bt" ".*sleep.*main.*" "$threadtype: attach2 to stopped bt"
|
||||
+ }
|
||||
+ gdb_breakpoint [gdb_get_line_number "$threadtype: Second sleep"]
|
||||
+ set test "$threadtype: attach2 continue"
|
||||
+ send_gdb "continue\n"
|
||||
+ gdb_expect {
|
||||
+ -re "Continuing"
|
||||
+ { pass "continue ($test)" }
|
||||
+ timeout
|
||||
+ { fail "continue ($test) (timeout)" }
|
||||
+ }
|
||||
+
|
||||
+ # For this to work we must be sure to consume the "Continuing."
|
||||
+ # message first, or GDB's signal handler may not be in place.
|
||||
+ after 1000 {send_gdb "\003"}
|
||||
+ set test "$threadtype: attach2 stop interrupt"
|
||||
+ gdb_expect 10 {
|
||||
+ -re "Program received signal SIGINT.*$gdb_prompt $"
|
||||
+ {
|
||||
+ pass $test
|
||||
+ }
|
||||
+ -re "Breakpoint \[0-9\].*$srcfile.*$gdb_prompt $"
|
||||
+ {
|
||||
+ pass $test
|
||||
+ }
|
||||
+ timeout
|
||||
+ {
|
||||
+ fail $test
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ gdb_exit
|
||||
+
|
||||
+ # Avoid some race:
|
||||
+ sleep 2
|
||||
+
|
||||
+ # At this point, the process should be sleeping
|
||||
+
|
||||
+ if [catch {open /proc/${testpid}/status r} fileid2] {
|
||||
+ set line2 "NOTFOUND"
|
||||
+ } else {
|
||||
+ gets $fileid2 line1;
|
||||
+ gets $fileid2 line2;
|
||||
+ close $fileid2;
|
||||
+ }
|
||||
+
|
||||
+ set test "$threadtype: attach2, exit leaves process sleeping"
|
||||
+ if {[string match "*(sleeping)*" $line2]} {
|
||||
+ pass $test
|
||||
+ } else {
|
||||
+ fail $test
|
||||
+ }
|
||||
+
|
||||
+ # Make sure we don't leave a process around to confuse
|
||||
+ # the next test run (and prevent the compile by keeping
|
||||
+ # the text file busy), in case the "set should_exit" didn't
|
||||
+ # work.
|
||||
+
|
||||
+ remote_exec build "kill -9 ${testpid}"
|
||||
+}
|
||||
+
|
||||
+# build the test case first without threads
|
||||
+#
|
||||
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
||||
+ gdb_suppress_entire_file "Testcase nonthraded compile failed, so all tests in this file will automatically fail."
|
||||
+}
|
||||
+
|
||||
+corefunc nonthreaded
|
||||
+
|
||||
+# build the test case first without threads
|
||||
+#
|
||||
+if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DUSE_THREADS}] != "" } {
|
||||
+ gdb_suppress_entire_file "Testcase threaded compile failed, so all tests in this file will automatically fail."
|
||||
+}
|
||||
+
|
||||
+corefunc threaded
|
||||
+
|
||||
+return 0
|
||||
diff -u -X /home/short/.diffi.list -ruNp gdb-6.5-unpatched/gdb/testsuite/gdb.threads/attachstop-mt.c gdb-6.5/gdb/testsuite/gdb.threads/attachstop-mt.c
|
||||
--- gdb-6.5-unpatched/gdb/testsuite/gdb.threads/attachstop-mt.c 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ gdb-6.5/gdb/testsuite/gdb.threads/attachstop-mt.c 2008-01-09 15:26:29.000000000 +0100
|
||||
@@ -0,0 +1,56 @@
|
||||
+/* This testcase is part of GDB, the GNU debugger.
|
||||
+
|
||||
+ Copyright 2005 Free Software Foundation, Inc.
|
||||
+
|
||||
+ 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 2 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, write to the Free Software
|
||||
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
+
|
||||
+/* This program is intended to be started outside of gdb, then
|
||||
+ manually stopped via a signal. */
|
||||
+
|
||||
+#include <unistd.h>
|
||||
+#include <pthread.h>
|
||||
+#include <stdio.h>
|
||||
+
|
||||
+/* Red Hat BZ PR 197584.c */
|
||||
+
|
||||
+void *func (void *arg)
|
||||
+{
|
||||
+ sleep (10000); /* Ridiculous time, but we will eventually kill it. */
|
||||
+ sleep (10000); /* RHEL3U8 kernel-2.4.21-47.EL will cut the sleep time. */
|
||||
+
|
||||
+ return NULL; /* thread-sleep */
|
||||
+}
|
||||
+
|
||||
+int main ()
|
||||
+{
|
||||
+ pthread_t t1,t2;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = pthread_create (&t1, NULL, func, NULL);
|
||||
+ if (ret)
|
||||
+ fprintf(stderr, "pthread_create(): %s", strerror (ret));
|
||||
+ ret = pthread_create (&t2, NULL, func, NULL);
|
||||
+ if (ret)
|
||||
+ fprintf(stderr, "pthread_create(): %s", strerror (ret));
|
||||
+
|
||||
+ ret = pthread_join (t1, NULL);
|
||||
+ if (ret) /* first-join */
|
||||
+ fprintf(stderr, "pthread_join(): %s", strerror (ret));
|
||||
+ ret = pthread_join (t2, NULL);
|
||||
+ if (ret)
|
||||
+ fprintf(stderr, "pthread_join(): %s", strerror (ret));
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
diff -u -X /home/short/.diffi.list -ruNp gdb-6.5-unpatched/gdb/testsuite/gdb.threads/attachstop-mt.exp gdb-6.5/gdb/testsuite/gdb.threads/attachstop-mt.exp
|
||||
--- gdb-6.5-unpatched/gdb/testsuite/gdb.threads/attachstop-mt.exp 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ gdb-6.5/gdb/testsuite/gdb.threads/attachstop-mt.exp 2008-01-09 18:13:49.000000000 +0100
|
||||
@@ -0,0 +1,278 @@
|
||||
+# Copyright 2006
|
||||
+
|
||||
+# 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 2 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, write to the Free Software
|
||||
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
+
|
||||
+# This test was created by modifying gdb.threads/attachstop.
|
||||
+# This file was created by Jan Kratochvil <jan.kratochvil@redhat.com>.
|
||||
+# Regression for: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=197584
|
||||
+
|
||||
+if $tracelevel then {
|
||||
+ strace $tracelevel
|
||||
+}
|
||||
+
|
||||
+set prms_id 0
|
||||
+set bug_id 0
|
||||
+
|
||||
+# This test only works on Linux
|
||||
+if { ![istarget "*-*-linux-gnu*"] } {
|
||||
+ return 0
|
||||
+}
|
||||
+
|
||||
+set testfile "attachstop-mt"
|
||||
+set srcfile ${testfile}.c
|
||||
+set binfile ${objdir}/${subdir}/${testfile}
|
||||
+set escapedbinfile [string_to_regexp ${objdir}/${subdir}/${testfile}]
|
||||
+
|
||||
+#execute_anywhere "rm -f ${binfile}"
|
||||
+remote_exec build "rm -f ${binfile}"
|
||||
+# For debugging this test
|
||||
+#
|
||||
+#log_user 1
|
||||
+
|
||||
+# build the test case
|
||||
+#
|
||||
+if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
|
||||
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
||||
+}
|
||||
+
|
||||
+if [get_compiler_info ${binfile}] {
|
||||
+ return -1
|
||||
+}
|
||||
+
|
||||
+# Start the program running and then wait for a bit, to be sure
|
||||
+# that it can be attached to.
|
||||
+
|
||||
+set testpid [eval exec $binfile &]
|
||||
+
|
||||
+# No race
|
||||
+sleep 2
|
||||
+
|
||||
+# Do not: set testpid2 [expr $testpid + 1]
|
||||
+# as it will not exist on Red Hat 2.6.9-34.0.2.ELsmp
|
||||
+set testpid2 [expr $testpid + 2]
|
||||
+
|
||||
+set status2 /proc/${testpid}/task/${testpid2}/status
|
||||
+if {[expr ! [file exists $status2]]} {
|
||||
+ # kernel-2.4
|
||||
+ set status2 /proc/${testpid2}/status
|
||||
+}
|
||||
+
|
||||
+# Initial sanity test it is normally sleeping
|
||||
+set fileid0 [open $status2 r];
|
||||
+gets $fileid0 line1;
|
||||
+gets $fileid0 line2;
|
||||
+close $fileid0;
|
||||
+
|
||||
+set test "attach0, initial sanity check of the sleeping state"
|
||||
+if {[string match "*(sleeping)*" $line2]} {
|
||||
+ pass $test
|
||||
+} else {
|
||||
+ fail $test
|
||||
+}
|
||||
+
|
||||
+# Sttach and detach to test it will not become stopped
|
||||
+gdb_start
|
||||
+gdb_reinitialize_dir $srcdir/$subdir
|
||||
+gdb_load ${binfile}
|
||||
+
|
||||
+set test "attach0 to sleeping"
|
||||
+gdb_test_multiple "attach $testpid" "$test" {
|
||||
+ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" {
|
||||
+ pass "$test"
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+gdb_test "gcore /dev/null" ".*aved corefile.*" "attach0 to sleeping gcore invocation"
|
||||
+
|
||||
+gdb_test "thread 2" ".*witching to thread 2 .*" "attach0 to sleeping switch thread"
|
||||
+
|
||||
+gdb_test "bt" ".*sleep.*func.*" "attach0 to sleeping bt"
|
||||
+
|
||||
+# Exit and detach the process.
|
||||
+
|
||||
+gdb_exit
|
||||
+
|
||||
+# No race
|
||||
+sleep 2
|
||||
+
|
||||
+# Check it did not get stopped by our gdb
|
||||
+set fileid1 [open $status2 r];
|
||||
+gets $fileid1 line1;
|
||||
+gets $fileid1 line2;
|
||||
+close $fileid1;
|
||||
+
|
||||
+set test "attach1, post-gdb sanity check of the sleeping state - Red Hat BZ 197584"
|
||||
+if {[string match "*(sleeping)*" $line2]} {
|
||||
+ pass $test
|
||||
+} else {
|
||||
+ fail $test
|
||||
+}
|
||||
+
|
||||
+# Stop the program
|
||||
+remote_exec build "kill -s STOP ${testpid}"
|
||||
+
|
||||
+# No race
|
||||
+sleep 2
|
||||
+
|
||||
+# Check it really got stopped by kill(1)
|
||||
+set fileid2 [open $status2 r];
|
||||
+gets $fileid2 line1;
|
||||
+gets $fileid2 line2;
|
||||
+close $fileid2;
|
||||
+
|
||||
+set test "attach2, initial sanity check of the stopped state"
|
||||
+if {[string match "*(stopped)*" $line2]} {
|
||||
+ pass $test
|
||||
+} else {
|
||||
+ fail $test
|
||||
+}
|
||||
+
|
||||
+# Start with clean gdb
|
||||
+gdb_start
|
||||
+gdb_reinitialize_dir $srcdir/$subdir
|
||||
+gdb_load ${binfile}
|
||||
+
|
||||
+# Verify that we can attach to the process by first giving its
|
||||
+# executable name via the file command, and using attach with the
|
||||
+# process ID.
|
||||
+
|
||||
+set test "set file, before attach3 to stopped process"
|
||||
+gdb_test_multiple "file $binfile" "$test" {
|
||||
+ -re "Load new symbol table from.*y or n. $" {
|
||||
+ gdb_test "y" "Reading symbols from $escapedbinfile\.\.\.*done." \
|
||||
+ "$test (re-read)"
|
||||
+ }
|
||||
+ -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $" {
|
||||
+ pass "$test"
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+set test "attach3 to stopped, after setting file"
|
||||
+gdb_test_multiple "attach $testpid" "$test" {
|
||||
+ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" {
|
||||
+ pass "$test"
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+# We may be already after the threads phase.
|
||||
+# `thread 2' command is important for the test to switch the current thread to
|
||||
+# a non-primary one for the detach process.
|
||||
+
|
||||
+gdb_test "thread 2" ".*(witching to thread 2 |hread ID 2 not known).*" "attach3 to stopped switch thread"
|
||||
+gdb_test "bt" ".*sleep.*(func|main).*" "attach3 to stopped bt"
|
||||
+
|
||||
+# Exit and detach the process.
|
||||
+gdb_exit
|
||||
+
|
||||
+# No race
|
||||
+sleep 2
|
||||
+
|
||||
+set fileid3 [open $status2 r];
|
||||
+gets $fileid3 line1;
|
||||
+gets $fileid3 line2;
|
||||
+close $fileid3;
|
||||
+
|
||||
+set test "attach3, exit leaves process stopped"
|
||||
+if {[string match "*(stopped)*" $line2]} {
|
||||
+ pass $test
|
||||
+} else {
|
||||
+ fail $test
|
||||
+}
|
||||
+
|
||||
+# At this point, the process should still be stopped
|
||||
+
|
||||
+# Continue the test as we would hit another expected bug regarding
|
||||
+# Program received signal SIGSTOP, Stopped (signal).
|
||||
+# across NPTL threads.
|
||||
+
|
||||
+gdb_start
|
||||
+gdb_reinitialize_dir $srcdir/$subdir
|
||||
+gdb_load ${binfile}
|
||||
+
|
||||
+# Verify that we can attach to the process just by giving the
|
||||
+# process ID.
|
||||
+
|
||||
+set test "attach4 to stopped, after setting file"
|
||||
+gdb_test_multiple "attach $testpid" "$test" {
|
||||
+ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" {
|
||||
+ pass "$test"
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+# We may be already after the threads phase.
|
||||
+# `thread 2' command is important for the test to switch the current thread to
|
||||
+# a non-primary one for the detach process.
|
||||
+
|
||||
+gdb_test "thread 2" ".*(witching to thread 2 |hread ID 2 not known).*" "attach4 to stopped switch thread"
|
||||
+gdb_test "bt" ".*sleep.*(func|main).*" "attach4 to stopped bt"
|
||||
+
|
||||
+# RHEL3U8 kernel-2.4.21-47.EL will not return SIGINT but only shorten the sleep.
|
||||
+gdb_breakpoint [gdb_get_line_number "Ridiculous time"]
|
||||
+gdb_breakpoint [gdb_get_line_number "cut the sleep time"]
|
||||
+set test "attach4 continue"
|
||||
+send_gdb "continue\n"
|
||||
+gdb_expect {
|
||||
+ -re "Continuing"
|
||||
+ { pass "continue ($test)" }
|
||||
+ timeout
|
||||
+ { fail "continue ($test) (timeout)" }
|
||||
+}
|
||||
+
|
||||
+# For this to work we must be sure to consume the "Continuing."
|
||||
+# message first, or GDB's signal handler may not be in place.
|
||||
+after 1000 {send_gdb "\003"}
|
||||
+set test "attach4 stop by interrupt"
|
||||
+gdb_expect {
|
||||
+ -re "Program received signal SIGINT.*$gdb_prompt $"
|
||||
+ {
|
||||
+ pass $test
|
||||
+ }
|
||||
+ -re "Breakpoint \[0-9\].*$srcfile.*$gdb_prompt $"
|
||||
+ {
|
||||
+ pass $test
|
||||
+ }
|
||||
+ timeout
|
||||
+ {
|
||||
+ fail "$test (timeout)"
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+gdb_exit
|
||||
+
|
||||
+# No race
|
||||
+sleep 2
|
||||
+
|
||||
+# At this point, the process should be sleeping
|
||||
+
|
||||
+set fileid4 [open $status2 r];
|
||||
+gets $fileid4 line1;
|
||||
+gets $fileid4 line2;
|
||||
+close $fileid4;
|
||||
+
|
||||
+set test "attach4, exit leaves process sleeping"
|
||||
+if {[string match "*(sleeping)*" $line2]} {
|
||||
+ pass $test
|
||||
+} else {
|
||||
+ fail $test
|
||||
+}
|
||||
+
|
||||
+# Make sure we don't leave a process around to confuse
|
||||
+# the next test run (and prevent the compile by keeping
|
||||
+# the text file busy), in case the "set should_exit" didn't
|
||||
+# work.
|
||||
+
|
||||
+remote_exec build "kill -9 ${testpid}"
|
||||
+
|
||||
+return 0
|
26
gdb.spec
26
gdb.spec
@ -11,7 +11,7 @@ Name: gdb
|
||||
Version: 6.7.1
|
||||
|
||||
# The release always contains a leading reserved number, start it at 1.
|
||||
Release: 7%{?dist}
|
||||
Release: 8%{?dist}
|
||||
|
||||
License: GPL
|
||||
Group: Development/Debuggers
|
||||
@ -287,7 +287,8 @@ Patch254: gdb-6.6-testsuite-timeouts.patch
|
||||
|
||||
# Fix attaching to stopped processes (BZ 219118, 233852).
|
||||
# Fix attaching during a pending signal being delivered.
|
||||
Patch256: gdb-6.6-bz233852-attach-signalled.patch
|
||||
Patch256: gdb-6.7-bz233852-attach-signalled-fix.patch
|
||||
Patch275: gdb-6.7-bz233852-attach-signalled-test.patch
|
||||
|
||||
# Support for stepping over PPC atomic instruction sequences (BZ 237572).
|
||||
Patch258: gdb-6.6-bz237572-ppc-atomic-sequence-test.patch
|
||||
@ -329,10 +330,16 @@ Patch284: gdb-6.7-ppc-clobbered-registers-O2-test.patch
|
||||
# Testsuite fixes for more stable/comparable results.
|
||||
Patch287: gdb-6.7-testsuite-stable-results.patch
|
||||
|
||||
# Test ia64 memory leaks of the code using libunwind.
|
||||
Patch289: gdb-6.5-ia64-libunwind-leak-test.patch
|
||||
|
||||
# Support DW_TAG_interface_type the same way as DW_TAG_class_type (BZ 426600).
|
||||
Patch293: gdb-6.7-bz426600-DW_TAG_interface_type-fix.patch
|
||||
Patch294: gdb-6.7-bz426600-DW_TAG_interface_type-test.patch
|
||||
|
||||
# Test gcore memory and time requirements for large inferiors.
|
||||
Patch296: gdb-6.5-gcore-buffer-limit-test.patch
|
||||
|
||||
BuildRequires: ncurses-devel glibc-devel gcc make gzip texinfo dejagnu gettext
|
||||
BuildRequires: flex bison sharutils expat-devel
|
||||
Requires: readline
|
||||
@ -471,6 +478,7 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
|
||||
%patch265 -p1
|
||||
%patch266 -p1
|
||||
%patch274 -p1
|
||||
%patch275 -p1
|
||||
%patch276 -p1
|
||||
%patch277 -p1
|
||||
%patch278 -p1
|
||||
@ -479,8 +487,10 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc-exp.c gdb/p-exp.c
|
||||
%patch283 -p1
|
||||
%patch284 -p1
|
||||
%patch287 -p1
|
||||
%patch289 -p1
|
||||
%patch293 -p1
|
||||
%patch294 -p1
|
||||
%patch296 -p1
|
||||
|
||||
# Change the version that gets printed at GDB startup, so it is RedHat
|
||||
# specific.
|
||||
@ -560,13 +570,12 @@ gcc -o ./orphanripper %{SOURCE2} -Wall -lutil
|
||||
# "threadcrash.exp" is incompatible on ia64 with old kernels.
|
||||
# No `%{?_smp_mflags}' here as it may race.
|
||||
# WARNING: can't generate a core file - core tests suppressed - check ulimit
|
||||
# "attachstop.exp" - Functionality is currently broken but timeout is long.
|
||||
# "readline-overflow.exp" - Testcase is broken, functionality is OK.
|
||||
(
|
||||
# ULIMIT required for `gdb.base/auxv.exp'.
|
||||
ulimit -H -c
|
||||
ulimit -c unlimited || :
|
||||
./orphanripper make -k check RUNTESTFLAGS='--ignore "bigcore.exp chng-syms.exp checkpoint.exp threadcrash.exp attachstop.exp readline-overflow.exp"' || :
|
||||
./orphanripper make -k check RUNTESTFLAGS='--ignore "bigcore.exp chng-syms.exp checkpoint.exp threadcrash.exp readline-overflow.exp"' || :
|
||||
)
|
||||
for t in sum log; do
|
||||
ln gdb.$t gdb-%{_target_platform}.$t || :
|
||||
@ -639,6 +648,15 @@ fi
|
||||
# don't include the files in include, they are part of binutils
|
||||
|
||||
%changelog
|
||||
* Thu Jan 10 2008 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.7.1-8
|
||||
- Fix detaching from a threaded formerly stopped process with non-primary
|
||||
thread currently active (general BZ 233852).
|
||||
- Enable back again the testcases named `attachstop.exp' (no such exist now).
|
||||
- Rename the testcase `gdb.threads/attachstop' to `gdb.threads/attachstop-mt'.
|
||||
- Test ia64 memory leaks of the code using libunwind.
|
||||
- Testcase delay increase (for BZ 247354).
|
||||
- Test gcore memory and time requirements for large inferiors.
|
||||
|
||||
* Mon Jan 7 2008 Jan Kratochvil <jan.kratochvil@redhat.com> - 6.7.1-7
|
||||
- Backport the gcc-4.3 compatibility -Werror fixes.
|
||||
- Fix documentation on hardware watchpoints wrt multiple threads.
|
||||
|
Loading…
Reference in New Issue
Block a user