Collaboration diagram for mpqc::Debugger:

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.

Public Member Functions

 Debugger (const KeyVal &)
 The KeyVal constructor. More...
 
 Debugger (const char *exec=0)
 Programmatic construction of Debugger. More...
 
 ~Debugger ()
 
virtual void debug (const char *reason=0)
 
virtual void traceback (const char *reason=0)
 
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 actived when sig is caught. More...
 
virtual void release (int sig)
 
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...
 
- Public Member Functions inherited from mpqc::DescribedClass
 DescribedClass ()=default
 
virtual ~DescribedClass ()
 
std::string class_key () const
 
- Public Member Functions inherited from mpqc::enable_shared_from_this< DescribedClass >
virtual ~enable_shared_from_this ()=default
 
std::shared_ptr< DescribedClassshared_from_this ()
 returns the pointer to this object More...
 
std::shared_ptr< std::add_const_t< DescribedClass > > shared_from_this () const
 returns the pointer to this object More...
 
- Public Member Functions inherited from mpqc::detail::virt_base_of_enable_shared_from_this
virtual ~virt_base_of_enable_shared_from_this ()=default
 
bool shared_from_this_possible () const
 
template<typename Target , typename = std::enable_if_t<!std::is_const_v<Target>>>
std::shared_ptr< Target > cast_shared_from_this_to ()
 returns the pointer to this cast to a particular type More...
 
template<typename Target >
std::shared_ptr< std::add_const_t< Target > > cast_shared_from_this_to () const
 returns the pointer to this cast to a particular type 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...
 
- Static Public Member Functions inherited from mpqc::DescribedClass
static keyval_ctor_wrapper_type type_to_keyval_ctor (const std::string &type_name)
 
template<typename T >
static void register_keyval_ctor ()
 
template<typename T >
static bool is_registered ()
 
template<typename T >
static std::string class_key ()
 
static const keyval_ctor_registry_type & keyval_ctor_registry ()
 returns const ref to the keyval ctor registry More...
 

Protected Member Functions

void init ()
 

Static Protected Member Functions

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

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_
 
std::unique_ptr< int[]> mysigs_
 

Static Protected Attributes

static std::shared_ptr< Debuggerdefault_debugger_
 

Additional Inherited Members

- Public Types inherited from mpqc::DescribedClass
typedef std::shared_ptr< DescribedClass >(* keyval_ctor_wrapper_type) (const KeyVal &)
 

Constructor & Destructor Documentation

◆ Debugger() [1/2]

mpqc::Debugger::Debugger ( const KeyVal keyval)

The KeyVal constructor.

The KeyVal object will be queried for the following keywords:

debug

Try to start a debugger when an error occurs. Doesn't work on all machines. The default is true, if possible.

traceback

Try to print out a traceback extracting return addresses from the call stack. Doesn't work on most machines. The default is true, if possible.

exit

Exit on errors. The default is true.

wait_for_debugger

When starting a debugger go into an infinite loop to give the debugger a chance to attach to the process. The default is true.

sleep

When starting a debugger wait this many seconds to give the debugger a chance to attach to the process. The default is 0.

handle_defaults

Handle a standard set of signals such as SIGBUS, SIGSEGV, etc. The default is true.

prefix

Gives a string that is printed before each line that is printed by Debugger. The default is nothing.

cmd

Gives a command to be executed to start the debugger. If the environment variable DISPLAY is not set, the default is to skip launching the debugger, and to spin in a loop until the user attaches debugger to it manually. If DISPLAY is set, the default command is set to lldb_xterm if MPQC compiled with Clang compiler, or gdb_xterm otherwise, where lldb_xterm and gdb_xterm are aliases for xterm -title "" -e lldb -p & and xterm -title "" -e gdb &, respectively; token is replaced by the value of keyword prefix, is replaced by the name of the current executable, and is the process ID of each process. These commands launch one xterm per MPI rank, each running an lldb or gdb instance.

◆ Debugger() [2/2]

mpqc::Debugger::Debugger ( const char *  exec = 0)

Programmatic construction of Debugger.

This is equivalent to:

Debugger d(KeyVal());
d.set_exec(exec);
Parameters
execthe executable name

◆ ~Debugger()

mpqc::Debugger::~Debugger ( )

Member Function Documentation

◆ __traceback()

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

prints out a backtrace

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

◆ debug()

void mpqc::Debugger::debug ( const char *  reason = 0)
virtual

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

◆ default_cmd()

void mpqc::Debugger::default_cmd ( )
virtual

Calls set_cmd with a hopefully suitable default.

◆ default_debugger()

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

Return the global default debugger.

◆ got_signal()

void mpqc::Debugger::got_signal ( int  sig)
virtual

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

◆ handle()

void mpqc::Debugger::handle ( int  sig)
virtual

The Debugger will be actived when sig is caught.

◆ handle_defaults()

void mpqc::Debugger::handle_defaults ( )
virtual

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

◆ init()

void mpqc::Debugger::init ( )
protected

◆ release()

void mpqc::Debugger::release ( int  sig)
virtual

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

◆ set_cmd()

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

Sets the command to be exectuted 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.

◆ set_debug_on_signal()

void mpqc::Debugger::set_debug_on_signal ( int  v)
virtual

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

◆ set_default_debugger()

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

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

◆ set_exec()

void mpqc::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.

◆ set_exit_on_signal()

void mpqc::Debugger::set_exit_on_signal ( int  v)
virtual

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

◆ set_prefix() [1/2]

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

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

◆ set_prefix() [2/2]

void mpqc::Debugger::set_prefix ( int  p)
virtual

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

◆ set_traceback_on_signal()

void mpqc::Debugger::set_traceback_on_signal ( int  v)
virtual

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

◆ set_wait_for_debugger()

void mpqc::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.

◆ traceback()

void mpqc::Debugger::traceback ( const char *  reason = 0)
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

Member Data Documentation

◆ cmd_

std::string mpqc::Debugger::cmd_
protected

◆ debug_

bool mpqc::Debugger::debug_
protected

◆ debugger_ready_

volatile int mpqc::Debugger::debugger_ready_
protected

◆ default_debugger_

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

◆ exec_

std::string mpqc::Debugger::exec_
protected

◆ exit_on_signal_

bool mpqc::Debugger::exit_on_signal_
protected

◆ handle_sigint_

bool mpqc::Debugger::handle_sigint_
protected

◆ mysigs_

std::unique_ptr<int[]> mpqc::Debugger::mysigs_
protected

◆ prefix_

std::string mpqc::Debugger::prefix_
protected

◆ sleep_

bool mpqc::Debugger::sleep_
protected

◆ traceback_

bool mpqc::Debugger::traceback_
protected

◆ wait_for_debugger_

bool mpqc::Debugger::wait_for_debugger_
protected

The documentation for this class was generated from the following files:
Debugger(const KeyVal &)
The KeyVal constructor.
Definition: bug.cpp:67