From bae9d2bdb32ee8cdc717537ae498eee03a25543b Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 24 Sep 2021 04:39:58 +0300 Subject: libcamera: base: Add Backtrace class Create a new class to abstract generation and access to call stack backtraces. The current implementation depends on the glibc backtrace() implementation and is copied from the logger. Future development will bring support for libunwind, transparently for the users of the class. The logger backtrace implementation is dropped, replaced by usage of the new Backtrace class. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- include/libcamera/base/backtrace.h | 34 ++++++++++++++++++++++++++++++++++ include/libcamera/base/meson.build | 1 + 2 files changed, 35 insertions(+) create mode 100644 include/libcamera/base/backtrace.h (limited to 'include/libcamera') diff --git a/include/libcamera/base/backtrace.h b/include/libcamera/base/backtrace.h new file mode 100644 index 00000000..aefc76de --- /dev/null +++ b/include/libcamera/base/backtrace.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021, Ideas on Board Oy + * + * backtrace.h - Call stack backtraces + */ +#ifndef __LIBCAMERA_BASE_BACKTRACE_H__ +#define __LIBCAMERA_BASE_BACKTRACE_H__ + +#include +#include + +#include + +#include + +namespace libcamera { + +class Backtrace +{ +public: + Backtrace(); + + std::string toString(unsigned int skipLevels = 0) const; + +private: + LIBCAMERA_DISABLE_COPY(Backtrace) + + std::vector backtrace_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_BASE_BACKTRACE_H__ */ diff --git a/include/libcamera/base/meson.build b/include/libcamera/base/meson.build index 9feb4b93..525aba9d 100644 --- a/include/libcamera/base/meson.build +++ b/include/libcamera/base/meson.build @@ -3,6 +3,7 @@ libcamera_base_include_dir = libcamera_include_dir / 'base' libcamera_base_headers = files([ + 'backtrace.h', 'bound_method.h', 'class.h', 'event_dispatcher.h', -- cgit v1.2.1