Tor  0.4.7.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.

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.

◆ 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_().

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().