Your application is responsible for managing trace buffers when writing to them and deleting them. Component trace manages the buffers while they are being captured until they are ready for reuse. Your application uses the CTRACECS macro to update and track the status of its buffers. Each buffer has an associated trace buffer writer control (TBWC) area to store the state of the buffer and the sequence number associated with the buffer. Each buffer has 4 possible states:
State | Description | Set by: |
---|---|---|
FILLING | trace is filling the buffer | application |
FULL | full and ready to be written to datasets | application |
CAPTURE | Component trace is writing to datasets | Component trace |
AVAILABLE | available for use by the trace | Component trace |
CTRACECS TBWC=TBWCAREA, x
MODE=AVAIL, x
COM='Initialize buffers to available state'
LA R6,3 x
ST R6,EXPSEQ x
CTRACECS TBWC=TBWCAREA, x
TESTMODE=AVAIL, x
MODE=FILLING, x
CSLABEL=NOT_AVAIL, x
BUFFSEQ#=NEWSEQ#, x
COM='Mark Buffer filling if available'
.
.
NOT_AVAIL
*The buffer is not available, try another buffer.
LA R6,2 x
ST R6,EXPSEQ x
x
CTRACECS TBWC=TBWCAREA, x
MODE=FULL, x
TESTMODE=FILLING, x
TESTSEQ#=EXPSEQ, x
CSLABEL=NOT_FILLING, x
COM='MARK buffer full if filling'
.
.
NOT_FILLING
*The buffer is not filling or the buffer sequence number
assigned to the buffer is not the expected value. The
buffer is not marked full.
LA R6,1 x
ST R6,EXPSEQ x
x
CTRACECS TBWC=TBWCAREA, x
MODE=AVAIL, x
TESTSEQ#=EXPSEQ, x
CSLABEL=WRONGBUFFER, x
COM='Mark buffer# 1 available'
.
.
WRONG_BUFFER
*The is not buffer# 1 and is not marked available.
The CTRACECS macro requires that a unique TBWC buffer sequence number be provided by the application. The application must serialize the buffer sequence number assigned to each buffer. The sequence number must be unique for every buffer passed to the external writer on the CTRACEWR macro.
CSLABEL is optional with TESTMODE=CURRENT but required with TESTMODE=AVAIL/FULL/FILLING and TESTSEQ#. If you specify CSLABEL=RETRY, the default, the code will branch to a generated label that retries the current value of the TBWC until the update is successful.
The TBWC contains the current buffer sequence number (TBWCSEQ), which must also equal the expected buffer sequence number (TESTSEQ#), before it can be updated to the desired buffer status. Use TESTSEQ# to ensure a new buffer sequence number is not being associated with the current TBWC. All four TBWC fields and the buffer sequence number are used to communicate between your application and a component trace external writer.
THE CTRACEWR macro: To write trace buffers to trace data sets on DASD or tape, your application must be connected to an external writer. The CTRACEWR macro writes the trace buffers out to trace data sets. The trace buffer status should be set to full by the application using the CTRACECS macro before issuing the CTRACEWR macro. When the CTRACEWR macro is issued, CTRACE marks the buffer captured and when CTRACE is finished capturing the buffer, it marks the buffer available for use again. If the application tries to reuse the buffer when it is marked captured, CTRACE will not write the buffer to the external data set.