libexcept 1.1.21
Stack trace along C++ exceptions
Classes | Namespaces | Functions | Variables
stack_trace.cpp File Reference

Implementation of the stack trace. More...

#include "libexcept/exception.h"
#include "libexcept/demangle.h"
#include <iostream>
#include <memory>
#include <vector>
#include <backtrace.h>
#include <execinfo.h>
#include <link.h>
#include <unistd.h>
Include dependency graph for stack_trace.cpp:

Go to the source code of this file.

Classes

struct  libexcept::anonymous_namespace{stack_trace.cpp}::symbol_info
 Structure used to collect symbol information. More...
 

Namespaces

namespace  libexcept
 
namespace  libexcept::anonymous_namespace{stack_trace.cpp}
 

Functions

int libexcept::anonymous_namespace{stack_trace.cpp}::backtrace_callback (void *data, uintptr_t pc, char const *filename, int line, char const *function)
 Call back with backtrace data.
 
stack_trace_t libexcept::collect_stack_trace (int stack_trace_depth)
 Collect the raw stack trace in a list of strings.
 
stack_trace_t libexcept::collect_stack_trace_with_line_numbers (int stack_trace_depth)
 Collect the stack trace in a list of strings.
 
void libexcept::anonymous_namespace{stack_trace.cpp}::error_callback (void *data, char const *msg, int err)
 Capture errors while running backtrace_pcinfo().
 
backtrace_state * libexcept::anonymous_namespace{stack_trace.cpp}::get_backtrace_state ()
 Retrieve a pointer to the backtrace state.
 
bool libexcept::get_extended_stack ()
 Get the extended stack flag status.
 
void libexcept::set_extended_stack (bool extended_stack)
 Set the extended stack flag status.
 

Variables

bool libexcept::anonymous_namespace{stack_trace.cpp}::g_extended_stack = false
 The extended stack flag.
 

Detailed Description

This file includes the functions that are used to gather the stack trace from those very functions.

By default, the stack trace is turned on in our exception library. When turned on, we gather the information from the stack using the functions defined in this file. This can be very helpful when the code is able to gather the filenames and line numbers as it will tell you exactly where each function failed.

If you are running in release mode, it is likely that no line numbers will be generated since they will be removed from your executables.

Definition in file stack_trace.cpp.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.