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.

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

Related topics

The Modify Breakpoint dialog box

Modifying a Breakpoint

More on an action point’s width

Controlling an Action Point’s Width

Linking with the dbfork library

Linking with the dbfork Library

More on share groups and control

How TotalView Creates Groups

Debugging Processes that Call the execve() Function

You can control how TotalView handles system calls to execve(). See Exec Handling.

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 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?

  3. Answer Yes.

    (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, set the breakpoint options using the action point properties dialog.

  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

Linking with the dbfork library

Linking with the dbfork Library

Controlling system calls to execve().

Exec Handling