libcamera: libcamera::Backtrace Class Reference

libcamera v0.7.1 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
libcamera::Backtrace Class Reference

Representation of a call stack backtrace. More...

## Public Member Functions
| Backtrace ()
| Construct a backtrace.
std::string | toString (unsigned int skipLevels=0) const
| Convert a backtrace to a string representation.

## Detailed Description

Representation of a call stack backtrace.

The Backtrace class represents a function call stack. Constructing an instance captures the call stack at the point the instance is constructed. The instance can later be used to access the call stack and to generate a human-readable representation with the toString() function.

Depending on the platform, different backends can be used to generate the backtrace. The Backtrace class provides a best effort to capture accurate backtraces, but doesn't offer any guarantee of a particular backtrace format.

## Constructor & Destructor Documentation

## ◆ Backtrace()

libcamera::Backtrace::Backtrace | ( |  | ) |

Construct a backtrace.

The backtrace captures the call stack at the point where it is constructed. It can later be converted to a string with toString().

## Member Function Documentation

## ◆ toString()

std::string libcamera::Backtrace::toString | ( | unsigned int | skipLevels = 0 | ) | const

Convert a backtrace to a string representation.

Parameters

  [in] | skipLevels | Number of initial levels to skip in the backtrace

The string representation of the backtrace is a multi-line string, with one line per call stack entry. The format of the entries isn't specified and is platform-dependent.

The skipLevels parameter indicates how many initial entries to skip from the backtrace. This can be used to hide functions that wrap the construction of the Backtrace instance from the call stack. The Backtrace constructor itself is automatically skipped and never shown in the backtrace.

If backtrace generation fails for any reason (usually because the platform doesn't support this feature), an empty string is returned.

Returns
  A string representation of the backtrace, or an empty string if backtrace generation isn't possible

The documentation for this class was generated from the following files:

- include/libcamera/base/backtrace.h
- src/libcamera/base/backtrace.cpp