backtrace.h
Go to the documentation of this file.
/*
* Copyright © 2014 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authored by: Thomas Voß <thomas.voss@canonical.com>
*/
#ifndef CORE_POSIX_BACKTRACE_H_
#define CORE_POSIX_BACKTRACE_H_
#include <core/posix/visibility.h>
#include <functional>
#include <memory>
#include <string>
namespace core
{
namespace posix
{
namespace backtrace
{
class Frame
{
public:
class Symbol
{
public:
static std::shared_ptr<Symbol> for_testing_from_raw_symbol(const char* symbol);
Symbol(const Symbol&) = delete;
virtual ~Symbol() = default;
Symbol& operator=(const Symbol&) = delete;
virtual bool is_cxx() const = 0;
virtual std::string demangled() const = 0;
virtual std::string raw() const = 0;
protected:
Symbol() = default;
};
Frame(const Frame&) = delete;
virtual ~Frame() = default;
Frame& operator=(const Frame&) = delete;
virtual std::size_t depth() const = 0;
virtual void* frame_pointer() const = 0;
virtual const Symbol& symbol() const = 0;
protected:
Frame() = default;
};
typedef std::function<bool(const Frame& frame)> FrameHandler;
void visit_with_handler(const FrameHandler& handler);
}
}
}
#endif // CORE_POSIX_BACKTRACE_H_
core::posix::backtrace::Frame::Symbol
The Symbol class models the symbolic representation of a frame pointer.
Definition backtrace.h:44
core::posix::backtrace::Frame::Symbol::demangled
virtual std::string demangled() const =0
demangled returns the demangled C++ symbol name or raw.
core::posix::backtrace::Frame::Symbol::raw
virtual std::string raw() const =0
raw The raw symbolic representation of a frame pointer.
core::posix::backtrace::Frame::Symbol::for_testing_from_raw_symbol
static std::shared_ptr< Symbol > for_testing_from_raw_symbol(const char *symbol)
Definition backtrace.cpp:120
core::posix::backtrace::Frame::Symbol::Symbol
Symbol(const Symbol &)=delete
core::posix::backtrace::Frame::Symbol::~Symbol
virtual ~Symbol()=default
core::posix::backtrace::Frame::Symbol::Symbol
Symbol()=default
core::posix::backtrace::Frame::Symbol::is_cxx
virtual bool is_cxx() const =0
is_cxx checks whether the symbol refers to a mangled C++ symbol.
core::posix::backtrace::Frame::Symbol::operator=
Symbol & operator=(const Symbol &)=delete
core::posix::backtrace::Frame
The Frame class models an individual frame of a backtrace.
Definition backtrace.h:38
core::posix::backtrace::Frame::operator=
Frame & operator=(const Frame &)=delete
core::posix::backtrace::Frame::symbol
virtual const Symbol & symbol() const =0
symbol returns the symbolic representation of this frame.
core::posix::backtrace::Frame::Frame
Frame(const Frame &)=delete
core::posix::backtrace::Frame::~Frame
virtual ~Frame()=default
core::posix::backtrace::Frame::Frame
Frame()=default
core::posix::backtrace::Frame::frame_pointer
virtual void * frame_pointer() const =0
frame_pointer returns the the raw frame pointer of this frame.
core::posix::backtrace::Frame::depth
virtual std::size_t depth() const =0
depth returns the depth of this frame in the overall backtrace.
core::posix::backtrace::visit_with_handler
void visit_with_handler(const FrameHandler &handler)
visit_with_handler iterates the backtrace of the calling program, invoking the handler for every fram...
Definition backtrace.cpp:125
core::posix::backtrace::FrameHandler
std::function< bool(const Frame &frame)> FrameHandler
FrameHandler is the functor invoked for every frame of a backtrace.
Definition backtrace.h:106
core
Definition child_process.h:32
visibility.h