This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb/gdb-7.10-branch] PR remote/18965: vforkdone stop reply should indicate parent PID
- From: Pedro Alves <palves at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 15 Sep 2015 17:02:30 -0000
- Subject: [binutils-gdb/gdb-7.10-branch] PR remote/18965: vforkdone stop reply should indicate parent PID
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=487bf2f7066948fffd3447a3c6dd83389a037e2d
commit 487bf2f7066948fffd3447a3c6dd83389a037e2d
Author: Pedro Alves <palves@redhat.com>
Date: Tue Sep 15 17:45:26 2015 +0100
PR remote/18965: vforkdone stop reply should indicate parent PID
The vforkdone stop reply misses indicating the thread ID of the vfork
parent which the event relates to:
@cindex vfork events, remote reply
@item vfork
The packet indicates that @code{vfork} was called, and @var{r}
is the thread ID of the new child process. Refer to
@ref{thread-id syntax} for the format of the @var{thread-id}
field. This packet is only applicable to targets that support
vfork events.
@cindex vforkdone events, remote reply
@item vforkdone
The packet indicates that a child process created by a vfork
has either called @code{exec} or terminated, so that the
address spaces of the parent and child process are no longer
shared. The @var{r} part is ignored. This packet is only
applicable to targets that support vforkdone events.
Unfortunately, this is not just a documentation issue. GDBserver
is really not specifying the thread ID. I noticed because
in non-stop mode, gdb complains:
[Thread 6089.6089] #1 stopped.
#0 0x0000003615a011f0 in ?? ()
0x0000003615a011f0 in ?? ()
(gdb) set debug remote 1
(gdb) c
Continuing.
Sending packet: $QPassSignals:e;10;14;17;1a;1b;1c;21;24;25;2c;4c;#5f...Packet received: OK
Sending packet: $vCont;c:p17c9.17c9#88...Packet received: OK
Notification received: Stop:T05vfork:p17ce.17ce;06:40d7ffffff7f0000;07:30d7ffffff7f0000;10:e4c9eb1536000000;thread:p17c9.17c9;core:2;
Sending packet: $vStopped#55...Packet received: OK
Sending packet: $D;17ce#af...Packet received: OK
Sending packet: $vCont;c:p17c9.17c9#88...Packet received: OK
Notification received: Stop:T05vforkdone:;
No process or thread specified in stop reply: T05vforkdone:;
(gdb)
This is not non-stop-mode-specific, however. Consider e.g., that in
all-stop, you may be debugging more than one process at the same time.
You continue, and both processes vfork. So when you next get a
T05vforkdone, there's no way to tell which of the parent processes is
done with the vfork.
Tests will be added later.
Tested on x86_64 Fedora 20.
gdb/gdbserver/ChangeLog:
2015-09-15 Pedro Alves <palves@redhat.com>
PR remote/18965
* remote-utils.c (prepare_resume_reply): Merge
TARGET_WAITKIND_VFORK_DONE switch case with the
TARGET_WAITKIND_FORKED case.
gdb/doc/ChangeLog:
2015-09-15 Pedro Alves <palves@redhat.com>
PR remote/18965
* gdb.texinfo (Stop Reply Packets): Explain that vforkdone's 'r'
part indicates the thread ID of the parent process.
Diff:
---
gdb/doc/ChangeLog | 6 ++++++
gdb/doc/gdb.texinfo | 11 ++++++-----
gdb/gdbserver/ChangeLog | 7 +++++++
gdb/gdbserver/remote-utils.c | 17 +++++++----------
4 files changed, 26 insertions(+), 15 deletions(-)
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index e9964aa..5cb722c 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,9 @@
+2015-09-15 Pedro Alves <palves@redhat.com>
+
+ PR remote/18965
+ * gdb.texinfo (Stop Reply Packets): Explain that vforkdone's 'r'
+ part indicates the thread ID of the parent process.
+
2015-07-20 Doug Evans <dje@google.com>
* Makefile.in (STABS_DOC_BUILD_INCLUDES): Add gdb-cfg.texi, GDBvn.texi.
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 4477048..d090224 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -35628,11 +35628,12 @@ indicating support.
@cindex vforkdone events, remote reply
@item vforkdone
-The packet indicates that a child process created by a vfork
-has either called @code{exec} or terminated, so that the
-address spaces of the parent and child process are no longer
-shared. The @var{r} part is ignored. This packet is only
-applicable to targets that support vforkdone events.
+The packet indicates that a child process created by a vfork has
+either called @code{exec} or terminated, so that the address spaces of
+the parent and child process are no longer shared. The @var{r} part
+is the thread ID of the parent process. Refer to @ref{thread-id
+syntax} for the format of the @var{thread-id} field. This packet is
+only applicable to targets that support vforkdone events.
This packet should not be sent by default; older @value{GDBN} versions
did not support it. @value{GDBN} requests it, by supplying an
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index c8bf717..05e3860 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,10 @@
+2015-09-15 Pedro Alves <palves@redhat.com>
+
+ PR remote/18965
+ * remote-utils.c (prepare_resume_reply): Merge
+ TARGET_WAITKIND_VFORK_DONE switch case with the
+ TARGET_WAITKIND_FORKED case.
+
2015-08-19 Gary Benson <gbenson@redhat.com>
* hostio.c (handle_pread): Do not attempt to read more data
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index bb31456..cee7fa5 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -1116,6 +1116,7 @@ prepare_resume_reply (char *buf, ptid_t ptid,
case TARGET_WAITKIND_STOPPED:
case TARGET_WAITKIND_FORKED:
case TARGET_WAITKIND_VFORKED:
+ case TARGET_WAITKIND_VFORK_DONE:
{
struct thread_info *saved_thread;
const char **regp;
@@ -1133,6 +1134,12 @@ prepare_resume_reply (char *buf, ptid_t ptid,
buf = write_ptid (buf, status->value.related_pid);
strcat (buf, ";");
}
+ else if (status->kind == TARGET_WAITKIND_VFORK_DONE && report_vfork_events)
+ {
+ enum gdb_signal signal = GDB_SIGNAL_TRAP;
+
+ sprintf (buf, "T%02xvforkdone:;", signal);
+ }
else
sprintf (buf, "T%02x", status->value.sig);
@@ -1248,16 +1255,6 @@ prepare_resume_reply (char *buf, ptid_t ptid,
else
sprintf (buf, "X%02x", status->value.sig);
break;
- case TARGET_WAITKIND_VFORK_DONE:
- if (report_vfork_events)
- {
- enum gdb_signal signal = GDB_SIGNAL_TRAP;
-
- sprintf (buf, "T%02xvforkdone:;", signal);
- }
- else
- sprintf (buf, "T%02x", GDB_SIGNAL_0);
- break;
default:
error ("unhandled waitkind");
break;