Tor 0.4.9.0-alpha-dev
Macros | Functions | Variables
backtrace.c File Reference

Functions to produce backtraces on bugs, crashes, or assertion failures. More...

#include "orconfig.h"
#include "lib/err/torerr.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "lib/cc/ctassert.h"
#include "lib/err/backtrace.h"

Go to the source code of this file.

Macros

#define BACKTRACE_PRIVATE
 
#define NO_BACKTRACE_IMPL
 
#define raw_free   free
 

Functions

void log_backtrace_impl (int severity, log_domain_mask_t domain, const char *msg, tor_log_fn logger)
 
static int install_bt_handler (void)
 
static void remove_bt_handler (void)
 
void dump_stack_symbols_to_error_fds (void)
 
const char * get_tor_backtrace_version (void)
 
int configure_backtrace_handler (const char *tor_version)
 
void clean_up_backtrace_handler (void)
 

Variables

static char bt_version [128] = ""
 

Detailed Description

Functions to produce backtraces on bugs, crashes, or assertion failures.

Currently, we've only got an implementation here using the backtrace() family of functions, which are sometimes provided by libc and sometimes provided by libexecinfo. We tie into the sigaction() backend in order to detect crashes.

This is one of the lowest-level modules, since nearly everything needs to be able to log an error. As such, it doesn't call the log module or any other higher-level modules directly.

Definition in file backtrace.c.

Macro Definition Documentation

◆ BACKTRACE_PRIVATE

#define BACKTRACE_PRIVATE

Definition at line 57 of file backtrace.c.

◆ NO_BACKTRACE_IMPL

#define NO_BACKTRACE_IMPL

Definition at line 67 of file backtrace.c.

◆ raw_free

#define raw_free   free

Definition at line 71 of file backtrace.c.

Function Documentation

◆ clean_up_backtrace_handler()

void clean_up_backtrace_handler ( void  )

Perform end-of-process cleanup for code that generates error messages on crashes.

Definition at line 359 of file backtrace.c.

◆ configure_backtrace_handler()

int configure_backtrace_handler ( const char *  tor_version)

Set up code to handle generating error messages on crashes.

Definition at line 330 of file backtrace.c.

◆ dump_stack_symbols_to_error_fds()

void dump_stack_symbols_to_error_fds ( void  )

Definition at line 315 of file backtrace.c.

◆ get_tor_backtrace_version()

const char * get_tor_backtrace_version ( void  )

Return the tor version used for error messages on crashes. Signal-safe: returns a pointer to a static array.

Definition at line 323 of file backtrace.c.

Referenced by tor_raw_assertion_failed_msg_().

◆ install_bt_handler()

static int install_bt_handler ( void  )
static

Definition at line 304 of file backtrace.c.

◆ log_backtrace_impl()

void log_backtrace_impl ( int  severity,
log_domain_mask_t  domain,
const char *  msg,
tor_log_fn  logger 
)

Definition at line 296 of file backtrace.c.

◆ remove_bt_handler()

static void remove_bt_handler ( void  )
static

Definition at line 310 of file backtrace.c.

Variable Documentation

◆ bt_version

char bt_version[128] = ""
static

Version of Tor to report in backtrace messages.

Definition at line 74 of file backtrace.c.

Referenced by get_tor_backtrace_version().