]> git.pld-linux.org Git - packages/gdb.git/blame - gdb-6.8-attach-signalled-detach-stopped.patch
- update to 6.8.91.20090930-1 from fedora
[packages/gdb.git] / gdb-6.8-attach-signalled-detach-stopped.patch
CommitLineData
7566401a 1Index: gdb-6.8.50.20090803/gdb/linux-nat.c
3a58abaf 2===================================================================
7566401a
ER
3--- gdb-6.8.50.20090803.orig/gdb/linux-nat.c 2009-08-03 17:24:03.000000000 +0200
4+++ gdb-6.8.50.20090803/gdb/linux-nat.c 2009-08-03 17:27:23.000000000 +0200
5@@ -202,6 +202,9 @@ blocked. */
3a58abaf
AM
6 static struct target_ops *linux_ops;
7 static struct target_ops linux_ops_saved;
8
9+/* PID of the inferior stopped by SIGSTOP before attaching (or zero). */
10+static pid_t pid_was_stopped;
11+
12 /* The method to call, if any, when a new thread is attached. */
13 static void (*linux_nat_new_thread) (ptid_t);
14
7566401a
ER
15@@ -790,7 +793,14 @@ linux_child_follow_fork (struct target_o
16 linux_parent_pid = parent_pid;
3a58abaf 17 }
7566401a 18 else if (detach_fork)
3a58abaf
AM
19- target_detach (NULL, 0);
20+ {
21+ /* We should check PID_WAS_STOPPED and detach it stopped accordingly.
22+ In this point of code it cannot be 1 as we would not get FORK
23+ executed without CONTINUE first which resets PID_WAS_STOPPED.
24+ We would have to first TARGET_STOP and WAITPID it as with running
25+ inferior PTRACE_DETACH, SIGSTOP will ignore the signal. */
26+ target_detach (NULL, 0);
27+ }
28
29 inferior_ptid = ptid_build (child_pid, child_pid, 0);
7566401a
ER
30 add_thread (inferior_ptid);
31@@ -1231,6 +1241,7 @@ linux_nat_post_attach_wait (ptid_t ptid,
3a58abaf
AM
32 if (debug_linux_nat)
33 fprintf_unfiltered (gdb_stdlog,
34 "LNPAW: Attaching to a stopped process\n");
35+ pid_was_stopped = GET_PID (ptid);
36
37 /* The process is definitely stopped. It is in a job control
38 stop, unless the kernel predates the TASK_STOPPED /
7566401a 39@@ -1512,6 +1523,9 @@ GPT: lwp %s had signal %s, but it is in
3a58abaf
AM
40 *status = lp->status;
41 }
42
43+ if (*status == 0 && GET_PID (lp->ptid) == pid_was_stopped)
44+ *status = W_STOPCODE (SIGSTOP);
45+
46 return 0;
47 }
48
7566401a 49@@ -1621,6 +1635,8 @@ linux_nat_detach (struct target_ops *ops
3a58abaf
AM
50 }
51 else
52 linux_ops->to_detach (ops, args, from_tty);
53+
54+ pid_was_stopped = 0;
55 }
56
57 /* Resume LP. */
7566401a 58@@ -1774,6 +1790,14 @@ linux_nat_resume (struct target_ops *ops
3a58abaf
AM
59 resume_callback. */
60 lp->stopped = 0;
61
62+ /* At this point, we are going to resume the inferior and if we
63+ have attached to a stopped process, we no longer should leave
64+ it as stopped if the user detaches. PTID variable has PID set to LWP
65+ while we need to check the real PID here. */
66+
67+ if (!step && lp && pid_was_stopped == GET_PID (lp->ptid))
68+ pid_was_stopped = 0;
69+
7566401a
ER
70 if (resume_many)
71 iterate_over_lwps (ptid, resume_callback, NULL);
3a58abaf 72
7566401a 73@@ -3322,6 +3346,8 @@ linux_nat_mourn_inferior (struct target_
3a58abaf
AM
74 there are other viable forks to debug. Delete the exiting
75 one and context-switch to the first available. */
76 linux_fork_mourn_inferior ();
77+
78+ pid_was_stopped = 0;
79 }
80
81 /* Convert a native/host siginfo object, into/from the siginfo in the
7566401a 82Index: gdb-6.8.50.20090803/gdb/testsuite/gdb.threads/attach-stopped.exp
3a58abaf 83===================================================================
7566401a
ER
84--- gdb-6.8.50.20090803.orig/gdb/testsuite/gdb.threads/attach-stopped.exp 2009-01-03 06:58:07.000000000 +0100
85+++ gdb-6.8.50.20090803/gdb/testsuite/gdb.threads/attach-stopped.exp 2009-08-03 17:26:22.000000000 +0200
3a58abaf
AM
86@@ -62,7 +62,65 @@ proc corefunc { threadtype } {
87 gdb_reinitialize_dir $srcdir/$subdir
88 gdb_load ${binfile}
89
90- # Verify that we can attach to the stopped process.
91+ # Verify that we can attach to the process by first giving its
92+ # executable name via the file command, and using attach with the
93+ # process ID.
94+
95+ set test "$threadtype: set file, before attach1 to stopped process"
96+ gdb_test_multiple "file $binfile" "$test" {
97+ -re "Load new symbol table from.*y or n. $" {
98+ gdb_test "y" "Reading symbols from $escapedbinfile\.\.\.*done." \
99+ "$test (re-read)"
100+ }
101+ -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $" {
102+ pass "$test"
103+ }
104+ }
105+
106+ set test "$threadtype: attach1 to stopped, after setting file"
107+ gdb_test_multiple "attach $testpid" "$test" {
108+ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" {
109+ pass "$test"
110+ }
111+ }
112+
113+ # ".*sleep.*clone.*" would fail on s390x as bt stops at START_THREAD there.
114+ if {[string equal $threadtype threaded]} {
115+ gdb_test "thread apply all bt" ".*sleep.*start_thread.*" "$threadtype: attach1 to stopped bt"
116+ } else {
117+ gdb_test "bt" ".*sleep.*main.*" "$threadtype: attach1 to stopped bt"
118+ }
119+
120+ # Exit and detach the process.
121+
122+ gdb_exit
123+
124+ # Avoid some race:
125+ sleep 2
126+
127+ if [catch {open /proc/${testpid}/status r} fileid] {
128+ set line2 "NOTFOUND"
129+ } else {
130+ gets $fileid line1;
131+ gets $fileid line2;
132+ close $fileid;
133+ }
134+
135+ set test "$threadtype: attach1, exit leaves process stopped"
136+ if {[string match "*(stopped)*" $line2]} {
137+ pass $test
138+ } else {
139+ fail $test
140+ }
141+
142+ # At this point, the process should still be stopped
143+
144+ gdb_start
145+ gdb_reinitialize_dir $srcdir/$subdir
146+ gdb_load ${binfile}
147+
148+ # Verify that we can attach to the process just by giving the
149+ # process ID.
150
151 set test "$threadtype: attach2 to stopped, after setting file"
152 gdb_test_multiple "attach $testpid" "$test" {
7566401a 153Index: gdb-6.8.50.20090803/gdb/testsuite/gdb.threads/attachstop-mt.exp
3a58abaf 154===================================================================
7566401a
ER
155--- gdb-6.8.50.20090803.orig/gdb/testsuite/gdb.threads/attachstop-mt.exp 2009-01-03 06:58:07.000000000 +0100
156+++ gdb-6.8.50.20090803/gdb/testsuite/gdb.threads/attachstop-mt.exp 2009-08-03 17:26:22.000000000 +0200
3a58abaf
AM
157@@ -176,12 +176,23 @@ gdb_test "bt" ".*sleep.*(func|main).*" "
158 # Exit and detach the process.
159 gdb_exit
160
161-# Stop the program
162-remote_exec build "kill -s STOP ${testpid}"
163-
164 # No race
165 sleep 2
166
167+set fileid3 [open $status2 r];
168+gets $fileid3 line1;
169+gets $fileid3 line2;
170+close $fileid3;
171+
172+set test "attach3, exit leaves process stopped"
173+if {[string match "*(stopped)*" $line2]} {
174+ pass $test
175+} else {
176+ fail $test
177+}
178+
179+# At this point, the process should still be stopped
180+
181 # Continue the test as we would hit another expected bug regarding
182 # Program received signal SIGSTOP, Stopped (signal).
183 # across NPTL threads.
This page took 0.048906 seconds and 4 git commands to generate.