From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14295 invoked by alias); 28 Apr 2014 17:33:12 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 14253 invoked by uid 89); 28 Apr 2014 17:33:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 28 Apr 2014 17:33:06 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1WepQL-0003sU-GO from donb@codesourcery.com for gdb@sourceware.org; Mon, 28 Apr 2014 10:33:01 -0700 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 28 Apr 2014 10:33:01 -0700 Received: from NA-MBX-02.mgc.mentorg.com ([169.254.2.230]) by SVR-ORW-FEM-05.mgc.mentorg.com ([169.254.102.222]) with mapi id 14.02.0247.003; Mon, 28 Apr 2014 10:31:48 -0700 From: "Breazeal, Don" To: "gdb@sourceware.org" Subject: RE: Follow-fork-mode / detach-on-fork expected behavior? Date: Tue, 29 Apr 2014 17:07:00 -0000 Message-ID: References: In-Reply-To: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes X-SW-Source: 2014-04/txt/msg00080.txt.bz2 Hi To make my questions below more palatable, I'll reframe them as a proposal = for how follow-fork & detach-on-fork should work. So, true or false: When GDB is handling a fork, (1) any process that is detached due to detach-on-fork should have all brea= kpoints and single step state removed (obvious) (2) any process that is not detached should keep all the breakpoints and si= ngle-step state that originated in the parent - both the parent and child w= ill have them (3) after a process is detached due to detach-on-fork, it should not show u= p in the inferiors list (info inferiors) If all three of these statements are true, then there are a couple of bugs = related to this in native GDB, described below. If that's the case I'll vo= lunteer to look at them, but I'd like some agreement on what the desired be= havior is before I commit time to that work. Thanks --Don > -----Original Message----- > From: gdb-owner@sourceware.org [mailto:gdb-owner@sourceware.org] On > Behalf Of Breazeal, Don > Sent: Thursday, April 24, 2014 3:06 PM > To: gdb@sourceware.org > Subject: Follow-fork-mode / detach-on-fork expected behavior? >=20 > Hi >=20 > 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. >=20 > 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 >=20 > 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: >=20 > 1) follow parent / detach child (default settings) > - prints msg about detaching after fork > - stops after the next command in the parent > - one inferior left >=20 > 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 >=20 > So far, so good, this is what I expect. >=20 > 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' >=20 > 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. >=20 > 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' >=20 > 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? >=20 > 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