diagnostic.h File Reference

interface to the exception classes for timing and diagnostic within LIBPF More...

#include <string>
#include <iostream>
#include <algorithm>
#include "Error.h"

Classes

class  Diagnostic
 

Macros

#define diagnostic(verbosityLevel_, diagnosticMessage_)   { if (verbosityLevel_ <= verbosityLocal + verbosityFile + verbosityInstance + verbosityGlobal) { std::cout << CURRENT_FUNCTION << " " << std::string(std::max(0, verbosityLevel_+1), '*') << " " << diagnosticMessage_ << std::endl; } }
 
#define my_assert(assertion_, errorMessage_)   { if (assertion_) { ++count; } else { std::cout << CURRENT_FUNCTION << " *** test failed: " << errorMessage_ << std::endl; ++count; ++failcount; }}
 

Functions

int quit (int id)
 
void setIdFile (int id)
 on Unix and OSX, write to a "id.txt" file the id More...
 
std::string shorten (const char *s1)
 

Variables

int verbosityGlobal
 control global verbosity level; set to 0 for (default) level, 3 for detailed diagnostic level, 10 for maximum level More...
 

Detailed Description

interface to the exception classes for timing and diagnostic within LIBPF

This file is part of LIBPF All rights reserved; do not distribute without permission.

Author
(C) Copyright 2004-2023 Paolo Greppi simevo s.r.l.

Macro Definition Documentation

◆ diagnostic

#define diagnostic (   verbosityLevel_,
  diagnosticMessage_ 
)    { if (verbosityLevel_ <= verbosityLocal + verbosityFile + verbosityInstance + verbosityGlobal) { std::cout << CURRENT_FUNCTION << " " << std::string(std::max(0, verbosityLevel_+1), '*') << " " << diagnosticMessage_ << std::endl; } }

Print diagnostic message diagnosticMessage_ if the verbosity level is higher than verbosityLevel_ Set verbosityLevel_ to:

  • 0 for high-priority messages
  • 1 for informational messages
  • 2 for function and member function entry/exit
  • 3 for detailed diagnostic

◆ my_assert

#define my_assert (   assertion_,
  errorMessage_ 
)    { if (assertion_) { ++count; } else { std::cout << CURRENT_FUNCTION << " *** test failed: " << errorMessage_ << std::endl; ++count; ++failcount; }}

Function Documentation

◆ quit()

int quit ( int  id)

customized exit function

  • on Unix and OSX, exit statuses are restricted to values 0-255 (the range of an unsigned 8-bit integer) to return an integer we write it to a "id.txt" (
    See also
    setIdFile)
  • on Windows, the integer can be returned as the process's exit code

◆ setIdFile()

void setIdFile ( int  id)

on Unix and OSX, write to a "id.txt" file the id

◆ shorten()

std::string shorten ( const char *  s1)

used to shorten GCC's __PRETTY_FUNCTION__ to make it equivalent with other compilers

Remarks
implemented in Error.cc

Variable Documentation

◆ verbosityGlobal

int verbosityGlobal
extern

control global verbosity level; set to 0 for (default) level, 3 for detailed diagnostic level, 10 for maximum level