libcamera: tracing: Implement tracing infrastructure
Implement tracing infrastructure in libcamera. It takes .tp files, as required by lttng, and generates a tracepoint header and C file, as lttng requires. meson is updated accordingly to get it to compile with the rest of libcamera. Update the documentation accordingly. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
4757ff4ab7
commit
fcc6d4bd76
12 changed files with 149 additions and 1 deletions
|
@ -840,7 +840,9 @@ EXCLUDE = @TOP_SRCDIR@/include/libcamera/span.h \
|
||||||
@TOP_SRCDIR@/src/libcamera/device_enumerator_sysfs.cpp \
|
@TOP_SRCDIR@/src/libcamera/device_enumerator_sysfs.cpp \
|
||||||
@TOP_SRCDIR@/src/libcamera/device_enumerator_udev.cpp \
|
@TOP_SRCDIR@/src/libcamera/device_enumerator_udev.cpp \
|
||||||
@TOP_SRCDIR@/src/libcamera/pipeline/ \
|
@TOP_SRCDIR@/src/libcamera/pipeline/ \
|
||||||
@TOP_SRCDIR@/src/libcamera/proxy/
|
@TOP_SRCDIR@/src/libcamera/proxy/ \
|
||||||
|
@TOP_SRCDIR@/src/libcamera/tracepoints.cpp \
|
||||||
|
@TOP_BUILDDIR@/include/libcamera/internal/tracepoints.h
|
||||||
|
|
||||||
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
|
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
|
||||||
# directories that are symbolic links (a Unix file system feature) are excluded
|
# directories that are symbolic links (a Unix file system feature) are excluded
|
||||||
|
|
|
@ -81,6 +81,9 @@ for gstreamer: [optional]
|
||||||
for qcam: [optional]
|
for qcam: [optional]
|
||||||
qtbase5-dev libqt5core5a libqt5gui5 libqt5widgets5 qttools5-dev-tools libtiff-dev
|
qtbase5-dev libqt5core5a libqt5gui5 libqt5widgets5 qttools5-dev-tools libtiff-dev
|
||||||
|
|
||||||
|
for tracing with lttng: [optional]
|
||||||
|
lttng-ust-dev python3-jinja2
|
||||||
|
|
||||||
Using GStreamer plugin
|
Using GStreamer plugin
|
||||||
~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,14 @@
|
||||||
# SPDX-License-Identifier: CC0-1.0
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
|
subdir('tracepoints')
|
||||||
|
|
||||||
|
libcamera_tracepoint_header = custom_target(
|
||||||
|
'tp_header',
|
||||||
|
input: [ 'tracepoints.h.in', tracepoint_files ],
|
||||||
|
output: 'tracepoints.h',
|
||||||
|
command: [ gen_tracepoints_header, '@OUTPUT@', '@INPUT@' ],
|
||||||
|
)
|
||||||
|
|
||||||
libcamera_internal_headers = files([
|
libcamera_internal_headers = files([
|
||||||
'byte_stream_buffer.h',
|
'byte_stream_buffer.h',
|
||||||
'camera_controls.h',
|
'camera_controls.h',
|
||||||
|
|
61
include/libcamera/internal/tracepoints.h.in
Normal file
61
include/libcamera/internal/tracepoints.h.in
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
|
/*
|
||||||
|
* Copyright (C) {{year}}, Google Inc.
|
||||||
|
*
|
||||||
|
* tracepoints.h - Tracepoints with lttng
|
||||||
|
*
|
||||||
|
* This file is auto-generated. Do not edit.
|
||||||
|
*/
|
||||||
|
#ifndef __LIBCAMERA_INTERNAL_TRACEPOINTS_H__
|
||||||
|
#define __LIBCAMERA_INTERNAL_TRACEPOINTS_H__
|
||||||
|
|
||||||
|
#if HAVE_TRACING
|
||||||
|
#define LIBCAMERA_TRACEPOINT(...) tracepoint(libcamera, __VA_ARGS__)
|
||||||
|
|
||||||
|
#define LIBCAMERA_TRACEPOINT_IPA_BEGIN(pipe, func) \
|
||||||
|
tracepoint(libcamera, ipa_call_begin, #pipe, #func)
|
||||||
|
|
||||||
|
#define LIBCAMERA_TRACEPOINT_IPA_END(pipe, func) \
|
||||||
|
tracepoint(libcamera, ipa_call_end, #pipe, #func)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
template <typename ...Args>
|
||||||
|
inline void unused([[maybe_unused]] Args&& ...args)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace */
|
||||||
|
|
||||||
|
#define LIBCAMERA_TRACEPOINT(category, ...) unused(__VA_ARGS__)
|
||||||
|
|
||||||
|
#define LIBCAMERA_TRACEPOINT_IPA_BEGIN(pipe, func)
|
||||||
|
#define LIBCAMERA_TRACEPOINT_IPA_END(pipe, func)
|
||||||
|
|
||||||
|
#endif /* HAVE_TRACING */
|
||||||
|
|
||||||
|
#endif /* __LIBCAMERA_INTERNAL_TRACEPOINTS_H__ */
|
||||||
|
|
||||||
|
|
||||||
|
#if HAVE_TRACING
|
||||||
|
|
||||||
|
#undef TRACEPOINT_PROVIDER
|
||||||
|
#define TRACEPOINT_PROVIDER libcamera
|
||||||
|
|
||||||
|
#undef TRACEPOINT_INCLUDE
|
||||||
|
#define TRACEPOINT_INCLUDE "{{path}}"
|
||||||
|
|
||||||
|
#if !defined(INCLUDE_LIBCAMERA_INTERNAL_TRACEPOINTS_TP_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
|
||||||
|
#define INCLUDE_LIBCAMERA_INTERNAL_TRACEPOINTS_TP_H
|
||||||
|
|
||||||
|
#include <lttng/tracepoint.h>
|
||||||
|
|
||||||
|
{{source}}
|
||||||
|
|
||||||
|
#endif /* INCLUDE_LIBCAMERA_INTERNAL_TRACEPOINTS_TP_H */
|
||||||
|
|
||||||
|
#include <lttng/tracepoint-event.h>
|
||||||
|
|
||||||
|
#endif /* HAVE_TRACING */
|
4
include/libcamera/internal/tracepoints/meson.build
Normal file
4
include/libcamera/internal/tracepoints/meson.build
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
|
tracepoint_files = files([
|
||||||
|
])
|
|
@ -108,6 +108,9 @@ libcamera_includes = include_directories('include')
|
||||||
# Sub-directories fill py_modules with their dependencies.
|
# Sub-directories fill py_modules with their dependencies.
|
||||||
py_modules = []
|
py_modules = []
|
||||||
|
|
||||||
|
# Libraries used by multiple components
|
||||||
|
liblttng = cc.find_library('lttng-ust', required : get_option('tracing'))
|
||||||
|
|
||||||
# Utilities are parsed first to provide support for other components.
|
# Utilities are parsed first to provide support for other components.
|
||||||
subdir('utils')
|
subdir('utils')
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,11 @@ option('test',
|
||||||
type : 'boolean',
|
type : 'boolean',
|
||||||
description: 'Compile and include the tests')
|
description: 'Compile and include the tests')
|
||||||
|
|
||||||
|
option('tracing',
|
||||||
|
type : 'feature',
|
||||||
|
value : 'auto',
|
||||||
|
description: 'Enable tracing (based on lttng)')
|
||||||
|
|
||||||
option('v4l2',
|
option('v4l2',
|
||||||
type : 'boolean',
|
type : 'boolean',
|
||||||
value : false,
|
value : false,
|
||||||
|
|
|
@ -55,6 +55,7 @@ libcamera_sources = files([
|
||||||
])
|
])
|
||||||
|
|
||||||
libcamera_sources += libcamera_public_headers
|
libcamera_sources += libcamera_public_headers
|
||||||
|
libcamera_sources += libcamera_tracepoint_header
|
||||||
|
|
||||||
includes = [
|
includes = [
|
||||||
libcamera_includes,
|
libcamera_includes,
|
||||||
|
@ -72,6 +73,11 @@ if libgnutls.found()
|
||||||
config_h.set('HAVE_GNUTLS', 1)
|
config_h.set('HAVE_GNUTLS', 1)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if liblttng.found()
|
||||||
|
config_h.set('HAVE_TRACING', 1)
|
||||||
|
libcamera_sources += files(['tracepoints.cpp'])
|
||||||
|
endif
|
||||||
|
|
||||||
if libudev.found()
|
if libudev.found()
|
||||||
config_h.set('HAVE_LIBUDEV', 1)
|
config_h.set('HAVE_LIBUDEV', 1)
|
||||||
libcamera_sources += files([
|
libcamera_sources += files([
|
||||||
|
@ -114,6 +120,7 @@ libcamera_deps = [
|
||||||
libatomic,
|
libatomic,
|
||||||
libdl,
|
libdl,
|
||||||
libgnutls,
|
libgnutls,
|
||||||
|
liblttng,
|
||||||
libudev,
|
libudev,
|
||||||
dependency('threads'),
|
dependency('threads'),
|
||||||
]
|
]
|
||||||
|
|
10
src/libcamera/tracepoints.cpp
Normal file
10
src/libcamera/tracepoints.cpp
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2020, Google Inc.
|
||||||
|
*
|
||||||
|
* tracepoints.cpp - Tracepoints with lttng
|
||||||
|
*/
|
||||||
|
#define TRACEPOINT_CREATE_PROBES
|
||||||
|
#define TRACEPOINT_DEFINE
|
||||||
|
|
||||||
|
#include "libcamera/internal/tracepoints.h"
|
|
@ -1,6 +1,7 @@
|
||||||
# SPDX-License-Identifier: CC0-1.0
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
subdir('ipu3')
|
subdir('ipu3')
|
||||||
|
subdir('tracepoints')
|
||||||
|
|
||||||
## Code generation
|
## Code generation
|
||||||
py_modules += ['yaml']
|
py_modules += ['yaml']
|
||||||
|
|
38
utils/tracepoints/gen-tp-header.py
Normal file
38
utils/tracepoints/gen-tp-header.py
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
# Copyright (C) 2020, Google Inc.
|
||||||
|
#
|
||||||
|
# Author: Paul Elder <paul.elder@ideasonboard.com>
|
||||||
|
#
|
||||||
|
# gen-tp-header.py - Generate header file to contain lttng tracepoints
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
import jinja2
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def main(argv):
|
||||||
|
if len(argv) < 3:
|
||||||
|
print(f'Usage: {argv[0]} output template tp_files...')
|
||||||
|
return 1
|
||||||
|
|
||||||
|
output = argv[1]
|
||||||
|
template = argv[2]
|
||||||
|
|
||||||
|
year = datetime.datetime.now().year
|
||||||
|
path = output.replace('include/', '', 1)
|
||||||
|
|
||||||
|
source = ''
|
||||||
|
for fname in argv[3:]:
|
||||||
|
source += open(fname, 'r', encoding='utf-8').read() + '\n\n'
|
||||||
|
|
||||||
|
template = jinja2.Template(open(template, 'r', encoding='utf-8').read())
|
||||||
|
string = template.render(year=year, path=path, source=source)
|
||||||
|
|
||||||
|
f = open(output, 'w', encoding='utf-8').write(string)
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(main(sys.argv))
|
5
utils/tracepoints/meson.build
Normal file
5
utils/tracepoints/meson.build
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
|
py_modules += ['jinja2']
|
||||||
|
|
||||||
|
gen_tracepoints_header = find_program('./gen-tp-header.py')
|
Loading…
Add table
Add a link
Reference in a new issue