* [PATCH] detaching and threaded linux apps
@ 2002-06-03 11:36 Liam Stewart
2002-06-03 14:53 ` Mark Kettenis
0 siblings, 1 reply; 3+ messages in thread
From: Liam Stewart @ 2002-06-03 11:36 UTC (permalink / raw)
To: gdb-patches
thread_db_detach and lin_lwp_detach don't remove their target operation
structures from the target list when a detach on a threaded application
is done. This leads to the failure of the num_lwps == 1 assertion if a
gdb user (for some reason) detaches again before starting/attaching to a
new inferior.
Liam
--
Liam Stewart :: Red Hat Canada, Ltd. :: liams@redhat.com
2002-06-03 Liam Stewart <liams@redhat.com>
* lin-lwp.c (lin_lwp_detach): Remove target operation structure
from target stack after detach operations are done.
* thread-db.c (thread_db_detach): Ditto.
Index: lin-lwp.c
===================================================================
RCS file: /cvs/src/src/gdb/lin-lwp.c,v
retrieving revision 1.34
diff -c -p -r1.34 lin-lwp.c
*** lin-lwp.c 31 Mar 2002 15:10:38 -0000 1.34
--- lin-lwp.c 3 Jun 2002 18:23:54 -0000
*************** lin_lwp_detach (char *args, int from_tty
*** 498,503 ****
--- 498,505 ----
inferior_ptid = pid_to_ptid (GET_PID (inferior_ptid));
child_ops.to_detach (args, from_tty);
+
+ unpush_target(&lin_lwp_ops);
}
\f
Index: thread-db.c
===================================================================
RCS file: /cvs/src/src/gdb/thread-db.c,v
retrieving revision 1.22
diff -c -p -r1.22 thread-db.c
*** thread-db.c 23 Mar 2002 17:38:13 -0000 1.22
--- thread-db.c 3 Jun 2002 18:23:54 -0000
*************** thread_db_detach (char *args, int from_t
*** 627,632 ****
--- 627,634 ----
proc_handle.pid = 0;
target_beneath->to_detach (args, from_tty);
+
+ unpush_target(&thread_db_ops);
}
static void
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] detaching and threaded linux apps
2002-06-03 11:36 [PATCH] detaching and threaded linux apps Liam Stewart
@ 2002-06-03 14:53 ` Mark Kettenis
2002-06-04 8:54 ` Liam Stewart
0 siblings, 1 reply; 3+ messages in thread
From: Mark Kettenis @ 2002-06-03 14:53 UTC (permalink / raw)
To: Liam Stewart; +Cc: gdb-patches
Liam Stewart <liams@redhat.com> writes:
> thread_db_detach and lin_lwp_detach don't remove their target operation
> structures from the target list when a detach on a threaded application
> is done. This leads to the failure of the num_lwps == 1 assertion if a
> gdb user (for some reason) detaches again before starting/attaching to a
> new inferior.
The fact that thread_db_detach and lin_lwp_detach don't unpush their
targect vector is intentional. The target vector is installed as a
result of loading the thread library, not (necessarily) as a result of
attaching to a threaded application. Therefore is should only be
uninstalled if the thread library is unloaded. The right wat of
fixing this would be to prevent the assertion being triggered if
num_lwps == 0. Explicitly checking for this condition and displaying
an error message in lin_lwp_detach() might be sufficient.
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] detaching and threaded linux apps
2002-06-03 14:53 ` Mark Kettenis
@ 2002-06-04 8:54 ` Liam Stewart
0 siblings, 0 replies; 3+ messages in thread
From: Liam Stewart @ 2002-06-04 8:54 UTC (permalink / raw)
To: gdb-patches; +Cc: Mark Kettenis
On Mon, Jun 03, 2002 at 11:53:03PM +0200, Mark Kettenis wrote:
>
> The fact that thread_db_detach and lin_lwp_detach don't unpush their
> targect vector is intentional. The target vector is installed as a
> result of loading the thread library, not (necessarily) as a result of
> attaching to a threaded application. Therefore is should only be
> uninstalled if the thread library is unloaded. The right wat of
> fixing this would be to prevent the assertion being triggered if
> num_lwps == 0. Explicitly checking for this condition and displaying
> an error message in lin_lwp_detach() might be sufficient.
Ok. I see exactly what's going on now. Returning from lin_lwp_detach
when there are no lwps works as expected. I don't think that displaying
an error message is neccessary - the behaviour of detach remains
consistent.
Liam
--
Liam Stewart :: Red Hat Canada, Ltd. :: liams@redhat.com
2002-06-04 Liam Stewart <liams@redhat.com>
* lin-lwp.c (lin_lwp_detach): Don't attempt to detach if there
* are no lwps.
Index: lin-lwp.c
===================================================================
RCS file: /cvs/src/src/gdb/lin-lwp.c,v
retrieving revision 1.34
diff -c -p -r1.34 lin-lwp.c
*** lin-lwp.c 31 Mar 2002 15:10:38 -0000 1.34
--- lin-lwp.c 4 Jun 2002 15:32:03 -0000
*************** detach_callback (struct lwp_info *lp, vo
*** 482,487 ****
--- 482,490 ----
static void
lin_lwp_detach (char *args, int from_tty)
{
+ if (num_lwps == 0)
+ return;
+
iterate_over_lwps (detach_callback, NULL);
/* Only the initial process should be left right now. */
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-06-04 15:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-03 11:36 [PATCH] detaching and threaded linux apps Liam Stewart
2002-06-03 14:53 ` Mark Kettenis
2002-06-04 8:54 ` Liam Stewart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox