| <!-- |
| Documentation/_templates/layout.html |
| |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. The |
| ASF licenses this file to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance with the |
| License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| License for the specific language governing permissions and limitations |
| under the License. |
| --> |
| |
| |
| |
| <!DOCTYPE html> |
| <html class="writer-html5" lang="en" > |
| <head> |
| <meta charset="utf-8" /> |
| |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| |
| <title>Task Trace Internals — NuttX latest documentation</title> |
| |
| |
| |
| <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" /> |
| <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> |
| <link rel="stylesheet" href="../_static/tabs.css" type="text/css" /> |
| <link rel="stylesheet" href="../_static/custom.css" type="text/css" /> |
| |
| |
| |
| <link rel="shortcut icon" href="../_static/favicon.ico"/> |
| |
| |
| |
| |
| |
| |
| |
| |
| <!--[if lt IE 9]> |
| <script src="../_static/js/html5shiv.min.js"></script> |
| <![endif]--> |
| |
| |
| <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> |
| <script src="../_static/jquery.js"></script> |
| <script src="../_static/underscore.js"></script> |
| <script src="../_static/doctools.js"></script> |
| |
| <script type="text/javascript" src="../_static/js/theme.js"></script> |
| |
| |
| <link rel="index" title="Index" href="../genindex.html" /> |
| <link rel="search" title="Search" href="../search.html" /> |
| <link rel="next" title="C++ Example using CMake" href="cpp_cmake.html" /> |
| <link rel="prev" title="Task Trace User Guide" href="tasktraceuser.html" /> |
| </head> |
| |
| <body class="wy-body-for-nav"> |
| |
| |
| <div class="wy-grid-for-nav"> |
| |
| <nav data-toggle="wy-nav-shift" class="wy-nav-side"> |
| <div class="wy-side-scroll"> |
| <div class="wy-side-nav-search" > |
| |
| |
| <a href="../index.html" class="icon icon-home"> NuttX |
| |
| |
| |
| |
| <img src="../_static/NuttX.png" class="logo" alt="Logo"/> |
| |
| </a> |
| |
| <!-- this version selector is quite ugly, should be probably replaced by something |
| more modern --> |
| |
| <div class="version-selector"> |
| <select onchange="javascript:location.href = this.value;"> |
| |
| <option value="../../latest" selected="selected">latest</option> |
| |
| <option value="../../10.0.0" >10.0.0</option> |
| |
| <option value="../../10.0.1" >10.0.1</option> |
| |
| <option value="../../10.1.0" >10.1.0</option> |
| |
| <option value="../../10.2.0" >10.2.0</option> |
| |
| <option value="../../10.3.0" >10.3.0</option> |
| |
| <option value="../../11.0.0" >11.0.0</option> |
| |
| <option value="../../12.0.0" >12.0.0</option> |
| |
| <option value="../../12.1.0" >12.1.0</option> |
| |
| <option value="../../12.2.0" >12.2.0</option> |
| |
| <option value="../../12.2.1" >12.2.1</option> |
| |
| <option value="../../12.3.0" >12.3.0</option> |
| |
| <option value="../../12.4.0" >12.4.0</option> |
| |
| <option value="../../12.5.0" >12.5.0</option> |
| |
| <option value="../../12.5.1" >12.5.1</option> |
| |
| <option value="../../12.6.0" >12.6.0</option> |
| |
| <option value="../../12.7.0" >12.7.0</option> |
| |
| <option value="../../12.8.0" >12.8.0</option> |
| |
| <option value="../../12.9.0" >12.9.0</option> |
| |
| <option value="../../12.10.0" >12.10.0</option> |
| |
| <option value="../../12.11.0" >12.11.0</option> |
| |
| </select> |
| </div> |
| |
| |
| <div role="search"> |
| <form id="rtd-search-form" class="wy-form" action="../search.html" method="get"> |
| <input type="text" name="q" placeholder="Search docs" /> |
| <input type="hidden" name="check_keywords" value="yes" /> |
| <input type="hidden" name="area" value="default" /> |
| </form> |
| </div> |
| |
| </div> |
| |
| |
| <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> |
| |
| |
| |
| |
| |
| |
| <p class="caption"><span class="caption-text">Table of Contents</span></p> |
| <ul class="current"> |
| <li class="toctree-l1"><a class="reference internal" href="../index.html">Home</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../introduction/index.html">Introduction</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../quickstart/index.html">Getting Started</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../contributing/index.html">Contributing</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../introduction/inviolables.html">The Inviolable Principles of NuttX</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../platforms/index.html">Supported Platforms</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../components/index.html">OS Components</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../applications/index.html">Applications</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../reference/index.html">API Reference</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../faq/index.html">FAQ</a></li> |
| <li class="toctree-l1 current"><a class="reference internal" href="index.html">Guides</a><ul class="current"> |
| <li class="toctree-l2"><a class="reference internal" href="nfs.html">NFS Client How-To</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="usbtrace.html">USB Device Trace</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="simulator.html">Simulator</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="drivers.html">Drivers</a></li> |
| <li class="toctree-l2 current"><a class="reference internal" href="tasktrace.html">Task Trace</a><ul class="current"> |
| <li class="toctree-l3"><a class="reference internal" href="tasktraceuser.html">Task Trace User Guide</a></li> |
| <li class="toctree-l3 current"><a class="current reference internal" href="#">Task Trace Internals</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="#overview">Overview</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="#nuttx-kernel-events-collection">NuttX kernel events collection</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="#filter-logic-nuttx-sched-sched-note-c">Filter logic (<code class="docutils literal notranslate"><span class="pre">nuttx/sched/sched_note.c</span></code>)</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="#noteram-device-driver-nuttx-drivers-note-noteram-driver-c">Noteram device driver (<code class="docutils literal notranslate"><span class="pre">nuttx/drivers/note/noteram_driver.c</span></code>)</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="#notectl-device-driver-nuttx-drivers-note-notectl-driver-c">Notectl device driver (<code class="docutils literal notranslate"><span class="pre">nuttx/drivers/note/notectl_driver.c</span></code>)</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="#trace-built-in-application-apps-system-trace-trace-c">“<code class="docutils literal notranslate"><span class="pre">trace</span></code>” Built-In Application (<code class="docutils literal notranslate"><span class="pre">apps/system/trace/trace.c</span></code>)</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l4"><a class="reference internal" href="#getting-the-system-call-events">Getting the system call events</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="#flat-build">FLAT build</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="#protected-kernel-build">PROTECTED/KERNEL build</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="cpp_cmake.html">C++ Example using CMake</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="pysimcoder.html">pysimCoder integration with NuttX</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l1"><a class="reference internal" href="../glossary.html">Glossary</a></li> |
| </ul> |
| |
| |
| |
| </div> |
| |
| </div> |
| </nav> |
| |
| <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> |
| |
| |
| <nav class="wy-nav-top" aria-label="top navigation"> |
| |
| <i data-toggle="wy-nav-top" class="fa fa-bars"></i> |
| <a href="../index.html">NuttX</a> |
| |
| </nav> |
| |
| |
| <div class="wy-nav-content"> |
| |
| <div class="rst-content"> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <div role="navigation" aria-label="breadcrumbs navigation"> |
| |
| <ul class="wy-breadcrumbs"> |
| |
| <li><a href="../index.html" class="icon icon-home"></a> »</li> |
| |
| <li><a href="index.html">Guides</a> »</li> |
| |
| <li><a href="tasktrace.html">Task Trace</a> »</li> |
| |
| <li>Task Trace Internals</li> |
| |
| |
| <li class="wy-breadcrumbs-aside"> |
| |
| |
| <a href="../_sources/guides/tasktraceinternal.rst.txt" rel="nofollow"> View page source</a> |
| |
| |
| </li> |
| |
| </ul> |
| |
| |
| <hr/> |
| </div> |
| <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> |
| <div itemprop="articleBody"> |
| |
| <div class="section" id="task-trace-internals"> |
| <h1>Task Trace Internals<a class="headerlink" href="#task-trace-internals" title="Permalink to this headline">¶</a></h1> |
| <div class="section" id="overview"> |
| <h2>Overview<a class="headerlink" href="#overview" title="Permalink to this headline">¶</a></h2> |
| <img alt="../_images/task-trace-internal.png" src="../_images/task-trace-internal.png" /> |
| <p>The Task Trace is constructed by the following functions.</p> |
| <div class="section" id="nuttx-kernel-events-collection"> |
| <h3>NuttX kernel events collection<a class="headerlink" href="#nuttx-kernel-events-collection" title="Permalink to this headline">¶</a></h3> |
| <p>The kernel events are collected by <code class="docutils literal notranslate"><span class="pre">sched_note_*()</span></code> API calls embedded in NuttX kernel.</p> |
| <blockquote> |
| <div><ul class="simple"> |
| <li><p>For task switch events</p> |
| <ul> |
| <li><p><code class="docutils literal notranslate"><span class="pre">sched_note_start()</span></code></p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">sched_note_stop()</span></code></p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">sched_note_suspend()</span></code></p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">sched_note_resume()</span></code></p></li> |
| </ul> |
| </li> |
| <li><p>For system call events</p> |
| <ul> |
| <li><p><code class="docutils literal notranslate"><span class="pre">sched_note_syscall_enter()</span></code></p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">sched_note_syscall_leave()</span></code></p></li> |
| </ul> |
| </li> |
| <li><p>For interrupt event</p> |
| <ul> |
| <li><p><code class="docutils literal notranslate"><span class="pre">sched_note_irqhandler()</span></code></p></li> |
| </ul> |
| </li> |
| </ul> |
| </div></blockquote> |
| </div> |
| <div class="section" id="filter-logic-nuttx-sched-sched-note-c"> |
| <h3>Filter logic (<code class="docutils literal notranslate"><span class="pre">nuttx/sched/sched_note.c</span></code>)<a class="headerlink" href="#filter-logic-nuttx-sched-sched-note-c" title="Permalink to this headline">¶</a></h3> |
| <ul class="simple"> |
| <li><p>The <code class="docutils literal notranslate"><span class="pre">sched_note_*()</span></code> APIs are implemented here.</p></li> |
| <li><p>Filter the notes and pass them to noteram driver by <code class="docutils literal notranslate"><span class="pre">sched_note_add()</span></code> API.</p></li> |
| </ul> |
| </div> |
| <div class="section" id="noteram-device-driver-nuttx-drivers-note-noteram-driver-c"> |
| <h3>Noteram device driver (<code class="docutils literal notranslate"><span class="pre">nuttx/drivers/note/noteram_driver.c</span></code>)<a class="headerlink" href="#noteram-device-driver-nuttx-drivers-note-noteram-driver-c" title="Permalink to this headline">¶</a></h3> |
| <ul class="simple"> |
| <li><p>Accumurate incoming note records into the buffer.</p></li> |
| <li><p>Read the note records from the buffer by user requests.</p></li> |
| <li><p>The notes are recorded in the binary format of <code class="docutils literal notranslate"><span class="pre">struct</span> <span class="pre">note_*_s</span></code>.</p></li> |
| <li><p>The detail function is described in <a class="reference internal" href="../components/drivers/character/note.html"><span class="doc">Note Driver Interface</span></a>.</p></li> |
| </ul> |
| </div> |
| <div class="section" id="notectl-device-driver-nuttx-drivers-note-notectl-driver-c"> |
| <h3>Notectl device driver (<code class="docutils literal notranslate"><span class="pre">nuttx/drivers/note/notectl_driver.c</span></code>)<a class="headerlink" href="#notectl-device-driver-nuttx-drivers-note-notectl-driver-c" title="Permalink to this headline">¶</a></h3> |
| <ul class="simple"> |
| <li><p><code class="docutils literal notranslate"><span class="pre">/dev/notectl</span></code> device driver.</p></li> |
| <li><p>Control the filter logic in <code class="docutils literal notranslate"><span class="pre">sched_note.c</span></code> by calling note filter APIs.</p></li> |
| <li><p>The detail function is described in <a class="reference internal" href="../components/drivers/character/note.html"><span class="doc">Note Driver Interface</span></a>.</p></li> |
| </ul> |
| </div> |
| <div class="section" id="trace-built-in-application-apps-system-trace-trace-c"> |
| <h3>“<code class="docutils literal notranslate"><span class="pre">trace</span></code>” Built-In Application (<code class="docutils literal notranslate"><span class="pre">apps/system/trace/trace.c</span></code>)<a class="headerlink" href="#trace-built-in-application-apps-system-trace-trace-c" title="Permalink to this headline">¶</a></h3> |
| <ul class="simple"> |
| <li><p><code class="docutils literal notranslate"><span class="pre">trace</span></code> Built-In Application to control the trace function interactively.</p></li> |
| <li><p>Read binary note records from <code class="docutils literal notranslate"><span class="pre">/dev/note</span></code> and convert into the ftrace text format which is acceptable by <a class="reference external" href="https://www.eclipse.org/tracecompass/">“Trace Compass”</a>.</p></li> |
| <li><p>The command syntax is described in <a class="reference internal" href="tasktraceuser.html"><span class="doc">Task Trace User Guide</span></a>.</p></li> |
| </ul> |
| </div> |
| </div> |
| <div class="section" id="getting-the-system-call-events"> |
| <h2>Getting the system call events<a class="headerlink" href="#getting-the-system-call-events" title="Permalink to this headline">¶</a></h2> |
| <p>To get the system call events, two different methods are used for FLAT build and PROTECTED/KERNEL build.</p> |
| <div class="section" id="flat-build"> |
| <h3>FLAT build<a class="headerlink" href="#flat-build" title="Permalink to this headline">¶</a></h3> |
| <p>In FLAT build, a system call is just a function call into the NuttX kernel.</p> |
| <img alt="../_images/syscall-flat-before.png" src="../_images/syscall-flat-before.png" /> |
| <p>To get the system call events, <a class="reference external" href="https://sourceware.org/binutils/docs/ld/Options.html#index-_002d_002dwrap_003dsymbol">wrapper function option</a> of the GNU Linker is used.</p> |
| <p>The mksyscall tool is fixed to generate the system call wrapper which call system call enter/leave hook. |
| The wrapper supersedes the system call function call of the NuttX binary by passing <code class="docutils literal notranslate"><span class="pre">--wrap</span></code> linker option to the build system. |
| The wrapper calls the system call hooks before and after calling the real system call function.</p> |
| <img alt="../_images/syscall-flat-after.png" src="../_images/syscall-flat-after.png" /> |
| </div> |
| <div class="section" id="protected-kernel-build"> |
| <h3>PROTECTED/KERNEL build<a class="headerlink" href="#protected-kernel-build" title="Permalink to this headline">¶</a></h3> |
| <p>Different to FLAT build, in PROTECTED and KERNEL build, a system call is issued by an user space is handled as the following steps.</p> |
| <ol class="arabic simple"> |
| <li><p>System call issued by an application code is handled by the system call proxy (automatically generated by mksyscall).</p></li> |
| <li><p>System call proxy issues the supervisor call instruction to enter into the kernel space.</p></li> |
| <li><p>System call handler in the kernel space calls the system call stub (automatically generated by mksyscall).</p></li> |
| <li><p>System call stub calls the API implementation in the NuttX kernel.</p></li> |
| </ol> |
| <img alt="../_images/syscall-protected-before.png" src="../_images/syscall-protected-before.png" /> |
| <p>To get the system call events, the mksyscall tool is fixed to generate the system call wrapper which supersedes the system call function call in the system call stub.</p> |
| <img alt="../_images/syscall-protected-after.png" src="../_images/syscall-protected-after.png" /> |
| </div> |
| </div> |
| </div> |
| |
| |
| </div> |
| |
| </div> |
| <footer> |
| <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> |
| <a href="cpp_cmake.html" class="btn btn-neutral float-right" title="C++ Example using CMake" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> |
| <a href="tasktraceuser.html" class="btn btn-neutral float-left" title="Task Trace User Guide" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> |
| </div> |
| |
| <hr/> |
| |
| <div role="contentinfo"> |
| <p> |
| © Copyright 2020, The Apache Software Foundation. |
| |
| </p> |
| </div> |
| |
| </footer> |
| </div> |
| </div> |
| |
| </section> |
| |
| </div> |
| |
| |
| <script type="text/javascript"> |
| jQuery(function () { |
| SphinxRtdTheme.Navigation.enable(true); |
| }); |
| </script> |
| |
| |
| |
| |
| |
| |
| </body> |
| </html> |