libunwind has an API to provide symbolic names for functions. It's less optimal than using backtrace_symbols() or libdw, as it doesn't allow deferring the symbolic names lookup, but it can be usefull as a fallback if no other option is available. A sample backtrace when falling back to libunwind looks like libcamera::VimcCameraData::init()+0xbd libcamera::PipelineHandlerVimc::match(libcamera::DeviceEnumerator*)+0x3e0 libcamera::CameraManager::Private::createPipelineHandlers()+0x1a7 libcamera::CameraManager::Private::init()+0x98 libcamera::CameraManager::Private::run()+0x9f libcamera::Thread::startThread()+0xee decltype(*(std::__1::forward<libcamera::Thread*>(fp0)).*fp()) std::__1::__invoke<void (libcamera::Thread::*)(), libcamera::Thread*, void>(void (libcamera::Thread::*&&)(), libcamera::Thread*&&)+0x77 void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (libcamera::Thread::*)(), libcamera::Thread*, 2ul>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (libcamera::Thread::*)(), libcamera::Thread*>&, std::__1::__tuple_indices<2ul>)+0x3e void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (libcamera::Thread::*)(), libcamera::Thread*> >(void*)+0x62 start_thread+0xde ??? Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
39 lines
693 B
C++
39 lines
693 B
C++
/* 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)
|
|
|
|
bool backtraceTrace();
|
|
bool unwindTrace();
|
|
|
|
std::vector<void *> backtrace_;
|
|
std::vector<std::string> backtraceText_;
|
|
};
|
|
|
|
} /* namespace libcamera */
|
|
|
|
#endif /* __LIBCAMERA_BASE_BACKTRACE_H__ */
|