Show a patch.

GET /api/1.1/patches/10297/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 10297,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/10297/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10297/",
    "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": "<20201029101629.61798-2-paul.elder@ideasonboard.com>",
    "date": "2020-10-29T10:16:24",
    "name": "[libcamera-devel,v3,1/6] libcamera: tracing: Implement tracing infrastructure",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "9fd429ac71b5a54a9b99a34772a975b90bff59d1",
    "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/10297/mbox/",
    "series": [
        {
            "id": 1432,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1432/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1432",
            "date": "2020-10-29T10:16:23",
            "name": "Tracing",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/1432/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10297/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10297/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 6BC67BDB9B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 29 Oct 2020 10:16:43 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3B90D628AF;\n\tThu, 29 Oct 2020 11:16:43 +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 91235627D7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 29 Oct 2020 11:16:41 +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 B029350E;\n\tThu, 29 Oct 2020 11:16:39 +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=\"e/cYmfpc\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1603966601;\n\tbh=xGWnRd/3c+6hS82EcCiEaPcdOYKJQHO2ciEoPtMC0WA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=e/cYmfpcSXEtem4/pmWqOHH5hdcXdt2y8yh8Q9mp6Qe7tlhigYdCwD5lWPJxJhuoT\n\t8fJ2Y5+gZ1ZlKVqMGmPs8DJxqbRKnb+xNyoc2IZdh1GF7uMrDVkJtwc6yCRDqhg4JP\n\t0LB2h79EkEMsUHSCetW2NUhGER8HaTdfhe3sIIHw=",
        "From": "Paul Elder <paul.elder@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 29 Oct 2020 19:16:24 +0900",
        "Message-Id": "<20201029101629.61798-2-paul.elder@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.27.0",
        "In-Reply-To": "<20201029101629.61798-1-paul.elder@ideasonboard.com>",
        "References": "<20201029101629.61798-1-paul.elder@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v3 1/6] 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>\n\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                     |  2 +\n README.rst                                    |  3 +\n include/libcamera/internal/meson.build        |  9 +++\n include/libcamera/internal/tracepoints.h.in   | 62 +++++++++++++++++++\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(+)\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 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..5c4b6989 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 8dd744fd..592635a9 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..830c61d7\n--- /dev/null\n+++ b/include/libcamera/internal/tracepoints.h.in\n@@ -0,0 +1,62 @@\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) unused(#pipe, #func)\n+\n+#define LIBCAMERA_TRACEPOINT_IPA_END(pipe, func) unused(#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 24f7ea3d..51925bd6 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_ipa_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('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@@ -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/gen-tp-header.py b/utils/tracepoints/gen-tp-header.py\nnew file mode 100644\nindex 00000000..9500e474\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').read())\n+    string = template.render(year=year, path=path, source=source)\n+\n+    f = open(output, 'w').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",
        "v3",
        "1/6"
    ]
}