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.
This commit is contained in:
John Darrington 2018-08-29 21:51:26 +02:00
parent eb528ad18b
commit c1168a2f66
9 changed files with 173 additions and 2 deletions

View file

@ -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;