From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21675 invoked by alias); 19 Apr 2002 16:10:15 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 21652 invoked from network); 19 Apr 2002 16:10:12 -0000 Received: from unknown (HELO nevyn.them.org) (128.2.145.6) by sources.redhat.com with SMTP; 19 Apr 2002 16:10:12 -0000 Received: from drow by nevyn.them.org with local (Exim 3.35 #1 (Debian)) id 16yay6-0006Jm-00; Fri, 19 Apr 2002 12:10:38 -0400 Date: Fri, 19 Apr 2002 09:10:00 -0000 From: Daniel Jacobowitz To: Frank Schaefer Cc: gdb@sources.redhat.com Subject: Re: Problems debugging forked processes Message-ID: <20020419121038.A24030@nevyn.them.org> Mail-Followup-To: Frank Schaefer , gdb@sources.redhat.com References: <1019202349.3213.5.camel@ADMIN> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1019202349.3213.5.camel@ADMIN> User-Agent: Mutt/1.3.23i X-SW-Source: 2002-04/txt/msg00331.txt.bz2 On Fri, Apr 19, 2002 at 09:45:49AM +0200, Frank Schaefer wrote: > Hi there, > > I've written a network daemon and client. The daemon forks to serve a > client request. > Everything runs fine outside of the debugger, but I want to trace the > code at least once, before I release it. > > Here goes my problem: > # gdb daemon > GNU gdb 5.0 > Copyright 2000 Free Software Foundation, Inc. > GDB is free software, covered by the GNU General Public License, and you > are > welcome to change it and/or distribute copies of it under certain > conditions. > Type "show copying" to see the conditions. > There is absolutely no warranty for GDB. Type "show warranty" for > details. > This GDB was configured as "i686-pc-linux-gnu"... > (gdb) b 13 > Breakpoint 1 at 0x8048899: file daemon.c, line 13. > (gdb) show follow-fork-mode > Debugger response to a program call of fork or vfork is "parent". > (gdb) set follow-fork-mode child > (gdb) show follow-fork-mode > Debugger response to a program call of fork or vfork is "child". This variable doesn't actually affect GNU/Linux. Yeah, I know, I know. We need a documentation patch to address this; please file a PR (http://sources.redhat.com/gdb/, Bugs). > If I use the attach method from a second instance of gdb ( there's the > sleep() above for ), the child process exits on exceptions ( mostly > segmentation fault and sometimes invalid operation ) on different > (random???) lines in the code. This happens everytime in the fixup() > from ld.linux.so. Because the breakpoints which were inserted when the application forked turn into traps. There's no clear solution to this without actually implementing fork-following - which should not be hard, but no one has stepped up to do it. -- Daniel Jacobowitz Carnegie Mellon University MontaVista Software Debian GNU/Linux Developer