MDAT  1.0
 All Classes Files Functions Variables Typedefs Pages
TraceManager Class Reference

trace manager More...

Public Member Functions

void init (char *fileName, bool _useConsole)
 Initializes the trace manager. More...
 
void finish ()
 Stops the trace. More...
 
void printHeader (string header)
 Prints the header. More...
 
void printThreadId (int id)
 Prints the thread ID. More...
 
void printSection (string section)
 Prints the section. More...
 
void printMessage (string message)
 Prints the message. More...
 
void printTables ()
 Prints thread, lock, and semaphore tables. More...
 
void internalError (string errorMsg)
 Report an internal error of MDAT and abort the program. More...
 
void externalError (string errorMsg)
 Report an external error of MDAT and abort the program. More...
 

Detailed Description

The trace manager is responsible for displaying state about the threads, locks, and semaphores to the trace file and/or screen.

The trace format is as follows:

  • HeaderLine: required
  • Repeated 0 or more times:
    • ThreadLine: required
    • SectionLine: optional
    • MessageLine: required
    • Tables: required
  • ErrorLine: optional

More information regarding each of the the lines in the trace format:

  • The HeaderLine gives some information about the trace such as the number of threads and the random seed.
  • The ThreadLine indicates which thread has been selected by the scheduler.
  • The SectionLine indicates that the currently running thread has entered a new section. The line indicates which section has been entered. This line is only printed out when a thread enters a new section.
  • The MessageLine gives a message on what event has occurred to cause a change in state. Often, this is a message indicating that the scheduler has been invoked. It can also gives information on changes to locks and semaphores.
  • The Tables show the state of the threads, locks, and semaphores.
  • The ErrorLine displays the error that occurs if one does occur.

Note that the trace manager is only responsible for printing. The data used by the trace manager is supplied by the appropriate managers, typically by data that is passed into the function.

The trace manager will check to make sure that the lines are printed in the proper order. This is done by an internal traceState variable which can have one of the following states:

  • HEADER: header line is next required thing to print
  • THREAD: thread line is next required thing to print
  • MESSAGE: message line is next required thing to print
  • TABLE: tables are next required thing to print

If lines are attempted to be printed out of order, the trace manager will abort the program with an error message.

All errors are handled by the trace manager so that the error message can appear in the trace file. Error messages are also printed to the console even if console output has been turned off.

Member Function Documentation

void TraceManager::init ( char *  fileName,
bool  _useConsole 
)

Initializes the trace manager. The traceState is set to HEADER.

Parameters
[in]fileNamename of trace file or NULL for no trace file
[in]_useConsoleif true, write state to console
void TraceManager::finish ( )

Stops the trace, writes the final trailing line(s) and closes the trace file.

void TraceManager::printHeader ( string  header)

Prints the header line. The traceState must be HEADER when the function is called. Switches the traceState to THREAD.

Parameters
[in]headerheader string
void TraceManager::printThreadId ( int  id)

Prints the thread id. The traceState must be THREAD when the function is called. Switches the traceState to MESSAGE.

Parameters
[in]idthread id
void TraceManager::printSection ( string  section)

Prints the section. The traceState must be MESSAGE when the function is called. The traceState remains at MESSAGE.

Parameters
[in]sectionname of section entered
void TraceManager::printMessage ( string  message)

Prints the message. The traceState must be MESSAGE when the function is called. Switches the traceState to TABLE.

Parameters
[in]messagemessage to add to trace
void TraceManager::printTables ( )

Prints the thread, lock, and semaphore tables. The traceState must be TABLE when the function is called. Switches the traceState to THREAD.

void TraceManager::internalError ( string  errorMsg)

Report an internal error of MDAT and abort the program. This function is used to report failed assertions or sanity checks within MDAT. If MDAT is implemented correctly, this function should never be called.

Parameters
[in]errorMsgerror message
void TraceManager::externalError ( string  errorMsg)

Report an external error of MDAT and abort the program. This function is used to report errors detected by MDAT. This could be due to errors detected by the checker, deadlock, or due to incorrect use of the MDAT functions.

Parameters
[in]errorMsgerror message
This is a personal WEB site developed and maintained by an individual and not by Seattle University. The content and link(s) provided on this site do not represent or reflect the view(s) of Seattle University. The individual who authored this site is solely responsible for the site's content. This site and its author are subject to applicable University policies including the Computer Acceptable Use Policy (www.seattleu.edu/policies).