* patch: Clean shutdown if still attached at exit in batch mode
@ 2004-04-29 13:15 Ashley Pittman
2004-07-26 19:13 ` [commit/6.2] Detach when in batch mode; Was: " Andrew Cagney
2004-07-26 19:30 ` patch: " Daniel Jacobowitz
0 siblings, 2 replies; 4+ messages in thread
From: Ashley Pittman @ 2004-04-29 13:15 UTC (permalink / raw)
To: gdb-patches
Hi,
I've been hitting some problems running gdb against live processes on
ia64 nodes, often stack traces are incomplete due to signal handler
issues or such like. If running gdb interactively then gdb drops back
to the prompt and everything is fine but if run in batch mode it stops
parsing the batch file and exits.
The problem here is that it does not detach before quiting so the
process becomes a zombie. Attached is a patch to prevent this.
I'm not cc'd to this list so please include me on any replies.
Ashley,
*** gdb-6.1/gdb/main.c 2004-02-18 00:21:00.000000000 +0000
--- gdb-6.1-modified/gdb/main.c 2004-04-29 14:10:17.000000000 +0100
***************
*** 736,742 ****
init_history ();
if (batch)
! {
/* We have hit the end of the batch file. */
exit (0);
}
--- 736,752 ----
init_history ();
if (batch)
! {
! if ( attach_flag) {
! /* If there is a problem executing the command in the batch file
! * then we might not have parsed all of it and might be attached.
! * Simply calling exit() would leave zombies so be nice and detach
! * but let the user know that there was a problem.
! */
! target_detach(NULL,0);
! exit(1);
! }
!
/* We have hit the end of the batch file. */
exit (0);
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* [commit/6.2] Detach when in batch mode; Was: Clean shutdown if still attached at exit in batch mode
2004-04-29 13:15 patch: Clean shutdown if still attached at exit in batch mode Ashley Pittman
@ 2004-07-26 19:13 ` Andrew Cagney
2004-07-26 19:30 ` patch: " Daniel Jacobowitz
1 sibling, 0 replies; 4+ messages in thread
From: Andrew Cagney @ 2004-07-26 19:13 UTC (permalink / raw)
To: Ashley Pittman; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1694 bytes --]
> Hi,
>
> I've been hitting some problems running gdb against live processes on
> ia64 nodes, often stack traces are incomplete due to signal handler
> issues or such like. If running gdb interactively then gdb drops back
> to the prompt and everything is fine but if run in batch mode it stops
> parsing the batch file and exits.
>
> The problem here is that it does not detach before quiting so the
> process becomes a zombie. Attached is a patch to prevent this.
I've committed the attached (mainline and 6.2). Even when the script
didn't abort GDB would kill the attached inferior :-(
As for getting GDB to return a non-zero exit when the batch script fails
- yes but it is a separate bug. We'd need to record that the script
failed and exit non-zero based on that.
Andrew
> Ashley,
>
> *** gdb-6.1/gdb/main.c 2004-02-18 00:21:00.000000000 +0000
> --- gdb-6.1-modified/gdb/main.c 2004-04-29 14:10:17.000000000 +0100
> ***************
> *** 736,742 ****
> init_history ();
>
> if (batch)
> ! {
> /* We have hit the end of the batch file. */
> exit (0);
> }
> --- 736,752 ----
> init_history ();
>
> if (batch)
> ! {
> ! if ( attach_flag) {
> ! /* If there is a problem executing the command in the batch file
> ! * then we might not have parsed all of it and might be attached.
> ! * Simply calling exit() would leave zombies so be nice and detach
> ! * but let the user know that there was a problem.
> ! */
> ! target_detach(NULL,0);
> ! exit(1);
> ! }
> !
> /* We have hit the end of the batch file. */
> exit (0);
> }
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 852 bytes --]
2004-07-26 Andrew Cagney <cagney@gnu.org>
Problem reported by Ashley Pittman <ashley@quadrics.com>.
* main.c (captured_main): When in batch mode always detach.
Index: main.c
===================================================================
RCS file: /cvs/src/src/gdb/main.c,v
retrieving revision 1.42
diff -p -u -r1.42 main.c
--- main.c 17 Jul 2004 03:25:10 -0000 1.42
+++ main.c 26 Jul 2004 19:00:46 -0000
@@ -729,6 +729,13 @@ extern int gdbtk_test (char *);
if (batch)
{
+ if (attach_flag)
+ /* Either there was a problem executing the command in the
+ batch file aborted early, or the batch file forgot to do an
+ explicit detach. Explicitly detach the inferior ensuring
+ that there are no zombies. */
+ target_detach (NULL, 0);
+
/* We have hit the end of the batch file. */
exit (0);
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: patch: Clean shutdown if still attached at exit in batch mode
2004-04-29 13:15 patch: Clean shutdown if still attached at exit in batch mode Ashley Pittman
2004-07-26 19:13 ` [commit/6.2] Detach when in batch mode; Was: " Andrew Cagney
@ 2004-07-26 19:30 ` Daniel Jacobowitz
2004-07-27 9:40 ` Ashley Pittman
1 sibling, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2004-07-26 19:30 UTC (permalink / raw)
To: Ashley Pittman; +Cc: gdb-patches
On Thu, Apr 29, 2004 at 02:15:44PM +0100, Ashley Pittman wrote:
>
> Hi,
>
> I've been hitting some problems running gdb against live processes on
> ia64 nodes, often stack traces are incomplete due to signal handler
> issues or such like. If running gdb interactively then gdb drops back
> to the prompt and everything is fine but if run in batch mode it stops
> parsing the batch file and exits.
>
> The problem here is that it does not detach before quiting so the
> process becomes a zombie. Attached is a patch to prevent this.
This should not cause the process to become a zombie. Do you mean that
it hangs around in the T (stopped) state?
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: patch: Clean shutdown if still attached at exit in batch mode
2004-07-26 19:30 ` patch: " Daniel Jacobowitz
@ 2004-07-27 9:40 ` Ashley Pittman
0 siblings, 0 replies; 4+ messages in thread
From: Ashley Pittman @ 2004-07-27 9:40 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
On Mon, 2004-07-26 at 20:28, Daniel Jacobowitz wrote:
> On Thu, Apr 29, 2004 at 02:15:44PM +0100, Ashley Pittman wrote:
> >
> > The problem here is that it does not detach before quiting so the
> > process becomes a zombie. Attached is a patch to prevent this.
>
> This should not cause the process to become a zombie. Do you mean that
> it hangs around in the T (stopped) state?
Yes, it appears that I do. On the basis of this I've just noticed that
kill -CONT <pid> brings it back to life so perhaps this isn't as serious
as I had previously thought.
I'm running a different kernel now though so can't say for sure,
previously I know I had to reboot the node to clear it however this was
a function of the way that I was starting processes. Curiously this
only seemed to affect Redhat kernels so I switched to using vanilla
kernels which combined with running a modified gdb means I haven't
observed this happen for a while.
Ashley,
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-07-27 9:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-29 13:15 patch: Clean shutdown if still attached at exit in batch mode Ashley Pittman
2004-07-26 19:13 ` [commit/6.2] Detach when in batch mode; Was: " Andrew Cagney
2004-07-26 19:30 ` patch: " Daniel Jacobowitz
2004-07-27 9:40 ` Ashley Pittman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox