Skip Navigation Links | |
Exit Print View | |
Oracle Solaris Studio 12.3: Thread Analyzer User's Guide Oracle Solaris Studio 12.3 Information Library |
1. What is the Thread Analyzer and What Does It Do?
A. APIs Recognized by the Thread Analyzer
Tips for instrumenting an application for data race detection before collecting an experiment:
If you get an error message from the compiler saying that the compiler option -xinstrument=datarace is illegal, you are using an older version of the Sun Studio compiler that does not support the Thread Analyzer. You can check the version of the compiler you are using by typing the command cc -Version. The earliest version that supports Thread Analyzer is dated June 2006.
The collect -r race command issues a warning if the binary is not instrumented for data race detection, as shown here:
% collect -r races a.out WARNING: Target `a.out' is not instrumented for datarace detection; reported datarace data may be misleading
You can determine whether a binary is instrumented for data race detection by using the nm command and looking for calls to tha routines. If routines whose names begin with __tha_ are shown, the binary is instrumented. Example output is shown below.
Source-level instrumentation:
% cc -xopenmp -g -xinstrument=datarace source.c % nm a.out | grep __tha_ [71] | 135408| 0|FUNC |GLOB |0 |UNDEF |__tha_get_stack_id [53] | 135468| 0|FUNC |GLOB |0 |UNDEF |__tha_src_read_w_frame [61] | 135444| 0|FUNC |GLOB |0 |UNDEF |__tha_src_write_w_frame
Binary-level instrumentation:
% cc -xopenmp -g source.c % discover -i datarace -o a.out.i a.out % nm a.out.i | grep __tha_ [88] | 0| 0|NOTY |GLOB |0 |UNDEF |__tha_read_w_pc_frame [49] | 0| 0|NOTY |GLOB |0 |UNDEF |__tha_write_w_pc_frame
To use discover, the input binary must be compiled with one of the compiler optimization flags (-xO1, -xO2, -xO3, -xO4, -xO5). The compiler must be from a release no earlier than Oracle Solaris Studio 12 Update 1. The operating system must be at least Oracle Solaris 10 Update 5 or Oracle Solaris 11. Otherwise, you may get a warning as shown here.
% discover -i datarace -o a.out.i a.out discover (warning): a.out has no annotations. Results may be incomplete. See discover documentation for compiler flag/OS recommendation
You might also be able to use the discover tool on an earlier Solaris version running on a SPARC-based system if the binary was compiled with the compiler option -xbinopt=prepare. See the cc(1), CC(1), or f95(1) man pages for information about this compiler option.