aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog31
-rw-r--r--gdb/config/i386/xm-i386sco.h4
-rw-r--r--gdb/config/i386/xm-i386v32.h4
-rw-r--r--gdb/config/m88k/xm-delta88.h3
-rw-r--r--gdb/config/rs6000/xm-rs6000.h5
-rw-r--r--gdb/config/sparc/xm-sun4os4.h6
-rw-r--r--gdb/config/xm-sysv4.h12
-rw-r--r--gdb/fork-child.c15
-rw-r--r--gdb/ser-go32.c49
-rw-r--r--gdb/ser-tcp.c40
-rw-r--r--gdb/ser-unix.c266
-rw-r--r--gdb/serial.h45
-rw-r--r--gdb/signals.h9
13 files changed, 438 insertions, 51 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index febebb7..3b44753 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,34 @@
+Tue Jun 29 11:02:58 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
+
+ * inftarg.c: Remove unused include of terminal.h.
+ * signals.h: Don't undefine signals anymore.
+ * main.c: Use job_control from serial.h.
+ * fork-child.c (fork_inferior): Use gdb_setpgid.
+ * serial.h, ser-unix.c, ser-go32.c: Provide gdb_setpgid.
+ * utils.c (quit): Use current_target->to_terminal_ours to figure
+ out whether we care about lack of job control, rather than __GO32__.
+ * utils.c: Include serial.h not terminal.h
+ (quit): Use job_control not TIOCGPGRP.
+ * terminal.h: Don't undefine TIOCGPGRP.
+ * serial.h, ser-unix.c, ser-go32.c, ser-tcp.c: Add SERIAL_FLUSH_OUTPUT.
+ * utils.c (quit): Use it.
+ * serial.h: Add SERIAL_UN_FDOPEN.
+ * utils.c (quit): Use it.
+ * ser-unix.c: Add process group to ttystate.
+ [HAVE_SGTTY]: Add tchars, ltchars, and lmode to ttystate.
+ * inflow.c: Include serial.h not terminal.h.
+ Use serial.h stuff to replace most of the maze of #ifdef's.
+ * inflow.c, main.c, inferior.h: make gdb_has_a_terminal a function.
+ * serial.h: Document SERIAL_SET_TTY_STATE as being immediate.
+ * ser-unix.c: Use TIOCSETN not TIOCSETP so it is true.
+ * serial.h, ser-unix.c, ser-go32.c, ser-tcp.c:
+ Add SERIAL_PRINT_TTY_STATE, SERIAL_NOFLUSH_SET_TTY_STATE, and
+ SERIAL_SET_PROCESS_GROUP.
+ * inflow.c: Use them.
+ * config/xm-svr4.h, config/rs6000/xm-rs6000.h, config/sparc/sun4os4.h:
+ Define HAVE_TERMIOS.
+ * Various: Remove all use of TIOC*_BROKEN.
+
Wed Jun 30 12:20:51 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
* config/m68k/tm-sun3.h (BELIEVE_PCC_PROMOTION_TYPE): Define.
diff --git a/gdb/config/i386/xm-i386sco.h b/gdb/config/i386/xm-i386sco.h
index e500e26..968e0a0 100644
--- a/gdb/config/i386/xm-i386sco.h
+++ b/gdb/config/i386/xm-i386sco.h
@@ -27,10 +27,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
the name of this field is. */
#define U_FPSTATE(u) u.u_fps.u_fpstate
-/* TIOCGETC is defined in System V 3.2 termio.h, but struct tchars
- is not. This makes problems for inflow.c. */
-#define TIOCGETC_BROKEN
-
/* All the job control definitions exist in SCO Unix, but the standard
shells don't use them. So we must disable job control. */
/* This is no longer true with 3.2v2 and later */
diff --git a/gdb/config/i386/xm-i386v32.h b/gdb/config/i386/xm-i386v32.h
index 129f8b8..bdec338 100644
--- a/gdb/config/i386/xm-i386v32.h
+++ b/gdb/config/i386/xm-i386v32.h
@@ -22,7 +22,3 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Apparently there is inconsistency among various System V's about what
the name of this field is. */
#define U_FPSTATE(u) u.u_fps.u_fpstate
-
-/* TIOCGETC is defined in System V 3.2 termio.h, but struct tchars
- is not. This makes problems for inflow.c. */
-#define TIOCGETC_BROKEN
diff --git a/gdb/config/m88k/xm-delta88.h b/gdb/config/m88k/xm-delta88.h
index 1fa0214..7398f58 100644
--- a/gdb/config/m88k/xm-delta88.h
+++ b/gdb/config/m88k/xm-delta88.h
@@ -24,9 +24,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define USG 1
#endif
-#define TIOCGETC_BROKEN 1
-#define TIOCGLTC_BROKEN 1
-
#include <sys/param.h>
#include <sys/time.h>
diff --git a/gdb/config/rs6000/xm-rs6000.h b/gdb/config/rs6000/xm-rs6000.h
index 718b10a..b44287d 100644
--- a/gdb/config/rs6000/xm-rs6000.h
+++ b/gdb/config/rs6000/xm-rs6000.h
@@ -37,7 +37,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define HOST_BYTE_ORDER BIG_ENDIAN
-#define HAVE_TERMIO 1
+/* At least as of AIX 3.2, we have termios. */
+#define HAVE_TERMIOS 1
+/* #define HAVE_TERMIO 1 */
+
#define USG 1
#define HAVE_SIGSETMASK 1
diff --git a/gdb/config/sparc/xm-sun4os4.h b/gdb/config/sparc/xm-sun4os4.h
index db2c815..03d1c8f 100644
--- a/gdb/config/sparc/xm-sun4os4.h
+++ b/gdb/config/sparc/xm-sun4os4.h
@@ -57,3 +57,9 @@ extern int free ();
/* SunOS 4.x uses nonstandard "char *" as type of third argument to ptrace() */
#define PTRACE_ARG3_TYPE char*
+
+/* Using termios is required to save and restore ICRNL and ONLCR
+ separately. */
+
+/* At least SunOS 4.1.1 has termios. I'm not sure about 4.0.3. */
+#define HAVE_TERMIOS
diff --git a/gdb/config/xm-sysv4.h b/gdb/config/xm-sysv4.h
index c2cc1f6..0805768 100644
--- a/gdb/config/xm-sysv4.h
+++ b/gdb/config/xm-sysv4.h
@@ -22,22 +22,14 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define SVR4_SHARED_LIBS
-/* SVR4 has termio facilities. */
+/* SVR4 has termios facilities. */
-#define HAVE_TERMIO
+#define HAVE_TERMIOS
/* SVR4 has mmap facilities */
#define HAVE_MMAP
-/* TIOCGETC and TIOCGLTC are picked up somewhere, but struct tchars
- and struct ltchars are not. This makes problems for inflow.c.
- It is unknown at this time if this is a generic SVR4 problem or
- one just limited to the initial SVR4 port host machine. */
-
-#define TIOCGETC_BROKEN
-#define TIOCGLTC_BROKEN
-
/* SVR4 is a derivative of System V Release 3 (USG) */
#define USG
diff --git a/gdb/fork-child.c b/gdb/fork-child.c
index 613f1ee..b413889 100644
--- a/gdb/fork-child.c
+++ b/gdb/fork-child.c
@@ -24,7 +24,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "target.h"
#include "wait.h"
#include "gdbcore.h"
-#include "terminal.h" /* For #ifdef TIOCGPGRP and new_tty */
+#include "serial.h" /* For job_control. */
+#include "terminal.h" /* For new_tty */
#include <signal.h>
@@ -152,20 +153,10 @@ fork_inferior (exec_file, allargs, env, traceme_fun, init_trace_fun)
if (debug_fork)
sleep (debug_fork);
-#ifdef TIOCGPGRP
/* Run inferior in a separate process group. */
-#ifdef NEED_POSIX_SETPGID
- debug_setpgrp = setpgid (0, 0);
-#else
-#if defined(USG) && !defined(SETPGRP_ARGS)
- debug_setpgrp = setpgrp ();
-#else
- debug_setpgrp = setpgrp (getpid (), getpid ());
-#endif /* USG */
-#endif /* NEED_POSIX_SETPGID */
+ debug_setpgrp = gdb_setpgid ();
if (debug_setpgrp == -1)
perror("setpgrp failed in child");
-#endif /* TIOCGPGRP */
#ifdef SET_STACK_LIMIT_HUGE
/* Reset the stack limit back to what it was. */
diff --git a/gdb/ser-go32.c b/gdb/ser-go32.c
index 8689e24..ff1bdf1 100644
--- a/gdb/ser-go32.c
+++ b/gdb/ser-go32.c
@@ -266,6 +266,14 @@ go32_open (scb, name)
return 0;
}
+static int
+go32_flush_output (scb)
+ serial_t scb;
+{
+ /* No need to flush, because there is no buffering. */
+ return 0;
+}
+
static void
go32_raw (scb)
serial_t scb;
@@ -311,6 +319,24 @@ go32_set_tty_state(scb, ttystate)
}
static int
+go32_noflush_set_tty_state (scb, new_ttystate, old_ttystate)
+ serial_t scb;
+ serial_ttystate new_ttystate;
+ serial_ttystate old_ttystate;
+{
+ return 0;
+}
+
+static void
+go32_print_tty_state (scb, ttystate)
+ serial_t scb;
+ serial_ttystate ttystate;
+{
+ /* Nothing to print. */
+ return;
+}
+
+static int
go32_setbaudrate (scb, rate)
serial_t scb;
int rate;
@@ -319,6 +345,15 @@ go32_setbaudrate (scb, rate)
}
static int
+go32_set_process_group (scb, ttystate, group)
+ serial_t scb;
+ serial_ttystate ttystate;
+ int group;
+{
+ return 0;
+}
+
+static int
go32_write (scb, str, len)
serial_t scb;
const char *str;
@@ -343,13 +378,25 @@ static struct serial_ops go32_ops =
go32_close,
go32_readchar,
go32_write,
+ go32_flush_output,
go32_raw,
go32_get_tty_state,
go32_set_tty_state,
- go32_setbaudrate
+ go32_print_tty_state,
+ go32_noflush_set_tty_state,
+ go32_setbaudrate,
+ go32_set_process_group
};
+/* There is never job control on go32. */
+int
+gdb_setpgid ()
+{
+ return 0;
+}
+
_initialize_ser_go32 ()
{
+ job_control = 0;
serial_add_interface (&go32_ops);
}
diff --git a/gdb/ser-tcp.c b/gdb/ser-tcp.c
index 5afe63e..6ff79aa 100644
--- a/gdb/ser-tcp.c
+++ b/gdb/ser-tcp.c
@@ -140,6 +140,15 @@ tcp_set_tty_state(scb, ttystate)
return 0;
}
+static int
+tcp_flush_output (scb)
+ serial_t scb;
+{
+ /* This is only used by utils.c on stdout, so it doesn't need to work
+ for tcp. */
+ return 0;
+}
+
static void
tcp_raw(scb)
serial_t scb;
@@ -227,6 +236,24 @@ tcp_readchar(scb, timeout)
}
static int
+tcp_noflush_set_tty_state (scb, new_ttystate, old_ttystate)
+ serial_t scb;
+ serial_ttystate new_ttystate;
+ serial_ttystate old_ttystate;
+{
+ return 0;
+}
+
+static void
+tcp_print_tty_state (scb, ttystate)
+ serial_t scb;
+ serial_ttystate ttystate;
+{
+ /* Nothing to print. */
+ return;
+}
+
+static int
tcp_setbaudrate(scb, rate)
serial_t scb;
int rate;
@@ -235,6 +262,15 @@ tcp_setbaudrate(scb, rate)
}
static int
+tcp_set_process_group (scb, ttystate, group)
+ serial_t scb;
+ serial_ttystate ttystate;
+ int group;
+{
+ return 0;
+}
+
+static int
tcp_write(scb, str, len)
serial_t scb;
const char *str;
@@ -273,10 +309,14 @@ static struct serial_ops tcp_ops =
tcp_close,
tcp_readchar,
tcp_write,
+ tcp_flush_output,
tcp_raw,
tcp_get_tty_state,
tcp_set_tty_state,
+ tcp_print_tty_state,
+ tcp_noflush_set_tty_state,
tcp_setbaudrate,
+ tcp_set_process_group
};
void
diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c
index eb34da5..e88fbb7 100644
--- a/gdb/ser-unix.c
+++ b/gdb/ser-unix.c
@@ -33,6 +33,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
struct hardwire_ttystate
{
struct termios termios;
+ pid_t process_group;
};
#endif
@@ -42,6 +43,7 @@ struct hardwire_ttystate
struct hardwire_ttystate
{
struct termio termio;
+ int process_group;
};
#endif
@@ -55,6 +57,17 @@ struct hardwire_ttystate
struct hardwire_ttystate
{
struct sgttyb sgttyb;
+ struct tchars tc;
+ struct ltchars ltc;
+ /* Line discipline flags. */
+ int lmode;
+
+#ifdef SHORT_PGRP
+ /* This is only used for the ultra. Does it have pid_t? */
+ short process_group;
+#else
+ int process_group;
+#endif
};
#endif
@@ -92,15 +105,45 @@ get_tty_state(scb, state)
struct hardwire_ttystate *state;
{
#ifdef HAVE_TERMIOS
- return tcgetattr(scb->fd, &state->termios);
+ pid_t new_process_group;
+
+ if (tcgetattr(scb->fd, &state->termios) < 0)
+ return -1;
+
+ if (!job_control)
+ return 0;
+
+ new_process_group = tcgetpgrp (scb->fd);
+ if (new_process_group == (pid_t)-1)
+ return -1;
+ state->process_group = new_process_group;
+ return 0;
#endif
#ifdef HAVE_TERMIO
- return ioctl (scb->fd, TCGETA, &state->termio);
+ if (ioctl (scb->fd, TCGETA, &state->termio) < 0)
+ return -1;
+
+ if (!job_control)
+ return 0;
+
+ return ioctl (scb->fd, TIOCGPGRP, &state->process_group);
#endif
#ifdef HAVE_SGTTY
- return ioctl (scb->fd, TIOCGETP, &state->sgttyb);
+ if (ioctl (scb->fd, TIOCGETP, &state->sgttyb) < 0)
+ return -1;
+ if (ioctl (scb->fd, TIOCGETC, &state->tc) < 0)
+ return -1;
+ if (ioctl (scb->fd, TIOCGLTC, &state->ltc) < 0)
+ return -1;
+ if (ioctl (scb->fd, TIOCLGET, &state->lmode) < 0)
+ return -1;
+
+ if (!job_control)
+ return 0;
+
+ return ioctl (scb->fd, TIOCGPGRP, &state->process_group);
#endif
}
@@ -109,18 +152,40 @@ set_tty_state(scb, state)
serial_t scb;
struct hardwire_ttystate *state;
{
- int err;
-
#ifdef HAVE_TERMIOS
- return tcsetattr(scb->fd, TCSANOW, &state->termios);
+ if (tcsetattr(scb->fd, TCSANOW, &state->termios) < 0)
+ return -1;
+
+ if (!job_control)
+ return 0;
+
+ /* Need to ignore errors, at least if attach_flag is set. */
+ tcsetpgrp (scb->fd, state->process_group);
+ return 0;
#endif
#ifdef HAVE_TERMIO
- return ioctl (scb->fd, TCSETA, &state->termio);
+ if (ioctl (scb->fd, TCSETA, &state->termio) < 0)
+ return -1;
+
+ if (!job_control)
+ return 0;
+
+ /* Need to ignore errors, at least if attach_flag is set. */
+ ioctl (scb->fd, TIOCSPGRP, &state->process_group);
+ return 0;
#endif
#ifdef HAVE_SGTTY
- return ioctl (scb->fd, TIOCSETP, &state->sgttyb);
+ if (ioctl (scb->fd, TIOCSETN, &state->sgttyb) < 0)
+ return -1;
+
+ if (!job_control)
+ return 0;
+
+ /* Need to ignore errors, at least if attach_flag is set. */
+ ioctl (scb->fd, TIOCSPGRP, &state->process_group);
+ return 0;
#endif
}
@@ -150,6 +215,120 @@ hardwire_set_tty_state(scb, ttystate)
return set_tty_state(scb, state);
}
+static int
+hardwire_noflush_set_tty_state (scb, new_ttystate, old_ttystate)
+ serial_t scb;
+ serial_ttystate new_ttystate;
+ serial_ttystate old_ttystate;
+{
+ struct hardwire_ttystate new_state =
+ *(struct hardwire_ttystate *)new_ttystate;
+ struct hardwire_ttystate *state = (struct hardwire_ttystate *) old_ttystate;
+
+#ifdef HAVE_TERMIOS
+ /* I'm not sure whether this is necessary; the manpage makes no mention
+ of discarding input when switching to/from ICANON. */
+ if (state->termios.c_lflag & ICANON)
+ new_state.termios.c_lflag |= ICANON;
+ else
+ new_state.termios.c_lflag &= ~ICANON;
+#endif
+
+#ifdef HAVE_TERMIO
+ /* I'm not sure whether this is necessary; the manpage makes no mention
+ of discarding input when switching to/from ICANON. */
+ if (state->termio.c_lflag & ICANON)
+ new_state.termio.c_lflag |= ICANON;
+ else
+ new_state.termio.c_lflag &= ~ICANON;
+#endif
+
+#ifdef HAVE_SGTTY
+ if (state->sgttyb.sg_flags & RAW)
+ new_state.sgttyb.sg_flags |= RAW;
+ else
+ new_state.sgttyb.sg_flags &= ~RAW;
+
+ /* I'm not sure whether this is necessary; the manpage just mentions
+ RAW not CBREAK. */
+ if (state->sgttyb.sg_flags & CBREAK)
+ new_state.sgttyb.sg_flags |= CBREAK;
+ else
+ new_state.sgttyb.sg_flags &= ~CBREAK;
+#endif
+
+ return set_tty_state (scb, &new_state);
+}
+
+static void
+hardwire_print_tty_state (scb, ttystate)
+ serial_t scb;
+ serial_ttystate ttystate;
+{
+ struct hardwire_ttystate *state = (struct hardwire_ttystate *) ttystate;
+ int i;
+
+ printf_filtered ("Process group = %d\n", state->process_group);
+
+#ifdef HAVE_TERMIOS
+ printf_filtered ("c_iflag = 0x%x, c_oflag = 0x%x,\n",
+ state->termios.c_iflag, state->termios.c_oflag);
+ printf_filtered ("c_cflag = 0x%x, c_lflag = 0x%x, c_line = 0x%x.\n",
+ state->termios.c_cflag, state->termios.c_lflag,
+ state->termios.c_line);
+ printf_filtered ("c_cc: ");
+ for (i = 0; i < NCCS; i += 1)
+ printf_filtered ("0x%x ", state->termios.c_cc[i]);
+ printf_filtered ("\n");
+#endif
+
+#ifdef HAVE_TERMIO
+ printf_filtered ("c_iflag = 0x%x, c_oflag = 0x%x,\n",
+ state->termio.c_iflag, state->termio.c_oflag);
+ printf_filtered ("c_cflag = 0x%x, c_lflag = 0x%x, c_line = 0x%x.\n",
+ state->termio.c_cflag, state->termio.c_lflag,
+ state->termio.c_line);
+ printf_filtered ("c_cc: ");
+ for (i = 0; i < NCC; i += 1)
+ printf_filtered ("0x%x ", state->termio.c_cc[i]);
+ printf_filtered ("\n");
+#endif
+
+#ifdef HAVE_SGTTY
+ printf_filtered ("sgttyb.sg_flags = 0x%x.\n", state->sgttyb.sg_flags);
+
+ printf_filtered ("tchars: ");
+ for (i = 0; i < (int)sizeof (struct tchars); i++)
+ printf_filtered ("0x%x ", ((unsigned char *)&state->tc)[i]);
+ printf_filtered ("\n");
+
+ printf_filtered ("ltchars: ");
+ for (i = 0; i < (int)sizeof (struct ltchars); i++)
+ printf_filtered ("0x%x ", ((unsigned char *)&state->ltc)[i]);
+ printf_filtered ("\n");
+
+ printf_filtered ("lmode: 0x%x\n", state->lmode);
+#endif
+}
+
+static int
+hardwire_flush_output (scb)
+ serial_t scb;
+{
+#ifdef HAVE_TERMIOS
+ return tcflush (scb->fd, TCOFLUSH);
+#endif
+
+#ifdef HAVE_TERMIO
+ return ioctl (scb->fd, TCFLSH, 1);
+#endif
+
+#ifdef HAVE_SGTTY
+ /* This flushes both input and output, but we can't do better. */
+ return ioctl (scb->fd, TIOCFLUSH, 0);
+#endif
+}
+
static void
hardwire_raw(scb)
serial_t scb;
@@ -380,6 +559,16 @@ hardwire_setbaudrate(scb, rate)
}
static int
+hardwire_set_process_group (scb, ttystate, group)
+ serial_t scb;
+ serial_ttystate ttystate;
+ int group;
+{
+ ((struct hardwire_ttystate *)ttystate)->process_group = group;
+ return 0;
+}
+
+static int
hardwire_write(scb, str, len)
serial_t scb;
const char *str;
@@ -418,14 +607,75 @@ static struct serial_ops hardwire_ops =
hardwire_close,
hardwire_readchar,
hardwire_write,
+ hardwire_flush_output,
hardwire_raw,
hardwire_get_tty_state,
hardwire_set_tty_state,
+ hardwire_print_tty_state,
+ hardwire_noflush_set_tty_state,
hardwire_setbaudrate,
+ hardwire_set_process_group
};
+int job_control;
+#if defined (HAVE_TERMIOS)
+#include <unistd.h>
+#endif
+
+/* This is here because this is where we figure out whether we (probably)
+ have job control. Just using job_control only does part of it because
+ setpgid or setpgrp might not exist on a system without job control.
+ It might be considered misplaced (on the other hand, process groups and
+ job control are closely related to ttys).
+
+ For a more clean implementation, in libiberty, put a setpgid which merely
+ calls setpgrp and a setpgrp which does nothing (any system with job control
+ will have one or the other). */
+int
+gdb_setpgid ()
+{
+ int retval = 0;
+ if (job_control)
+ {
+#if defined (NEED_POSIX_SETPGID) || defined (HAVE_TERMIOS)
+ /* Do all systems with termios have setpgid? I hope so. */
+ retval = setpgid (0, 0);
+#else
+#if defined (TIOCGPGRP)
+#if defined(USG) && !defined(SETPGRP_ARGS)
+ retval = setpgrp ();
+#else
+ retval = setpgrp (getpid (), getpid ());
+#endif /* USG */
+#endif /* TIOCGPGRP. */
+#endif /* NEED_POSIX_SETPGID */
+ }
+ return retval;
+}
+
void
_initialize_ser_hardwire ()
{
serial_add_interface (&hardwire_ops);
+
+ /* OK, figure out whether we have job control. */
+
+#if defined (HAVE_TERMIOS)
+ /* Do all systems with termios have the POSIX way of identifying job
+ control? I hope so. */
+#ifdef _POSIX_JOB_CONTROL
+ job_control = _POSIX_JOB_CONTROL;
+#else
+ job_control = sysconf (_SC_JOB_CONTROL);
+#endif
+
+#else /* not termios. */
+
+#ifdef TIOCGPGRP
+ job_control = 1;
+#else
+ job_control = 0;
+#endif /* TIOCGPGRP */
+
+#endif /* not termios. */
}
diff --git a/gdb/serial.h b/gdb/serial.h
index f83fda7..630ed43 100644
--- a/gdb/serial.h
+++ b/gdb/serial.h
@@ -41,10 +41,15 @@ struct serial_ops {
void (*close) PARAMS ((serial_t));
int (*readchar) PARAMS ((serial_t, int timeout));
int (*write) PARAMS ((serial_t, const char *str, int len));
+ int (*flush_output) PARAMS ((serial_t));
void (*go_raw) PARAMS ((serial_t));
serial_ttystate (*get_tty_state) PARAMS ((serial_t));
int (*set_tty_state) PARAMS ((serial_t, serial_ttystate));
+ void (*print_tty_state) PARAMS ((serial_t, serial_ttystate));
+ int (*noflush_set_tty_state)
+ PARAMS ((serial_t, serial_ttystate, serial_ttystate));
int (*setbaudrate) PARAMS ((serial_t, int rate));
+ int (*set_process_group) PARAMS ((serial_t, serial_ttystate, int));
};
/* Add a new serial interface to the interface list */
@@ -67,14 +72,36 @@ serial_t serial_fdopen PARAMS ((int fd));
#define SERIAL_FDOPEN(FD) serial_fdopen(FD)
+/* Flush pending output. */
+
+#define SERIAL_FLUSH_OUTPUT(SERIAL_T) \
+ ((SERIAL_T)->ops->flush_output((SERIAL_T)))
+
/* Turn the port into raw mode. */
#define SERIAL_RAW(SERIAL_T) (SERIAL_T)->ops->go_raw((SERIAL_T))
+/* Return a pointer to a newly malloc'd ttystate containing the state
+ of the tty. */
#define SERIAL_GET_TTY_STATE(SERIAL_T) (SERIAL_T)->ops->get_tty_state((SERIAL_T))
+/* Set the state of the tty to TTYSTATE. The change is immediate.
+ When changing to or from raw mode, input might be discarded. */
#define SERIAL_SET_TTY_STATE(SERIAL_T, TTYSTATE) (SERIAL_T)->ops->set_tty_state((SERIAL_T), (TTYSTATE))
+/* printf_filtered a user-comprehensible description of ttystate. */
+#define SERIAL_PRINT_TTY_STATE(SERIAL_T, TTYSTATE) \
+ ((*((SERIAL_T)->ops->print_tty_state)) ((SERIAL_T), (TTYSTATE)))
+
+/* Set the tty state to NEW_TTYSTATE, where OLD_TTYSTATE is the
+ current state (generally obtained from a recent call to
+ SERIAL_GET_TTY_STATE), but be careful not to discard any input.
+ This means that we never switch in or out of raw mode, even
+ if NEW_TTYSTATE specifies a switch. */
+#define SERIAL_NOFLUSH_SET_TTY_STATE(SERIAL_T, NEW_TTYSTATE, OLD_TTYSTATE) \
+ ((*((SERIAL_T)->ops->noflush_set_tty_state)) \
+ ((SERIAL_T), (NEW_TTYSTATE), (OLD_TTYSTATE)))
+
/* Read one char from the serial device with TIMEOUT seconds timeout.
Returns char if ok, else one of the following codes. Note that all
error codes are guaranteed to be < 0. */
@@ -101,3 +128,21 @@ void serial_close PARAMS ((serial_t));
#define SERIAL_CLOSE(SERIAL_T) serial_close(SERIAL_T)
+/* Destroy SERIAL_T without doing the rest of the stuff that SERIAL_CLOSE
+ does. */
+
+#define SERIAL_UN_FDOPEN(SERIAL_T) (free (SERIAL_T))
+
+/* Set the process group saved in TTYSTATE to GROUP. This just modifies
+ the ttystate setting; need to call SERIAL_SET_TTY_STATE for this to
+ actually have any effect. If no job control, then don't do anything. */
+#define SERIAL_SET_PROCESS_GROUP(SERIAL_T, TTYSTATE, GROUP) \
+ ((*((SERIAL_T)->ops->set_process_group)) (SERIAL_T, TTYSTATE, GROUP))
+
+/* Do we have job control? Can be assumed to always be the same within
+ a given run of GDB. In ser-unix.c, ser-go32.c, etc. */
+extern int job_control;
+
+/* Set the process group of the caller to its own pid, or do nothing if
+ we lack job control. */
+extern int gdb_setpgid PARAMS ((void));
diff --git a/gdb/signals.h b/gdb/signals.h
index a89fc03..08fa606 100644
--- a/gdb/signals.h
+++ b/gdb/signals.h
@@ -22,13 +22,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
eliminates certain signal names when job control is not supported,
(or, on some systems, when job control is there but doesn't work
the way GDB expects it to work). */
+/* This has been superceded by the job_control variable in serial.h. */
#include <signal.h>
-
-#ifdef NO_JOB_CONTROL
-# undef SIGTSTP
-# undef SIGSTOP
-# undef SIGCONT
-# undef SIGTTIN
-# undef SIGTTOU
-#endif