From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: Marc Khouzam <marc.khouzam@ericsson.com>,
"'gdb-patches@sourceware.org'"
<gdb-patches@sourceware.org>
Subject: Re: [patch] [gdbserver] Do not crash on file load without inferior
Date: Fri, 04 Mar 2011 21:37:00 -0000 [thread overview]
Message-ID: <20110304213728.GA16487@host1.jankratochvil.net> (raw)
In-Reply-To: <201103042132.52768.pedro@codesourcery.com>
[-- Attachment #1: Type: text/plain, Size: 1056 bytes --]
On Fri, 04 Mar 2011 22:32:52 +0100, Pedro Alves wrote:
> On Friday 04 March 2011 21:24:51, Marc Khouzam wrote:
>
> > That sounds pretty bad.
> >
> > Any chance of getting a fix for this in the 7_2 branch?
> > Which I gather would fix the problem Jan originally reported.
> > Having to specify the 'file' before connecting to the target
> > is a regression from previous versions of GDB and I was hoping
> > not to have to special-case it in Eclipse :-)
>
> Indeed. I'll try getting to it soon if Jan doesn't. It
> should be a one liner patch to gdb.
That patch already IMO required a regression test. So far I never could do
any gdbserver regression testing as gdbserver generates multiple gigabytes of:
Remote side has terminated connection. GDBserver will reopen the connection.
Can't open socket: Too many open files.
I wrote some patches for it but I haven't yet got to posting them, the second
one IIRC does not yet work. After making gdbserver regression testable
I would like to get back to the original gdbserver problem.
Thanks,
Jan
[-- Attachment #2: p0.patch --]
[-- Type: text/plain, Size: 1637 bytes --]
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index 88ef347..dd40014 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -321,7 +321,10 @@ remote_open (char *name)
if (bind (listen_desc, (struct sockaddr *) &sockaddr, sizeof (sockaddr))
|| listen (listen_desc, 1))
- perror_with_name ("Can't bind address");
+ {
+ close (listen_desc);
+ perror_with_name ("Can't bind address");
+ }
/* If port is zero, a random port will be selected, and the
fprintf below needs to know what port was selected. */
@@ -331,7 +334,10 @@ remote_open (char *name)
if (getsockname (listen_desc,
(struct sockaddr *) &sockaddr, &len) < 0
|| len < sizeof (sockaddr))
- perror_with_name ("Can't determine port");
+ {
+ close (listen_desc);
+ perror_with_name ("Can't determine port");
+ }
port = ntohs (sockaddr.sin_port);
}
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 0ddf9de..b04a50d 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -2650,6 +2650,9 @@ main (int argc, char *argv[])
while (1)
{
+ /* Wait a moment when for example the listening port is now busy. */
+ int delay = 1;
+
noack_mode = 0;
multi_process = 0;
/* Be sure we're out of tfind mode. */
@@ -2665,7 +2668,11 @@ main (int argc, char *argv[])
write_enn (own_buf);
putpkt (own_buf);
}
+
+ if (delay)
+ sleep (1);
}
+ delay = 0;
/* Wait for events. This will return when all event sources are
removed from the event loop. */
[-- Attachment #3: p1.patch --]
[-- Type: text/plain, Size: 1608 bytes --]
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index b04a50d..76a027f 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -2312,7 +2312,8 @@ gdbserver_usage (FILE *stream)
" --debug Enable general debugging output.\n"
" --remote-debug Enable remote protocol debugging output.\n"
" --version Display version information and exit.\n"
- " --wrapper WRAPPER -- Run WRAPPER to start new programs.\n");
+ " --wrapper WRAPPER -- Run WRAPPER to start new programs.\n"
+ " --once Exit after the first connection closed.\n");
if (REPORT_BUGS_TO[0] && stream == stdout)
fprintf (stream, "Report bugs to \"%s\".\n", REPORT_BUGS_TO);
}
@@ -2536,6 +2537,8 @@ main (int argc, char *argv[])
}
}
}
+ else if (strcmp (*next_arg, "--once") == 0)
+ exit_requested = 1;
else
{
fprintf (stderr, "Unknown argument: %s\n", *next_arg);
diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp
index 3a098ae..c045c5f 100644
--- a/gdb/testsuite/lib/gdbserver-support.exp
+++ b/gdb/testsuite/lib/gdbserver-support.exp
@@ -218,10 +218,16 @@ proc gdbserver_start { options arguments } {
# Fire off the debug agent.
set gdbserver_command "$gdbserver"
+
+ # GDB client could accidentally connect to a stale server.
+ append gdbserver_command " --once"
+
if { $options != "" } {
append gdbserver_command " $options"
}
+
append gdbserver_command " :$portnum"
+
if { $arguments != "" } {
append gdbserver_command " $arguments"
}
next prev parent reply other threads:[~2011-03-04 21:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-24 12:42 Jan Kratochvil
2011-02-24 14:26 ` Pedro Alves
2011-03-04 21:25 ` Marc Khouzam
2011-03-04 21:32 ` Pedro Alves
2011-03-04 21:37 ` Jan Kratochvil [this message]
2011-03-04 22:05 ` Pedro Alves
2011-03-04 22:14 ` Michael Snyder
2011-03-05 4:11 ` Jan Kratochvil
2011-03-05 11:18 ` Pedro Alves
2011-03-05 12:19 ` Jan Kratochvil
2011-03-08 13:37 ` Pedro Alves
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=20110304213728.GA16487@host1.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=marc.khouzam@ericsson.com \
--cc=pedro@codesourcery.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