* RFA[threads]: Fork event updates, part the thirteenth
@ 2002-12-15 13:43 Daniel Jacobowitz
2003-01-06 23:54 ` Michael Snyder
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2002-12-15 13:43 UTC (permalink / raw)
To: gdb-patches; +Cc: msnyder, kettenis
Now is where it starts to get interesting. Michael, I mentioned this patch
to you at lunch last week. If you take a short-lived program, run it, and
detach it, and run it again, you'll see the exit of the _previous_ copy.
Then GDB gets hopelessly confused. I have a testcase for this which I'll
post in a moment.
The reason it's included here is that that's essentially what happens if you
are using "set follow-fork-mode child". We detach from the parent, which
exits, confusing GDB.
Is this OK?
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
2002-12-15 Daniel Jacobowitz <drow@mvista.com>
* lin-lwp.c (child_wait): Ignore exit statuses for processes other
than inferior_ptid.
(lin_lwp_wait): Ignore exit statuses for unknown LWPs.
Index: lin-lwp.c
===================================================================
RCS file: /cvs/src/src/gdb/lin-lwp.c,v
retrieving revision 1.39
diff -u -p -r1.39 lin-lwp.c
--- lin-lwp.c 9 Dec 2002 18:41:42 -0000 1.39
+++ lin-lwp.c 15 Dec 2002 21:16:34 -0000
@@ -964,6 +964,14 @@ child_wait (ptid_t ptid, struct target_w
pid = waitpid (GET_PID (ptid), &status, __WCLONE);
save_errno = errno;
+ /* Make sure we don't report an event for the exit of the
+ original program, if we've detached from it. */
+ if (pid != -1 && ! WIFSTOPPED (status) && pid != GET_PID (inferior_ptid))
+ {
+ pid = -1;
+ save_errno = EINTR;
+ }
+
clear_sigio_trap ();
clear_sigint_trap ();
}
@@ -1091,6 +1099,17 @@ lin_lwp_wait (ptid_t ptid, struct target
gdb_assert (pid == -1 || lwpid == pid);
lp = find_lwp_pid (pid_to_ptid (lwpid));
+
+ /* Make sure we don't report an event for the exit of an LWP not in
+ our list, i.e. not part of the current process. This can happen
+ if we detach from a program we original forked and then it
+ exits. */
+ if (! WIFSTOPPED (status) && ! lp)
+ {
+ status = 0;
+ continue;
+ }
+
if (! lp)
{
lp = add_lwp (BUILD_LWP (lwpid, GET_PID (inferior_ptid)));
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFA[threads]: Fork event updates, part the thirteenth
2002-12-15 13:43 RFA[threads]: Fork event updates, part the thirteenth Daniel Jacobowitz
@ 2003-01-06 23:54 ` Michael Snyder
2003-01-07 0:50 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Michael Snyder @ 2003-01-06 23:54 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches, kettenis
Daniel Jacobowitz wrote:
>
> Now is where it starts to get interesting. Michael, I mentioned this patch
> to you at lunch last week. If you take a short-lived program, run it, and
> detach it, and run it again, you'll see the exit of the _previous_ copy.
> Then GDB gets hopelessly confused. I have a testcase for this which I'll
> post in a moment.
>
> The reason it's included here is that that's essentially what happens if you
> are using "set follow-fork-mode child". We detach from the parent, which
> exits, confusing GDB.
>
> Is this OK?
Hi Dan,
Please excuse the delay. This seems OK. In child_wait,
would it be possible to add a check to see if the exiting
process is in our lwp list?
Michael
>
> --
> Daniel Jacobowitz
> MontaVista Software Debian GNU/Linux Developer
>
> 2002-12-15 Daniel Jacobowitz <drow@mvista.com>
>
> * lin-lwp.c (child_wait): Ignore exit statuses for processes other
> than inferior_ptid.
> (lin_lwp_wait): Ignore exit statuses for unknown LWPs.
>
> Index: lin-lwp.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/lin-lwp.c,v
> retrieving revision 1.39
> diff -u -p -r1.39 lin-lwp.c
> --- lin-lwp.c 9 Dec 2002 18:41:42 -0000 1.39
> +++ lin-lwp.c 15 Dec 2002 21:16:34 -0000
> @@ -964,6 +964,14 @@ child_wait (ptid_t ptid, struct target_w
> pid = waitpid (GET_PID (ptid), &status, __WCLONE);
> save_errno = errno;
>
> + /* Make sure we don't report an event for the exit of the
> + original program, if we've detached from it. */
> + if (pid != -1 && ! WIFSTOPPED (status) && pid != GET_PID (inferior_ptid))
> + {
> + pid = -1;
> + save_errno = EINTR;
> + }
> +
> clear_sigio_trap ();
> clear_sigint_trap ();
> }
> @@ -1091,6 +1099,17 @@ lin_lwp_wait (ptid_t ptid, struct target
> gdb_assert (pid == -1 || lwpid == pid);
>
> lp = find_lwp_pid (pid_to_ptid (lwpid));
> +
> + /* Make sure we don't report an event for the exit of an LWP not in
> + our list, i.e. not part of the current process. This can happen
> + if we detach from a program we original forked and then it
> + exits. */
> + if (! WIFSTOPPED (status) && ! lp)
> + {
> + status = 0;
> + continue;
> + }
> +
> if (! lp)
> {
> lp = add_lwp (BUILD_LWP (lwpid, GET_PID (inferior_ptid)));
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFA[threads]: Fork event updates, part the thirteenth
2003-01-06 23:54 ` Michael Snyder
@ 2003-01-07 0:50 ` Daniel Jacobowitz
2003-01-09 19:16 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2003-01-07 0:50 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches, kettenis
On Mon, Jan 06, 2003 at 03:53:52PM -0800, Michael Snyder wrote:
> Daniel Jacobowitz wrote:
> >
> > Now is where it starts to get interesting. Michael, I mentioned this patch
> > to you at lunch last week. If you take a short-lived program, run it, and
> > detach it, and run it again, you'll see the exit of the _previous_ copy.
> > Then GDB gets hopelessly confused. I have a testcase for this which I'll
> > post in a moment.
> >
> > The reason it's included here is that that's essentially what happens if you
> > are using "set follow-fork-mode child". We detach from the parent, which
> > exits, confusing GDB.
> >
> > Is this OK?
>
> Hi Dan,
>
> Please excuse the delay. This seems OK. In child_wait,
> would it be possible to add a check to see if the exiting
> process is in our lwp list?
I _think_ that child_wait will never be called if there is anything in
the LWP list; if we have LWPs, we'll have pushed thread_db onto the
stack, and we'll go to lin_lwp_wait instead if thre are any LWPs. But
I'm sleepy, so I may be missing something; I'll sit on this and look at
it again tomorrow :)
Thanks.
> > 2002-12-15 Daniel Jacobowitz <drow@mvista.com>
> >
> > * lin-lwp.c (child_wait): Ignore exit statuses for processes other
> > than inferior_ptid.
> > (lin_lwp_wait): Ignore exit statuses for unknown LWPs.
> >
> > Index: lin-lwp.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/lin-lwp.c,v
> > retrieving revision 1.39
> > diff -u -p -r1.39 lin-lwp.c
> > --- lin-lwp.c 9 Dec 2002 18:41:42 -0000 1.39
> > +++ lin-lwp.c 15 Dec 2002 21:16:34 -0000
> > @@ -964,6 +964,14 @@ child_wait (ptid_t ptid, struct target_w
> > pid = waitpid (GET_PID (ptid), &status, __WCLONE);
> > save_errno = errno;
> >
> > + /* Make sure we don't report an event for the exit of the
> > + original program, if we've detached from it. */
> > + if (pid != -1 && ! WIFSTOPPED (status) && pid != GET_PID (inferior_ptid))
> > + {
> > + pid = -1;
> > + save_errno = EINTR;
> > + }
> > +
> > clear_sigio_trap ();
> > clear_sigint_trap ();
> > }
> > @@ -1091,6 +1099,17 @@ lin_lwp_wait (ptid_t ptid, struct target
> > gdb_assert (pid == -1 || lwpid == pid);
> >
> > lp = find_lwp_pid (pid_to_ptid (lwpid));
> > +
> > + /* Make sure we don't report an event for the exit of an LWP not in
> > + our list, i.e. not part of the current process. This can happen
> > + if we detach from a program we original forked and then it
> > + exits. */
> > + if (! WIFSTOPPED (status) && ! lp)
> > + {
> > + status = 0;
> > + continue;
> > + }
> > +
> > if (! lp)
> > {
> > lp = add_lwp (BUILD_LWP (lwpid, GET_PID (inferior_ptid)));
>
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFA[threads]: Fork event updates, part the thirteenth
2003-01-07 0:50 ` Daniel Jacobowitz
@ 2003-01-09 19:16 ` Daniel Jacobowitz
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2003-01-09 19:16 UTC (permalink / raw)
To: gdb-patches; +Cc: Michael Snyder, kettenis
On Mon, Jan 06, 2003 at 07:50:55PM -0500, Daniel Jacobowitz wrote:
> On Mon, Jan 06, 2003 at 03:53:52PM -0800, Michael Snyder wrote:
> > Daniel Jacobowitz wrote:
> > >
> > > Now is where it starts to get interesting. Michael, I mentioned this patch
> > > to you at lunch last week. If you take a short-lived program, run it, and
> > > detach it, and run it again, you'll see the exit of the _previous_ copy.
> > > Then GDB gets hopelessly confused. I have a testcase for this which I'll
> > > post in a moment.
> > >
> > > The reason it's included here is that that's essentially what happens if you
> > > are using "set follow-fork-mode child". We detach from the parent, which
> > > exits, confusing GDB.
> > >
> > > Is this OK?
> >
> > Hi Dan,
> >
> > Please excuse the delay. This seems OK. In child_wait,
> > would it be possible to add a check to see if the exiting
> > process is in our lwp list?
>
> I _think_ that child_wait will never be called if there is anything in
> the LWP list; if we have LWPs, we'll have pushed thread_db onto the
> stack, and we'll go to lin_lwp_wait instead if thre are any LWPs. But
> I'm sleepy, so I may be missing something; I'll sit on this and look at
> it again tomorrow :)
>
> Thanks.
Having convinced myself of this, I've checked in the patch as-is.
Thanks. Now for the testcase it fixes.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-01-09 19:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-15 13:43 RFA[threads]: Fork event updates, part the thirteenth Daniel Jacobowitz
2003-01-06 23:54 ` Michael Snyder
2003-01-07 0:50 ` Daniel Jacobowitz
2003-01-09 19:16 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox