Patch Detail
Show a patch.
GET /api/1.1/patches/10092/?format=api
{ "id": 10092, "url": "https://patchwork.libcamera.org/api/1.1/patches/10092/?format=api", "web_url": "https://patchwork.libcamera.org/patch/10092/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/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": "<20201019102529.28359-1-paul.elder@ideasonboard.com>", "date": "2020-10-19T10:25:28", "name": "[libcamera-devel,RFC,1/2] libcamera: tracing: Implement tracing infrastructure", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "84a6cb92e4b43d73d455ecb89f0cccfd26433a38", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/1.1/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/10092/mbox/", "series": [ { "id": 1383, "url": "https://patchwork.libcamera.org/api/1.1/series/1383/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1383", "date": "2020-10-19T10:25:28", "name": "[libcamera-devel,RFC,1/2] libcamera: tracing: Implement tracing infrastructure", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1383/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/10092/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/10092/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 0AD0BBDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 19 Oct 2020 10:25:43 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7F6A261373;\n\tMon, 19 Oct 2020 12:25:42 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 82B6A60CE6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 19 Oct 2020 12:25:41 +0200 (CEST)", "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 DE40548;\n\tMon, 19 Oct 2020 12:25:39 +0200 (CEST)" ], "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=\"GZPrhrWW\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1603103141;\n\tbh=sMFOGcg9V4O0CNpf0G26yp8ixJ6okqEZUVAOwNiI4dw=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=GZPrhrWWoD0YsSqb2qSE6juHMwpMYf22gwx4HFJQ4VJc0lca0nl8q9t66lpjTkfDh\n\tcY68WfZLuPfYQngc4+lfseGHaZTdMwO8OLBsaFguQ/X5mDsSz8y5H8FDUDwasV07Jv\n\t8uk8NvhuxHD8zF5kNA0AZ4gC3ZzN684jmeyDRwF0=", "From": "Paul Elder <paul.elder@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 19 Oct 2020 19:25:28 +0900", "Message-Id": "<20201019102529.28359-1-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.27.0", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [RFC PATCH 1/2] 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>\n---\n Documentation/Doxyfile.in | 2 +\n README.rst | 3 ++\n include/libcamera/internal/meson.build | 9 +++++\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/generate_header.py | 40 +++++++++++++++++++\n utils/tracepoints/header.tmpl | 40 +++++++++++++++++++\n utils/tracepoints/meson.build | 5 +++\n 12 files changed, 129 insertions(+)\n create mode 100644 include/libcamera/internal/tracepoints/meson.build\n create mode 100644 src/libcamera/tracepoints.cpp\n create mode 100644 utils/tracepoints/generate_header.py\n create mode 100644 utils/tracepoints/header.tmpl\n create mode 100644 utils/tracepoints/meson.build", "diff": "diff --git a/Documentation/Doxyfile.in b/Documentation/Doxyfile.in\nindex 5ccd0d05..9a7a3fb4 100644\n--- a/Documentation/Doxyfile.in\n+++ b/Documentation/Doxyfile.in\n@@ -842,6 +842,8 @@ EXCLUDE = @TOP_SRCDIR@/include/libcamera/span.h \\\n \t\t\t @TOP_SRCDIR@/src/libcamera/ipa_ipc_unixsocket.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/tracepoints.cpp \\\n+\t\t\t @TOP_BUILDDIR@/include/libcamera/internal/tracepoints.h \\\n \t\t\t @TOP_BUILDDIR@/include/libcamera/ipa/ \\\n \t\t\t @TOP_BUILDDIR@/src/libcamera/proxy/\n \ndiff --git a/README.rst b/README.rst\nindex fc8f4948..039015ac 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\n+\n Using GStreamer plugin\n ~~~~~~~~~~~~~~~~~~~~~~\n \ndiff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build\nindex 8dd744fd..21805edd 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_header_template, tracepoint_files ],\n+ output: 'tracepoints.h',\n+ command: [ tracepoints_header_generator, '@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/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 de15cc16..b6a8c2d2 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -103,6 +103,9 @@ libcamera_includes = include_directories('include')\n # Sub-directories fill py_modules with their dependencies.\n py_modules = []\n \n+# We need to check in include/ if we need to generate the tracepoint header\n+liblttng = cc.find_library('lttng-ust', required : get_option('tracepoints'))\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..9e768beb 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('tracepoints',\n+ type : 'feature',\n+ value : 'auto',\n+ description: 'Compile libcamera with lttng tracepoints')\n+\n option('v4l2',\n type : 'boolean',\n value : false,\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 42340eae..7dc77c67 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -58,6 +58,7 @@ libcamera_sources = files([\n \n libcamera_sources += libcamera_public_headers\n libcamera_sources += libcamera_generated_headers\n+libcamera_sources += libcamera_tracepoint_header\n \n includes = [\n libcamera_includes,\n@@ -75,6 +76,11 @@ if libgnutls.found()\n config_h.set('HAVE_GNUTLS', 1)\n endif\n \n+if liblttng.found()\n+ config_h.set('TRACING_ENABLED', 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@@ -117,6 +123,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 383d5285..8e28ada7 100644\n--- a/utils/meson.build\n+++ b/utils/meson.build\n@@ -2,6 +2,7 @@\n \n subdir('ipc')\n subdir('ipu3')\n+subdir('tracepoints')\n \n ## Code generation\n py_modules += ['yaml']\ndiff --git a/utils/tracepoints/generate_header.py b/utils/tracepoints/generate_header.py\nnew file mode 100644\nindex 00000000..52268eba\n--- /dev/null\n+++ b/utils/tracepoints/generate_header.py\n@@ -0,0 +1,40 @@\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+# generate_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').read() + '\\n\\n'\n+\n+ template = jinja2.Template(open(template, 'r').read())\n+ string = template.render(year=year, path=path, source=source)\n+\n+ f = open(output, 'w')\n+ f.write(string)\n+ f.close()\n+\n+ return 0\n+\n+\n+if __name__ == '__main__':\n+ sys.exit(main(sys.argv))\ndiff --git a/utils/tracepoints/header.tmpl b/utils/tracepoints/header.tmpl\nnew file mode 100644\nindex 00000000..b1595656\n--- /dev/null\n+++ b/utils/tracepoints/header.tmpl\n@@ -0,0 +1,40 @@\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 TRACING_ENABLED\n+#define LIBCAMERA_TRACEPOINT(...) tracepoint(libcamera, __VA_ARGS__)\n+#else\n+#define LIBCAMERA_TRACEPOINT(...) do {} while (0)\n+#endif\n+\n+#endif /* __LIBCAMERA_INTERNAL_TRACEPOINTS_H__ */\n+\n+\n+#if TRACING_ENABLED\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 /* TRACING_ENABLED */\ndiff --git a/utils/tracepoints/meson.build b/utils/tracepoints/meson.build\nnew file mode 100644\nindex 00000000..7294287b\n--- /dev/null\n+++ b/utils/tracepoints/meson.build\n@@ -0,0 +1,5 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+tracepoints_header_template = files(['header.tmpl'])\n+\n+tracepoints_header_generator = find_program('./generate_header.py')\n", "prefixes": [ "libcamera-devel", "RFC", "1/2" ] }