Covering multiple processes(Purify/Purecov)

来源:互联网 发布:lua 源码在哪里 编辑:程序博客网 时间:2024/06/05 05:58

You can cover multiple processes using fork, exec, or vfork.

Using fork

By default, PureCoverage does not accumulate coverage data for child processes, since a common reason for forking is to execute a new process right away.

You can specify the -follow-child-processes option if you want PureCoverage to accumulate coverage data for the child process. When this option is set and the child process exits or executes another process, PureCoverage writes the accumulated counts in the child to the .pcv file. Likewise, when the parent process exits, PureCoverage writes counts accumulated for the parent to the .pcv file.

By default, when this option is set, PureCoverage combines coverage data for both the parent and child in the same .pcv file.

To separate the counts for parent and child, you can use the option -counts-file=%v.%p.pcv to specify a counts file including the process pid in the filename, or call the API function purecov_set_filename() in either or both the parent or child process to control where the data is written.

Using exec

When an instrumented program calls exec or related functions with a valid executable filename specified in the path argument, PureCoverage accumulates the coverage data in the .pcv file for the calling process before the exec is attempted. The counts are then set to zero. If the exec fails, and the calling process continues to run, the counts are correctly updated when the process finally exits or does a successful exec.

If the exec is done from a child process and you have not set the -follow-child-processes option, no coverage data is accumulated, and no data is written at the time of the exec.

The process invoked by exec is a new process, and does not share coverage information or status with the calling process. If the invoked process is itself a PureCoverage instrumented program, it starts accumulating coverage data regardless of whether the program calling exec was instrumented, and whether you set the -follow-child-processes option.

Using vfork

A child process started with vfork shares a common address and accumulated coverage data with its parent. PureCoverage counting is not disabled in the child process of a vfork, even if you set the option -follow-child-processes=no.

原创粉丝点击