From owner-freebsd-hackers Wed Sep 8 14:41:46 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from luna.lyris.net (luna.shelby.com [207.90.155.6]) by hub.freebsd.org (Postfix) with ESMTP id CD8FB14CEA for ; Wed, 8 Sep 1999 14:41:32 -0700 (PDT) (envelope-from kip@lyris.com) Received: from luna.shelby.com by luna.lyris.net (8.9.1b+Sun/SMI-SVR4) id OAA01637; Wed, 8 Sep 1999 14:40:56 -0700 (PDT) Received: from (luna.shelby.com [207.90.155.6]) by luna.shelby.com with SMTP (MailShield v1.50); Wed, 08 Sep 1999 14:40:56 -0700 Date: Wed, 8 Sep 1999 14:40:56 -0700 (PDT) From: Kip Macy X-Sender: kip@luna To: Zhihui Zhang Cc: freebsd-hackers@freebsd.org Subject: Re: Using gdb with fork() In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SMTP-HELO: luna X-SMTP-MAIL-FROM: kip@lyris.com X-SMTP-RCPT-TO: zzhang@cs.binghamton.edu,freebsd-hackers@freebsd.org X-SMTP-PEER-INFO: luna.shelby.com [207.90.155.6] Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG You need to detach from your current process and attach to the spawned process. It might make it easier to attach in a timely fashion if you put a 3 second sleep in right after the fork. This would all be easiest using something like DDD where DDD will tell you what other processes are running with the same name, and allow you to attach to them through the GUI. -Kip On Wed, 8 Sep 1999, Zhihui Zhang wrote: > > I am using gdb 4.18 on FreeBSD-current. The program being debugged > consists of two small files: test1.c and test2.c. The main() in test1.c > has a call to fork() and for the child process case, it will call a > routine, say test(), in test2.c. > > I use "set follow-fork-mode child", "break fork", "step" command trying to > access the source in test2.c without success. The program is compiled > with "cc -g test1.c test2.c" and I run gdb with "gdb a.out". > > If there is no fork(), a call from test1.c to a routine in test2.c will > bring up the source of test2.c if I step that routine. Why it does not > work with fork()? Am I missing something? > > Thanks for any help. > > -------------------------------------------------- > Zhihui Zhang. Please visit http://www.freebsd.org > -------------------------------------------------- > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message