carl  24.04
Computer ARithmetic Library
debug.h File Reference
#include <csignal>
#include <forward_list>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <sstream>
#include <typeinfo>
#include <unordered_map>
#include <vector>
#include "../meta/platform.h"
#include <unistd.h>
Include dependency graph for debug.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 carl
 carl is the main namespace for the library.
 

Macros

#define REGISTER_ASSERT
 Registers an upcoming assertion with the SIGABRT signal handler. More...
 
#define UNREGISTER_ASSERT
 
#define REGISTERED_ASSERT(condition)   REGISTER_ASSERT; assert(condition); UNREGISTER_ASSERT
 

Functions

void carl::printStacktrace ()
 Uses GDB to print a stack trace. More...
 
std::string carl::demangle (const char *name)
 
std::string carl::callingFunction ()
 
template<typename T >
std::string carl::typeString ()
 

Detailed Description

Author
Gereon Kremer gereo.nosp@m.n.kr.nosp@m.emer@.nosp@m.cs.r.nosp@m.wth-a.nosp@m.ache.nosp@m.n.de This file contains convenience routines for debugging, e.g. to print more complex data structures like STL container or print stack traces.

Definition in file debug.h.

Macro Definition Documentation

◆ REGISTER_ASSERT

#define REGISTER_ASSERT
Value:
{\
std::stringstream ss; \
ss << __FILE__ << ":" << __LINE__ << " in " << __func__ << "()"; \
}
int last_assertion_code
Stores an integer representation of the last assertion that was registered via REGISTER_ASSERT.
Definition: debug.cpp:36
std::string last_assertion_string
Stores a textual representation of the last assertion that was registered via REGISTER_ASSERT.
Definition: debug.cpp:35

Registers an upcoming assertion with the SIGABRT signal handler.

If the program is compiled in debug mode, a signal handler is installed automatically that catches SIGABRT that is send when an assertion fails. The signal handler uses the data in last_assertion_string and last_assertion_code to generate an additional message and a custom exit code whenever an assertion is thrown. As for last_assertion_code the line number of the usage of this macro is used.

If REGISTER_ASSERT was not called before SIGABRT is catched, the exit code is 23.

This macro is intended to be used to identify a single assertion from the exit code in automated testing, for example using the delta debugger. The usage will usually look like this:

REGISTER_ASSERT; assert( ... );
#define REGISTER_ASSERT
Registers an upcoming assertion with the SIGABRT signal handler.
Definition: debug.h:71

Definition at line 71 of file debug.h.

◆ REGISTERED_ASSERT

#define REGISTERED_ASSERT (   condition)    REGISTER_ASSERT; assert(condition); UNREGISTER_ASSERT

Definition at line 81 of file debug.h.

◆ UNREGISTER_ASSERT

#define UNREGISTER_ASSERT
Value:

Definition at line 77 of file debug.h.