I am unable to get Solaris dbx to follow a child process after a
simple call to fork(). I have tried all manor of combinations of
setting follow_child modes without success.

I am using version 5.8 of solaris and Sun Dbx Debugger 7.2 2004/02/18
in SunStudio8

It would be helpful if someone can tell me if I’m doing something
wrong or If I have unrealistic expectations of dbx.

I have the following simple program which crates a simple object
then forks a process and prints which process the current execution is

I think I should be able to easily step through both execution paths
using dbx.


class Ptr

Ptr(double d) : mydouble(new double(d))
printf("made double %lf at address %p\n", *mydouble,

printf("deleting double in %lf in pid %d at address %p\n",
*mydouble, getpid(), mydouble);
delete mydouble;
mydouble = 0;

double* mydouble;

int main (void) {

pid_t p;

Ptr x(42);
printf("Original program, pid=%d\n", getpid());
p = fork();
if (p == 0) {
printf("In child process, pid=%d, ppid=%d\n",
getpid(), getppid());
} else {
printf("In parent, pid=%d, fork returned=%d\n",
getpid(), p);
printf("about to destroy in %d\n",getpid());

Which is build with this makefile command

CC -o ptest -g -mt –lpthread

I don’t think all of these flags are required, but I have tried
various options here to make the dbx work.

I use SunStudio8 to debug the program, putting a break point on the

If I set the follow_fork_mode to parent. I can set through the parent
process. This works ok.

If I set follow_fork_mode to to child, I cannot step into the child
process. After the fork dbx displays the message : dbx: warning:
stepping up to a function with srcline info.
It appers that dbx does not step into the child process as if I do a
where –l, it shows it is still in the fork.

(dbx) where -
[1], 0x1, 0x0, 0x0, 0x0, 0x0), at
[2], 0xff31d660, 0xff31d678,
0xff31c000, 0x281e0, 0xcc), at 0xff307a20
=>[3] ptest:main(), line 30 in "”

Trying to step or continue at this point makes the program run on
until its completed. This applies even if there is a breakpoint in the
child’s path and the setting that child inherits parents breakpoints
is on. Looking at the output of the program in the console, the child
route does not get executed (e.g. displayed). Its as if the child just
terminates or the output is lost.

If I set the follow_fork_mode to both then I am asked which path to
follow but neither of them work. They just do the same as the child
process above.

I think this should work. I should be able to set a breakpoint in the
child’s path and have dbx break at that point in the child, or just
set into the child after the fork.

Any help appreciated.