From: Tom Tromey <tromey@redhat.com>
To: Roland McGrath <roland@redhat.com>
Cc: Oleg Nesterov <oleg@redhat.com>,
archer@sourceware.org, utrace-devel@redhat.com
Subject: Re: problems with v3
Date: Fri, 13 Aug 2010 04:37:00 -0000 [thread overview]
Message-ID: <m3sk2j162p.fsf@fleche.redhat.com> (raw)
In-Reply-To: <20100813015844.B7703400E3@magilla.sf.frob.com> (Roland McGrath's message of "Thu, 12 Aug 2010 18:58:44 -0700 (PDT)")
Roland> I don't really know the gdb code, but I'm surprised it really
Roland> has multiple different "serial" backends.
I don't know this area well, but considering that ser-unix.c is just
chock full of tty-related goo, I think it is probably important for
something. My impression is that this API is not just used for target
communication but also for manipulating gdb's own terminal.
I looked closer and aside from open/close, ser-pipe is just falling back
to some generic code.
I've appended the patch I came up with. I have not tried it at all, but
it should all be pretty obvious.
Maybe I'd do it a little differently if this were going upstream.
That doesn't seem necessary though.
Tom
diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c
index 266453c..672b2a8 100644
--- a/gdb/ser-unix.c
+++ b/gdb/ser-unix.c
@@ -32,6 +32,7 @@
#include "gdb_select.h"
#include "gdb_string.h"
#include "gdbcmd.h"
+#include "gdb_stat.h"
#ifdef HAVE_TERMIOS
@@ -103,15 +104,56 @@ static int hardwire_setstopbits (struct serial *, int);
void _initialize_ser_hardwire (void);
+static struct serial_ops *
+get_pipe_like_ops (void)
+{
+ static struct serial_ops *ops;
+
+ if (ops == NULL)
+ {
+ ops = XMALLOC (struct serial_ops);
+ memset (ops, 0, sizeof (struct serial_ops));
+ ops->name = NULL;
+ ops->open = NULL;
+ ops->close = hardwire_close;
+ ops->readchar = ser_base_readchar;
+ ops->write = ser_base_write;
+ ops->flush_output = ser_base_flush_output;
+ ops->flush_input = ser_base_flush_input;
+ ops->send_break = ser_base_send_break;
+ ops->go_raw = ser_base_raw;
+ ops->get_tty_state = ser_base_get_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;
+ ops->setbaudrate = ser_base_setbaudrate;
+ ops->setstopbits = ser_base_setstopbits;
+ ops->drain_output = ser_base_drain_output;
+ ops->async = ser_base_async;
+ ops->read_prim = ser_unix_read_prim;
+ ops->write_prim = ser_unix_write_prim;
+ }
+
+ return ops;
+}
+
/* Open up a real live device for serial I/O */
static int
hardwire_open (struct serial *scb, const char *name)
{
+ struct stat buf;
+
scb->fd = open (name, O_RDWR);
if (scb->fd < 0)
return -1;
+ if (fstat (scb->fd, &buf) == 0 && S_ISFIFO (buf.st_mode))
+ {
+ /* Super hack! */
+ scb->ops = get_pipe_like_ops ();
+ }
+
return 0;
}
next prev parent reply other threads:[~2010-08-13 4:37 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-12 0:01 gdbstub initial code, v3 Oleg Nesterov
2010-08-12 1:14 ` Oleg Nesterov
2010-08-12 2:40 ` Oleg Nesterov
2010-08-12 4:37 ` Tom Tromey
2010-08-12 23:55 ` problems with v3 (Was: gdbstub initial code, v3) Oleg Nesterov
2010-08-13 1:45 ` problems with v3 Tom Tromey
2010-08-13 1:59 ` Roland McGrath
2010-08-13 4:37 ` Tom Tromey [this message]
2010-08-13 8:30 ` Roland McGrath
2010-08-13 16:31 ` Tom Tromey
2010-08-13 21:15 ` Oleg Nesterov
2010-08-13 21:18 ` Tom Tromey
2010-08-13 14:08 ` Daniel Jacobowitz
2010-08-13 20:56 ` problems with v3 (Was: gdbstub initial code, v3) Oleg Nesterov
2010-08-13 21:31 ` Roland McGrath
2010-08-13 1:02 ` gdbstub initial code, v3 Roland McGrath
2010-08-12 14:52 ` Kevin Buettner
2010-08-13 0:53 ` Roland McGrath
2010-08-13 3:31 ` Kevin Buettner
2010-08-12 15:06 ` Frank Ch. Eigler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3sk2j162p.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=archer@sourceware.org \
--cc=oleg@redhat.com \
--cc=roland@redhat.com \
--cc=utrace-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).