* [RFA] Make attach_command exception-safe
@ 2008-08-29 7:11 Vladimir Prus
2008-08-29 15:23 ` Daniel Jacobowitz
0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Prus @ 2008-08-29 7:11 UTC (permalink / raw)
To: gdb-patches
When attach_command executes, it might disable stdin. It further might
throw, and does not enable stdin in that case. For CLI case, top-level
event loop will catch the exception and enable stdin. For MI case, MI
interpreter catches the exception in order to print the error message,
and of course it has no idea about any stdin disabling.
This patch makes attach_command exception-safe, enabling stdin on
throw.
OK?
- Volodya
* infcmd.c (attach_command): Call async_enable_stdin
if exception is thrown.
---
ChangeLog.csl | 6 ++++++
gdb/infcmd.c | 4 ++++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/ChangeLog.csl b/ChangeLog.csl
index 9f4f686..5699492 100644
--- a/ChangeLog.csl
+++ b/ChangeLog.csl
@@ -1,3 +1,9 @@
+2008-08-28 Vladimir Prus <vladimir@codesourcery.com>
+
+ Make attach_command exception-safe
+ * infcmd.c (attach_command): Call async_enable_stdin
+ if exception is thrown.
+
2008-08-19 Pedro Alves <pedro@codesourcery.com>
* infcmd.c (post_create_inferior_1): If the solist is global,
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index feb045a..f0d3a6f 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2084,6 +2084,7 @@ attach_command (char *args, int from_tty)
char *exec_file;
char *full_exec_path = NULL;
int async_exec = 0;
+ struct cleanup *back_to = make_cleanup (null_cleanup, NULL);
dont_repeat (); /* Not for the faint of heart */
@@ -2139,6 +2140,7 @@ attach_command (char *args, int from_tty)
{
/* Simulate synchronous execution */
async_disable_stdin ();
+ make_cleanup ((make_cleanup_ftype *)async_enable_stdin, NULL);
}
target_attach (args, from_tty);
@@ -2181,6 +2183,7 @@ attach_command (char *args, int from_tty)
add_continuation (inferior_thread (),
attach_command_continuation, a,
attach_command_continuation_free_args);
+ discard_cleanups (back_to);
return;
}
@@ -2188,6 +2191,7 @@ attach_command (char *args, int from_tty)
}
attach_command_post_wait (args, from_tty, async_exec);
+ discard_cleanups (back_to);
}
/*
--
1.5.3.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA] Make attach_command exception-safe
2008-08-29 7:11 [RFA] Make attach_command exception-safe Vladimir Prus
@ 2008-08-29 15:23 ` Daniel Jacobowitz
2008-11-03 21:08 ` Vladimir Prus
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2008-08-29 15:23 UTC (permalink / raw)
To: Vladimir Prus; +Cc: gdb-patches
On Fri, Aug 29, 2008 at 07:10:42AM +0000, Vladimir Prus wrote:
>
> When attach_command executes, it might disable stdin. It further might
> throw, and does not enable stdin in that case. For CLI case, top-level
> event loop will catch the exception and enable stdin. For MI case, MI
> interpreter catches the exception in order to print the error message,
> and of course it has no idea about any stdin disabling.
>
> This patch makes attach_command exception-safe, enabling stdin on
> throw.
>
> OK?
OK.
> ChangeLog.csl | 6 ++++++
Not that bit :-)
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA] Make attach_command exception-safe
2008-08-29 15:23 ` Daniel Jacobowitz
@ 2008-11-03 21:08 ` Vladimir Prus
0 siblings, 0 replies; 3+ messages in thread
From: Vladimir Prus @ 2008-11-03 21:08 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
On Friday 29 August 2008 18:24:18 Daniel Jacobowitz wrote:
> On Fri, Aug 29, 2008 at 07:10:42AM +0000, Vladimir Prus wrote:
> >
> > When attach_command executes, it might disable stdin. It further might
> > throw, and does not enable stdin in that case. For CLI case, top-level
> > event loop will catch the exception and enable stdin. For MI case, MI
> > interpreter catches the exception in order to print the error message,
> > and of course it has no idea about any stdin disabling.
> >
> > This patch makes attach_command exception-safe, enabling stdin on
> > throw.
> >
> > OK?
>
> OK.
I've now checked this in.
Thanks,
Volodya
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-11-03 21:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-29 7:11 [RFA] Make attach_command exception-safe Vladimir Prus
2008-08-29 15:23 ` Daniel Jacobowitz
2008-11-03 21:08 ` Vladimir Prus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox