Zero  0.1.0
Functions | Variables
trace.cpp File Reference

Tracing module. To add a new tracing type, create a constant for the type in trace_types.h. Then register it in the switch() statement below. You may also want to add a macro for that tracing type in trace.h. More...

#include "util/trace.h"
#include <cstdio>
#include "kits_thread.h"

Functions

static void trace_print_pthread (FILE *out_stream, pthread_t thread)
 Print the specified pthread_t to the specified stream. This function is reentrant. It does not flush the specified stream when complete. More...
 
static void trace_stream (FILE *out_stream, const char *filename, int line_num, const char *function_name, char const *format, va_list ap)
 Prints the entire trace message to the specified stream. More...
 
void trace_set (unsigned int trace_type_mask)
 Specify the set of trace types that are currently enabled. More...
 
unsigned int trace_get ()
 Get the set of trace types that are currently enabled. More...
 

Variables

static unsigned int trace_current_setting = ~0u
 Bit vector representing the current set of messages to be printed. Should be set at runtime to turn different message types on and off. We initialize it here to enable all messages. That way, any messages we print during client startup will be printed. More...
 
static const int FORCE_BUFFER_SIZE = 256
 
static pthread_mutex_t stream_mutex = thread_mutex_create()
 

Detailed Description

Tracing module. To add a new tracing type, create a constant for the type in trace_types.h. Then register it in the switch() statement below. You may also want to add a macro for that tracing type in trace.h.

Author
Naju Mancheril (ngm)

Function Documentation

§ trace_get()

unsigned int trace_get ( )

Get the set of trace types that are currently enabled.

§ trace_print_pthread()

static void trace_print_pthread ( FILE *  out_stream,
pthread_t  thread 
)
static

Print the specified pthread_t to the specified stream. This function is reentrant. It does not flush the specified stream when complete.

Parameters
out_streamThe stream to print the pthread_t to.
threadThe pthread_t to print.
Returns
void

§ trace_set()

void trace_set ( unsigned int  trace_type_mask)

Specify the set of trace types that are currently enabled.

Parameters
trace_type_maskBitmask used to specify the current set of trace types.

§ trace_stream()

static void trace_stream ( FILE *  out_stream,
const char *  filename,
int  line_num,
const char *  function_name,
char const *  format,
va_list  ap 
)
static

Prints the entire trace message to the specified stream.

Parameters
out_streamThe stream to print to. We flush after the print. We also make one call to fprintf(), so the message should be printed atomically.
filenameThe filename that the message is coming from. Used in message prefix.
line_numThe line number that the message is coming from. Used in message prefix.
function_nameThe name of the function where the message is coming from. Used in message prefix.
formatThe format of the output message (not counting the prefix).
apThe parameters for format.
Returns
void

Variable Documentation

§ FORCE_BUFFER_SIZE

const int FORCE_BUFFER_SIZE = 256
static

§ stream_mutex

pthread_mutex_t stream_mutex = thread_mutex_create()
static

§ trace_current_setting

unsigned int trace_current_setting = ~0u
static

Bit vector representing the current set of messages to be printed. Should be set at runtime to turn different message types on and off. We initialize it here to enable all messages. That way, any messages we print during client startup will be printed.