---
name: "sc_Debugger"
section: "3"
platform: "linux"
package: "libsc-doc"
version: "2.3.1-22"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/sc_Debugger"
---

# sc\_Debugger(3)

The Debugger class describes what should be done when a catastrophic error causes unexpected program termination.

## NAME

sc::Debugger - The **Debugger** class describes what should be done when a catastrophic error causes unexpected program termination.

## SYNOPSIS

`#include <bug.h>`

Inherits **sc::SavableState**.

### Public Member Functions

**Debugger** (const char \*exec=0)\
 **Debugger** (const **Ref**\< **KeyVal** \> &)\
 The **KeyVal** constructor understands the following keywords:  **Debugger** (**StateIn** &)\
 virtual void **debug** (const char \*reason=0)\
 The debug member attempts to start a debugger running on the current process.  virtual void **traceback** (const char \*reason=0)\
 The traceback member attempts a stack traceback for the current process.  virtual void **set\_debug\_on\_signal** (int)\
 Turn on or off debugging on a signel. The default is on.  virtual void **set\_traceback\_on\_signal** (int)\
 Turn on or off traceback on a signel. The default is on.  virtual void **set\_exit\_on\_signal** (int)\
 Turn on or off exit after a signel. The default is on.  virtual void **set\_wait\_for\_debugger** (int)\
 Turn on or off running an infinite loop after the debugger is started.  virtual void **handle** (int sig)\
 The **Debugger** will be actived when sig is caught.  virtual void **handle\_defaults** ()\
 This calls **handle(int)** with all of the major signals.  virtual void **set\_prefix** (const char \*p)\
 This sets a prefix which preceeds all messages printing by **Debugger**.  virtual void **set\_prefix** (int p)\
 Set the prefix to the decimal represention of p followed by a ': '.  virtual void **set\_cmd** (const char \*)\
 Sets the command to be exectuted when debug is called.  virtual void **default\_cmd** ()\
 Calls set\_cmd with a hopefully suitable default.  virtual void **set\_exec** (const char \*)\
 Set the name of the exectuble for the current process.  virtual void **got\_signal** (int sig)\
 Called with signal sig is received. This is mainly for internal use.  void **save\_data\_state** (**StateOut** &)\
 Save the base classes (with save\_data\_state) and the members in the same order that the **StateIn** CTOR initializes them.

### Static Public Member Functions

static void **set\_default\_debugger** (const **Ref**\< **Debugger** \> &)\
 Set the global default debugger. The initial value is null.  static **Debugger** \* **default\_debugger** ()\
 Return the global default debugger.

### Protected Member Functions

void **init** ()\

### Protected Attributes

char \* **prefix\_**\
 char \* **exec\_**\
 char \* **cmd\_**\
 volatile int **debugger\_ready\_**\
 int **debug\_**\
 int **traceback\_**\
 int **exit\_on\_signal\_**\
 int **sleep\_**\
 int **wait\_for\_debugger\_**\
 int **handle\_sigint\_**\
 int \* **mysigs\_**\

### Static Protected Attributes

static **Debugger** \* **default\_debugger\_**\

## Detailed Description

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. \

## Constructor & Destructor Documentation

### sc::Debugger::Debugger (const Ref\< KeyVal \> &)

The **KeyVal** constructor understands 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. The default varies with machine.

## Member Function Documentation

### void sc::Debugger::save\_data\_state (StateOut &)` [virtual]`

Save the base classes (with save\_data\_state) and the members in the same order that the **StateIn** CTOR initializes them. This must be implemented by the derived class if the class has data.

Reimplemented from **sc::SavableState**.

### virtual void sc::Debugger::set\_cmd (const char \*)` [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.

### virtual void sc::Debugger::set\_exec (const char \*)` [virtual]`

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

### virtual void sc::Debugger::set\_wait\_for\_debugger (int)` [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.

### virtual void sc::Debugger::traceback (const char \* reason = `0`)` [virtual]`

The traceback member attempts a stack traceback for the current process. A symbol table must be saved for the executable if any sense is to be made of the traceback. Tracebacks are currently available only for a limited number of architectures.

## Author

Generated automatically by Doxygen for MPQC from the source code.
