Programming Tools:prgtools

Advanced topics Foundation

The utility pogram XppPat.exe provides standard information about a trace run that should be sufficient to answer most questions in analyzing profiler data. If a particular question cannot be answered by XppPat.exe, it is possible to program individual analyzing routines using data from the trace run.

Raw trace data

The PRF file contains raw trace data that can be accessed using the FOXDBE (default), or the DELDBE (if the option "human readable output" was selected in the profiler). The following code pattern can be used to examine raw data in a UDF:

#include "dmlb.ch" 
#include "foxdbe.ch" 

PROCEDURE Main 

  DbeLoad ( "FOXDBE" ) 
  DbeLoad ( "CDXDBE" ) 
  DbeBuild( "FOXCDX", "FOXDBE", "CDXDBE" ) 
  DbeSetDefault( "FOXCDX" ) 
  DbeInfo ( COMPONENT_DATA, FOXDBE_MEMOFILE_EXT, "PRV" ) 

  /* ... */ 

  USE Coffee.prf NEW SHARED VIA FOXCDX 

  /* just a sample loop */ 
  DO WHILE !EOF() 
     AEval( DbStruct(), {|a,i| QQout(FieldGet(FieldPos( a[i] ))) } ) 
     Qout("") 
     SKIP 
  ENDDO 
  USE 
RETURN 

Filtered data

Before trace data is saved while a program runs in profiling mode, unneccessary data is filtered. The filtering mechanism, however, cannot detect BEGIN SEQUENCE/BREAK situations. To obtain all unfiltered data, edit the .PRI file with a simple Text-Editor like NOTEPAD and change the line "OPERATIONMODE=1" to "OPERATIONMODE=4105".

This disables filtering of data and extended/double trace entries are stored in the field 'OP':

Unfiltered operations
Type of operation Description
i Trace entry before entering a function
I Trace entry when function is entered
O Trace entry when function is about to return
o Trace entry when function has returned

The unfiltered data must be interpreted differently from the filtered output. For instance, 'I'/'O'will only appear if subroutines were also compiled with /profile.

Flushing the output file while tracing

The normal operation mode writes all trace data into an output file, which will be closed when the application terminates. For some reasons it might be necessary to view the trace data without closing the application. Adding the value of 1024 to the OPERATIONMODE entry in the .pri-file forces the profiler to flush out data every OUTFLUSHEVERY= entries to disk.

Packeting trace output file while tracing

If not only the current data of the trace should be accessible during the trace, but also the latest data to be transferred over any media, the profiler offers the possibility to package the trace files. Add the value of 1024 (flush) and 2048 to the OPERATIONMODE entry in the .pri-file. The trace output will packeted in files, each contains OUTFLUSHEVERY trace entries.

Packeted files
Sample file name Description
TEST.PRF trace file header packet
TEST.PRF.000001 First packet
TEST.PRF....... other packets

Using the flush operation mode or the packet operation mode causes the program to run slower on arbitrary places. Concluding speed results from such a trace output is quite speculative. The trace file is most useful to watch execution flow.

How to transfer trace packets depends on the output format. Normally, any packet can be removed after a copy operation. Since the binary output format needs to update the header after each write, it is required to keep the header packet, but to transfer both the current and the header package to be able to rebuilt a usable trace file. If you don't have a need to rebuilt the trace file from the package immediately, you might defer the transfer of the header package.

Transfer options
file operation human readable (DELDBE) binary (FOXDBE)
copy ok ok
delete ok ok except the header packet
transfer and rebuilt current package current package + header package
transfer, rebuilt later current package current package, header package later

The header file and the packets can be rebuilt using the copy-command:

copy /b TEST.PRF + TEST.PRF.000001 + TEST.PRF.000002 TESTCOMPLETE.PRF 

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.