[comp.lang.c] Debugging programs with fork

pgarg@pollux.usc.edu (Pankaj K. Garg) (10/03/88)

 I am having trouble debugging programs which fork other
processes. Dbx doesn't seem to handle them easily. Is there
some feature of dbx that I am missing or is there another tool
which helps in this debugging process?

 I am using sun workstations running Unix 4.3.

			...pankaj

US Mail: Computer Science Department         E-mail: garg@cse.usc.edu
	 University of Southern California
	 Los Angeles, CA 90089-0782          Phone: (213)743-7995

chris@mimsy.UUCP (Chris Torek) (10/03/88)

In article <12523@oberon.USC.EDU> pgarg@pollux.usc.edu (Pankaj K. Garg) writes:
> I am having trouble debugging programs which fork other
>processes. Dbx doesn't seem to handle them easily.

> I am using sun workstations running Unix 4.3.

[Sun workstations do not run `Unix 4.3', by which I guess that you mean
`4.3BSD': Sun workstations run SunOS and Mach.  This question should
have been directed to a Unix-specific group, not comp.lang.c; I have
redirected followups to comp.unix.questions.]

You are quite right; the existing Unix debuggers cannot handle programs
that fork.  SunOS 4.0 provides new facilities that make it possible,
but if you are dealing with older Unixes, you must either delete the
fork, or fall back on more `traditional' debugging schemes.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris

greggy@infmx.UUCP (greg yachuk) (10/04/88)

In article <12523@oberon.USC.EDU> pgarg@pollux.usc.edu () writes:
> I am having trouble debugging programs which fork other
>processes. Dbx doesn't seem to handle them easily.

I've just gotten my evaluation copy of Saber-C (Version 2.0.1), but
haven't installed it yet.  Even though it is interpreted C (wait, don't
gag yet!), it claims to be able to handle forks and signals.  The demo
I saw also has some spiffy visual display of structs and linked lists.

I'll let you know after I try it.  I have no affiliation with Saber,
and am not even yet a satisfied customer.  Maybe soon...  They are:

	Saber Software, Inc.
	30 J.F.K. Street
	Cambridge, MA 02138
	(617) 876-7636
	{inhp4, decvax}!harvard!saber
	saber@harvard.harvard.edu

	-greg

Greg Yachuk		Informix Software Inc., Menlo Park, CA	(415) 322-4100
{uunet,pyramid}!infmx!greggy		why yes, I DID choose that login myself

mh@wlbr.EATON.COM (Mike Hoegeman) (10/04/88)

In article <12523@oberon.USC.EDU- pgarg@pollux.usc.edu () writes:
-
- I am having trouble debugging programs which fork other
-processes. Dbx doesn't seem to handle them easily. Is there
-some feature of dbx that I am missing or is there another tool
-which helps in this debugging process?
-

I've had this problem too. If you are debugging the parent somtimes you
have to put a sleep(2) in the child part of the fork so dbx "stays"
with debugging the parent. if you want to debug the child , do
something like put a pause() at the start of the child part of the fork
then attach to the child process with the "debug" feature of dbx (see
dbx man page). once you've attached send a signal with kill(1) to break
it out of the pause ( don't forget to put in a no-op signal catcher in
too).

hope this helps.

mlandau@bbn.com (Matt Landau) (10/04/88)

In comp.lang.c (<480@infmx.UUCP>), greggy@infmx.UUCP (greg yachuk) writes:
>I've just gotten my evaluation copy of Saber-C ...
>... it claims to be able to handle forks and signals.  The demo
>I saw also has some spiffy visual display of structs and linked lists.
>I'll let you know after I try it.  I have no affiliation with Saber,
>and am not even yet a satisfied customer.  Maybe soon...  

Well, I'm a pretty satisfied customer.  Yep, Saber does a decent job with
signals and forks.  I've uses it to debug server/client processes by running
each end of the system under a copy of Saber.  When the server forks, Saber
spwans another copy of itself to handle the child process.  Pretty spiffy.
--
 Matt Landau			Waiting for a flash of enlightenment
 mlandau@bbn.com			  in all this blood and thunder