[libcamera-devel] [PATCH v2 0/4] libcamera: Improve backtraces

Laurent Pinchart laurent.pinchart at ideasonboard.com
Mon Oct 4 00:36:02 CEST 2021


Hello,

This patch series improves backtrace generation. It stems from an effort
to implement a FileDescriptor leak tracker, and I'm posting it
separately because it's useful on its own.

Patch 1/4 extracts the backtrace generation code from the logger to a
new Backtrace class. The class allows capturing a backtrace (in a way
that is as lightweight as possible), and later formatting it in a
human-readable form (which can be more expensive). Backtrace instances
can thus be created relatively frequently and stored for possible later
usage.

Patches 2/4 to 4/4 then improve the Backtrace class to use libdw and/or
libunwind when available. libunwind provides both backtrace capture and
backtrace formatting capabilities, while libdw provides the latter only,
but with support for more detailed information. In both cases C++ symbol
names can now be demangled.

libdw and libunwind are optional dependencies, they will be used
automatically if found.

Changes compared to v1 are minor and listed in individual changelogs.

Laurent Pinchart (4):
  libcamera: base: Add Backtrace class
  libcamera: base: backtrace: Use libdw to provide symbolic names
  libcamera: base: backtrace: Use libunwind when available
  libcamera: base: backtrace: Fallback to libunwind for symbolic names

 include/libcamera/base/backtrace.h |  38 ++++
 include/libcamera/base/meson.build |   1 +
 meson.build                        |   4 -
 src/libcamera/base/backtrace.cpp   | 323 +++++++++++++++++++++++++++++
 src/libcamera/base/log.cpp         |  27 +--
 src/libcamera/base/meson.build     |  18 ++
 6 files changed, 388 insertions(+), 23 deletions(-)
 create mode 100644 include/libcamera/base/backtrace.h
 create mode 100644 src/libcamera/base/backtrace.cpp


base-commit: d79b41200199e03834578f5120bb8375bad37aec
-- 
Regards,

Laurent Pinchart



More information about the libcamera-devel mailing list