summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2010-07-07 16:14:04 +0000
committerJoel Brobecker <brobecker@gnat.com>2010-07-07 16:14:04 +0000
commit6bd31874685a739404578403651d7b1ad5d20a3e (patch)
tree547eace37b15788ae0840c2d945110e5301a62f0
parent2f2241f14651e177f430128c5d22755628a7d91d (diff)
downloadbinutils-gdb-6bd31874685a739404578403651d7b1ad5d20a3e.tar.gz
[PATCH] Unexpected EOF read from connection with GDB after inferior exits.
This is on GNU/Linux. GDBserver does not exit properly when the inferior exits, as demonstrated with any program using the procedure below: % gdbserver-head :4444 simple_main Process simple_main created; pid = 25681 Listening on port 4444 Then, in another terminal, start GDB, connect to GDBserver, and run the program to completion: % gdb-head simple_main (gdb) tar rem :4444 (gdb) cont Continuing. Program exited normally. Going back to the terminal where GDBserver is running, we see the following output: Child exited with status 0 readchar: Got EOF Remote side has terminated connection. GDBserver will reopen the connection. Listening on port 4444 The problem is that we're missing a call to mourn_inferior. As a result, after we've handled the vCont packet, we fail to notice that there are no process left to debug (target_running() returns true), and thus try to continue reading from the remote socket. However, since GDB just disconnected after having received the "exit with status 0" reply to the vCont request, the read triggers the EOF exception. gdb/gdbserver/ChangeLog: * server.c (handle_v_cont): Call mourn_inferior if process just exited. (myresume): Likewise.
-rw-r--r--gdb/gdbserver/ChangeLog6
-rw-r--r--gdb/gdbserver/server.c8
2 files changed, 14 insertions, 0 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 531bc6c8c00..8f50ce01e94 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,9 @@
+2010-07-07 Joel Brobecker <brobecker@adacore.com>
+
+ * server.c (handle_v_cont): Call mourn_inferior if process
+ just exited.
+ (myresume): Likewise.
+
2010-07-01 Pedro Alves <pedro@codesourcery.com>
Static tracepoints, and integration with UST.
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 226d123e56e..9125f0ef60f 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -1779,6 +1779,10 @@ handle_v_cont (char *own_buf)
last_ptid = mywait (minus_one_ptid, &last_status, 0, 1);
prepare_resume_reply (own_buf, last_ptid, &last_status);
disable_async_io ();
+
+ if (last_status.kind == TARGET_WAITKIND_EXITED
+ || last_status.kind == TARGET_WAITKIND_SIGNALLED)
+ mourn_inferior (find_process_pid (ptid_get_pid (last_ptid)));
}
return;
@@ -2079,6 +2083,10 @@ myresume (char *own_buf, int step, int sig)
last_ptid = mywait (minus_one_ptid, &last_status, 0, 1);
prepare_resume_reply (own_buf, last_ptid, &last_status);
disable_async_io ();
+
+ if (last_status.kind == TARGET_WAITKIND_EXITED
+ || last_status.kind == TARGET_WAITKIND_SIGNALLED)
+ mourn_inferior (find_process_pid (ptid_get_pid (last_ptid)));
}
}