1999-04-16 01:35:26 +00:00
|
|
|
|
/* Generic serial interface routines
|
2001-01-31 01:24:03 +00:00
|
|
|
|
|
2005-12-17 22:34:03 +00:00
|
|
|
|
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
|
2002-03-19 02:51:09 +00:00
|
|
|
|
2001, 2002 Free Software Foundation, Inc.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
This file is part of GDB.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
(at your option) any later version.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
2005-12-17 22:34:03 +00:00
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
|
Boston, MA 02110-1301, USA. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include "serial.h"
|
|
|
|
|
#include "gdb_string.h"
|
|
|
|
|
#include "gdbcmd.h"
|
|
|
|
|
|
1999-09-22 03:28:34 +00:00
|
|
|
|
extern void _initialize_serial (void);
|
1999-05-25 18:09:09 +00:00
|
|
|
|
|
1999-10-05 23:13:56 +00:00
|
|
|
|
/* Is serial being debugged? */
|
|
|
|
|
|
|
|
|
|
static int global_serial_debug_p;
|
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
/* Linked list of serial I/O handlers */
|
|
|
|
|
|
|
|
|
|
static struct serial_ops *serial_ops_list = NULL;
|
|
|
|
|
|
|
|
|
|
/* This is the last serial stream opened. Used by connect command. */
|
|
|
|
|
|
2001-07-11 17:52:32 +00:00
|
|
|
|
static struct serial *last_serial_opened = NULL;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
/* Pointer to list of scb's. */
|
|
|
|
|
|
2001-07-11 17:52:32 +00:00
|
|
|
|
static struct serial *scb_base;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
/* Non-NULL gives filename which contains a recording of the remote session,
|
|
|
|
|
suitable for playback by gdbserver. */
|
|
|
|
|
|
|
|
|
|
static char *serial_logfile = NULL;
|
2000-02-02 00:21:19 +00:00
|
|
|
|
static struct ui_file *serial_logfp = NULL;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-09-22 03:28:34 +00:00
|
|
|
|
static struct serial_ops *serial_interface_lookup (char *);
|
2000-02-02 00:21:19 +00:00
|
|
|
|
static void serial_logchar (struct ui_file *stream, int ch_type, int ch, int timeout);
|
2000-06-08 00:52:56 +00:00
|
|
|
|
static const char logbase_hex[] = "hex";
|
|
|
|
|
static const char logbase_octal[] = "octal";
|
|
|
|
|
static const char logbase_ascii[] = "ascii";
|
|
|
|
|
static const char *logbase_enums[] =
|
1999-07-07 20:19:36 +00:00
|
|
|
|
{logbase_hex, logbase_octal, logbase_ascii, NULL};
|
2000-06-08 00:52:56 +00:00
|
|
|
|
static const char *serial_logbase = logbase_ascii;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
static int serial_current_type = 0;
|
|
|
|
|
|
|
|
|
|
/* Log char CH of type CHTYPE, with TIMEOUT */
|
|
|
|
|
|
|
|
|
|
/* Define bogus char to represent a BREAK. Should be careful to choose a value
|
|
|
|
|
that can't be confused with a normal char, or an error code. */
|
|
|
|
|
#define SERIAL_BREAK 1235
|
|
|
|
|
|
|
|
|
|
static void
|
2000-02-02 00:21:19 +00:00
|
|
|
|
serial_logchar (struct ui_file *stream, int ch_type, int ch, int timeout)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
if (ch_type != serial_current_type)
|
|
|
|
|
{
|
1999-10-05 23:13:56 +00:00
|
|
|
|
fprintf_unfiltered (stream, "\n%c ", ch_type);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
serial_current_type = ch_type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (serial_logbase != logbase_ascii)
|
1999-10-05 23:13:56 +00:00
|
|
|
|
fputc_unfiltered (' ', stream);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
switch (ch)
|
|
|
|
|
{
|
|
|
|
|
case SERIAL_TIMEOUT:
|
1999-10-05 23:13:56 +00:00
|
|
|
|
fprintf_unfiltered (stream, "<Timeout: %d seconds>", timeout);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
return;
|
|
|
|
|
case SERIAL_ERROR:
|
1999-10-05 23:13:56 +00:00
|
|
|
|
fprintf_unfiltered (stream, "<Error: %s>", safe_strerror (errno));
|
1999-04-16 01:35:26 +00:00
|
|
|
|
return;
|
|
|
|
|
case SERIAL_EOF:
|
1999-10-05 23:13:56 +00:00
|
|
|
|
fputs_unfiltered ("<Eof>", stream);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
return;
|
|
|
|
|
case SERIAL_BREAK:
|
1999-10-05 23:13:56 +00:00
|
|
|
|
fputs_unfiltered ("<Break>", stream);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
return;
|
|
|
|
|
default:
|
|
|
|
|
if (serial_logbase == logbase_hex)
|
1999-10-05 23:13:56 +00:00
|
|
|
|
fprintf_unfiltered (stream, "%02x", ch & 0xff);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
else if (serial_logbase == logbase_octal)
|
1999-10-05 23:13:56 +00:00
|
|
|
|
fprintf_unfiltered (stream, "%03o", ch & 0xff);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
else
|
|
|
|
|
switch (ch)
|
|
|
|
|
{
|
1999-07-07 20:19:36 +00:00
|
|
|
|
case '\\':
|
1999-10-05 23:13:56 +00:00
|
|
|
|
fputs_unfiltered ("\\\\", stream);
|
1999-07-07 20:19:36 +00:00
|
|
|
|
break;
|
|
|
|
|
case '\b':
|
1999-10-05 23:13:56 +00:00
|
|
|
|
fputs_unfiltered ("\\b", stream);
|
1999-07-07 20:19:36 +00:00
|
|
|
|
break;
|
|
|
|
|
case '\f':
|
1999-10-05 23:13:56 +00:00
|
|
|
|
fputs_unfiltered ("\\f", stream);
|
1999-07-07 20:19:36 +00:00
|
|
|
|
break;
|
|
|
|
|
case '\n':
|
1999-10-05 23:13:56 +00:00
|
|
|
|
fputs_unfiltered ("\\n", stream);
|
1999-07-07 20:19:36 +00:00
|
|
|
|
break;
|
|
|
|
|
case '\r':
|
1999-10-05 23:13:56 +00:00
|
|
|
|
fputs_unfiltered ("\\r", stream);
|
1999-07-07 20:19:36 +00:00
|
|
|
|
break;
|
|
|
|
|
case '\t':
|
1999-10-05 23:13:56 +00:00
|
|
|
|
fputs_unfiltered ("\\t", stream);
|
1999-07-07 20:19:36 +00:00
|
|
|
|
break;
|
|
|
|
|
case '\v':
|
1999-10-05 23:13:56 +00:00
|
|
|
|
fputs_unfiltered ("\\v", stream);
|
1999-07-07 20:19:36 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
1999-10-05 23:13:56 +00:00
|
|
|
|
fprintf_unfiltered (stream, isprint (ch) ? "%c" : "\\x%02x", ch & 0xFF);
|
1999-07-07 20:19:36 +00:00
|
|
|
|
break;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
1999-09-22 03:28:34 +00:00
|
|
|
|
serial_log_command (const char *cmd)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
if (!serial_logfp)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
serial_current_type = 'c';
|
|
|
|
|
|
|
|
|
|
fputs_unfiltered ("\nc ", serial_logfp);
|
|
|
|
|
fputs_unfiltered (cmd, serial_logfp);
|
|
|
|
|
|
|
|
|
|
/* Make sure that the log file is as up-to-date as possible,
|
|
|
|
|
in case we are getting ready to dump core or something. */
|
|
|
|
|
gdb_flush (serial_logfp);
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-22 03:28:34 +00:00
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
static struct serial_ops *
|
1999-09-22 03:28:34 +00:00
|
|
|
|
serial_interface_lookup (char *name)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
struct serial_ops *ops;
|
|
|
|
|
|
|
|
|
|
for (ops = serial_ops_list; ops; ops = ops->next)
|
|
|
|
|
if (strcmp (name, ops->name) == 0)
|
|
|
|
|
return ops;
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
1999-09-22 03:28:34 +00:00
|
|
|
|
serial_add_interface (struct serial_ops *optable)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
optable->next = serial_ops_list;
|
|
|
|
|
serial_ops_list = optable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Open up a device or a network socket, depending upon the syntax of NAME. */
|
|
|
|
|
|
2001-07-11 17:52:32 +00:00
|
|
|
|
struct serial *
|
1999-09-22 03:28:34 +00:00
|
|
|
|
serial_open (const char *name)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2001-07-11 17:52:32 +00:00
|
|
|
|
struct serial *scb;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
struct serial_ops *ops;
|
1999-09-22 03:28:34 +00:00
|
|
|
|
const char *open_name = name;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
for (scb = scb_base; scb; scb = scb->next)
|
|
|
|
|
if (scb->name && strcmp (scb->name, name) == 0)
|
|
|
|
|
{
|
|
|
|
|
scb->refcnt++;
|
|
|
|
|
return scb;
|
|
|
|
|
}
|
|
|
|
|
|
2002-02-24 03:59:50 +00:00
|
|
|
|
if (strcmp (name, "pc") == 0)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
ops = serial_interface_lookup ("pc");
|
|
|
|
|
else if (strchr (name, ':'))
|
|
|
|
|
ops = serial_interface_lookup ("tcp");
|
|
|
|
|
else if (strncmp (name, "lpt", 3) == 0)
|
|
|
|
|
ops = serial_interface_lookup ("parallel");
|
1999-07-12 11:15:22 +00:00
|
|
|
|
else if (strncmp (name, "|", 1) == 0)
|
1999-09-22 03:28:34 +00:00
|
|
|
|
{
|
|
|
|
|
ops = serial_interface_lookup ("pipe");
|
|
|
|
|
open_name = name + 1; /* discard ``|'' */
|
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
else
|
|
|
|
|
ops = serial_interface_lookup ("hardwire");
|
|
|
|
|
|
|
|
|
|
if (!ops)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2001-07-09 14:38:49 +00:00
|
|
|
|
scb = XMALLOC (struct serial);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
scb->ops = ops;
|
|
|
|
|
|
|
|
|
|
scb->bufcnt = 0;
|
|
|
|
|
scb->bufp = scb->buf;
|
|
|
|
|
|
1999-09-22 03:28:34 +00:00
|
|
|
|
if (scb->ops->open (scb, open_name))
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2000-12-15 01:01:51 +00:00
|
|
|
|
xfree (scb);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2001-01-31 01:24:03 +00:00
|
|
|
|
scb->name = xstrdup (name);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
scb->next = scb_base;
|
|
|
|
|
scb->refcnt = 1;
|
1999-10-05 23:13:56 +00:00
|
|
|
|
scb->debug_p = 0;
|
|
|
|
|
scb->async_state = 0;
|
1999-09-22 03:28:34 +00:00
|
|
|
|
scb->async_handler = NULL;
|
|
|
|
|
scb->async_context = NULL;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
scb_base = scb;
|
|
|
|
|
|
|
|
|
|
last_serial_opened = scb;
|
|
|
|
|
|
|
|
|
|
if (serial_logfile != NULL)
|
|
|
|
|
{
|
|
|
|
|
serial_logfp = gdb_fopen (serial_logfile, "w");
|
|
|
|
|
if (serial_logfp == NULL)
|
|
|
|
|
perror_with_name (serial_logfile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return scb;
|
|
|
|
|
}
|
|
|
|
|
|
2001-07-11 17:52:32 +00:00
|
|
|
|
struct serial *
|
1999-09-22 03:28:34 +00:00
|
|
|
|
serial_fdopen (const int fd)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2001-07-11 17:52:32 +00:00
|
|
|
|
struct serial *scb;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
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)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2001-07-09 14:38:49 +00:00
|
|
|
|
scb = XMALLOC (struct serial);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
scb->ops = ops;
|
|
|
|
|
|
|
|
|
|
scb->bufcnt = 0;
|
|
|
|
|
scb->bufp = scb->buf;
|
|
|
|
|
|
|
|
|
|
scb->fd = fd;
|
|
|
|
|
|
|
|
|
|
scb->name = NULL;
|
|
|
|
|
scb->next = scb_base;
|
|
|
|
|
scb->refcnt = 1;
|
1999-10-05 23:13:56 +00:00
|
|
|
|
scb->debug_p = 0;
|
|
|
|
|
scb->async_state = 0;
|
1999-09-22 03:28:34 +00:00
|
|
|
|
scb->async_handler = NULL;
|
|
|
|
|
scb->async_context = NULL;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
scb_base = scb;
|
|
|
|
|
|
|
|
|
|
last_serial_opened = scb;
|
|
|
|
|
|
|
|
|
|
return scb;
|
|
|
|
|
}
|
|
|
|
|
|
1999-09-22 03:28:34 +00:00
|
|
|
|
static void
|
2001-07-11 17:52:32 +00:00
|
|
|
|
do_serial_close (struct serial *scb, int really_close)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2001-07-11 17:52:32 +00:00
|
|
|
|
struct serial *tmp_scb;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
last_serial_opened = NULL;
|
|
|
|
|
|
|
|
|
|
if (serial_logfp)
|
|
|
|
|
{
|
|
|
|
|
fputs_unfiltered ("\nEnd of log\n", serial_logfp);
|
|
|
|
|
serial_current_type = 0;
|
|
|
|
|
|
|
|
|
|
/* XXX - What if serial_logfp == gdb_stdout or gdb_stderr? */
|
2000-02-02 00:21:19 +00:00
|
|
|
|
ui_file_delete (serial_logfp);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
serial_logfp = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This is bogus. It's not our fault if you pass us a bad scb...! Rob, you
|
|
|
|
|
should fix your code instead. */
|
|
|
|
|
|
|
|
|
|
if (!scb)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
scb->refcnt--;
|
|
|
|
|
if (scb->refcnt > 0)
|
|
|
|
|
return;
|
|
|
|
|
|
1999-09-22 03:28:34 +00:00
|
|
|
|
/* ensure that the FD has been taken out of async mode */
|
|
|
|
|
if (scb->async_handler != NULL)
|
|
|
|
|
serial_async (scb, NULL, NULL);
|
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
if (really_close)
|
|
|
|
|
scb->ops->close (scb);
|
|
|
|
|
|
|
|
|
|
if (scb->name)
|
2000-12-15 01:01:51 +00:00
|
|
|
|
xfree (scb->name);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2000-12-15 01:01:51 +00:00
|
|
|
|
xfree (scb);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-09-22 03:28:34 +00:00
|
|
|
|
void
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_close (struct serial *scb)
|
1999-09-22 03:28:34 +00:00
|
|
|
|
{
|
|
|
|
|
do_serial_close (scb, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_un_fdopen (struct serial *scb)
|
1999-09-22 03:28:34 +00:00
|
|
|
|
{
|
|
|
|
|
do_serial_close (scb, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_readchar (struct serial *scb, int timeout)
|
1999-09-22 03:28:34 +00:00
|
|
|
|
{
|
|
|
|
|
int ch;
|
|
|
|
|
|
1999-10-12 04:37:53 +00:00
|
|
|
|
/* FIXME: cagney/1999-10-11: Don't enable this check until the ASYNC
|
|
|
|
|
code is finished. */
|
2001-07-15 20:34:14 +00:00
|
|
|
|
if (0 && serial_is_async_p (scb) && timeout < 0)
|
2001-02-08 06:03:54 +00:00
|
|
|
|
internal_error (__FILE__, __LINE__,
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-11 18:13:55 +00:00
|
|
|
|
_("serial_readchar: blocking read in async mode"));
|
1999-10-12 04:37:53 +00:00
|
|
|
|
|
1999-09-22 03:28:34 +00:00
|
|
|
|
ch = scb->ops->readchar (scb, timeout);
|
|
|
|
|
if (serial_logfp != NULL)
|
|
|
|
|
{
|
1999-10-05 23:13:56 +00:00
|
|
|
|
serial_logchar (serial_logfp, 'r', ch, timeout);
|
1999-09-22 03:28:34 +00:00
|
|
|
|
|
|
|
|
|
/* Make sure that the log file is as up-to-date as possible,
|
|
|
|
|
in case we are getting ready to dump core or something. */
|
|
|
|
|
gdb_flush (serial_logfp);
|
|
|
|
|
}
|
2001-07-15 20:34:14 +00:00
|
|
|
|
if (serial_debug_p (scb))
|
1999-10-05 23:13:56 +00:00
|
|
|
|
{
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "[");
|
|
|
|
|
serial_logchar (gdb_stdlog, 'r', ch, timeout);
|
|
|
|
|
fprintf_unfiltered (gdb_stdlog, "]");
|
|
|
|
|
gdb_flush (gdb_stdlog);
|
|
|
|
|
}
|
1999-09-22 03:28:34 +00:00
|
|
|
|
|
|
|
|
|
return (ch);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_write (struct serial *scb, const char *str, int len)
|
1999-09-22 03:28:34 +00:00
|
|
|
|
{
|
|
|
|
|
if (serial_logfp != NULL)
|
|
|
|
|
{
|
|
|
|
|
int count;
|
|
|
|
|
|
|
|
|
|
for (count = 0; count < len; count++)
|
1999-10-05 23:13:56 +00:00
|
|
|
|
serial_logchar (serial_logfp, 'w', str[count] & 0xff, 0);
|
1999-09-22 03:28:34 +00:00
|
|
|
|
|
|
|
|
|
/* Make sure that the log file is as up-to-date as possible,
|
|
|
|
|
in case we are getting ready to dump core or something. */
|
|
|
|
|
gdb_flush (serial_logfp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (scb->ops->write (scb, str, len));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_printf (struct serial *desc, const char *format,...)
|
1999-09-22 03:28:34 +00:00
|
|
|
|
{
|
|
|
|
|
va_list args;
|
|
|
|
|
char *buf;
|
|
|
|
|
va_start (args, format);
|
|
|
|
|
|
2004-06-29 14:57:39 +00:00
|
|
|
|
buf = xstrvprintf (format, args);
|
2001-07-15 20:34:14 +00:00
|
|
|
|
serial_write (desc, buf, strlen (buf));
|
1999-09-22 03:28:34 +00:00
|
|
|
|
|
2000-12-15 01:01:51 +00:00
|
|
|
|
xfree (buf);
|
1999-09-22 03:28:34 +00:00
|
|
|
|
va_end (args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_drain_output (struct serial *scb)
|
1999-09-22 03:28:34 +00:00
|
|
|
|
{
|
|
|
|
|
return scb->ops->drain_output (scb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_flush_output (struct serial *scb)
|
1999-09-22 03:28:34 +00:00
|
|
|
|
{
|
|
|
|
|
return scb->ops->flush_output (scb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_flush_input (struct serial *scb)
|
1999-09-22 03:28:34 +00:00
|
|
|
|
{
|
|
|
|
|
return scb->ops->flush_input (scb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_send_break (struct serial *scb)
|
1999-09-22 03:28:34 +00:00
|
|
|
|
{
|
|
|
|
|
if (serial_logfp != NULL)
|
1999-10-05 23:13:56 +00:00
|
|
|
|
serial_logchar (serial_logfp, 'w', SERIAL_BREAK, 0);
|
1999-09-22 03:28:34 +00:00
|
|
|
|
|
|
|
|
|
return (scb->ops->send_break (scb));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_raw (struct serial *scb)
|
1999-09-22 03:28:34 +00:00
|
|
|
|
{
|
|
|
|
|
scb->ops->go_raw (scb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
serial_ttystate
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_get_tty_state (struct serial *scb)
|
1999-09-22 03:28:34 +00:00
|
|
|
|
{
|
|
|
|
|
return scb->ops->get_tty_state (scb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_set_tty_state (struct serial *scb, serial_ttystate ttystate)
|
1999-09-22 03:28:34 +00:00
|
|
|
|
{
|
|
|
|
|
return scb->ops->set_tty_state (scb, ttystate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_print_tty_state (struct serial *scb,
|
1999-09-22 03:28:34 +00:00
|
|
|
|
serial_ttystate ttystate,
|
2000-02-02 00:21:19 +00:00
|
|
|
|
struct ui_file *stream)
|
1999-09-22 03:28:34 +00:00
|
|
|
|
{
|
|
|
|
|
scb->ops->print_tty_state (scb, ttystate, stream);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_noflush_set_tty_state (struct serial *scb,
|
1999-09-22 03:28:34 +00:00
|
|
|
|
serial_ttystate new_ttystate,
|
|
|
|
|
serial_ttystate old_ttystate)
|
|
|
|
|
{
|
|
|
|
|
return scb->ops->noflush_set_tty_state (scb, new_ttystate, old_ttystate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_setbaudrate (struct serial *scb, int rate)
|
1999-09-22 03:28:34 +00:00
|
|
|
|
{
|
|
|
|
|
return scb->ops->setbaudrate (scb, rate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_setstopbits (struct serial *scb, int num)
|
1999-09-22 03:28:34 +00:00
|
|
|
|
{
|
|
|
|
|
return scb->ops->setstopbits (scb, num);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_can_async_p (struct serial *scb)
|
1999-09-22 03:28:34 +00:00
|
|
|
|
{
|
|
|
|
|
return (scb->ops->async != NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_is_async_p (struct serial *scb)
|
1999-09-22 03:28:34 +00:00
|
|
|
|
{
|
|
|
|
|
return (scb->ops->async != NULL) && (scb->async_handler != NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_async (struct serial *scb,
|
1999-09-22 03:28:34 +00:00
|
|
|
|
serial_event_ftype *handler,
|
|
|
|
|
void *context)
|
|
|
|
|
{
|
|
|
|
|
/* Only change mode if there is a need. */
|
|
|
|
|
if ((scb->async_handler == NULL)
|
|
|
|
|
!= (handler == NULL))
|
|
|
|
|
scb->ops->async (scb, handler != NULL);
|
|
|
|
|
scb->async_handler = handler;
|
|
|
|
|
scb->async_context = context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-07-11 17:52:32 +00:00
|
|
|
|
deprecated_serial_fd (struct serial *scb)
|
1999-09-22 03:28:34 +00:00
|
|
|
|
{
|
|
|
|
|
/* FIXME: should this output a warning that deprecated code is being
|
|
|
|
|
called? */
|
|
|
|
|
if (scb->fd < 0)
|
|
|
|
|
{
|
2001-02-08 06:03:54 +00:00
|
|
|
|
internal_error (__FILE__, __LINE__,
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-11 18:13:55 +00:00
|
|
|
|
_("serial: FD not valid"));
|
1999-09-22 03:28:34 +00:00
|
|
|
|
}
|
|
|
|
|
return scb->fd; /* sigh */
|
|
|
|
|
}
|
|
|
|
|
|
1999-10-05 23:13:56 +00:00
|
|
|
|
void
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_debug (struct serial *scb, int debug_p)
|
1999-10-05 23:13:56 +00:00
|
|
|
|
{
|
|
|
|
|
scb->debug_p = debug_p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2001-07-11 17:52:32 +00:00
|
|
|
|
serial_debug_p (struct serial *scb)
|
1999-10-05 23:13:56 +00:00
|
|
|
|
{
|
|
|
|
|
return scb->debug_p || global_serial_debug_p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#if 0
|
2001-07-11 17:52:32 +00:00
|
|
|
|
/* The connect command is #if 0 because I hadn't thought of an elegant
|
|
|
|
|
way to wait for I/O on two `struct serial *'s simultaneously. Two
|
|
|
|
|
solutions came to mind:
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
1) Fork, and have have one fork handle the to user direction,
|
|
|
|
|
and have the other hand the to target direction. This
|
|
|
|
|
obviously won't cut it for MSDOS.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
2) Use something like select. This assumes that stdin and
|
|
|
|
|
the target side can both be waited on via the same
|
|
|
|
|
mechanism. This may not be true for DOS, if GDB is
|
|
|
|
|
talking to the target via a TCP socket.
|
2001-07-11 17:52:32 +00:00
|
|
|
|
-grossman, 8 Jun 93 */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
/* Connect the user directly to the remote system. This command acts just like
|
|
|
|
|
the 'cu' or 'tip' command. Use <CR>~. or <CR>~^D to break out. */
|
|
|
|
|
|
2001-07-11 17:52:32 +00:00
|
|
|
|
static struct serial *tty_desc; /* Controlling terminal */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
static void
|
1999-09-22 03:28:34 +00:00
|
|
|
|
cleanup_tty (serial_ttystate ttystate)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
printf_unfiltered ("\r\n[Exiting connect mode]\r\n");
|
2001-07-15 20:34:14 +00:00
|
|
|
|
serial_set_tty_state (tty_desc, ttystate);
|
2000-12-15 01:01:51 +00:00
|
|
|
|
xfree (ttystate);
|
2001-07-15 20:34:14 +00:00
|
|
|
|
serial_close (tty_desc);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
1999-09-22 03:28:34 +00:00
|
|
|
|
connect_command (char *args, int fromtty)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
int c;
|
|
|
|
|
char cur_esc = 0;
|
|
|
|
|
serial_ttystate ttystate;
|
2001-07-11 17:52:32 +00:00
|
|
|
|
struct serial *port_desc; /* TTY port */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
dont_repeat ();
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
if (args)
|
1999-07-07 20:19:36 +00:00
|
|
|
|
fprintf_unfiltered (gdb_stderr, "This command takes no args. They have been ignored.\n");
|
|
|
|
|
|
|
|
|
|
printf_unfiltered ("[Entering connect mode. Use ~. or ~^D to escape]\n");
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2001-07-15 20:34:14 +00:00
|
|
|
|
tty_desc = serial_fdopen (0);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
port_desc = last_serial_opened;
|
|
|
|
|
|
2001-07-15 20:34:14 +00:00
|
|
|
|
ttystate = serial_get_tty_state (tty_desc);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2001-07-15 20:34:14 +00:00
|
|
|
|
serial_raw (tty_desc);
|
|
|
|
|
serial_raw (port_desc);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
make_cleanup (cleanup_tty, ttystate);
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
int mask;
|
|
|
|
|
|
2001-07-15 20:34:14 +00:00
|
|
|
|
mask = serial_wait_2 (tty_desc, port_desc, -1);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
if (mask & 2)
|
|
|
|
|
{ /* tty input */
|
|
|
|
|
char cx;
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
2001-07-15 20:34:14 +00:00
|
|
|
|
c = serial_readchar (tty_desc, 0);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
if (c == SERIAL_TIMEOUT)
|
1999-07-07 20:19:36 +00:00
|
|
|
|
break;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
if (c < 0)
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-11 18:13:55 +00:00
|
|
|
|
perror_with_name (_("connect"));
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
cx = c;
|
2001-07-15 20:34:14 +00:00
|
|
|
|
serial_write (port_desc, &cx, 1);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
switch (cur_esc)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
if (c == '\r')
|
|
|
|
|
cur_esc = c;
|
|
|
|
|
break;
|
|
|
|
|
case '\r':
|
|
|
|
|
if (c == '~')
|
|
|
|
|
cur_esc = c;
|
|
|
|
|
else
|
|
|
|
|
cur_esc = 0;
|
|
|
|
|
break;
|
|
|
|
|
case '~':
|
|
|
|
|
if (c == '.' || c == '\004')
|
|
|
|
|
return;
|
|
|
|
|
else
|
|
|
|
|
cur_esc = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mask & 1)
|
|
|
|
|
{ /* Port input */
|
|
|
|
|
char cx;
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
2001-07-15 20:34:14 +00:00
|
|
|
|
c = serial_readchar (port_desc, 0);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
if (c == SERIAL_TIMEOUT)
|
1999-07-07 20:19:36 +00:00
|
|
|
|
break;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
if (c < 0)
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-11 18:13:55 +00:00
|
|
|
|
perror_with_name (_("connect"));
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
cx = c;
|
|
|
|
|
|
2001-07-15 20:34:14 +00:00
|
|
|
|
serial_write (tty_desc, &cx, 1);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif /* 0 */
|
|
|
|
|
|
2001-09-26 23:27:39 +00:00
|
|
|
|
/* Serial set/show framework. */
|
|
|
|
|
|
|
|
|
|
static struct cmd_list_element *serial_set_cmdlist;
|
|
|
|
|
static struct cmd_list_element *serial_show_cmdlist;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
serial_set_cmd (char *args, int from_tty)
|
|
|
|
|
{
|
|
|
|
|
printf_unfiltered ("\"set serial\" must be followed by the name of a command.\n");
|
|
|
|
|
help_list (serial_set_cmdlist, "set serial ", -1, gdb_stdout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
serial_show_cmd (char *args, int from_tty)
|
|
|
|
|
{
|
|
|
|
|
cmd_show_list (serial_show_cmdlist, from_tty, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
void
|
1999-09-22 03:28:34 +00:00
|
|
|
|
_initialize_serial (void)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
#if 0
|
2005-02-15 Andrew Cagney <cagney@gnu.org>
Mark up add_com, add_info and add_prefix_cmd.
* breakpoint.c, cp-support.c, dcache.c, dwarf2read.c: Update.
* exec.c, f-valprint.c, frame.c, gcore.c, gnu-nat.c: Update.
* go32-nat.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* kod.c, language.c, linux-nat.c, m32r-rom.c, macrocmd.c: Update.
* maint.c, memattr.c, mips-tdep.c, nto-procfs.c, objc-lang.c: Update.
* ocd.c, pa64solib.c, printcmd.c, procfs.c, regcache.c: Update.
* remote-e7000.c, remote-m32r-sdi.c, remote-mips.c: Update.
* remote-sds.c, remote-sim.c, remote-st.c, remote-utils.c: Update.
* remote.c, rs6000-tdep.c, ser-go32.c, serial.c: Update.
* sh-tdep.c, solib.c, somsolib.c, source.c, stack.c: Update.
* symfile.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, typeprint.c, utils.c, valprint.c: Update.
* win32-nat.c, xcoffsolib.c, cli/cli-cmds.c, cli/cli-dump.c: Update.
* cli/cli-logging.c, tui/tui-layout.c, tui/tui-regs.c: Update.
* tui/tui-stack.c, tui/tui-win.c: Update.
2005-02-15 15:49:28 +00:00
|
|
|
|
add_com ("connect", class_obscure, connect_command, _("\
|
|
|
|
|
Connect the terminal directly up to the command monitor.\n\
|
|
|
|
|
Use <CR>~. or <CR>~^D to break out."));
|
1999-04-16 01:35:26 +00:00
|
|
|
|
#endif /* 0 */
|
|
|
|
|
|
2005-02-15 Andrew Cagney <cagney@gnu.org>
Mark up add_com, add_info and add_prefix_cmd.
* breakpoint.c, cp-support.c, dcache.c, dwarf2read.c: Update.
* exec.c, f-valprint.c, frame.c, gcore.c, gnu-nat.c: Update.
* go32-nat.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* kod.c, language.c, linux-nat.c, m32r-rom.c, macrocmd.c: Update.
* maint.c, memattr.c, mips-tdep.c, nto-procfs.c, objc-lang.c: Update.
* ocd.c, pa64solib.c, printcmd.c, procfs.c, regcache.c: Update.
* remote-e7000.c, remote-m32r-sdi.c, remote-mips.c: Update.
* remote-sds.c, remote-sim.c, remote-st.c, remote-utils.c: Update.
* remote.c, rs6000-tdep.c, ser-go32.c, serial.c: Update.
* sh-tdep.c, solib.c, somsolib.c, source.c, stack.c: Update.
* symfile.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, typeprint.c, utils.c, valprint.c: Update.
* win32-nat.c, xcoffsolib.c, cli/cli-cmds.c, cli/cli-dump.c: Update.
* cli/cli-logging.c, tui/tui-layout.c, tui/tui-regs.c: Update.
* tui/tui-stack.c, tui/tui-win.c: Update.
2005-02-15 15:49:28 +00:00
|
|
|
|
add_prefix_cmd ("serial", class_maintenance, serial_set_cmd, _("\
|
|
|
|
|
Set default serial/parallel port configuration."),
|
2001-09-26 23:27:39 +00:00
|
|
|
|
&serial_set_cmdlist, "set serial ",
|
|
|
|
|
0/*allow-unknown*/,
|
|
|
|
|
&setlist);
|
|
|
|
|
|
2005-02-15 Andrew Cagney <cagney@gnu.org>
Mark up add_com, add_info and add_prefix_cmd.
* breakpoint.c, cp-support.c, dcache.c, dwarf2read.c: Update.
* exec.c, f-valprint.c, frame.c, gcore.c, gnu-nat.c: Update.
* go32-nat.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* kod.c, language.c, linux-nat.c, m32r-rom.c, macrocmd.c: Update.
* maint.c, memattr.c, mips-tdep.c, nto-procfs.c, objc-lang.c: Update.
* ocd.c, pa64solib.c, printcmd.c, procfs.c, regcache.c: Update.
* remote-e7000.c, remote-m32r-sdi.c, remote-mips.c: Update.
* remote-sds.c, remote-sim.c, remote-st.c, remote-utils.c: Update.
* remote.c, rs6000-tdep.c, ser-go32.c, serial.c: Update.
* sh-tdep.c, solib.c, somsolib.c, source.c, stack.c: Update.
* symfile.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, typeprint.c, utils.c, valprint.c: Update.
* win32-nat.c, xcoffsolib.c, cli/cli-cmds.c, cli/cli-dump.c: Update.
* cli/cli-logging.c, tui/tui-layout.c, tui/tui-regs.c: Update.
* tui/tui-stack.c, tui/tui-win.c: Update.
2005-02-15 15:49:28 +00:00
|
|
|
|
add_prefix_cmd ("serial", class_maintenance, serial_show_cmd, _("\
|
|
|
|
|
Show default serial/parallel port configuration."),
|
2001-09-26 23:27:39 +00:00
|
|
|
|
&serial_show_cmdlist, "show serial ",
|
|
|
|
|
0/*allow-unknown*/,
|
|
|
|
|
&showlist);
|
|
|
|
|
|
2005-02-17 17:11:04 +00:00
|
|
|
|
add_setshow_filename_cmd ("remotelogfile", no_class, &serial_logfile, _("\
|
|
|
|
|
Set filename for remote session recording."), _("\
|
|
|
|
|
Show filename for remote session recording."), _("\
|
1999-04-16 01:35:26 +00:00
|
|
|
|
This file is used to record the remote session for future playback\n\
|
2005-02-17 17:11:04 +00:00
|
|
|
|
by gdbserver."),
|
|
|
|
|
NULL,
|
|
|
|
|
NULL, /* FIXME: i18n: */
|
|
|
|
|
&setlist, &showlist);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2005-02-21 04:31:59 +00:00
|
|
|
|
add_setshow_enum_cmd ("remotelogbase", no_class, logbase_enums,
|
|
|
|
|
&serial_logbase, _("\
|
|
|
|
|
Set numerical base for remote session logging"), _("\
|
|
|
|
|
Show numerical base for remote session logging"), NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
NULL, /* FIXME: i18n: */
|
|
|
|
|
&setlist, &showlist);
|
1999-10-05 23:13:56 +00:00
|
|
|
|
|
2005-02-18 Andrew Cagney <cagney@gnu.org>
Use add_setshow_zinteger_cmd through out. Re-sync gdbarch.sh
and gdbarch.c.
* breakpoint.c, frame.c, gdb-events.sh, gdbarch.sh: Update.
* gdbtypes.c, infrun.c, linux-nat.c, maint.c, monitor.c: Update.
* pa64solib.c, parse.c, remote-mips.c, ser-go32.c: Update.
* serial.c, solib-frv.c, somsolib.c, target.c, top.c: Update.
* varobj.c, cli/cli-cmds.c: Update.
* gdbarch.c, gdb-events.c: Regenerate.
2005-02-18 18:58:56 +00:00
|
|
|
|
add_setshow_zinteger_cmd ("serial", class_maintenance,
|
|
|
|
|
&global_serial_debug_p, _("\
|
|
|
|
|
Set serial debugging."), _("\
|
|
|
|
|
Show serial debugging."), _("\
|
|
|
|
|
When non-zero, serial port debugging is enabled."),
|
|
|
|
|
NULL,
|
|
|
|
|
NULL, /* FIXME: i18n: */
|
|
|
|
|
&setdebuglist, &showdebuglist);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
}
|