From 442f516c6215aa0bbdeec4c7f2d6c406521a92fd Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 23 Nov 2019 11:20:29 +0200 Subject: libcamera: Print backtrace on fatal errors When a fatal error occurs the program aborts, and all the logger provides is the location of the line that caused the error. Extend this with a full backtrace to help debugging. The backtrace is generated using the backtrace() call, a GNU extension to the C library. It is available in glibc and uClibc but not in musl. Test for availability of the function to condition compilation of the backtrace printing. Implementing backtrace support with musl is an exercise left to the reader if desired. The LogOutput class is extended to support writing string messages directly to the output. Strings written directly will be considered as LogDebug messages when written to the Syslog. Signed-off-by: Laurent Pinchart Tested-by: Kieran Bingham Reviewed-by: Kieran Bingham --- meson.build | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'meson.build') diff --git a/meson.build b/meson.build index 0a222ba9..63448858 100644 --- a/meson.build +++ b/meson.build @@ -26,6 +26,10 @@ libcamera_version = libcamera_git_version.split('+')[0] cc = meson.get_compiler('c') config_h = configuration_data() +if cc.has_header_symbol('execinfo.h', 'backtrace') + config_h.set('HAVE_BACKTRACE', 1) +endif + if cc.has_header_symbol('stdlib.h', 'secure_getenv', prefix : '#define _GNU_SOURCE') config_h.set('HAVE_SECURE_GETENV', 1) endif -- cgit v1.2.1