* remote.c: Add arg names to prototypes, in a modest effort at
clarification. Also add prototypes for some new functions. * (remote_wait): Better error reporting for 'T' responses. * ser-go32.c (strncasecmp): Make str1 & str2 be const. * (dos_async_init): Make usage message reflect requested port #. * ser-tcp.c (tcp_open): Terminate hostname properly to prevent random hostname lookup failures. Add nicer message for unknown host error. (wait_for): Wake up in case of exceptions. Also, restart select() if we got EINTR. * ser-unix.c (wait_for): Restart select() if we got EINTR. * serial.c: (serial_close): Clean up code.
This commit is contained in:
parent
2685ead7d6
commit
a037b21e75
5 changed files with 67 additions and 36 deletions
|
@ -1,3 +1,17 @@
|
||||||
|
Fri Jun 25 17:02:45 1993 Stu Grossman (grossman at cygnus.com)
|
||||||
|
|
||||||
|
* remote.c: Add arg names to prototypes, in a modest effort at
|
||||||
|
clarification. Also add prototypes for some new functions.
|
||||||
|
* (remote_wait): Better error reporting for 'T' responses.
|
||||||
|
* ser-go32.c (strncasecmp): Make str1 & str2 be const.
|
||||||
|
* (dos_async_init): Make usage message reflect requested port #.
|
||||||
|
* ser-tcp.c (tcp_open): Terminate hostname properly to prevent
|
||||||
|
random hostname lookup failures. Add nicer message for unknown
|
||||||
|
host error. (wait_for): Wake up in case of exceptions. Also,
|
||||||
|
restart select() if we got EINTR.
|
||||||
|
* ser-unix.c (wait_for): Restart select() if we got EINTR.
|
||||||
|
* serial.c: (serial_close): Clean up code.
|
||||||
|
|
||||||
Fri Jun 25 11:22:28 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
|
Fri Jun 25 11:22:28 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
|
||||||
|
|
||||||
* Makefile.in (*.tab.c): Use ./c-exp.tab.c not just c-exp.tab.c.
|
* Makefile.in (*.tab.c): Use ./c-exp.tab.c not just c-exp.tab.c.
|
||||||
|
|
|
@ -49,7 +49,7 @@ static void go32_restore PARAMS ((serial_t scb));
|
||||||
static void go32_close PARAMS ((serial_t scb));
|
static void go32_close PARAMS ((serial_t scb));
|
||||||
static serial_ttystate go32_get_tty_state PARAMS ((serial_t scb));
|
static serial_ttystate go32_get_tty_state PARAMS ((serial_t scb));
|
||||||
static int go32_set_tty_state PARAMS ((serial_t scb, serial_ttystate state));
|
static int go32_set_tty_state PARAMS ((serial_t scb, serial_ttystate state));
|
||||||
static int strncasecmp PARAMS ((char *str1, char *str2, int len));
|
static int strncasecmp PARAMS ((const char *str1, const char *str2, int len));
|
||||||
static char *aptr PARAMS ((short p));
|
static char *aptr PARAMS ((short p));
|
||||||
static ASYNC_STRUCT *getivec PARAMS ((int which));
|
static ASYNC_STRUCT *getivec PARAMS ((int which));
|
||||||
static int dos_async_init PARAMS ((int port));
|
static int dos_async_init PARAMS ((int port));
|
||||||
|
@ -78,7 +78,7 @@ static int iov;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
strncasecmp(str1, str2, len)
|
strncasecmp(str1, str2, len)
|
||||||
char *str1, *str2;
|
const char *str1, *str2;
|
||||||
register int len;
|
register int len;
|
||||||
{
|
{
|
||||||
unsigned char c1, c2;
|
unsigned char c1, c2;
|
||||||
|
@ -143,13 +143,12 @@ dos_async_init(port)
|
||||||
|
|
||||||
if (!async)
|
if (!async)
|
||||||
{
|
{
|
||||||
error("GDB can not connect to asynctsr program, check that it is installed\n\
|
error("GDB cannot connect to asynctsr program, check that it is installed\n\
|
||||||
and that serial I/O is not being redirected (perhaps by NFS)\n\n\
|
and that serial I/O is not being redirected (perhaps by NFS)\n\n\
|
||||||
example configuration:\n\
|
example configuration:\n\
|
||||||
C> mode com2:9600,n,8,1,p\n\
|
C> mode com%d:9600,n,8,1,p\n\
|
||||||
C> asynctsr 2\n\
|
C> asynctsr %d\n\
|
||||||
C> gdb \n");
|
C> gdb \n", port, port);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
iov = async->iov;
|
iov = async->iov;
|
||||||
|
|
|
@ -64,14 +64,16 @@ tcp_open(scb, name)
|
||||||
if (!port_str)
|
if (!port_str)
|
||||||
error ("tcp_open: No colon in host name!"); /* Shouldn't ever happen */
|
error ("tcp_open: No colon in host name!"); /* Shouldn't ever happen */
|
||||||
|
|
||||||
tmp = min(port_str - name + 1, sizeof hostname);
|
tmp = min (port_str - name, sizeof hostname - 1);
|
||||||
strncpy (hostname, name, tmp - 1); /* Don't want colon */
|
strncpy (hostname, name, tmp); /* Don't want colon */
|
||||||
|
hostname[tmp] = '\000'; /* Tie off host name */
|
||||||
port = atoi (port_str + 1);
|
port = atoi (port_str + 1);
|
||||||
|
|
||||||
hostent = gethostbyname (hostname);
|
hostent = gethostbyname (hostname);
|
||||||
|
|
||||||
if (!hostent)
|
if (!hostent)
|
||||||
{
|
{
|
||||||
|
fprintf (stderr, "%s: unknown host\n", hostname);
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -93,9 +95,10 @@ tcp_open(scb, name)
|
||||||
memcpy (&sockaddr.sin_addr.s_addr, hostent->h_addr,
|
memcpy (&sockaddr.sin_addr.s_addr, hostent->h_addr,
|
||||||
sizeof (struct in_addr));
|
sizeof (struct in_addr));
|
||||||
|
|
||||||
if (connect(scb->fd, &sockaddr, sizeof(sockaddr)))
|
if (connect (scb->fd, &sockaddr, sizeof(sockaddr)))
|
||||||
{
|
{
|
||||||
close(scb->fd);
|
close(scb->fd);
|
||||||
|
scb->fd = -1;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,27 +161,34 @@ wait_for(scb, timeout)
|
||||||
{
|
{
|
||||||
int numfds;
|
int numfds;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
fd_set readfds;
|
fd_set readfds, exceptfds;
|
||||||
|
|
||||||
FD_ZERO (&readfds);
|
FD_ZERO (&readfds);
|
||||||
|
FD_ZERO (&exceptfds);
|
||||||
|
|
||||||
tv.tv_sec = timeout;
|
tv.tv_sec = timeout;
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
FD_SET(scb->fd, &readfds);
|
FD_SET(scb->fd, &readfds);
|
||||||
|
FD_SET(scb->fd, &exceptfds);
|
||||||
|
|
||||||
if (timeout >= 0)
|
while (1)
|
||||||
numfds = select(scb->fd+1, &readfds, 0, 0, &tv);
|
{
|
||||||
else
|
if (timeout >= 0)
|
||||||
numfds = select(scb->fd+1, &readfds, 0, 0, 0);
|
numfds = select(scb->fd+1, &readfds, 0, &exceptfds, &tv);
|
||||||
|
else
|
||||||
|
numfds = select(scb->fd+1, &readfds, 0, &exceptfds, 0);
|
||||||
|
|
||||||
if (numfds <= 0)
|
if (numfds <= 0)
|
||||||
if (numfds == 0)
|
if (numfds == 0)
|
||||||
return SERIAL_TIMEOUT;
|
return SERIAL_TIMEOUT;
|
||||||
else
|
else if (errno == EINTR)
|
||||||
return SERIAL_ERROR; /* Got an error from select or poll */
|
continue;
|
||||||
|
else
|
||||||
|
return SERIAL_ERROR; /* Got an error from select or poll */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read a character with user-specified timeout. TIMEOUT is number of seconds
|
/* Read a character with user-specified timeout. TIMEOUT is number of seconds
|
||||||
|
|
|
@ -212,18 +212,23 @@ wait_for(scb, timeout)
|
||||||
|
|
||||||
FD_SET(scb->fd, &readfds);
|
FD_SET(scb->fd, &readfds);
|
||||||
|
|
||||||
if (timeout >= 0)
|
while (1)
|
||||||
numfds = select(scb->fd+1, &readfds, 0, 0, &tv);
|
{
|
||||||
else
|
if (timeout >= 0)
|
||||||
numfds = select(scb->fd+1, &readfds, 0, 0, 0);
|
numfds = select(scb->fd+1, &readfds, 0, 0, &tv);
|
||||||
|
else
|
||||||
|
numfds = select(scb->fd+1, &readfds, 0, 0, 0);
|
||||||
|
|
||||||
if (numfds <= 0)
|
if (numfds <= 0)
|
||||||
if (numfds == 0)
|
if (numfds == 0)
|
||||||
return SERIAL_TIMEOUT;
|
return SERIAL_TIMEOUT;
|
||||||
else
|
else if (errno == EINTR)
|
||||||
return SERIAL_ERROR; /* Got an error from select or poll */
|
continue;
|
||||||
|
else
|
||||||
|
return SERIAL_ERROR; /* Got an error from select or poll */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* HAVE_SGTTY */
|
#endif /* HAVE_SGTTY */
|
||||||
|
|
||||||
|
|
13
gdb/serial.c
13
gdb/serial.c
|
@ -116,11 +116,14 @@ serial_close(scb)
|
||||||
{
|
{
|
||||||
last_serial_opened = NULL;
|
last_serial_opened = NULL;
|
||||||
|
|
||||||
if (scb != NULL)
|
/* This is bogus. It's not our fault if you pass us a bad scb...! Rob, you
|
||||||
{
|
should fix your code instead. */
|
||||||
scb->ops->close(scb);
|
|
||||||
free(scb);
|
if (!scb)
|
||||||
}
|
return;
|
||||||
|
|
||||||
|
scb->ops->close(scb);
|
||||||
|
free(scb);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
Loading…
Add table
Reference in a new issue