Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "Breazeal, Don" <donb@codesourcery.com>
To: "gdb@sourceware.org" <gdb@sourceware.org>
Subject: Follow-fork-mode / detach-on-fork expected behavior?
Date: Mon, 28 Apr 2014 17:33:00 -0000	[thread overview]
Message-ID: <DA279C53C4A5884A907135DFCD7A059A0E1DB9D4@NA-MBX-02.mgc.mentorg.com> (raw)

Hi

I'm working on implementation of follow-fork in gdbserver.  My intent is to make it work just like it works in native GDB.  However, I am confused by what looks like inconsistent behavior in native GDB.  I'm hoping to get some feedback on my observations so that I know how to proceed.  I want to make sure things are working in native GDB before going any further with gdbserver.

Apologies for the length of this email.  The only way I can think of to explain my questions is by describing what I see in a test case.  I'm using a test case that uses 'fork' (not 'vfork') in all-stop mode (gdb.base/foll-fork).  Aside from the fork mode settings, the commands are:
(gdb) set verbose   # to see the fork msgs
(gdb) break main
(gdb) run
(gdb) next 2        # this executes past the fork call

The behavior is inconsistent when following the child, depending on the setting for detach-on-fork.  Below is the behavior I see in the four possible combinations of fork settings after the 'next 2' command is entered, along with my specific questions:

1) follow parent / detach child (default settings)
  -  prints msg about detaching after fork
  -  stops after the next command in the parent
  -  one inferior left

2) follow parent / don't detach child
  -  prints [New process] msg
  -  prints symbol reading/loading msgs
  -  stops in parent after next
  -  two inferiors left, info inferiors shows pids of both

So far, so good, this is what I expect.

3) follow child / detach parent
  -  prints msg about attach to child after fork
  -  prints [New process] msg
  -  prints [Switching to process ] msg
  -  stops in child after 'next' command
  -  two inferiors left, info inferiors shows parent 'null'

This looks like there might be a problem:
  Q1: shouldn't there only be one inferior?
  Q2: should the child have stopped?
The manual doesn't make this completely clear.

4) follow child / don't detach parent
  -  prints msg about attach to child after fork
  -  prints [New process] msg
  -  prints symbol reading/loading msgs
  -  child runs to completion
  -  two inferiors left, info inferiors shows child 'null'

Something seems wrong here.  
  Q3: to be consistent, shouldn't the child process either have stopped after the 'next' command in both (3) and (4) or run to completion in both cases?

I'd appreciate it if someone could clarify the expected behavior for me, or if what I'm seeing is expected, explain the rationale.  If something needs to be fixed in the native implementation, I'll want to look at that before continuing with the remote case.
Thanks
--Don


             reply	other threads:[~2014-04-24 22:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-28 17:33 Breazeal, Don [this message]
2014-04-29 17:07 ` Breazeal, Don
2014-05-16 12:51 ` Pedro Alves
2014-05-16 17:08   ` Breazeal, Don

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=DA279C53C4A5884A907135DFCD7A059A0E1DB9D4@NA-MBX-02.mgc.mentorg.com \
    --to=donb@codesourcery.com \
    --cc=gdb@sourceware.org \
    /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