aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2011-03-04 19:23:42 +0000
committerUlrich Weigand <uweigand@de.ibm.com>2011-03-04 19:23:42 +0000
commit1e182ce8c375de8f86fe00198b07d0331e4c4e0d (patch)
tree0e7ec4987f47fe39ec610faff8caef45208eec64
parent2abae99411dbbced25ad99232ab329ad59578294 (diff)
downloadgdb-1e182ce8c375de8f86fe00198b07d0331e4c4e0d.zip
gdb-1e182ce8c375de8f86fe00198b07d0331e4c4e0d.tar.gz
gdb-1e182ce8c375de8f86fe00198b07d0331e4c4e0d.tar.bz2
* inflow.c (terminal_init_inferior_with_pgrp): Copy ttystate.
(terminal_save_ours): Remove misleading comment. (inflow_inferior_data_cleanup): Free ttystate. (inflow_inferior_exit): Likewise. (copy_terminal_info): Copy ttystate. * serial.c (serial_copy_tty_state): New function. * serial.h (serial_copy_tty_state): Add prototype. (struct serial_ops): Add copy_tty_state callback. * ser-base.c (ser_base_copy_tty_state): New function. * ser-base.h (ser_base_copy_tty_state): Add prototype. * ser-go32.c (dos_copy_tty_state): New function. (dos_ops): Install copy_tty_state callback. * ser-mingw.c (_initialize_ser_windows): Likewise. * ser-pipe.c (_initialize_ser_pipe): Likewise. * ser-unix.c (hardwire_copy_tty_state): New function. (_initialize_ser_hardwire): Install it.
-rw-r--r--gdb/ChangeLog20
-rw-r--r--gdb/inflow.c18
-rw-r--r--gdb/ser-base.c7
-rw-r--r--gdb/ser-base.h2
-rw-r--r--gdb/ser-go32.c12
-rw-r--r--gdb/ser-mingw.c4
-rw-r--r--gdb/ser-pipe.c1
-rw-r--r--gdb/ser-tcp.c1
-rw-r--r--gdb/ser-unix.c12
-rw-r--r--gdb/serial.c6
-rw-r--r--gdb/serial.h7
11 files changed, 85 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 12a6431..1311dc0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,23 @@
+2011-03-04 Ulrich Weigand <ulrich.weigand@linaro.org>
+
+ * inflow.c (terminal_init_inferior_with_pgrp): Copy ttystate.
+ (terminal_save_ours): Remove misleading comment.
+ (inflow_inferior_data_cleanup): Free ttystate.
+ (inflow_inferior_exit): Likewise.
+ (copy_terminal_info): Copy ttystate.
+
+ * serial.c (serial_copy_tty_state): New function.
+ * serial.h (serial_copy_tty_state): Add prototype.
+ (struct serial_ops): Add copy_tty_state callback.
+ * ser-base.c (ser_base_copy_tty_state): New function.
+ * ser-base.h (ser_base_copy_tty_state): Add prototype.
+ * ser-go32.c (dos_copy_tty_state): New function.
+ (dos_ops): Install copy_tty_state callback.
+ * ser-mingw.c (_initialize_ser_windows): Likewise.
+ * ser-pipe.c (_initialize_ser_pipe): Likewise.
+ * ser-unix.c (hardwire_copy_tty_state): New function.
+ (_initialize_ser_hardwire): Install it.
+
2011-03-04 Michael Snyder <msnyder@vmware.com>
* breakpoint.c (create_breakpoint): Add missing break statement.
diff --git a/gdb/inflow.c b/gdb/inflow.c
index 9975904..7876347 100644
--- a/gdb/inflow.c
+++ b/gdb/inflow.c
@@ -224,10 +224,9 @@ terminal_init_inferior_with_pgrp (int pgrp)
struct inferior *inf = current_inferior ();
struct terminal_info *tinfo = get_inflow_inferior_data (inf);
- /* We could just as well copy our_ttystate (if we felt like
- adding a new function serial_copy_tty_state()). */
xfree (tinfo->ttystate);
- tinfo->ttystate = serial_get_tty_state (stdin_serial);
+ tinfo->ttystate = serial_copy_tty_state (stdin_serial,
+ our_terminal_info.ttystate);
#ifdef PROCESS_GROUP_TYPE
tinfo->process_group = pgrp;
@@ -249,8 +248,6 @@ terminal_save_ours (void)
{
if (gdb_has_a_terminal ())
{
- /* We could just as well copy our_ttystate (if we felt like adding
- a new function serial_copy_tty_state). */
xfree (our_terminal_info.ttystate);
our_terminal_info.ttystate = serial_get_tty_state (stdin_serial);
}
@@ -495,6 +492,7 @@ inflow_inferior_data_cleanup (struct inferior *inf, void *arg)
if (info != NULL)
{
xfree (info->run_terminal);
+ xfree (info->ttystate);
xfree (info);
}
}
@@ -532,6 +530,7 @@ inflow_inferior_exit (struct inferior *inf)
if (info != NULL)
{
xfree (info->run_terminal);
+ xfree (info->ttystate);
xfree (info);
set_inferior_data (inf, inflow_inferior_data, NULL);
}
@@ -544,10 +543,19 @@ copy_terminal_info (struct inferior *to, struct inferior *from)
tinfo_to = get_inflow_inferior_data (to);
tinfo_from = get_inflow_inferior_data (from);
+
+ xfree (tinfo_to->run_terminal);
+ xfree (tinfo_to->ttystate);
+
*tinfo_to = *tinfo_from;
+
if (tinfo_from->run_terminal)
tinfo_to->run_terminal
= xstrdup (tinfo_from->run_terminal);
+
+ if (tinfo_from->ttystate)
+ tinfo_to->ttystate
+ = serial_copy_tty_state (stdin_serial, tinfo_from->ttystate);
}
void
diff --git a/gdb/ser-base.c b/gdb/ser-base.c
index 8f014d0..368afa6 100644
--- a/gdb/ser-base.c
+++ b/gdb/ser-base.c
@@ -463,6 +463,13 @@ ser_base_get_tty_state (struct serial *scb)
return (serial_ttystate) XMALLOC (int);
}
+serial_ttystate
+ser_base_copy_tty_state (struct serial *scb, serial_ttystate ttystate)
+{
+ /* Allocate another dummy. */
+ return (serial_ttystate) XMALLOC (int);
+}
+
int
ser_base_set_tty_state (struct serial *scb, serial_ttystate ttystate)
{
diff --git a/gdb/ser-base.h b/gdb/ser-base.h
index 6a06e04..8cbc225 100644
--- a/gdb/ser-base.h
+++ b/gdb/ser-base.h
@@ -32,6 +32,8 @@ extern int ser_base_flush_input (struct serial *scb);
extern int ser_base_send_break (struct serial *scb);
extern void ser_base_raw (struct serial *scb);
extern serial_ttystate ser_base_get_tty_state (struct serial *scb);
+extern serial_ttystate ser_base_copy_tty_state (struct serial *scb,
+ serial_ttystate ttystate);
extern int ser_base_set_tty_state (struct serial *scb,
serial_ttystate ttystate);
extern void ser_base_print_tty_state (struct serial *scb,
diff --git a/gdb/ser-go32.c b/gdb/ser-go32.c
index 44fea13..835d8e0 100644
--- a/gdb/ser-go32.c
+++ b/gdb/ser-go32.c
@@ -652,6 +652,17 @@ dos_get_tty_state (struct serial *scb)
return (serial_ttystate) state;
}
+static serial_ttystate
+dos_copy_tty_state (struct serial *scb, serial_ttystate ttystate)
+{
+ struct dos_ttystate *state;
+
+ state = (struct dos_ttystate *) xmalloc (sizeof *state);
+ *state = *(struct dos_ttystate *) ttystate;
+
+ return (serial_ttystate) state;
+}
+
static int
dos_set_tty_state (struct serial *scb, serial_ttystate ttystate)
{
@@ -851,6 +862,7 @@ static struct serial_ops dos_ops =
dos_sendbreak,
dos_raw,
dos_get_tty_state,
+ dos_copy_tty_state,
dos_set_tty_state,
dos_print_tty_state,
dos_noflush_set_tty_state,
diff --git a/gdb/ser-mingw.c b/gdb/ser-mingw.c
index 928a03b..6de3471 100644
--- a/gdb/ser-mingw.c
+++ b/gdb/ser-mingw.c
@@ -1244,6 +1244,7 @@ _initialize_ser_windows (void)
/* These are only used for stdin; we do not need them for serial
ports, so supply the standard dummies. */
ops->get_tty_state = ser_base_get_tty_state;
+ ops->copy_tty_state = ser_base_copy_tty_state;
ops->set_tty_state = ser_base_set_tty_state;
ops->print_tty_state = ser_base_print_tty_state;
ops->noflush_set_tty_state = ser_base_noflush_set_tty_state;
@@ -1272,6 +1273,7 @@ _initialize_ser_windows (void)
ops->close = ser_console_close;
ops->get_tty_state = ser_console_get_tty_state;
+ ops->copy_tty_state = ser_base_copy_tty_state;
ops->set_tty_state = ser_base_set_tty_state;
ops->print_tty_state = ser_base_print_tty_state;
ops->noflush_set_tty_state = ser_base_noflush_set_tty_state;
@@ -1297,6 +1299,7 @@ _initialize_ser_windows (void)
ops->send_break = ser_base_send_break;
ops->go_raw = ser_base_raw;
ops->get_tty_state = ser_base_get_tty_state;
+ ops->copy_tty_state = ser_base_copy_tty_state;
ops->set_tty_state = ser_base_set_tty_state;
ops->print_tty_state = ser_base_print_tty_state;
ops->noflush_set_tty_state = ser_base_noflush_set_tty_state;
@@ -1331,6 +1334,7 @@ _initialize_ser_windows (void)
ops->send_break = ser_tcp_send_break;
ops->go_raw = ser_base_raw;
ops->get_tty_state = ser_base_get_tty_state;
+ ops->copy_tty_state = ser_base_copy_tty_state;
ops->set_tty_state = ser_base_set_tty_state;
ops->print_tty_state = ser_base_print_tty_state;
ops->noflush_set_tty_state = ser_base_noflush_set_tty_state;
diff --git a/gdb/ser-pipe.c b/gdb/ser-pipe.c
index fd6650a..9bf0d04 100644
--- a/gdb/ser-pipe.c
+++ b/gdb/ser-pipe.c
@@ -214,6 +214,7 @@ _initialize_ser_pipe (void)
ops->send_break = ser_base_send_break;
ops->go_raw = ser_base_raw;
ops->get_tty_state = ser_base_get_tty_state;
+ ops->copy_tty_state = ser_base_copy_tty_state;
ops->set_tty_state = ser_base_set_tty_state;
ops->print_tty_state = ser_base_print_tty_state;
ops->noflush_set_tty_state = ser_base_noflush_set_tty_state;
diff --git a/gdb/ser-tcp.c b/gdb/ser-tcp.c
index cbf3149..e3d5640 100644
--- a/gdb/ser-tcp.c
+++ b/gdb/ser-tcp.c
@@ -390,6 +390,7 @@ _initialize_ser_tcp (void)
ops->send_break = ser_tcp_send_break;
ops->go_raw = ser_base_raw;
ops->get_tty_state = ser_base_get_tty_state;
+ ops->copy_tty_state = ser_base_copy_tty_state;
ops->set_tty_state = ser_base_set_tty_state;
ops->print_tty_state = ser_base_print_tty_state;
ops->noflush_set_tty_state = ser_base_noflush_set_tty_state;
diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c
index c213b3d..da3a4c3 100644
--- a/gdb/ser-unix.c
+++ b/gdb/ser-unix.c
@@ -188,6 +188,17 @@ hardwire_get_tty_state (struct serial *scb)
return (serial_ttystate) state;
}
+static serial_ttystate
+hardwire_copy_tty_state (struct serial *scb, serial_ttystate ttystate)
+{
+ struct hardwire_ttystate *state;
+
+ state = (struct hardwire_ttystate *) xmalloc (sizeof *state);
+ *state = *(struct hardwire_ttystate *) ttystate;
+
+ return (serial_ttystate) state;
+}
+
static int
hardwire_set_tty_state (struct serial *scb, serial_ttystate ttystate)
{
@@ -911,6 +922,7 @@ _initialize_ser_hardwire (void)
ops->send_break = hardwire_send_break;
ops->go_raw = hardwire_raw;
ops->get_tty_state = hardwire_get_tty_state;
+ ops->copy_tty_state = hardwire_copy_tty_state;
ops->set_tty_state = hardwire_set_tty_state;
ops->print_tty_state = hardwire_print_tty_state;
ops->noflush_set_tty_state = hardwire_noflush_set_tty_state;
diff --git a/gdb/serial.c b/gdb/serial.c
index 954d22a..7c8fbc2 100644
--- a/gdb/serial.c
+++ b/gdb/serial.c
@@ -493,6 +493,12 @@ serial_get_tty_state (struct serial *scb)
return scb->ops->get_tty_state (scb);
}
+serial_ttystate
+serial_copy_tty_state (struct serial *scb, serial_ttystate ttystate)
+{
+ return scb->ops->copy_tty_state (scb, ttystate);
+}
+
int
serial_set_tty_state (struct serial *scb, serial_ttystate ttystate)
{
diff --git a/gdb/serial.h b/gdb/serial.h
index 58207c7..a1eba8d 100644
--- a/gdb/serial.h
+++ b/gdb/serial.h
@@ -129,6 +129,12 @@ extern void serial_raw (struct serial *scb);
extern serial_ttystate serial_get_tty_state (struct serial *scb);
+/* Return a pointer to a newly malloc'd ttystate containing a copy
+ of the state in TTYSTATE. */
+
+extern serial_ttystate serial_copy_tty_state (struct serial *scb,
+ serial_ttystate ttystate);
+
/* Set the state of the tty to TTYSTATE. The change is immediate.
When changing to or from raw mode, input might be discarded.
Returns 0 for success, negative value for error (in which case
@@ -250,6 +256,7 @@ struct serial_ops
int (*send_break) (struct serial *);
void (*go_raw) (struct serial *);
serial_ttystate (*get_tty_state) (struct serial *);
+ serial_ttystate (*copy_tty_state) (struct serial *, serial_ttystate);
int (*set_tty_state) (struct serial *, serial_ttystate);
void (*print_tty_state) (struct serial *, serial_ttystate,
struct ui_file *);