From: Daniel Jacobowitz <drow@false.org>
To: Denis PILAT <denis.pilat@st.com>
Cc: gdb-patches <gdb-patches@sourceware.org>
Subject: Re: gdbserver with reversed arguments goes into an infinite loop
Date: Sat, 30 Dec 2006 15:45:00 -0000 [thread overview]
Message-ID: <20061230154533.GC15107@nevyn.them.org> (raw)
In-Reply-To: <45802031.2020402@st.com>
On Wed, Dec 13, 2006 at 04:45:53PM +0100, Denis PILAT wrote:
> But may be it would be better to open only character device (S_ISCHR
> macro) than excluding ordinary files (S_ISREG macro). It's up to you !
Good idea. FIFOs are OK too. I've committed a nicer version of this.
> I took this opportunity to remove a warning on a strncpy() usage.
Why did it warn? I omitted this bit, because I don't see any reason
(or any warning).
> I'm wondering about the compilation of this code under windows. I never
> compiled a gdbserver on windows, is there any gdbserver hosted under
> windows ?
If you were working against HEAD, you'd see that there was now - but
we don't support serial ports there, so it's not a problem. It's all
#ifdef'd out.
--
Daniel Jacobowitz
CodeSourcery
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.
Index: remote-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/remote-utils.c,v
retrieving revision 1.34
diff -u -p -r1.34 remote-utils.c
--- remote-utils.c 16 Nov 2006 15:08:25 -0000 1.34
+++ remote-utils.c 30 Dec 2006 15:23:37 -0000
@@ -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");
Index: server.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/server.c,v
retrieving revision 1.42
diff -u -p -r1.42 server.c
--- server.c 16 Nov 2006 15:08:25 -0000 1.42
+++ server.c 30 Dec 2006 15:23:37 -0000
@@ -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]);
next prev parent reply other threads:[~2006-12-30 15:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-13 9:58 Denis PILAT
2006-12-13 13:37 ` Daniel Jacobowitz
2006-12-13 15:46 ` Denis PILAT
2006-12-30 15:45 ` Daniel Jacobowitz [this message]
2007-01-03 9:08 ` Denis PILAT
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061230154533.GC15107@nevyn.them.org \
--to=drow@false.org \
--cc=denis.pilat@st.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox