Totalview® for HPC User Guide : PART II Debugging Tools and Tasks : Chapter 8 Setting Action Points : Setting Breakpoints and Barriers : Setting Breakpoints When Using the fork()/execve() Functions
Setting Breakpoints When Using the fork()/execve() Functions
You must link with the dbfork library before debugging programs that call the fork() and execve() functions. See "Compiling Programs".
Debugging Processes That Call the fork() Function
By default, TotalView places breakpoints in all processes in a share group. (For information on share groups, see "Organizing Chaos".) When any process in the share group reaches a breakpoint, TotalView stops all processes in the control group. This means that TotalView stops the control group that contains the share group. This control can contain more than one share group.
To override these defaults:
1. Dive into the line number to display the Action Point > Properties Dialog Box.
2. Clear the Plant in share group check box and make sure that the Group radio button is selected.
Debugging Processes that Call the execve() Function
Shared breakpoints are not set in children that have different executables.
To set the breakpoints for children that call the execve() function:
1. Set the breakpoints and breakpoint options in the parent and the children that do not call the execve() function.
2. Start the multi-process program by displaying the Group > Go command.
When the first child calls the execve() function, TotalView displays the following message:
Process name has exec’d name.
Do you want to stop it now?
CLI: G
3. Answer Yes.
TotalView opens a Process Window for the process. (If you answer No, you won’t have an opportunity to set breakpoints.)
4. Set breakpoints for the process.
After you set breakpoints for the first child using this executable, TotalView won’t prompt when other children call the execve() function. This means that if you do not want to share breakpoints in children that use the same executable, dive into the breakpoints and set the breakpoint options.
5. Select the Group > Go command.
Example: Multi-process Breakpoint
The following program excerpt illustrates the places where you can set breakpoints in a multi-process program:
1 pid = fork();
2 if (pid == -1)
3 error ("fork failed");
4 else if (pid == 0)
5 children_play();
6 else
7 parents_work();
The following table describes what happens when you set a breakpoint at different places:
 
Line Number
Result
1
Stops the parent process before it forks.
2
Stops both the parent and child processes.
3
Stops the parent process if the fork() function failed.
5
Stops the child process.
7
Stops the parent process.
 
RELATED TOPICS 
 
Share groups and TotalView’s default design for organizing multiple processes into groups
The dbfork library
"Compiling Programs", and "Linking with the dbfork Library" in the TotalView for HPC Platforms Guide