aboutsummaryrefslogtreecommitdiff
path: root/gdb/serial.c
diff options
context:
space:
mode:
authorJohn Darrington <john@darrington.wattle.id.au>2018-08-29 21:51:26 +0200
committerJohn Darrington <john@darrington.wattle.id.au>2018-10-02 16:10:57 +0200
commitc1168a2f66553cd4730931cf59e3be8378a1a03f (patch)
tree51f93d65860c1b74207ab7581c1d4bc461b55758 /gdb/serial.c
parenteb528ad18b276117cb1016edbb12419819786366 (diff)
downloadgdb-c1168a2f66553cd4730931cf59e3be8378a1a03f.zip
gdb-c1168a2f66553cd4730931cf59e3be8378a1a03f.tar.gz
gdb-c1168a2f66553cd4730931cf59e3be8378a1a03f.tar.bz2
Allow remote debugging over a Unix local domain socket.
Extend the "target remote" and "target extended-remote" commands such that if the filename provided is a Unix local domain (AF_UNIX) socket, then it'll be treated as such, instead of trying to open it as if it were a character device. gdb/ChangeLog: * NEWS: Mention changed commands. * ser-uds.c: New file. * configure.ac (SER_HARDWIRE): Add ser-uds.o. * configure: Regenerate. * Makefile.in: Add new file. * serial.c (serial_open): Check if filename is a socket and lookup the appropriate interface accordingly. gdb/doc/ChangeLog: * gdb.texinfo (Remote Connection Commands): Describe the changes to target remote and target extended-remote relating to Unix domain sockets.
Diffstat (limited to 'gdb/serial.c')
-rw-r--r--gdb/serial.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/gdb/serial.c b/gdb/serial.c
index fb2b212..7f9362a 100644
--- a/gdb/serial.c
+++ b/gdb/serial.c
@@ -213,7 +213,17 @@ serial_open (const char *name)
else if (strchr (name, ':'))
ops = serial_interface_lookup ("tcp");
else
- ops = serial_interface_lookup ("hardwire");
+ {
+#ifndef USE_WIN32API
+ /* Check to see if name is a socket. If it is, then treat it
+ as such. Otherwise assume that it's a character device. */
+ struct stat sb;
+ if (stat (name, &sb) == 0 && (sb.st_mode & S_IFMT) == S_IFSOCK)
+ ops = serial_interface_lookup ("local");
+ else
+#endif
+ ops = serial_interface_lookup ("hardwire");
+ }
if (!ops)
return NULL;