Page MenuHomePhabricator

[scan-build] Compiler call interceptor for Linux
Needs ReviewPublic

Authored by a.sidorin on May 5 2014, 7:00 AM.



This patch enables interception of compiler calls without replacement of environment variables. It uses strace (v.4.8) to compute root directory of processes (in case of chroot), working directory, process name and its environment variables and tries to guess some header directories. This approach works well with Android and some build systems like OBS (local build with osc client) and GBS (checked on Tizen). This behaviour can be enabled with --use-interceptor option. If this option is not specified, old behaviour is used (this patch was made to not break it).

Interceptor uses process pool to analyze multiple files at a time. Pool size can be specified with NUM_PROCESSES environment variable. Default pool size is a number of processors.

If we have a trace of build (that may be created with strace -f -v -s 1000000 -o $trace_file_name -e trace=vfork,fork,clone,execve,chdir,chroot -e signal= $build_cmd), it can be passed via TRACE_FILE environment variable. This will not launch parallel build (analysis only). If option is not specified, temporary pipe is used, analyzer and compiler are executed in parallel.

-additional-arg option was also added to pass additional parameters to analyzer. Sometimes scan-build cannot determine all required parameters if some custom toolchain is used.

Interceptor was tested on Ubuntu 12.04 and 14.04 with strace 4.8. Strace v.4.6 is known to have some issues with interception of gcc.

Diff Detail

Event Timeline

a.sidorin updated this revision to Diff 9072.May 5 2014, 7:00 AM
a.sidorin retitled this revision from to [scan-build] Compiler call interceptor for Linux.
a.sidorin updated this object.
a.sidorin edited the test plan for this revision. (Show Details)
a.sidorin added a reviewer: jordan_rose.
a.sidorin added a subscriber: Unknown Object (MLST).May 6 2014, 11:26 PM