diff options
author | Daniel Jacobowitz <dan@debian.org> | 2006-12-30 15:44:51 +0000 |
---|---|---|
committer | Daniel Jacobowitz <dan@debian.org> | 2006-12-30 15:44:51 +0000 |
commit | 3b59d6de79360cf680631a1415b7c6eff48e7ac3 (patch) | |
tree | 3a66178d7eaf0cb68bb5be518627c6e82332e664 /gdb/gdbserver | |
parent | 97eee90dc4327008286bac83fdfc5d7219e975ef (diff) | |
download | gdb-3b59d6de79360cf680631a1415b7c6eff48e7ac3.tar.gz |
* remote-utils.c (remote_open): Check the type of specified
serial port devices before opening them.
* server.c (main): Kill the inferior if an error occurs during
the first remote_open.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/gdbserver/remote-utils.c | 20 | ||||
-rw-r--r-- | gdb/gdbserver/server.c | 7 |
3 files changed, 32 insertions, 3 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 02db4dd3a3f..d2b7d3b67b4 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,11 @@ +2006-12-30 Denis PILAT <denis.pilat@st.com> + Daniel Jacobowitz <dan@codesourcery.com> + + * remote-utils.c (remote_open): Check the type of specified + serial port devices before opening them. + * server.c (main): Kill the inferior if an error occurs during + the first remote_open. + 2006-12-05 Markus Deuling <deuling@de.ibm.com> * README: Update supported targets. diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c index fd5c844679f..80c63434569 100644 --- a/gdb/gdbserver/remote-utils.c +++ b/gdb/gdbserver/remote-utils.c @@ -52,6 +52,8 @@ #if HAVE_ARPA_INET_H #include <arpa/inet.h> #endif +#include <sys/stat.h> +#include <errno.h> #if USE_WIN32API #include <winsock.h> @@ -94,13 +96,25 @@ remote_open (char *name) #if defined(F_SETFL) && defined (FASYNC) int save_fcntl_flags; #endif - - if (!strchr (name, ':')) + char *port_str; + + port_str = strchr (name, ':'); + if (port_str == NULL) { #ifdef USE_WIN32API error ("Only <host>:<port> is supported on this platform."); #else - remote_desc = open (name, O_RDWR); + struct stat statbuf; + + if (stat (name, &statbuf) == 0 + && (S_ISCHR (statbuf.st_mode) || S_ISFIFO (statbuf.st_mode))) + remote_desc = open (name, O_RDWR); + else + { + errno = EINVAL; + remote_desc = -1; + } + if (remote_desc < 0) perror_with_name ("Could not open remote device"); diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 10a891eb5b5..84d0d684912 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -614,6 +614,13 @@ main (int argc, char *argv[]) } } + if (setjmp (toplevel)) + { + fprintf (stderr, "Killing inferior\n"); + kill_inferior (); + exit (1); + } + while (1) { remote_open (argv[1]); |