aboutsummaryrefslogtreecommitdiff
path: root/gdb/serial.c
diff options
context:
space:
mode:
authorStu Grossman <grossman@cygnus>1995-06-08 22:42:36 +0000
committerStu Grossman <grossman@cygnus>1995-06-08 22:42:36 +0000
commit4887063b3ce78e39fac8a79d01fa01234ab95174 (patch)
tree0c715153cace5669953c7feca4a67d1a3d010651 /gdb/serial.c
parent311f7c4b6a19b0e4376e8985491a832cfd28a315 (diff)
downloadgdb-4887063b3ce78e39fac8a79d01fa01234ab95174.zip
gdb-4887063b3ce78e39fac8a79d01fa01234ab95174.tar.gz
gdb-4887063b3ce78e39fac8a79d01fa01234ab95174.tar.bz2
* defs.h maint.c monitor.c remote-mips.c remote.c: Add support
for `watchdog' variable. This allows the user to put an upper limit on the amount of time that GDB will wait for the target to return from a step or continue operation. This will primarily be used for the testsuite, where it is difficult to come up with a reasonable timeout for things like function calls, which can take as long as three minutes under some circumstances. If the watchdog timer expires, GDB will generate an error that looks like `Watchdog has expired.', and will detach from the target. * remote-mips.c (mips_open): Setup initial frame from target. Print it out so that user is told where the program is stopped when they attach. * remote-nrom.c: Loads of cleanups. Use serial code to open network connections. Use expect() to wait for response to download command. * ser-tcp.c (tcp_open): Retry connection if we get ECONNREFUSED. * serial.c serial.h (serial_open serial_fdopen serial_close): Allow users to open the same device multiple times. They all get to share the same serial_t. This is about the only way to have multiple active targets use the same device (for download and debug). * sparcl-tdep.c: Keep #include <unistd.h> away from GO32. * target.c: Add `targetdebug' variable. If this is non-zero, then a special target is put at the top of the target stack which will cause all calls through the target vector to have their args and results printed out.
Diffstat (limited to 'gdb/serial.c')
-rw-r--r--gdb/serial.c50
1 files changed, 48 insertions, 2 deletions
diff --git a/gdb/serial.c b/gdb/serial.c
index 631f0f3..291ff3d 100644
--- a/gdb/serial.c
+++ b/gdb/serial.c
@@ -58,6 +58,13 @@ serial_open (name)
serial_t scb;
struct serial_ops *ops;
+ for (scb = scb_base; scb; scb = scb->next)
+ if (scb->name && strcmp (scb->name, name) == 0)
+ {
+ scb->refcnt++;
+ return scb;
+ }
+
if (strcmp (name, "pc") == 0)
ops = serial_interface_lookup ("pc");
else if (strchr (name, ':'))
@@ -81,18 +88,30 @@ serial_open (name)
return NULL;
}
+ scb->name = strsave (name);
+ scb->next = scb_base;
+ scb->refcnt = 1;
+ scb_base = scb;
+
last_serial_opened = scb;
return scb;
}
serial_t
-serial_fdopen(fd)
+serial_fdopen (fd)
const int fd;
{
serial_t scb;
struct serial_ops *ops;
+ for (scb = scb_base; scb; scb = scb->next)
+ if (scb->fd == fd)
+ {
+ scb->refcnt++;
+ return scb;
+ }
+
ops = serial_interface_lookup ("hardwire");
if (!ops)
@@ -107,6 +126,11 @@ serial_fdopen(fd)
scb->fd = fd;
+ scb->name = NULL;
+ scb->next = scb_base;
+ scb->refcnt = 1;
+ scb_base = scb;
+
last_serial_opened = scb;
return scb;
@@ -116,6 +140,8 @@ void
serial_close(scb)
serial_t scb;
{
+ serial_t tmp_scb;
+
last_serial_opened = NULL;
/* This is bogus. It's not our fault if you pass us a bad scb...! Rob, you
@@ -124,7 +150,27 @@ serial_close(scb)
if (!scb)
return;
- scb->ops->close(scb);
+ scb->refcnt--;
+ if (scb->refcnt > 0)
+ return;
+
+ scb->ops->close (scb);
+
+ if (scb->name)
+ free (scb->name);
+
+ if (scb_base == scb)
+ scb_base = scb_base->next;
+ else
+ for (tmp_scb = scb_base; tmp_scb; tmp_scb = tmp_scb->next)
+ {
+ if (tmp_scb->next != scb)
+ continue;
+
+ tmp_scb->next = tmp_scb->next->next;
+ break;
+ }
+
free(scb);
}