Article View: gnu.misc.discuss
Article #63005Re: GDB: following fork?
From: Michael Schumacher
Date: Tue, 28 Mar 1995 08:50
Date: Tue, 28 Mar 1995 08:50
20 lines
1513 bytes
1513 bytes
Gioacchino La_vecchia (gio@cli.di.unipi.it) wrote:
: Does gdb follow forking process.
: If so, how can I use this feature?
I'm not aware of *any* debugger which could trace child processes (this has
to do with the memory management of the underlying OS). The following hack
might be helpful if your OS allows to attach to running processes: right
after the fork, put an endless loop which is controlled by a variable, i.e.
if ((pid = fork()) == 0)
{ int i = 1;
while (i);
/* real child code */
}
Now open a shell window (xterm or such) and issue a ps command to find out
the pid of the newly created child process. Then start another gdb session,
and attach to this pid. Works perfectly for me, and hopefully for you, too.
mike
Technical Details
Message-ID:
<3l8iks$fco@hades.rz.uni-sb.de>Path:
arc1-ca.pugleaf.net!nntp.gmd.de!stern.fokus.gmd.de!ceres.fokus.gmd.de!zib-berlin.de!fu-berlin.de!news.dfn.de!news.coli.uni-sb.de!hades.rz.uni-sb.de!sbusol.rz.uni-sb.de!hightecReferences:
<3ka5sr$rpm@serra.unipi.it>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1025b4,e9f1530a634deb70 X-Google-Attributes: gid1025b4,public X-Google-ArrivalTime: 1995-03-28 15:23:50 PST Path: arc1-ca.pugleaf.net!nntp.gmd.de!stern.fokus.gmd.de!ceres.fokus.gmd.de!zib-berlin.de!fu-berlin.de!news.dfn.de!news.coli.uni-sb.de!hades.rz.uni-sb.de!sbusol.rz.uni-sb.de!hightec From: hightec@sbusol.rz.uni-sb.de (Michael Schumacher) Newsgroups: gnu.misc.discuss Subject: Re: GDB: following fork? Date: 28 Mar 1995 08:50:36 GMT Organization: University of Saarland, Computing Center, Germany. Lines: 20 Distribution: world Message-ID: <3l8iks$fco@hades.rz.uni-sb.de> References: <3ka5sr$rpm@serra.unipi.it> NNTP-Posting-Host: sbusol.rz.uni-sb.de X-Newsreader: TIN [version 1.2 PL2]