-
Notifications
You must be signed in to change notification settings - Fork 0
callstack.hpp
This header defines the C++ wrapper class for the callstack structure.
It's not necessary to include this header on its own, this is automatically done by callstack.h.
The namespace used to separate the wrapper class from the struct callstack, declared in
callstack.h.
The actual wrapper class, consisting of all necessary operators and constructors for seamlessly integration into C++ code.
typedef ::callstack struct_callstack
A typedef to improve the readability of the code.
struct_callstack self
A private variable containing the underlying struct callstack.
Note
The underlying callstack object is managed by this class.
The default constructor. Creates a new backtrace unless emplace is set to false.
In either case, the underlying struct callstack is properly initialized.
If the backtrace could not be created a runtime_error or a system_error if compiled using C++11 or newer is thrown.
Initializes the underlying struct callstack creating a backtrace of the calling function,
ignoring all frames after the given address.
If the backtrace could not be created a runtime_error or a system_error if compiled using C++11 or newer is thrown.
Constructs the underlying struct callstack using the given trace.
If the length of the trace is smaller than 0 a runtime_error or a system_error if compiled using C++11 or newer
is thrown.
callstack::callstack(const callstack&other)
Trivial copy constructor.
explicit callstack::callstack(const struct_callstack* other)
Constructs a callstack object using the given struct callstack.
callstack::callstack(callstack&& other)
Trivial move constructor. Only available when compiled using a compiler supporting C++11 or newer.
Trivial destructor.
callstack& operator=(const callstack& other)
Trivial copy assignment operator.
callstack& operator=(callstack&& other)
Trivial move assignment operator. Only available when compiled using a compiler supporting C++11 or newer.
operator struct_callstack*()
Implicit casting operator. Returns a pointer to the underlying struct callstack.
operator const struct_callstack*() const
Implicit casting operator. Returns a pointer to the underlying struct callstack.
struct_callstack* operator->()
Dereferencing operator. Returns a pointer to the underlying struct callstack.
Note
Added in version 1.1.
const struct_callstack* operator->() const
Dereferencing operator. Returns a pointer to the underlying struct callstack.
Note
Added in version 1.1.
Private helper function used to throw either a system_error if compiled using C++11
or newer or to throw a runtime_error otherwise.
callstack& translate(const bool onlyBinaries = false)
Translates the callstack object.
If desired, only the runtime image names are deducted.
Throws an exception if the translation failed.
Note
Added in version 2.1.
void relativize(const char* binaryNames[CALLSTACK_BACKTRACE_SIZE])
Relativizes the callstack object. For each frame, the name of the binary file is placed into the given array, and the
address of the callstack frame is relative to its binary file.
This operation can be undone by using the method absolutize().
Note
Added in version 2.3.
std::array<const char*, CALLSTACK_BACKTRACE_SIZE> relativize()
Relativizes the callstack object. For each frame, the name of the binary file is placed into an array, which is
then returned. Afterward, the address of each callstack frame is relative to its binary file.
This operation can be undone by using the method absolutize().
This method is only available when using a compiler compatible with C++11 or newer.
Note
Added in version 2.3.
callstack_frame* absolutize(const char** binaryNames)
Absolutizes and translates the callstack object. Each frame is absolutized by using the indicated binary file name. The
given array of binary file names must at least contain as much file names as callstack frames of the callstack object.
The translated callstack frame array is returned.
Note
Added in version 2.3.
const callstack_frame* begin()
Returns a pointer to the first callstack frame in the translated callstack frame array.
This pointer can be used as begin iterator.
Note
Added in version 2.1.
const callstack_frame* end()
Returns a pointer past the last callstack frame in the translated callstack frame array.
This pointer can be used as (past the) end iterator.
Note
Added in version 2.1.
Copyright (C) 2022, 2024 - 2026 mhahnFr.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".