Debug.hpp File Reference

#include <iostream>
#include <cassert>
#include <sstream>
#include <string>
#include "PetscTools.hpp"
Include dependency graph for Debug.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define TRACE(stuff)   std::cout << FormDebugHead() << stuff << std::endl << std::flush;
#define MARK   std::cout << FormDebugHead() << __FILE__ << " at line " <<__LINE__ << std::endl << std::flush;
#define PRINT_VARIABLE(var)   std::cout << FormDebugHead() << #var " = " << var << std::endl << std::flush;
#define PRINT_2_VARIABLES(var1, var2)
#define PRINT_3_VARIABLES(var1, var2, var3)
#define PRINT_4_VARIABLES(var1, var2, var3, var4)
#define PRINT_5_VARIABLES(var1, var2, var3, var4, var5)
#define QUIT_AFTER_N_VISITS(n)   { static unsigned counter=0; if (++counter==(n)) {TRACE("User-forced quit."); assert(0);} }
#define HOW_MANY_TIMES_HERE(message)
#define TRACE_FROM_NTH_VISIT(stuff, n)
#define PRINT_VECTOR(v)

Functions

std::string FormDebugHead ()

Detailed Description

A bunch of useful macros for debugging. These all output information to stdout as lines starting "DEBUG: ". When running in parallel the process number is also displayed. Each line is flushed as soon as it is written.

Note:
Use of these should be removed from source code when committing.

Definition in file Debug.hpp.


Define Documentation

#define HOW_MANY_TIMES_HERE ( message   ) 
Value:
{ \
    static unsigned counter=1; \
    std::cout << FormDebugHead() << "Num times here (" << message << "): " << counter++ << std::endl << std::flush; }

Print how many times this line has been reached, everytime it is reached.

Parameters:
message message to include in brackets

Definition at line 105 of file Debug.hpp.

#define MARK   std::cout << FormDebugHead() << __FILE__ << " at line " <<__LINE__ << std::endl << std::flush;

Print some trace containing the file name and line number.

Definition at line 57 of file Debug.hpp.

#define PRINT_2_VARIABLES ( var1,
var2   ) 
Value:
std::cout << FormDebugHead() << #var1 " = " << var1 << ", " \
    #var2 " = " << var2 << std::endl << std::flush;

Print the name and value of the given variables.

Parameters:
var1 
var2 

Definition at line 67 of file Debug.hpp.

#define PRINT_3_VARIABLES ( var1,
var2,
var3   ) 
Value:
std::cout << FormDebugHead() << #var1 " = " << var1 << ", " \
    #var2 " = " << var2 << ", " #var3 " = " << var3 << std::endl << std::flush;

Print the name and value of the given variables.

Parameters:
var1 
var2 
var3 

Definition at line 75 of file Debug.hpp.

#define PRINT_4_VARIABLES ( var1,
var2,
var3,
var4   ) 
Value:
std::cout << FormDebugHead() << #var1 " = " << var1 << ", " \
    #var2 " = " << var2 << ", " #var3 " = " << var3 << ", " \
    #var4 " = " << var4 << std::endl << std::flush;

Print the name and value of the given variables.

Parameters:
var1 
var2 
var3 
var4 

Definition at line 84 of file Debug.hpp.

#define PRINT_5_VARIABLES ( var1,
var2,
var3,
var4,
var5   ) 
Value:
std::cout << FormDebugHead() << #var1 " = " << var1 << ", " \
    #var2 " = " << var2 << ", " #var3 " = " << var3 << ", " \
    #var4 " = " << var4 << ", " #var5 " = " << var5 <<std::endl << std::flush;

Print the name and value of the given variables.

Parameters:
var1 
var2 
var3 
var4 
var5 

Definition at line 95 of file Debug.hpp.

#define PRINT_VARIABLE ( var   )     std::cout << FormDebugHead() << #var " = " << var << std::endl << std::flush;

Print the name and value of the given variable.

Parameters:
var 

Definition at line 61 of file Debug.hpp.

#define PRINT_VECTOR (  ) 
Value:
{ std::cout << FormDebugHead() << #v " = {"; \
      for (unsigned _i=0; _i<v.size(); _i++) { \
          std::cout << (_i==0?"":",") << v[_i]; } \
      std::cout << "}" << std::endl << std::flush; }

Display a std::vector.

Parameters:
v 

Definition at line 118 of file Debug.hpp.

#define QUIT_AFTER_N_VISITS (  )     { static unsigned counter=0; if (++counter==(n)) {TRACE("User-forced quit."); assert(0);} }

Quit (assert(0)) on the n-th time this line is reached, for the given n.

Parameters:
n 

Definition at line 101 of file Debug.hpp.

#define TRACE ( stuff   )     std::cout << FormDebugHead() << stuff << std::endl << std::flush;

Print a debug message.

Parameters:
stuff what to print (can be a variable, or e.g. a << " " << b)

Definition at line 54 of file Debug.hpp.

#define TRACE_FROM_NTH_VISIT ( stuff,
 ) 
Value:
{ \
    static unsigned counter=0; \
    if (++counter>=(n)) {TRACE(stuff<<" (visit "<<counter<<")");} }

Prints the given message, but only from the n-th time that line is reached, for the given n.

Parameters:
stuff what to print
n 

Definition at line 112 of file Debug.hpp.


Function Documentation

std::string FormDebugHead (  ) 

Print a 'header' for a debug output line

Definition at line 31 of file Debug.cpp.

References PetscTools::GetMyRank(), and PetscTools::IsSequential().

Generated on Thu Dec 22 13:00:18 2011 for Chaste by  doxygen 1.6.3