Patch Detail
Show a patch.
GET /api/patches/10306/?format=api
{ "id": 10306, "url": "https://patchwork.libcamera.org/api/patches/10306/?format=api", "web_url": "https://patchwork.libcamera.org/patch/10306/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20201030085756.79329-2-paul.elder@ideasonboard.com>", "date": "2020-10-30T08:57:52", "name": "[libcamera-devel,v4,1/5] libcamera: tracing: Implement tracing infrastructure", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "6e5fc4f821b56858d6c9dcb2b75671ae9a3b21f4", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/10306/mbox/", "series": [ { "id": 1435, "url": "https://patchwork.libcamera.org/api/series/1435/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1435", "date": "2020-10-30T08:57:51", "name": "Tracing", "version": 4, "mbox": "https://patchwork.libcamera.org/series/1435/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/10306/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/10306/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 17C03BDB1E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 30 Oct 2020 08:58:08 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D9DC062983;\n\tFri, 30 Oct 2020 09:58:07 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9F9E5628A5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 30 Oct 2020 09:58:06 +0100 (CET)", "from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 866849B7;\n\tFri, 30 Oct 2020 09:58:04 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"u55kHE0h\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1604048286;\n\tbh=F4kQeRRzyycG1YWcGjo52mW1fxnD5O2thVzGFsuAGSk=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=u55kHE0hRr0RcC7PSkTCRZenXdsFV8Vz5qlfMC9HfHy3vEJy/ON12Frr+r24kaU7H\n\tRwzZgZ6TboLVKe9pVa1uiV/o+WrFj2079VgZUAH4VzVMSXh6E9q7nQAJxBcCBw9/Pe\n\tJGtW19vFTdNfPfwqDRF0reeahqw/k4RcZ1C3mT0k=", "From": "Paul Elder <paul.elder@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 30 Oct 2020 17:57:52 +0900", "Message-Id": "<20201030085756.79329-2-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.27.0", "In-Reply-To": "<20201030085756.79329-1-paul.elder@ideasonboard.com>", "References": "<20201030085756.79329-1-paul.elder@ideasonboard.com>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v4 1/5] libcamera: tracing: Implement\n\ttracing infrastructure", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Implement tracing infrastructure in libcamera. It takes .tp files, as\nrequired by lttng, and generates a tracepoint header and C file, as lttng\nrequires. meson is updated accordingly to get it to compile with the\nrest of libcamera. Update the documentation accordingly.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n---\nChanges in v4:\n- simplify no-tracing tracepoint macros\n- make gen-tp-header.py open *all* files as utf-8\n- rebase on master instead of ipc\n\nChanges in v3:\n- rename the tracepoints header generateor in meson\n- add protection against accidental unused variables when tracing is\n disabled\n- make gen-tp-header.py read files as utf-8\n- add macros LIBCAMERA_TRACEPOINT_IPA_{BEGIN,END}\n\nChanges in v2:\n- move header.tmpl to tracepoints.h.in\n- rename meson option 'tracepoints' to 'tracing'\n- make sure C++ objects work in tracepoint arguments\n- rename generate_header.py to gen-tp-header.py\n---\n Documentation/Doxyfile.in | 4 +-\n README.rst | 3 +\n include/libcamera/internal/meson.build | 9 +++\n include/libcamera/internal/tracepoints.h.in | 61 +++++++++++++++++++\n .../internal/tracepoints/meson.build | 4 ++\n meson.build | 3 +\n meson_options.txt | 5 ++\n src/libcamera/meson.build | 7 +++\n src/libcamera/tracepoints.cpp | 10 +++\n utils/meson.build | 1 +\n utils/tracepoints/gen-tp-header.py | 38 ++++++++++++\n utils/tracepoints/meson.build | 5 ++\n 12 files changed, 149 insertions(+), 1 deletion(-)\n create mode 100644 include/libcamera/internal/tracepoints.h.in\n create mode 100644 include/libcamera/internal/tracepoints/meson.build\n create mode 100644 src/libcamera/tracepoints.cpp\n create mode 100644 utils/tracepoints/gen-tp-header.py\n create mode 100644 utils/tracepoints/meson.build", "diff": "diff --git a/Documentation/Doxyfile.in b/Documentation/Doxyfile.in\nindex fa8d744b..87959e23 100644\n--- a/Documentation/Doxyfile.in\n+++ b/Documentation/Doxyfile.in\n@@ -840,7 +840,9 @@ EXCLUDE = @TOP_SRCDIR@/include/libcamera/span.h \\\n \t\t\t @TOP_SRCDIR@/src/libcamera/device_enumerator_sysfs.cpp \\\n \t\t\t @TOP_SRCDIR@/src/libcamera/device_enumerator_udev.cpp \\\n \t\t\t @TOP_SRCDIR@/src/libcamera/pipeline/ \\\n-\t\t\t @TOP_SRCDIR@/src/libcamera/proxy/\n+\t\t\t @TOP_SRCDIR@/src/libcamera/proxy/ \\\n+\t\t\t @TOP_SRCDIR@/src/libcamera/tracepoints.cpp \\\n+\t\t\t @TOP_BUILDDIR@/include/libcamera/internal/tracepoints.h\n \n # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or\n # directories that are symbolic links (a Unix file system feature) are excluded\ndiff --git a/README.rst b/README.rst\nindex 74babaf7..f8519b44 100644\n--- a/README.rst\n+++ b/README.rst\n@@ -81,6 +81,9 @@ for gstreamer: [optional]\n for qcam: [optional]\n \tqtbase5-dev libqt5core5a libqt5gui5 libqt5widgets5 qttools5-dev-tools libtiff-dev\n \n+for tracing with lttng: [optional]\n+ lttng-ust-dev python3-jinja2\n+\n Using GStreamer plugin\n ~~~~~~~~~~~~~~~~~~~~~~\n \ndiff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build\nindex 15010338..6500fe2a 100644\n--- a/include/libcamera/internal/meson.build\n+++ b/include/libcamera/internal/meson.build\n@@ -1,5 +1,14 @@\n # SPDX-License-Identifier: CC0-1.0\n \n+subdir('tracepoints')\n+\n+libcamera_tracepoint_header = custom_target(\n+ 'tp_header',\n+ input: [ 'tracepoints.h.in', tracepoint_files ],\n+ output: 'tracepoints.h',\n+ command: [ gen_tracepoints_header, '@OUTPUT@', '@INPUT@' ],\n+)\n+\n libcamera_internal_headers = files([\n 'byte_stream_buffer.h',\n 'camera_controls.h',\ndiff --git a/include/libcamera/internal/tracepoints.h.in b/include/libcamera/internal/tracepoints.h.in\nnew file mode 100644\nindex 00000000..d0fc1365\n--- /dev/null\n+++ b/include/libcamera/internal/tracepoints.h.in\n@@ -0,0 +1,61 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) {{year}}, Google Inc.\n+ *\n+ * tracepoints.h - Tracepoints with lttng\n+ *\n+ * This file is auto-generated. Do not edit.\n+ */\n+#ifndef __LIBCAMERA_INTERNAL_TRACEPOINTS_H__\n+#define __LIBCAMERA_INTERNAL_TRACEPOINTS_H__\n+\n+#if HAVE_TRACING\n+#define LIBCAMERA_TRACEPOINT(...) tracepoint(libcamera, __VA_ARGS__)\n+\n+#define LIBCAMERA_TRACEPOINT_IPA_BEGIN(pipe, func) \\\n+tracepoint(libcamera, ipa_call_begin, #pipe, #func)\n+\n+#define LIBCAMERA_TRACEPOINT_IPA_END(pipe, func) \\\n+tracepoint(libcamera, ipa_call_end, #pipe, #func)\n+\n+#else\n+\n+namespace {\n+\n+template <typename ...Args>\n+inline void unused([[maybe_unused]] Args&& ...args)\n+{\n+}\n+\n+} /* namespace */\n+\n+#define LIBCAMERA_TRACEPOINT(category, ...) unused(__VA_ARGS__)\n+\n+#define LIBCAMERA_TRACEPOINT_IPA_BEGIN(pipe, func)\n+#define LIBCAMERA_TRACEPOINT_IPA_END(pipe, func)\n+\n+#endif /* HAVE_TRACING */\n+\n+#endif /* __LIBCAMERA_INTERNAL_TRACEPOINTS_H__ */\n+\n+\n+#if HAVE_TRACING\n+\n+#undef TRACEPOINT_PROVIDER\n+#define TRACEPOINT_PROVIDER libcamera\n+\n+#undef TRACEPOINT_INCLUDE\n+#define TRACEPOINT_INCLUDE \"{{path}}\"\n+\n+#if !defined(INCLUDE_LIBCAMERA_INTERNAL_TRACEPOINTS_TP_H) || defined(TRACEPOINT_HEADER_MULTI_READ)\n+#define INCLUDE_LIBCAMERA_INTERNAL_TRACEPOINTS_TP_H\n+\n+#include <lttng/tracepoint.h>\n+\n+{{source}}\n+\n+#endif /* INCLUDE_LIBCAMERA_INTERNAL_TRACEPOINTS_TP_H */\n+\n+#include <lttng/tracepoint-event.h>\n+\n+#endif /* HAVE_TRACING */\ndiff --git a/include/libcamera/internal/tracepoints/meson.build b/include/libcamera/internal/tracepoints/meson.build\nnew file mode 100644\nindex 00000000..2dd6733e\n--- /dev/null\n+++ b/include/libcamera/internal/tracepoints/meson.build\n@@ -0,0 +1,4 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+tracepoint_files = files([\n+])\ndiff --git a/meson.build b/meson.build\nindex e6f6c84a..55cf36e1 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -108,6 +108,9 @@ libcamera_includes = include_directories('include')\n # Sub-directories fill py_modules with their dependencies.\n py_modules = []\n \n+# Libraries used by multiple components\n+liblttng = cc.find_library('lttng-ust', required : get_option('tracing'))\n+\n # Utilities are parsed first to provide support for other components.\n subdir('utils')\n \ndiff --git a/meson_options.txt b/meson_options.txt\nindex 7f7b3e59..53f2675e 100644\n--- a/meson_options.txt\n+++ b/meson_options.txt\n@@ -28,6 +28,11 @@ option('test',\n type : 'boolean',\n description: 'Compile and include the tests')\n \n+option('tracing',\n+ type : 'feature',\n+ value : 'auto',\n+ description: 'Enable tracing (based on lttng)')\n+\n option('v4l2',\n type : 'boolean',\n value : false,\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 07711b5f..99b27e66 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -55,6 +55,7 @@ libcamera_sources = files([\n ])\n \n libcamera_sources += libcamera_public_headers\n+libcamera_sources += libcamera_tracepoint_header\n \n includes = [\n libcamera_includes,\n@@ -72,6 +73,11 @@ if libgnutls.found()\n config_h.set('HAVE_GNUTLS', 1)\n endif\n \n+if liblttng.found()\n+ config_h.set('HAVE_TRACING', 1)\n+ libcamera_sources += files(['tracepoints.cpp'])\n+endif\n+\n if libudev.found()\n config_h.set('HAVE_LIBUDEV', 1)\n libcamera_sources += files([\n@@ -114,6 +120,7 @@ libcamera_deps = [\n libatomic,\n libdl,\n libgnutls,\n+ liblttng,\n libudev,\n dependency('threads'),\n ]\ndiff --git a/src/libcamera/tracepoints.cpp b/src/libcamera/tracepoints.cpp\nnew file mode 100644\nindex 00000000..0173b75a\n--- /dev/null\n+++ b/src/libcamera/tracepoints.cpp\n@@ -0,0 +1,10 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ *\n+ * tracepoints.cpp - Tracepoints with lttng\n+ */\n+#define TRACEPOINT_CREATE_PROBES\n+#define TRACEPOINT_DEFINE\n+\n+#include \"libcamera/internal/tracepoints.h\"\ndiff --git a/utils/meson.build b/utils/meson.build\nindex 3d83b975..7f2b9b4d 100644\n--- a/utils/meson.build\n+++ b/utils/meson.build\n@@ -1,6 +1,7 @@\n # SPDX-License-Identifier: CC0-1.0\n \n subdir('ipu3')\n+subdir('tracepoints')\n \n ## Code generation\n py_modules += ['yaml']\ndiff --git a/utils/tracepoints/gen-tp-header.py b/utils/tracepoints/gen-tp-header.py\nnew file mode 100644\nindex 00000000..bbd472d9\n--- /dev/null\n+++ b/utils/tracepoints/gen-tp-header.py\n@@ -0,0 +1,38 @@\n+#!/usr/bin/env python3\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+# Copyright (C) 2020, Google Inc.\n+#\n+# Author: Paul Elder <paul.elder@ideasonboard.com>\n+#\n+# gen-tp-header.py - Generate header file to contain lttng tracepoints\n+\n+import datetime\n+import jinja2\n+import os\n+import sys\n+\n+def main(argv):\n+ if len(argv) < 3:\n+ print(f'Usage: {argv[0]} output template tp_files...')\n+ return 1\n+\n+ output = argv[1]\n+ template = argv[2]\n+\n+ year = datetime.datetime.now().year\n+ path = output.replace('include/', '', 1)\n+\n+ source = ''\n+ for fname in argv[3:]:\n+ source += open(fname, 'r', encoding='utf-8').read() + '\\n\\n'\n+\n+ template = jinja2.Template(open(template, 'r', encoding='utf-8').read())\n+ string = template.render(year=year, path=path, source=source)\n+\n+ f = open(output, 'w', encoding='utf-8').write(string)\n+\n+ return 0\n+\n+\n+if __name__ == '__main__':\n+ sys.exit(main(sys.argv))\ndiff --git a/utils/tracepoints/meson.build b/utils/tracepoints/meson.build\nnew file mode 100644\nindex 00000000..807230fc\n--- /dev/null\n+++ b/utils/tracepoints/meson.build\n@@ -0,0 +1,5 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+py_modules += ['jinja2']\n+\n+gen_tracepoints_header = find_program('./gen-tp-header.py')\n", "prefixes": [ "libcamera-devel", "v4", "1/5" ] }