/* Remote utility routines for the remote server for GDB.
- Copyright (C) 1986, 1989, 1993 Free Software Foundation, Inc.
+ Copyright 1986, 1989, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+ Free Software Foundation, Inc.
This file is part of GDB.
#include <sys/ioctl.h>
#include <signal.h>
#include <fcntl.h>
+#include <sys/time.h>
+#include <unistd.h>
int remote_debug = 0;
struct ui_file *gdb_stdlog;
NAME is the filename used for communication. */
void
-remote_open (name)
- char *name;
+remote_open (char *name)
{
int save_fcntl_flags;
termios.c_lflag = 0;
termios.c_cflag &= ~(CSIZE | PARENB);
termios.c_cflag |= CLOCAL | CS8;
- termios.c_cc[VMIN] = 0;
+ termios.c_cc[VMIN] = 1;
termios.c_cc[VTIME] = 0;
tcsetattr (remote_desc, TCSANOW, &termios);
termio.c_lflag = 0;
termio.c_cflag &= ~(CSIZE | PARENB);
termio.c_cflag |= CLOCAL | CS8;
- termio.c_cc[VMIN] = 0;
+ termio.c_cc[VMIN] = 1;
termio.c_cc[VTIME] = 0;
ioctl (remote_desc, TCSETA, &termio);
#if defined(F_SETFL) && defined (FASYNC)
save_fcntl_flags = fcntl (remote_desc, F_GETFL, 0);
fcntl (remote_desc, F_SETFL, save_fcntl_flags | FASYNC);
+#if defined (F_SETOWN)
+ fcntl (remote_desc, F_SETOWN, getpid ());
+#endif
+#endif
disable_async_io ();
-#endif /* FASYNC */
fprintf (stderr, "Remote debugging using %s\n", name);
}
void
-remote_close ()
+remote_close (void)
{
close (remote_desc);
}
/* Convert hex digit A to a number. */
static int
-fromhex (a)
- int a;
+fromhex (int a)
{
if (a >= '0' && a <= '9')
return a - '0';
/* Convert number NIB to a hex digit. */
static int
-tohex (nib)
- int nib;
+tohex (int nib)
{
if (nib < 10)
return '0' + nib;
The data of the packet is in BUF. Returns >= 0 on success, -1 otherwise. */
int
-putpkt (buf)
- char *buf;
+putpkt (char *buf)
{
int i;
unsigned char csum = 0;
will cause us to send a SIGINT to the child. */
static void
-input_interrupt ()
+input_interrupt (void)
{
- int cc;
- char c;
+ fd_set readset;
+ struct timeval immediate = { 0, 0 };
- cc = read (remote_desc, &c, 1);
+ /* Protect against spurious interrupts. This has been observed to
+ be a problem under NetBSD 1.4 and 1.5. */
- if (cc != 1 || c != '\003')
+ FD_ZERO (&readset);
+ FD_SET (remote_desc, &readset);
+ if (select (remote_desc + 1, &readset, 0, 0, &immediate) > 0)
{
- fprintf (stderr, "input_interrupt, cc = %d c = %d\n", cc, c);
- return;
- }
+ int cc;
+ char c;
+
+ cc = read (remote_desc, &c, 1);
- kill (inferior_pid, SIGINT);
+ if (cc != 1 || c != '\003')
+ {
+ fprintf (stderr, "input_interrupt, cc = %d c = %d\n", cc, c);
+ return;
+ }
+
+ kill (inferior_pid, SIGINT);
+ }
}
void
-enable_async_io ()
+enable_async_io (void)
{
signal (SIGIO, input_interrupt);
}
void
-disable_async_io ()
+disable_async_io (void)
{
signal (SIGIO, SIG_IGN);
}
/* Returns next char from remote GDB. -1 if error. */
static int
-readchar ()
+readchar (void)
{
static char buf[BUFSIZ];
static int bufcnt = 0;
and store it in BUF. Returns length of packet, or negative if error. */
int
-getpkt (buf)
- char *buf;
+getpkt (char *buf)
{
char *bp;
unsigned char csum, c1, c2;
}
void
-write_ok (buf)
- char *buf;
+write_ok (char *buf)
{
buf[0] = 'O';
buf[1] = 'K';
}
void
-write_enn (buf)
- char *buf;
+write_enn (char *buf)
{
buf[0] = 'E';
buf[1] = 'N';
}
void
-convert_int_to_ascii (from, to, n)
- char *from, *to;
- int n;
+convert_int_to_ascii (char *from, char *to, int n)
{
int nib;
char ch;
void
-convert_ascii_to_int (from, to, n)
- char *from, *to;
- int n;
+convert_ascii_to_int (char *from, char *to, int n)
{
int nib1, nib2;
while (n--)
}
static char *
-outreg (regno, buf)
- int regno;
- char *buf;
+outreg (int regno, char *buf)
{
int regsize = REGISTER_RAW_SIZE (regno);
}
void
-prepare_resume_reply (buf, status, signo)
- char *buf;
- char status;
- unsigned char signo;
+prepare_resume_reply (char *buf, char status, unsigned char signo)
{
int nib;
}
void
-decode_m_packet (from, mem_addr_ptr, len_ptr)
- char *from;
- CORE_ADDR *mem_addr_ptr;
- unsigned int *len_ptr;
+decode_m_packet (char *from, CORE_ADDR *mem_addr_ptr, unsigned int *len_ptr)
{
int i = 0, j = 0;
char ch;
}
void
-decode_M_packet (from, mem_addr_ptr, len_ptr, to)
- char *from, *to;
- CORE_ADDR *mem_addr_ptr;
- unsigned int *len_ptr;
+decode_M_packet (char *from, CORE_ADDR *mem_addr_ptr, unsigned int *len_ptr,
+ char *to)
{
int i = 0;
char ch;