[bootlin/training-materials updates] master: debugging: add lttng-gen-tp examples and lab (77e09268)

Clément Léger clement.leger at bootlin.com
Mon Jan 30 10:46:18 CET 2023


Repository : https://github.com/bootlin/training-materials
On branch  : master
Link       : https://github.com/bootlin/training-materials/commit/77e0926803d085621001dfd1ec91e98c459f9870

>---------------------------------------------------------------

commit 77e0926803d085621001dfd1ec91e98c459f9870
Author: Clément Léger <clement.leger at bootlin.com>
Date:   Mon Jan 30 10:44:27 2023 +0100

    debugging: add lttng-gen-tp examples and lab
    
    Add a slide about lttng-gen-tp and modify the crc_random lab to include
    this usage.
    
    Closes #151
    
    Signed-off-by: Clément Léger <clement.leger at bootlin.com>


>---------------------------------------------------------------

77e0926803d085621001dfd1ec91e98c459f9870
 .../debugging-system-wide-profiling.tex            | 30 ++++++++++++++--------
 .../debugging-system-wide-profiling.tex            | 30 ++++++++++++++++++++++
 2 files changed, 49 insertions(+), 11 deletions(-)

diff --git a/labs/debugging-system-wide-profiling/debugging-system-wide-profiling.tex b/labs/debugging-system-wide-profiling/debugging-system-wide-profiling.tex
index 195d5963..9e848c3e 100644
--- a/labs/debugging-system-wide-profiling/debugging-system-wide-profiling.tex
+++ b/labs/debugging-system-wide-profiling/debugging-system-wide-profiling.tex
@@ -104,21 +104,29 @@ this. We'll add 2 tracepoints:
   \item One for the start of crc32 computation (\code{compute_crc_start})
     without any arguments.
   \item Another for the end of crc32 computation (\code{compute_crc_end}) with
-      a crc argument that will be displayed as an hexadecimal integer.
+      a crc \code{int} argument that will be displayed as an hexadecimal integer
+      using \code{lttng_ust_field_integer_hex()} output formatter.
 \end{itemize}
 
-For that, create a tracepoint provider header file template named
-\code{crc_random-tp.h} and another one for the tracepoint provider named
-\code{crc_random-tp.c}. These tracepoints should belong to the \code{crc_random}
-provider namespace.
+In order to create these tracepoints easily, we will create a
+\code{crc_random-tp.tp} file and generate the tracepoints using
+\code{lttng-gen-tp}. These tracepoints should belong to the \code{crc_random}
+provider namespace. Once written, generate the tracepoints provider package
+header and template using:
 
-You can then use the new tracepoints in your program to trace specific points
-of execution. Once added, you can compile your application using the following
-command:
+Once added, you can modify the \code{Makefile} by adding a new rule and
+modifying the existing one to use the generated files.
 
 \begin{bashinput}
-$ $(CROSS_COMPILE)-gcc -I. crc_random-tp.c crc_random.c  -llttng-ust -o crc_random
-\end{bashinput}
+  crc_random-tp.o: crc_random-tp.tp
+    lttng-gen-tp $<
+  
+  crc_random: crc_random.c crc_random-tp.o
+    ${CC} $^ -g3 -I. -llttng-ust -o $@
+  \end{bashinput}
+
+You can then use the new tracepoints in your program to trace specific points
+of execution as requested.
 
 Finally, on the target, enable the program tracepoints, run it and collect
 tracepoints. We are going to do that remotely using the \code{lttng-relayd} tool
@@ -143,7 +151,7 @@ $ lttng destroy
 \end{bashinput}
 
 Once finished, the traces will be visible in \code{$PWD/traces/<hostname>/<session>}
-on the remtoe computer. In our case, the hostname is buildroot so traces will be
+on the remote computer. In our case, the hostname is buildroot so traces will be
 located in \code{$PWD/traces/buildroot/<session>}
 
 Using \code{babeltrace2}, you can display the raw traces that were acquired:
diff --git a/slides/debugging-system-wide-profiling/debugging-system-wide-profiling.tex b/slides/debugging-system-wide-profiling/debugging-system-wide-profiling.tex
index 5e75bdc6..62bbc88f 100644
--- a/slides/debugging-system-wide-profiling/debugging-system-wide-profiling.tex
+++ b/slides/debugging-system-wide-profiling/debugging-system-wide-profiling.tex
@@ -1143,6 +1143,36 @@ $ gcc hello_world.c hello_world-tp.c -llttng-ust -o hello_world
   \end{block}
 \end{frame}
 
+\begin{frame}[fragile]
+  \frametitle{Generating tracepoints using \code{lttng-gen-tp}}
+  \begin{itemize}
+    \item Writing both the \code{.h} and \code{.c} boilerplate can be avoided
+          using \code{lttng-gen-tp}.
+    \item \code{lttng-gen-tp} takes a template file (\code{.tp}) as input and will
+          generate both the provider header and package files (\code{.h},
+          \code{.c} and \code{.o} files):
+  \end{itemize}
+  \begin{block}{}
+    \begin{minted}[fontsize=\tiny]{C}
+LTTNG_UST_TRACEPOINT_EVENT(
+// Tracepoint provider name
+hello_world,
+
+// Tracepoint/event name
+first_tp,
+
+// Tracepoint arguments (input)
+LTTNG_UST_TP_ARGS(char *, text),
+
+// Tracepoint/event fields (output)
+LTTNG_UST_ TP_FIELDS(
+  lttng_ust_field_string(message, text)
+)
+)
+   \end{minted}
+  \end{block}
+\end{frame}
+
 \begin{frame}[fragile]
   \frametitle{Using {\em LTTng}}
   \begin{block}{}




More information about the training-materials-updates mailing list