From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10525 invoked by alias); 24 Apr 2014 22:05:38 -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 10418 invoked by uid 89); 24 Apr 2014 22:05:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 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; Thu, 24 Apr 2014 22:05:36 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1WdRls-0001VZ-0R from donb@codesourcery.com for gdb@sourceware.org; Thu, 24 Apr 2014 15:05:32 -0700 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Thu, 24 Apr 2014 15:05:31 -0700 Received: from NA-MBX-02.mgc.mentorg.com ([169.254.2.230]) by SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) with mapi id 14.02.0247.003; Thu, 24 Apr 2014 15:05:31 -0700 From: "Breazeal, Don" To: "gdb@sourceware.org" Subject: Follow-fork-mode / detach-on-fork expected behavior? Date: Mon, 28 Apr 2014 17:33:00 -0000 Message-ID: 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/msg00079.txt.bz2 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 som= e feedback on my observations so that I know how to proceed. I want to mak= e sure things are working in native GDB before going any further with gdbse= rver. Apologies for the length of this email. The only way I can think of to exp= lain 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-fo= rk). 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 set= ting 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.=20=20 Q3: to be consistent, shouldn't the child process either have stopped aft= er the 'next' command in both (3) and (4) or run to completion in both case= s? 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