Macros | Functions | Variables
backtrace.c File Reference
#include "orconfig.h"
#include "lib/err/torerr.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "lib/err/backtrace.h"

Go to the source code of this file.


#define raw_free   free


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)


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 303 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 274 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 267 of file backtrace.c.

References bt_version.

Referenced by tor_raw_assertion_failed_msg_().

Variable Documentation

◆ bt_version

char bt_version[128] = ""

Version of Tor to report in backtrace messages.

Definition at line 72 of file backtrace.c.

Referenced by get_tor_backtrace_version().