You use the PowerScript functions and PowerBuilder objects listed in the following table to access the data in the trace file directly so that you can develop your own analysis tools.
Use this function |
With this object |
To do this |
---|---|---|
Open |
TraceFile |
Opens the trace file to be analyzed. |
NextActivity |
TraceFile |
Returns the next activity in the trace file. The value returned is of type TraceActivityNode. |
Reset |
TraceFile |
Resets the next activity to the beginning of the trace file. |
Close |
TraceFile |
Closes the open trace file. |
With the exception of NextActivity, each of these functions returns a value of type ErrorReturn. Each TraceActivityNode object includes information about the category of the activity, the timer value when the activity occurred, and the activity type.
Timer values
The category of the activity is either TraceIn! or TraceOut! for activities that have separate beginning and ending points, such as routines, garbage collection, and tracing itself. Each such activity has two timer values associated with it: the time when it began and the time when it completed.
Activities that have only one associated timer value are in the category TraceAtomic!. ActLine!, ActUser!, and ActError! are all atomic activities.
Inherited objects
The following objects inherit from TraceActivityNode and contain data about the associated activity type:
-
TraceBeginEnd
-
TraceError
-
TraceESQL
-
TraceGarbageCollect
-
TraceLine
-
TraceObject
-
TraceRoutine
-
TraceUser
TraceTreeNode and TraceActivityNode objects
The objects that inherit from TraceActivityNode are analogous to those that inherit from TraceTreeNode, and you can use similar techniques when you write applications that use them.
For a list of activity types, see Trace activities.
To access the data in the trace file directly, you create a TraceFile object, open a trace file, and then use the NextActivity function to access each activity in the trace file sequentially. For each node, determine what activity type it is by examining the TraceActivity enumerated datatype, and then use the appropriate trace object to extract information.
Example: direct access to trace data
The following example creates a TraceFile object, opens a trace file called ltcf_file, and then uses a function called of_dumpActivityNode to report the appropriate information for each activity depending on its activity type.
string ls_fileName TraceFile ltcf_file TraceActivityNode ltcan_node string ls_line ls_fileName = sle_filename.Text ltcf_file = CREATE TraceFile ltcf_file.Open(ls_fileName) ls_line = "CollectionTime = " + & String(Truncate(ltcf_file.CollectionTime, 6)) & + "~r~n" + "Number of Activities = " + & String(ltcf_file.NumberOfActivities) + "~r~n" + & "Time Stamp " + "Activity" + "~r~n" mle_output.text = ls_line ltcan_node = ltcf_file.NextActivity() DO WHILE IsValid(ltcan_node) ls_line += of_dumpActivityNode(ltcan_node) ltcan_node = ltcf_file.NextActivity() LOOP mle_output.text = ls_line ltcf_file.Close()
The following code shows part of of_dumpActivityNode:
string lstr_result lstr_result = String(Truncate(atcan_node. & TimerValue, 6)) + " " CHOOSE CASE atcan_node.ActivityType CASE ActRoutine! TraceRoutine ltcrt_routine ltcrt_routine = atcan_node IF ltcrt_routine.IsEvent THEN lstr_result += "Event: " ELSE lstr_result += "Function: " END IF lstr_result += ltcrt_routine.ClassName + "." + & ltcrt_routine.name + "(" + & ltcrt_routine.LibraryName + ") " & + String(ltcrt_routine.ObjectId) + "~r~n" CASE ActLine! TraceLine ltcln_line ltcln_line = atcan_node lstr_result += "Line: " + & String(ltcln_line.LineNumber) + "~r~n" CASE ActESQL! TraceESQL ltcSQL_eSQL ltcSQL_eSQL = atcan_node lstr_result += "ESQL: " + ltcSQL_eSQL.Name & + "~r~n" // CASE statements and code omitted ... CASE ActBegin! IF atcan_node.Category = TraceIn! THEN lstr_result += "Begin Tracing~r~n" ELSE lstr_result += "End Tracing~r~n" END IF CASE ActGarbageCollect! lstr_result += "Garbage Collection~r~n" CASE else lstr_result += "Unknown Activity~r~n" END CHOOSE RETURN lstr_result