Skip to content

Commit c84017e

Browse files
committed
tracing: introduce ram tracing snippet
This allows tracing any application and stores the data in RAM. Using gdb, the ram_tracing variable contents can then be saved and viewed using babeltrace. Signed-off-by: Anas Nashif <[email protected]>
1 parent a55381c commit c84017e

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed

snippets/ram-tracing/README.rst

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
.. _snippet-ram-tracing:
2+
3+
RAM Tracing Snippet (ram-tracing)
4+
############################################
5+
6+
.. code-block:: console
7+
8+
west build -S ram-tracing [...]
9+
10+
Overview
11+
********
12+
13+
This snippet enables CTF Tracing using the RAM backend.
14+
15+
After connecting to the target in GDB, you can dump the RAM tracing data to a
16+
binary file:
17+
18+
.. code-block:: console
19+
20+
(gdb) dump binary memory ram_tracing.bin ram_tracing ram_tracing+8192
21+
22+
Using babletrace, you can view the binary file as a CTF trace:
23+
24+
25+
.. code-block:: console
26+
27+
[19:00:00.023530800] (+?.?????????) thread_create: { thread_id = 2147621216, name = "unknown" }
28+
[19:00:00.023567100] (+0.000036300) thread_info: { thread_id = 2147621216, name = "unknown", stack_base = 2147705856, stack_size = 3072 }
29+
[19:00:00.023673700] (+0.000106600) thread_name_set: { thread_id = 2147621216, name = "test_abort_from_isr" }
30+
[19:00:00.023731100] (+0.000057400) thread_wakeup: { thread_id = 2147621216, name = "test_abort_from_isr" }
31+
[19:00:00.023827500] (+0.000096400) thread_switched_out: { thread_id = 2147621968, name = "main" }
32+
[19:00:00.023904500] (+0.000077000) thread_switched_in: { thread_id = 2147621216, name = "test_abort_from_isr" }
33+
[19:00:00.024807600] (+0.000903100) thread_create: { thread_id = 2147619320, name = "unknown" }
34+
[19:00:00.024843800] (+0.000036200) thread_info: { thread_id = 2147619320, name = "unknown", stack_base = 2147693568, stack_size = 3072 }
35+
[19:00:00.024898700] (+0.000054900) thread_wakeup: { thread_id = 2147619320, name = "unknown" }
36+
[19:00:00.025020000] (+0.000121300) thread_switched_out: { thread_id = 2147621216, name = "test_abort_from_isr" }
37+
[19:00:00.025130700] (+0.000110700) thread_switched_in: { thread_id = 2147621968, name = "main" }
38+
[19:00:00.025249900] (+0.000119200) thread_switched_out: { thread_id = 2147621968, name = "main" }
39+
[19:00:00.025353500] (+0.000103600) thread_switched_in: { thread_id = 2147619320, name = "unknown" }
40+
[19:00:00.026049900] (+0.000696400) thread_switched_in: { thread_id = 2147621216, name = "test_abort_from_isr" }
41+
[19:00:00.026759200] (+0.000709300) semaphore_give_enter: { id = 2147735664 }
42+
[19:00:00.026773600] (+0.000014400) semaphore_give_exit: { id = 2147735664 }
43+
[19:00:00.027346600] (+0.000573000) thread_switched_out: { thread_id = 2147621216, name = "test_abort_from_isr" }
44+
[19:00:00.027457400] (+0.000110800) thread_switched_in: { thread_id = 2147621968, name = "main" }
45+
[19:00:00.029552800] (+0.002095400) thread_create: { thread_id = 2147621216, name = "unknown" }
46+
[19:00:00.029589000] (+0.000036200) thread_info: { thread_id = 2147621216, name = "unknown", stack_base = 2147705856, stack_size = 3072 }
47+
[19:00:00.029697400] (+0.000108400) thread_name_set: { thread_id = 2147621216, name = "test_abort_from_isr" }
48+
[19:00:00.029754800] (+0.000057400) thread_wakeup: { thread_id = 2147621216, name = "test_abort_from_isr" }
49+
[19:00:00.029851200] (+0.000096400) thread_switched_out: { thread_id = 2147621968, name = "main" }
50+
[19:00:00.029928200] (+0.000077000) thread_switched_in: { thread_id = 2147621216, name = "test_abort_from_isr" }
51+
[19:00:00.029968400] (+0.000040200) semaphore_init: { id = 2147623436, ret = 0 }
52+
[19:00:00.030851900] (+0.000883500) thread_create: { thread_id = 2147619320, name = "unknown" }
53+
[19:00:00.030888100] (+0.000036200) thread_info: { thread_id = 2147619320, name = "unknown", stack_base = 2147693568, stack_size = 3072 }
54+
[19:00:00.030943000] (+0.000054900) thread_wakeup: { thread_id = 2147619320, name = "unknown" }
55+
[19:00:00.030989600] (+0.000046600) semaphore_take_enter: { id = 2147623436, timeout = 4294957296 }
56+
[19:00:00.031005800] (+0.000016200) semaphore_take_blocking: { id = 2147623436, timeout = 4294957296 }
57+
[19:00:00.031099600] (+0.000093800) thread_switched_out: { thread_id = 2147621216, name = "test_abort_from_isr" }
58+
[19:00:00.031210300] (+0.000110700) thread_switched_in: { thread_id = 2147621968, name = "main" }
59+
[19:00:00.031329500] (+0.000119200) thread_switched_out: { thread_id = 2147621968, name = "main" }
60+
[19:00:00.031433100] (+0.000103600) thread_switched_in: { thread_id = 2147619320, name = "unknown" }
61+
[19:00:00.031469100] (+0.000036000) semaphore_give_enter: { id = 2147623436 }
62+

snippets/ram-tracing/ram-tracing.conf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright Zephyr Project Contributors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
5+
CONFIG_DEBUG_OPTIMIZATIONS=n
6+
CONFIG_DEBUG_THREAD_INFO=y
7+
8+
CONFIG_TRACING=y
9+
CONFIG_TRACING_CTF=y
10+
CONFIG_TRACING_BACKEND_RAM=y
11+
CONFIG_RAM_TRACING_BUFFER_SIZE=8192
12+
CONFIG_TRACING_SYNC=y

snippets/ram-tracing/snippet.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright Zephyr Project Contributors
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: ram-tracing
5+
append:
6+
EXTRA_CONF_FILE: ram-tracing.conf

0 commit comments

Comments
 (0)