Documentation

The Debugger class describes what should be done when a catastrophic error causes unexpected program termination. It can try things such as start a debugger running where the program died or it can attempt to produce a stack traceback showing roughly where the program died. These attempts will not always succeed.

Definition at line 270 of file bug.h.

Public Member Functions

 Debugger (const char *exec=nullptr)
 Programmatic construction of Debugger. More...
 
virtual ~Debugger ()
 
virtual void debug (const char *reason)
 
virtual void traceback (const char *reason)
 
virtual void set_debug_on_signal (int)
 Turn on or off debugging on a signel. The default is on. More...
 
virtual void set_traceback_on_signal (int)
 Turn on or off traceback on a signel. The default is on. More...
 
virtual void set_exit_on_signal (int)
 Turn on or off exit after a signel. The default is on. More...
 
virtual void set_wait_for_debugger (int)
 
virtual void handle (int sig)
 The Debugger will be activated when sig is caught. More...
 
virtual void release (int sig)
 Reverts the effect of handle(sig) , i.e. the Debugger will not be activated when sig is caught. More...
 
virtual void handle_defaults ()
 This calls handle(int) with all of the major signals. More...
 
virtual void set_prefix (const char *p)
 This sets a prefix which preceeds all messages printing by Debugger. More...
 
virtual void set_prefix (int p)
 Set the prefix to the decimal represention of p followed by a ": ". More...
 
virtual void set_cmd (const char *)
 
virtual void default_cmd ()
 Calls set_cmd with a hopefully suitable default. More...
 
virtual void set_exec (const char *)
 
virtual void got_signal (int sig)
 Called when signal sig is received. This is mainly for internal use. More...
 

Static Public Member Functions

static void set_default_debugger (const std::shared_ptr< Debugger > &)
 Set the global default debugger. The initial value is null. More...
 
static std::shared_ptr< Debuggerdefault_debugger ()
 Return the global default debugger. More...
 

Protected Member Functions

void init ()
 

Static Protected Member Functions

static void __traceback (const std::string &prefix, const char *reason=nullptr)
 

Protected Attributes

std::string prefix_
 
std::string exec_
 
std::string cmd_
 
volatile int debugger_ready_
 
bool debug_
 
bool traceback_
 
bool exit_on_signal_
 
bool sleep_
 
bool wait_for_debugger_
 
bool handle_sigint_
 
int * mysigs_
 

Static Protected Attributes

static std::shared_ptr< Debuggerdefault_debugger_
 

Constructor & Destructor Documentation

◆ Debugger()

Debugger::Debugger ( const char *  exec = nullptr)
explicit

Programmatic construction of Debugger.

Parameters
execthe executable name

Definition at line 157 of file bug.cpp.

◆ ~Debugger()

Debugger::~Debugger ( )
virtual

Definition at line 174 of file bug.cpp.

Member Function Documentation

◆ __traceback()

void Debugger::__traceback ( const std::string &  prefix,
const char *  reason = nullptr 
)
staticprotected

prints out a backtrace to std::cout

Parameters
prefixthis string will be prepended at the beginning of each line of Backtrace
reasonoptional string specifying the reason for traceback

Definition at line 414 of file bug.cpp.

◆ debug()

void Debugger::debug ( const char *  reason)
virtual

The debug member attempts to start a debugger running on the current process.

Definition at line 298 of file bug.cpp.

◆ default_cmd()

void Debugger::default_cmd ( )
virtual

Calls set_cmd with a hopefully suitable default.

Definition at line 271 of file bug.cpp.

◆ default_debugger()

std::shared_ptr< Debugger > Debugger::default_debugger ( )
static

Return the global default debugger.

Definition at line 408 of file bug.cpp.

◆ got_signal()

void Debugger::got_signal ( int  sig)
virtual

Called when signal sig is received. This is mainly for internal use.

Definition at line 360 of file bug.cpp.

◆ handle()

void Debugger::handle ( int  sig)
virtual

The Debugger will be activated when sig is caught.

Definition at line 204 of file bug.cpp.

◆ handle_defaults()

void Debugger::handle_defaults ( )
virtual

This calls handle(int) with all of the major signals.

Definition at line 219 of file bug.cpp.

◆ init()

void Debugger::init ( )
protected

Definition at line 181 of file bug.cpp.

◆ release()

void Debugger::release ( int  sig)
virtual

Reverts the effect of handle(sig) , i.e. the Debugger will not be activated when sig is caught.

Definition at line 212 of file bug.cpp.

◆ set_cmd()

void Debugger::set_cmd ( const char *  cmd)
virtual

Sets the command to be executed when debug is called. The character sequence "$(EXEC)" is replaced by the executable name (see set_exec), "$(PID)" is replaced by the current process id, and "$(PREFIX)" is replaced by the prefix.

Definition at line 289 of file bug.cpp.

◆ set_debug_on_signal()

void Debugger::set_debug_on_signal ( int  v)
virtual

Turn on or off debugging on a signel. The default is on.

Definition at line 398 of file bug.cpp.

◆ set_default_debugger()

void Debugger::set_default_debugger ( const std::shared_ptr< Debugger > &  d)
static

Set the global default debugger. The initial value is null.

Definition at line 406 of file bug.cpp.

◆ set_exec()

void Debugger::set_exec ( const char *  exec)
virtual

Set the name of the executable for the current process. It is up to the programmer to set this, even if the Debugger is initialized with the KeyVal constructor.

Definition at line 249 of file bug.cpp.

◆ set_exit_on_signal()

void Debugger::set_exit_on_signal ( int  v)
virtual

Turn on or off exit after a signel. The default is on.

Definition at line 404 of file bug.cpp.

◆ set_prefix() [1/2]

void Debugger::set_prefix ( const char *  p)
virtual

This sets a prefix which preceeds all messages printing by Debugger.

Definition at line 257 of file bug.cpp.

◆ set_prefix() [2/2]

void Debugger::set_prefix ( int  p)
virtual

Set the prefix to the decimal represention of p followed by a ": ".

Definition at line 265 of file bug.cpp.

◆ set_traceback_on_signal()

void Debugger::set_traceback_on_signal ( int  v)
virtual

Turn on or off traceback on a signel. The default is on.

Definition at line 400 of file bug.cpp.

◆ set_wait_for_debugger()

void Debugger::set_wait_for_debugger ( int  v)
virtual

Turn on or off running an infinite loop after the debugger is started. This loop gives the debugger a chance to attack to the process. The default is on.

Definition at line 402 of file bug.cpp.

◆ traceback()

void Debugger::traceback ( const char *  reason)
virtual

The traceback member attempts to produce a Backtrace for the current process. A symbol table must be saved for the executable if any sense is to be made of the traceback. This feature is available on platforms with (1) libunwind, (2) backtrace, or (3) certain platforms with hardwired unwinding.

Parameters
reasonoptional string specifying the reason for traceback

Definition at line 412 of file bug.cpp.

Member Data Documentation

◆ cmd_

std::string ttg::Debugger::cmd_
protected

Definition at line 274 of file bug.h.

◆ debug_

bool ttg::Debugger::debug_
protected

Definition at line 277 of file bug.h.

◆ debugger_ready_

volatile int ttg::Debugger::debugger_ready_
protected

Definition at line 275 of file bug.h.

◆ default_debugger_

std::shared_ptr< Debugger > Debugger::default_debugger_
staticprotected

Definition at line 287 of file bug.h.

◆ exec_

std::string ttg::Debugger::exec_
protected

Definition at line 273 of file bug.h.

◆ exit_on_signal_

bool ttg::Debugger::exit_on_signal_
protected

Definition at line 279 of file bug.h.

◆ handle_sigint_

bool ttg::Debugger::handle_sigint_
protected

Definition at line 282 of file bug.h.

◆ mysigs_

int* ttg::Debugger::mysigs_
protected

Definition at line 283 of file bug.h.

◆ prefix_

std::string ttg::Debugger::prefix_
protected

Definition at line 272 of file bug.h.

◆ sleep_

bool ttg::Debugger::sleep_
protected

Definition at line 280 of file bug.h.

◆ traceback_

bool ttg::Debugger::traceback_
protected

Definition at line 278 of file bug.h.

◆ wait_for_debugger_

bool ttg::Debugger::wait_for_debugger_
protected

Definition at line 281 of file bug.h.


The documentation for this class was generated from the following files: