Formatting a Db2 trace

The dump file created by the db2trc dmp command is in binary format and is not readable. You can format the binary dump file into a readable file to show the flow control and send the formatted output to a null device.

One of the ways to format the binary file is by issuing the db2trc command with the flow option, as shown in the following example:
db2trc flow example.trc nul 
where example.trc is the binary file.

If there was a problem reading the file and the trace output was wrapped, these would be reflected in the output for this command.

At this point, you can send the dump file to IBM Support. IBM® Support will format the file based on your Db2 service level. However, you might be asked to format the dump file into an ASCII file before sending it. You accomplish this by using the flow and format options. You must provide the name of the binary dump file and the name of the ASCII file that you want to create, as shown in the following example:

C:\>db2trc flw trace.dmp trace.flw
C:\Temp>db2trc flw trace.dmp trace.flw
Total number of trace records     : 18854
Trace truncated                   : NO
Trace wrapped                     : NO
Number of trace records formatted : 1513 (pid: 2196 tid 2148 node: -1)
Number of trace records formatted : 100 (pid: 1568 tid 1304 node: 0)

C:\>db2trc fmt trace.dmp trace.fmt
C:\Temp>db2trc fmt trace.dmp trace.fmt
Trace truncated                   : NO
Trace wrapped                     : NO
Total number of trace records     : 18854
Number of trace records formatted : 18854

If the output shows that the value of Trace wrapped is YES, the trace buffer was not large enough to contain all the information that was collected during the trace period. A wrapped trace might be acceptable, depending on the situation. If you are interested in the most recent information (the information that is maintained unless you specified the -i option), what is in the trace file might be sufficient. However, if you are interested in what happened at the beginning of the trace period or if you are interested in everything that occurred, you might want to redo the operation with a larger trace buffer.

There are options for formatting a binary file. For example, you can issue db2trc format -xml trace.dmp trace.fmt to convert the binary data into an XML format that can be parsed. You can also use the formattedFlow parameter of the db2trc command to parse the binary file into a formatted text file that is organized in chronological order. You can also create a performance report from a dump file by using the perfrep parameter. Additional options are shown in the description of the db2trc command.

On Linux® and UNIX operating systems, if a severe error occurs, the Db2 software automatically dumps the trace buffer to disk when it shuts down the instance due to a severe error. If tracing is enabled when an instance ends abnormally, a file is created in the diagnostic directory. The file name is db2trdmp.nnn, where nnn is the database partition number. The file creation in the diagnostic directory does not occur on Windows operating systems when an instance ends abnormally due to an error. You must dump the trace manually.

To summarize, the following example shows the common sequence of db2trc commands:

   db2trc on -l 8M
   db2trc clr
   <Execute problem recreation commands>
   db2trc dump db2trc.dmp
   db2trc off
   db2trc flw db2trc.dmp <filename>.flw
   db2trc fmt db2trc.dmp <filename>.fmt
   db2trc fmt -c db2trc.dmp <filename>.fmtc