* [PATCH RFA] lin-lwp.c: Mark main thread as stopped when attaching
@ 2001-11-07 16:06 Kevin Buettner
2001-11-08 13:04 ` Mark Kettenis
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Buettner @ 2001-11-07 16:06 UTC (permalink / raw)
To: gdb-patches
The patch below marks the main pid as stopped when attaching. If it
is not marked as such, then it is not (re)started when continuing if
the user first changes the current thread.
The practical effects of this problem may be demonstrated on a
Linux/x86 sytem as follows:
1) Start the linux-dp program and make note of the process id of the
main thread.
2) Debug the linux-dp program and attach to PID representing the
main thread.
3) Do ``info threads'' and pick out a thread other than the main
one.
4) Use GDB's ``thread'' command to switch to this thread.
5) Continue the program.
6) Attempt to interrupt the program with Ctrl-C. It will be impossible
to do so. (Examining the threads from another shell with the
``ps'' command is also instructive at this stage.)
Jim Blandy deserves credit for arriving at the above procedure for
reproducing this problem.
The patch below fixes this bug. Okay to commit?
* lin-lwp.c (lin_lwp_attach_lwp): Mark main thread as stopped.
Index: lin-lwp.c
===================================================================
RCS file: /cvs/src/src/gdb/lin-lwp.c,v
retrieving revision 1.30
diff -u -p -r1.30 lin-lwp.c
--- lin-lwp.c 2001/10/14 11:30:37 1.30
+++ lin-lwp.c 2001/11/19 19:08:10
@@ -381,6 +389,12 @@ lin_lwp_attach_lwp (ptid_t ptid, int ver
gdb_assert (pid == GET_LWP (ptid)
&& WIFSTOPPED (status) && WSTOPSIG (status));
+ lp->stopped = 1;
+ }
+ else
+ {
+ /* Mark original process (i.e. the one whose LWP id is equal to
+ the overall process id) as stopped too. */
lp->stopped = 1;
}
}
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH RFA] lin-lwp.c: Mark main thread as stopped when attaching
2001-11-07 16:06 [PATCH RFA] lin-lwp.c: Mark main thread as stopped when attaching Kevin Buettner
@ 2001-11-08 13:04 ` Mark Kettenis
2001-11-08 19:30 ` Kevin Buettner
0 siblings, 1 reply; 3+ messages in thread
From: Mark Kettenis @ 2001-11-08 13:04 UTC (permalink / raw)
To: Kevin Buettner; +Cc: gdb-patches
Kevin Buettner <kevinb@cygnus.com> writes:
> The patch below marks the main pid as stopped when attaching. If it
> is not marked as such, then it is not (re)started when continuing if
> the user first changes the current thread.
>
> The practical effects of this problem may be demonstrated on a
> Linux/x86 sytem as follows:
>
> 1) Start the linux-dp program and make note of the process id of the
> main thread.
> 2) Debug the linux-dp program and attach to PID representing the
> main thread.
> 3) Do ``info threads'' and pick out a thread other than the main
> one.
> 4) Use GDB's ``thread'' command to switch to this thread.
> 5) Continue the program.
> 6) Attempt to interrupt the program with Ctrl-C. It will be impossible
> to do so. (Examining the threads from another shell with the
> ``ps'' command is also instructive at this stage.)
Ah yes, the initial attach doesn't go through the lin_lwp layer. When
the libthreads_db stuff is detected and lin_lwp_attach_lwp is called
for all threads the main thread isn't marked as stopped.
> Jim Blandy deserves credit for arriving at the above procedure for
> reproducing this problem.
>
> The patch below fixes this bug. Okay to commit?
Could you change the comment to say that we *assume* that the thread is
stopped and therefore mark it as such? Otherwise OK.
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RFA] lin-lwp.c: Mark main thread as stopped when attaching
2001-11-08 13:04 ` Mark Kettenis
@ 2001-11-08 19:30 ` Kevin Buettner
0 siblings, 0 replies; 3+ messages in thread
From: Kevin Buettner @ 2001-11-08 19:30 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
On Nov 21, 1:07pm, Mark Kettenis wrote:
> Could you change the comment to say that we *assume* that the thread is
> stopped and therefore mark it as such? Otherwise OK.
Committed.
I changed the comment to read as follows:
/* We assume that the LWP representing the original process
is already stopped. Mark it as stopped in the data structure
that the lin-lwp 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. */
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-11-21 22:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-07 16:06 [PATCH RFA] lin-lwp.c: Mark main thread as stopped when attaching Kevin Buettner
2001-11-08 13:04 ` Mark Kettenis
2001-11-08 19:30 ` Kevin Buettner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox