HP-UX Linker and Libraries User's Guide
There are also certain non-terminating processes (such as servers, daemons, and operating systems)
which never call exit. For these processes, you must programmatically write the profile data to
the flow.data file. In order to do so, a process must call a routine called _write_counters().
This routine is defined in the icrt0.o file. A stub routine with the same name is present in the
crt0.o file so that the source does not have to change when instrumentation is not being done.
If flow.data does not exist, the program creates it. If flow.data exists, the program updates
the profile data.
As an example, suppose you have an instrumented program named prog.inst, and two
representative input data files named input_file1 and input_file2. Then the following lines
create a flow.data file:
$ prog.inst < input_file1
$ ls flow.data
flow.data
$ prog.inst < input_file2
The flow.data file includes profile data from both input files. To save the profile data to a file
other than flow.data in the current working directory, use the FLOW_DATA environment variable
as described in Specifying a Different flow.data with FLOW_DATA .
Storing Profile Information for Multiple Programs
A single flow.data file can store information for multiple programs. This allows an instrumented
program to spawn other instrumented programs, all of which share the same flow.data file.
To allow multiple programs to save their data in the same flow.data file, a program's profile
data is uniquely identified by the executable's basename (see basename(1)), the executable's file
size, and the time the executable was last modified.
Instead of using the executable's basename, you can specify a basename by setting the environment
variable PBO_PGM_PATH. This is useful when a number of programs are actually linked to the
same instrumented executables.
For example, consider profiling the ls, lsf and lsx commands (lsx is ls with the -x option
and lsf is ls with the -F option). Because the three commands could be linked to the same
instrumented executables, the developer may want to collect profile data under a single basename
by setting PBO_PGM_PATH=ls. If PBO_PGM_PATH=ls is not set, the profile data is saved under
the ls, the lsf, and the lsx basenames. When an instrumented program begins execution, it
checks whether the basename, size, and time-stamp match those in the existing flow.data file.
If the basename matches but the size or time-stamp does not match, that probably means that the
program has been relinked since it last created profile data. In this case, the following error message
is issued:
program: Can't update counters. Profile data exists
but does not correspond to this executable. Exit.
You can fix this problem in any one of the following ways:
• Remove or rename the existing flow.data file.
• Run the instrumented program in a different working directory.
• Set the FLOW_DATA environment variable so that profile data is written to a file other than
flow.data.
• Rename the instrumented program
Sharing the flow.data File Among Multiple Processes
A flow.data file can potentially be accessed by several processes at the same time. For example,
this can happen when you run more than one instrumented program at the same time in the same
directory, or when profiling one program while linking another with -P. Such asynchronous access
to the file can potentially corrupt the data. To prevent simultaneous access to the flow.data file
Linker Optimizations 209