Bug 18965 - new vforkdone stop reply should indicate parent process ID
Summary: new vforkdone stop reply should indicate parent process ID
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: remote (show other bugs)
Version: 7.10
: P2 normal
Target Milestone: 7.10
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-15 16:10 UTC by Pedro Alves
Modified: 2021-10-21 06:50 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pedro Alves 2015-09-15 16:10:19 UTC
The new vforkdone stop reply misses indicating the thread ID of the vfork parent which the event relates to:

Note:

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

vs:

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

Unfortunately, this is not just a documentation issue.  GDBserver
is really not specifying the thread ID.  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 if you next
a T05vforkdone, there's no way to tell which of the parent processes
is done with the vfork.
Comment 1 Sourceware Commits 2015-09-15 16:33:35 UTC
The master branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8228463cbca8d629572dbad99286c4e05886350b

commit 8228463cbca8d629572dbad99286c4e05886350b
Author: Pedro Alves <palves@redhat.com>
Date:   Tue Sep 15 17:32:45 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/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.
Comment 2 Sourceware Commits 2015-09-15 16:37:53 UTC
The master branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5a676acc4bba751c7746c4a200a054d6c557f3ee

commit 5a676acc4bba751c7746c4a200a054d6c557f3ee
Author: Pedro Alves <palves@redhat.com>
Date:   Tue Sep 15 17:35:21 2015 +0100

    Move ChangeLog entry to proper place
    
    gdb/ChangeLog -> 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.
Comment 3 Sourceware Commits 2015-09-15 17:03:02 UTC
The gdb-7.10-branch branch has been updated by Pedro Alves <palves@sourceware.org>:

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.
Comment 4 Pedro Alves 2015-09-15 17:06:51 UTC
Fixed in (the future) 7.10.1 and master.
Comment 5 Sourceware Commits 2015-09-15 18:34:14 UTC
The master branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e68fa6f07666ec4726cfef59f641a81244cc2e00

commit e68fa6f07666ec4726cfef59f641a81244cc2e00
Author: Pedro Alves <palves@redhat.com>
Date:   Tue Sep 15 19:29:37 2015 +0100

    gdb/doc: revert previous vforkdone change
    
    The previous manual change was wrong.  The vfork parent thread ID
    should be reported with the usual "thread" magic register:
    
       Sending packet: $vCont;c:p7260.7260#1e...Packet received: OK
     -   Notification received: Stop:T05vforkdone:;
     +   Notification received: Stop:T05vforkdone:;thread:p7260.7260
                                                   ^^^^^^^^^^^^^^^^^
    
    This is already how the parent is reported in the vfork/fork events,
    and is actually what the fix made gdbserver do.  Following the
    documentation change, the event would have been reported like this
    instead:
    
        Notification received: Stop:T05vforkdone:p7260.7260
    
    gdb/doc/ChangeLog:
    2015-09-15  Pedro Alves  <palves@redhat.com>
    
    	PR remote/18965
    	* gdb.texinfo (Stop Reply Packets): Revert previous change to
    	the vforkdone description.
Comment 6 Sourceware Commits 2015-09-15 18:37:30 UTC
The gdb-7.10-branch branch has been updated by Pedro Alves <palves@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9c53c9a4a221addc05c0cd3a8f44974d8c8b2444

commit 9c53c9a4a221addc05c0cd3a8f44974d8c8b2444
Author: Pedro Alves <palves@redhat.com>
Date:   Tue Sep 15 19:35:56 2015 +0100

    gdb/doc: revert previous vforkdone change
    
    The previous manual change was wrong.  The vfork parent thread ID
    should be reported with the usual "thread" magic register:
    
       Sending packet: $vCont;c:p7260.7260#1e...Packet received: OK
     -   Notification received: Stop:T05vforkdone:;
     +   Notification received: Stop:T05vforkdone:;thread:p7260.7260
                                                   ^^^^^^^^^^^^^^^^^
    
    This is already how the parent is reported in the vfork/fork events,
    and is actually what the fix made gdbserver do.  Following the
    documentation change, the event would have been reported like this
    instead:
    
        Notification received: Stop:T05vforkdone:p7260.7260
    
    gdb/doc/ChangeLog:
    2015-09-15  Pedro Alves  <palves@redhat.com>
    
    	PR remote/18965
    	* gdb.texinfo (Stop Reply Packets): Revert previous change to
    	the vforkdone description.
Comment 7 yaoltreza 2021-10-21 06:50:26 UTC Comment hidden (spam)