By Darryl Gove-Oracle on Sep 21, 2009
If you try to use the Sun Studio Performance Analyzer on something that is not an executable, you'll end up with an error message:
$ collect kstat Target `kstat' is not a valid ELF executable
The most reliable workaround for this that I've discovered is as follows. First of all make up shell script that executes the command passed into it:
$ more shell.sh #!/bin/sh $@
Then run the collect command as:
$ collect -F on /bin/sh shell.sh <script> <params>
-F on is required so that collect follows forked processes, otherwise collect will just profile the top
/bin/sh which will do minimal work before forking off the actual command.
When loading the resulting experiment into the Analyzer you have to load all the descendant processes. You can do this by going to the filter dialog box and selecting all the processes, or you can take the easier route of placing
en_desc on into your
.er.rc file in your home directory (this will tell the analyzer to always load the descendant processes, which might make loading experiments slower, but will guarantee that you actually load all the data, and not just the top-level code).
One other thing to note is that each new process can contribute wall and wait time, so the wall time shown in the analyzer can be a multiple of the actual wall time. To see this in action do:
$ collect -F on /bin/sh shell.sh shell.sh shell.sh shell.sh kstat
The wall time on this will be a multiple of the actual runtime because each shell script contributes wall time while it waits for the kstat command to complete.