11 Producing a Sampled Call Stack Profile Analysis

HP Caliper can produce a sampled call stack profile report (using the cstack measurement) from any compiled program. You do not need to compile your program in any special way to use this feature. HP Caliper periodically samples the application program counter and each of its thread's call stacks and then creates a call stack profile of the program's execution.

For more information about the report produced by the cstack measurement, see “cstack Measurement Report Description” (page 186).

Running HP Caliper to Produce a Call Stack Profile

You can start HP Caliper from the command line, a shell script, or your program's makefile to produce a call stack profile. The syntax is:

caliper cstack [caliper_options] program [program_arguments]

For example, the following command creates a call stack profile report in the file named results.save when profiling the program enh_thr_mutex1.

$ /opt/caliper/bin/caliper cstack -o results.save enh_thr_mutex1

You can use the --frame-depthoption to change the maximum number of stack frames to unwind while collecting call stack samples. The default value is 32. See “--frame-depth” (page 62).

You can use the -sor --sampling-specoption to specify the sampling period. See “-s or --sampling-spec” (page 53).

You can use the --group-by executable option to generate a per-executable call stack profile report merged across processes. You can use the caliper merge command to merge cstack data from multiple collection runs.

By default a cstack run collects the blocking primitives data, and a "Blocking Primitives" section will appear in the cstack reports if there are any samples that are blocked waiting for a thread primitive (mutex, condition variable, or rwlock) or inter process blocking primitive (like semaphore, socket, pipe, or file descriptor).

If an application is linked with libpthread version 11.31_BL2009_1012_2 (or later), the "Blocking Primitive Details" section would appear instead in the cstack report with information about holder and waiter threads for thread primitives (for example, mutexes). See “Thread Synchronization Primitive's Holder and Waiter Thread Analysis (HP-UX 11.31 only)” (page 149).

When HP Caliper is run as root, cstack measurement now records and reports both user and kernel space portions of the call stack (HP-UX only).

Call Stack Profile Text Report Example for HP-UX

An example report for HP Caliper on HP-UX is shown here. This report is the result of this command line:

$ /opt/caliper/bin/caliper cstack -o results.save enh_thr_mutex1

134 Producing a Sampled Call Stack Profile Analysis