This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch remote.c] Re-throw connect fail exception
- From: Andrew Cagney <ac131313 at cygnus dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Sun, 19 May 2002 16:13:54 -0400
- Subject: [patch remote.c] Re-throw connect fail exception
Hello,
The attached tweaks remote.c to so that failed connectsion are
re-propogated back through the caller.
This patch has been lurking in the wings for sometime only no one could
think of a test-case demonstrating that it fixed a bug. Today I got
lucky, compare:
(gdb)
-target-select remote /dev/null
&"get_tty_state failed: Operation not supported\n"
&"set_tty_state failed: Operation not supported\n"
&"get_tty_state failed: Operation not supported\n"
&"set_tty_state failed: Operation not supported\n"
~"Ignoring packet error, continuing...\n"
~"Ignoring packet error, continuing...\n"
~"Ignoring packet error, continuing...\n"
&"Couldn't establish connection to remote target\n"
&"Malformed response to offset query, timeout\n"
^connected
(gdb)
with:
(gdb)
-target-select remote /dev/null
&"get_tty_state failed: Operation not supported\n"
&"set_tty_state failed: Operation not supported\n"
&"get_tty_state failed: Operation not supported\n"
&"set_tty_state failed: Operation not supported\n"
~"Ignoring packet error, continuing...\n"
~"Ignoring packet error, continuing...\n"
~"Ignoring packet error, continuing...\n"
&"Couldn't establish connection to remote target\n"
&"Malformed response to offset query, timeout\n"
^error,msg="Malformed response to offset query, timeout"
(gdb)
The fix is in.
So, how legitimate is it do do something like:
(gdb) target remote /dev/null
as part of a test case?
Andrew
2002-05-19 Andrew Cagney <ac131313@redhat.com>
From Fernando Nasser:
* remote.c (remote_async_open_1): Re-throw the exception when the
connection fails.
(remote_cisco_open): Ditto.
(remote_open_1): Ditto.
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.83
diff -u -r1.83 remote.c
--- remote.c 19 May 2002 18:32:10 -0000 1.83
+++ remote.c 19 May 2002 20:00:34 -0000
@@ -2314,7 +2314,11 @@
#endif
/* Start the remote connection. If error() or QUIT, discard this
- target (we'd otherwise be in an inconsistent state).
+ target (we'd otherwise be in an inconsistent state) and then
+ propogate the error on up the exception chain. This ensures that
+ the caller doesn't stumble along blindly assuming that the
+ function succeeded. The CLI doesn't have this problem but other
+ UI's, such as MI do.
FIXME: cagney/2002-05-19: Instead of re-throwing the exception,
this function should return an error indication letting the
@@ -2332,7 +2336,7 @@
if (ex < 0)
{
pop_target ();
- return;
+ throw_exception (ex);
}
if (extended_p)
@@ -2437,7 +2441,8 @@
#endif
/* Start the remote connection; if error, discard this target. See
- the comments in remote_open_1() for further details. */
+ the comments in remote_open_1() for further details such as the
+ need to re-throw the exception. */
ex = catch_exceptions (uiout,
remote_start_remote, NULL,
"Couldn't establish connection to remote"
@@ -2447,7 +2452,7 @@
{
pop_target ();
wait_forever_enabled_p = 1;
- return;
+ throw_exception (ex);
}
wait_forever_enabled_p = 1;
@@ -5555,7 +5560,8 @@
inferior_ptid = pid_to_ptid (MAGIC_NULL_PID);
/* Start the remote connection; if error, discard this target. See
- the comments in remote_open_1() for further details. */
+ the comments in remote_open_1() for further details such as the
+ need to re-throw the exception. */
ex = catch_exceptions (uiout,
remote_start_remote_dummy, NULL,
"Couldn't establish connection to remote"
@@ -5564,7 +5570,7 @@
if (ex < 0)
{
pop_target ();
- return;
+ throw_exception (ex);
}
}