summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-09-24 04:39:58 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-10-15 05:05:20 +0300
commitbae9d2bdb32ee8cdc717537ae498eee03a25543b (patch)
treec582f59b5bf2a00363d17e4982f64997b9a4ce29 /include
parentca5fb994091e7b3ba6db484ae0a58e2ecd00abbf (diff)
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 <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/base/backtrace.h34
-rw-r--r--include/libcamera/base/meson.build1
2 files changed, 35 insertions, 0 deletions
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 <string>
+#include <vector>
+
+#include <libcamera/base/private.h>
+
+#include <libcamera/base/class.h>
+
+namespace libcamera {
+
+class Backtrace
+{
+public:
+ Backtrace();
+
+ std::string toString(unsigned int skipLevels = 0) const;
+
+private:
+ LIBCAMERA_DISABLE_COPY(Backtrace)
+
+ std::vector<void *> 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',