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.
On this page:
Debugging Processes That Call the fork() Function
By default, TotalView places breakpoints in all processes in a share group. 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, modify the breakpoint’s width in the action point’s properties, Modify Breakpoint dialog box.
dset SHARE_ACTION_POINT false
|
The Modify Breakpoint dialog box |
|
|
More on an action point’s width |
|
|
Linking with the dbfork library |
|
|
More on share groups and control |
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:
-
Set the breakpoints and breakpoint options in the parent and the children that do not call the execve() function.
-
Start the multi-process program using the Group > Go command. Alternatively use the CLI command dgo.
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?
-
Answer Yes.
(If you answer No, you won’t have an opportunity to set breakpoints.)
-
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, set the breakpoint options using the action point properties dialog.
-
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. |
|
Linking with the dbfork library |
|
|
Controlling system calls to execve(). |