From: David Whedon <davidw@gordian.com>
To: gdb-patches@cygnus.com
Subject: Simple Contribution to gdb (fwd)
Date: Tue, 04 Aug 1998 20:07:00 -0000 [thread overview]
Message-ID: <Pine.SGI.3.96.980804200555.21254A-100000@hermes> (raw)
I sent this to bug-gdb, but perhaps this is a better place to send it.
-David
---------- Forwarded message ----------
Date: Tue, 4 Aug 1998 12:49:32 -0700 (PDT)
From: David Whedon <davidw@gordian.com>
To: bug-gdb@prep.ai.mit.edu
Subject: Simple Contribution to gdb
Gdb Maintainers,
I made some small changes to ser-tcp.c that I hope will be incorporated in
the next release of gdb. Debugging remotely over the ethernet is a whole
lot easier if UDP packets are sent rather than tcp packets since the code
on the stub side ends up being simpler. All the changes were made in
tcp_open(), in ser-tcp.c.
I changed the function so that a UDP socket will be opened if:
target remote hostname:port/udp
is entered on the command line.
Thanks for your time maintaining such a useful tool,
David Whedon
-------begin modified tcp_open() -------------
/* Open up a raw tcp socket */
static int
tcp_open(scb, name)
serial_t scb;
const char *name;
{
/*
this function has been modified to support UDP between the host and
the
remote target. UDP is specified by the command:
target remote hostname:port/udp
*/
char *port_str;
int port;
struct hostent *hostent;
struct sockaddr_in sockaddr;
int tmp;
char hostname[100];
struct protoent *protoent;
int i;
char protocol[16];
port_str = strchr (name, ':');
if (!port_str)
error ("tcp_open: No colon in host name!"); /* Shouldn't ever happen
*/
tmp = min (port_str - name, (int) sizeof hostname - 1);
strncpy (hostname, name, tmp); /* Don't want colon */
hostname[tmp] = '\000'; /* Tie off host name */
port = atoi (port_str + 1);
if(strchr (name, '/')!= NULL){
strncpy(protocol , strchr (name, '/')+1, sizeof(protocol));
if( strncmp(protocol, "udp", sizeof("udp") )){
error("tcp_open: unknown protocol");
}
}
else
strcpy(protocol, "tcp");
hostent = gethostbyname (hostname);
if (!hostent)
{
fprintf_unfiltered (gdb_stderr, "%s: unknown host\n", hostname);
errno = ENOENT;
return -1;
}
for (i = 1; i <= 15; i++)
{
if(!strcmp(protocol, "udp")){
scb->fd = socket (PF_INET, SOCK_DGRAM, 0);
if (scb->fd < 0)
return -1;
}
else { /* if(!strcmp(protocol, "tcp")); */
scb->fd = socket (PF_INET, SOCK_STREAM, 0);
if (scb->fd < 0)
return -1;
}
/* Allow rapid reuse of this port. */
tmp = 1;
setsockopt (scb->fd, SOL_SOCKET, SO_REUSEADDR, (char *)&tmp,
sizeof(tmp));
/* Enable TCP keep alive process. */
tmp = 1;
setsockopt (scb->fd, SOL_SOCKET, SO_KEEPALIVE, (char *)&tmp,
sizeof(tmp));
sockaddr.sin_family = PF_INET;
sockaddr.sin_port = htons(port);
memcpy (&sockaddr.sin_addr.s_addr, hostent->h_addr,
sizeof (struct in_addr));
if (!connect (scb->fd, (struct sockaddr *) &sockaddr,
sizeof(sockaddr)))
break;
close (scb->fd);
scb->fd = -1;
/* We retry for ECONNREFUSED because that is often a temporary condition,
which
happens when the server is being restarted. */
if (errno != ECONNREFUSED)
return -1;
sleep (1);
}
if(!strcmp(protocol, "tcp")){
protoent = getprotobyname ("tcp");
if (!protoent)
return -1;
tmp = 1;
if (setsockopt (scb->fd, protoent->p_proto, TCP_NODELAY,
(char *)&tmp, sizeof(tmp)))
return -1;
}
signal(SIGPIPE, SIG_IGN); /* If we don't do this, then GDB simply
exits
when the remote side dies. */
return 0;
}
------------end tcp_open()---------------------
reply other threads:[~1998-08-04 20:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=Pine.SGI.3.96.980804200555.21254A-100000@hermes \
--to=davidw@gordian.com \
--cc=gdb-patches@cygnus.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