From 41abcc57c145907f7855176fee5ff1a02f69e217 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Thu, 6 Feb 2020 09:13:51 -0500 Subject: [PATCH] tracing: move tracing under subsys/ Tracing subsystem is growing and although related to debugging, it does deserve to belong into its own subsystem. Signed-off-by: Anas Nashif --- subsys/CMakeLists.txt | 1 + subsys/Kconfig | 2 + subsys/debug/CMakeLists.txt | 2 - subsys/debug/Kconfig | 175 ----------------- subsys/{debug => }/tracing/CMakeLists.txt | 0 subsys/tracing/Kconfig | 182 ++++++++++++++++++ subsys/{debug => tracing}/Kconfig.segger | 0 subsys/{debug => }/tracing/cpu_stats.c | 0 subsys/{debug => }/tracing/ctf/CMakeLists.txt | 0 subsys/{debug => }/tracing/ctf/ctf_top.c | 0 subsys/{debug => }/tracing/ctf/ctf_top.h | 0 subsys/{debug => }/tracing/ctf/tsdl/metadata | 0 .../tracing/include/SEGGER_SYSVIEW_Zephyr.h | 0 .../tracing/include/tracing_backend.h | 0 .../tracing/include/tracing_buffer.h | 0 .../tracing/include/tracing_core.h | 0 .../tracing/include/tracing_cpu_stats.h | 0 .../{debug => }/tracing/include/tracing_ctf.h | 0 .../tracing/include/tracing_format_common.h | 0 .../tracing/include/tracing_sysview.h | 0 .../tracing/include/tracing_test.h | 0 subsys/{debug => }/tracing/sysview.c | 0 .../tracing/sysview/SYSVIEW_Zephyr.txt | 0 subsys/{debug => }/tracing/sysview_config.c | 0 .../tracing/tracing_backend_posix.c | 0 .../tracing/tracing_backend_uart.c | 0 .../{debug => }/tracing/tracing_backend_usb.c | 0 subsys/{debug => }/tracing/tracing_buffer.c | 0 subsys/{debug => }/tracing/tracing_core.c | 0 .../tracing/tracing_format_async.c | 0 .../tracing/tracing_format_common.c | 0 .../{debug => }/tracing/tracing_format_sync.c | 0 32 files changed, 185 insertions(+), 177 deletions(-) rename subsys/{debug => }/tracing/CMakeLists.txt (100%) create mode 100644 subsys/tracing/Kconfig rename subsys/{debug => tracing}/Kconfig.segger (100%) rename subsys/{debug => }/tracing/cpu_stats.c (100%) rename subsys/{debug => }/tracing/ctf/CMakeLists.txt (100%) rename subsys/{debug => }/tracing/ctf/ctf_top.c (100%) rename subsys/{debug => }/tracing/ctf/ctf_top.h (100%) rename subsys/{debug => }/tracing/ctf/tsdl/metadata (100%) rename subsys/{debug => }/tracing/include/SEGGER_SYSVIEW_Zephyr.h (100%) rename subsys/{debug => }/tracing/include/tracing_backend.h (100%) rename subsys/{debug => }/tracing/include/tracing_buffer.h (100%) rename subsys/{debug => }/tracing/include/tracing_core.h (100%) rename subsys/{debug => }/tracing/include/tracing_cpu_stats.h (100%) rename subsys/{debug => }/tracing/include/tracing_ctf.h (100%) rename subsys/{debug => }/tracing/include/tracing_format_common.h (100%) rename subsys/{debug => }/tracing/include/tracing_sysview.h (100%) rename subsys/{debug => }/tracing/include/tracing_test.h (100%) rename subsys/{debug => }/tracing/sysview.c (100%) rename subsys/{debug => }/tracing/sysview/SYSVIEW_Zephyr.txt (100%) rename subsys/{debug => }/tracing/sysview_config.c (100%) rename subsys/{debug => }/tracing/tracing_backend_posix.c (100%) rename subsys/{debug => }/tracing/tracing_backend_uart.c (100%) rename subsys/{debug => }/tracing/tracing_backend_usb.c (100%) rename subsys/{debug => }/tracing/tracing_buffer.c (100%) rename subsys/{debug => }/tracing/tracing_core.c (100%) rename subsys/{debug => }/tracing/tracing_format_async.c (100%) rename subsys/{debug => }/tracing/tracing_format_common.c (100%) rename subsys/{debug => }/tracing/tracing_format_sync.c (100%) diff --git a/subsys/CMakeLists.txt b/subsys/CMakeLists.txt index dc0275c5045..a203f5bd34d 100644 --- a/subsys/CMakeLists.txt +++ b/subsys/CMakeLists.txt @@ -19,5 +19,6 @@ add_subdirectory(fb) add_subdirectory(power) add_subdirectory(stats) add_subdirectory(testsuite) +add_subdirectory(tracing) add_subdirectory_if_kconfig(jwt) add_subdirectory(canbus) diff --git a/subsys/Kconfig b/subsys/Kconfig index 6ffaca0c83b..615ae9762b6 100644 --- a/subsys/Kconfig +++ b/subsys/Kconfig @@ -35,6 +35,8 @@ source "subsys/settings/Kconfig" source "subsys/testsuite/Kconfig" +source "subsys/tracing/Kconfig" + source "subsys/fb/Kconfig" source "subsys/jwt/Kconfig" diff --git a/subsys/debug/CMakeLists.txt b/subsys/debug/CMakeLists.txt index 3048af72984..0387382575f 100644 --- a/subsys/debug/CMakeLists.txt +++ b/subsys/debug/CMakeLists.txt @@ -9,5 +9,3 @@ zephyr_sources_ifdef( CONFIG_ASAN asan_hacks.c ) - -add_subdirectory(tracing) diff --git a/subsys/debug/Kconfig b/subsys/debug/Kconfig index ed6c2b68454..612586341ee 100644 --- a/subsys/debug/Kconfig +++ b/subsys/debug/Kconfig @@ -39,133 +39,6 @@ config DEBUG only disables optimization, more debugging variants can be selected from here to allow more debugging. -config TRACING - bool "Enabling Tracing" - help - Enable system tracing. This requires a backend such as SEGGER - Systemview to be enabled as well. - -if TRACING - -choice - prompt "Tracing Method" - default TRACING_ASYNC - -config TRACING_SYNC - bool "Synchronous Tracing" - select RING_BUFFER - help - Enable synchronous tracing. This requires the backend to be - very low-latency. - -config TRACING_ASYNC - bool "Asynchronous Tracing" - select RING_BUFFER - help - Enable asynchronous tracing. This will buffer all the tracing - packets to the ring buffer first, tracing thread will try to - output as much data in ring buffer as possible when tracing - thread get scheduled. - -endchoice - -config TRACING_THREAD_STACK_SIZE - int "Stack size of tracing thread" - default 1024 - depends on TRACING_ASYNC - help - Stack size of tracing thread. - -config TRACING_THREAD_WAIT_THRESHOLD - int "Tracing thread waiting threshold" - default 100 - depends on TRACING_ASYNC - help - Tracing thread waiting period given in milliseconds after - every first packet put to tracing buffer. - -config TRACING_BUFFER_SIZE - int "Size of tracing buffer" - default 2048 if TRACING_ASYNC - default TRACING_PACKET_MAX_SIZE if TRACING_SYNC - range 32 65536 - help - Size of tracing buffer. If TRACING_ASYNC is enabled, tracing buffer - is used as ring_buffer to buffer data packet and string packet. If - TRACING_SYNC is enabled, it's used to hold the formated data. - -config TRACING_PACKET_MAX_SIZE - int "Max size of one tracing packet" - default 32 - help - Max size of one tracing packet. - -choice - prompt "Tracing Backend" - default TRACING_BACKEND_UART - -config TRACING_BACKEND_UART - bool "Enable UART backend" - depends on UART_CONSOLE - depends on TRACING_ASYNC - help - When enabled backend is using UART to output tracing data. - -config TRACING_BACKEND_USB - bool "Enable USB backend" - depends on TRACING_ASYNC - help - When enabled backend is using USB to output tracing data. - -config TRACING_BACKEND_POSIX - bool "Enable POSIX backend" - depends on TRACING_SYNC - depends on ARCH_POSIX - help - When enabled backend is using posix API to output tracing - data to file system. - -endchoice - -config TRACING_BACKEND_UART_NAME - string "Device Name of UART Device for UART backend" - default "$(dt_chosen_label,$(DT_CHOSEN_Z_CONSOLE))" if HAS_DTS - default "UART_0" - depends on TRACING_BACKEND_UART - help - This option specifies the name of UART device to be used for - tracing backend. - -config TRACING_USB_MPS - int "USB backend max packet size" - default 64 - depends on TRACING_BACKEND_USB - help - USB tracing backend max packet size(endpoint MPS). - -config TRACING_HANDLE_HOST_CMD - bool "Enable host cmd handle" - select UART_INTERRUPT_DRIVEN if TRACING_BACKEND_UART - help - When enabled tracing will handle cmd from host to dynamically - enable and disable tracing to have host capture tracing stream - data conveniently. - -config TRACING_CMD_BUFFER_SIZE - int "Size of tracing cmd buffer" - default 32 - range 32 128 - help - Size of tracing command buffer. - -config TRACING_ISR - bool "Enabling Tracing ISR" - help - Enable tracing ISR. This requires the backend to be - very low-latency. - -endif - config ASAN bool "Build with address sanitizer" depends on ARCH_POSIX @@ -409,53 +282,5 @@ config OPENOCD_SUPPORT OpenOCD to determine the state of running threads. (This option selects CONFIG_THREAD_MONITOR, so all of its caveats are implied.) -config TRACING_CPU_STATS - bool "Enable CPU usage tracing" - select THREAD_MONITOR - select THREAD_STACK_INFO - select TRACING - help - Module provides information about percent of CPU usage based on - tracing hooks for threads switching in and out, interrupts enters - and exits (only distinguishes between idle thread, non idle thread - and scheduler). Use provided API or enable automatic logging to - get values. - -config TRACING_CPU_STATS_LOG - bool "Enable current CPU usage logging" - depends on TRACING_CPU_STATS - help - Periodically displays information about CPU usage. - -config TRACING_CPU_STATS_INTERVAL - int "Logging interval for CPU measurements [ms]" - default 2000 - depends on TRACING_CPU_STATS_LOG - help - Time period of displaying information about CPU usage. - -config TRACING_CTF - bool "Tracing via Common Trace Format support" - select THREAD_MONITOR - select TRACING - help - Enable tracing to a Common Trace Format stream. - -config TRACING_CTF_TIMESTAMP - bool "Enable CTF internal timestamp" - default y - help - Timestamp prefix will be added to the beginning of CTF - event internally. - -config TRACING_TEST - bool "Tracing for test usage" - depends on TRACING - help - Enable tracing for testing kinds of format purpose. It must - implement the tracing hooks defined in tracing_test.h - - -source "subsys/debug/Kconfig.segger" endmenu diff --git a/subsys/debug/tracing/CMakeLists.txt b/subsys/tracing/CMakeLists.txt similarity index 100% rename from subsys/debug/tracing/CMakeLists.txt rename to subsys/tracing/CMakeLists.txt diff --git a/subsys/tracing/Kconfig b/subsys/tracing/Kconfig new file mode 100644 index 00000000000..1429f418bf5 --- /dev/null +++ b/subsys/tracing/Kconfig @@ -0,0 +1,182 @@ +# Debug configuration options + +# Copyright (c) 2015 Wind River Systems, Inc. +# SPDX-License-Identifier: Apache-2.0 + +DT_CHOSEN_Z_CONSOLE := zephyr,console + +config TRACING + bool "Enabling Tracing" + help + Enable system tracing. This requires a backend such as SEGGER + Systemview to be enabled as well. + +if TRACING + +choice + prompt "Tracing Method" + default TRACING_ASYNC + +config TRACING_SYNC + bool "Synchronous Tracing" + select RING_BUFFER + help + Enable synchronous tracing. This requires the backend to be + very low-latency. + +config TRACING_ASYNC + bool "Asynchronous Tracing" + select RING_BUFFER + help + Enable asynchronous tracing. This will buffer all the tracing + packets to the ring buffer first, tracing thread will try to + output as much data in ring buffer as possible when tracing + thread get scheduled. + +endchoice + +config TRACING_THREAD_STACK_SIZE + int "Stack size of tracing thread" + default 1024 + depends on TRACING_ASYNC + help + Stack size of tracing thread. + +config TRACING_THREAD_WAIT_THRESHOLD + int "Tracing thread waiting threshold" + default 100 + depends on TRACING_ASYNC + help + Tracing thread waiting period given in milliseconds after + every first packet put to tracing buffer. + +config TRACING_BUFFER_SIZE + int "Size of tracing buffer" + default 2048 if TRACING_ASYNC + default TRACING_PACKET_MAX_SIZE if TRACING_SYNC + range 32 65536 + help + Size of tracing buffer. If TRACING_ASYNC is enabled, tracing buffer + is used as ring_buffer to buffer data packet and string packet. If + TRACING_SYNC is enabled, it's used to hold the formated data. + +config TRACING_PACKET_MAX_SIZE + int "Max size of one tracing packet" + default 32 + help + Max size of one tracing packet. + +choice + prompt "Tracing Backend" + default TRACING_BACKEND_UART + +config TRACING_BACKEND_UART + bool "Enable UART backend" + depends on UART_CONSOLE + depends on TRACING_ASYNC + help + When enabled backend is using UART to output tracing data. + +config TRACING_BACKEND_USB + bool "Enable USB backend" + depends on TRACING_ASYNC + help + When enabled backend is using USB to output tracing data. + +config TRACING_BACKEND_POSIX + bool "Enable POSIX backend" + depends on TRACING_SYNC + depends on ARCH_POSIX + help + When enabled backend is using posix API to output tracing + data to file system. + +endchoice + +config TRACING_BACKEND_UART_NAME + string "Device Name of UART Device for UART backend" + default "$(dt_chosen_label,$(DT_CHOSEN_Z_CONSOLE))" if HAS_DTS + default "UART_0" + depends on TRACING_BACKEND_UART + help + This option specifies the name of UART device to be used for + tracing backend. + +config TRACING_USB_MPS + int "USB backend max packet size" + default 64 + depends on TRACING_BACKEND_USB + help + USB tracing backend max packet size(endpoint MPS). + +config TRACING_HANDLE_HOST_CMD + bool "Enable host cmd handle" + select UART_INTERRUPT_DRIVEN if TRACING_BACKEND_UART + help + When enabled tracing will handle cmd from host to dynamically + enable and disable tracing to have host capture tracing stream + data conveniently. + +config TRACING_CMD_BUFFER_SIZE + int "Size of tracing cmd buffer" + default 32 + range 32 128 + help + Size of tracing command buffer. + +config TRACING_ISR + bool "Enabling Tracing ISR" + help + Enable tracing ISR. This requires the backend to be + very low-latency. + +endif + +config TRACING_CPU_STATS + bool "Enable CPU usage tracing" + select THREAD_MONITOR + select THREAD_STACK_INFO + select TRACING + help + Module provides information about percent of CPU usage based on + tracing hooks for threads switching in and out, interrupts enters + and exits (only distinguishes between idle thread, non idle thread + and scheduler). Use provided API or enable automatic logging to + get values. + +config TRACING_CPU_STATS_LOG + bool "Enable current CPU usage logging" + depends on TRACING_CPU_STATS + help + Periodically displays information about CPU usage. + +config TRACING_CPU_STATS_INTERVAL + int "Logging interval for CPU measurements [ms]" + default 2000 + depends on TRACING_CPU_STATS_LOG + help + Time period of displaying information about CPU usage. + +config TRACING_CTF + bool "Tracing via Common Trace Format support" + select THREAD_MONITOR + select TRACING + help + Enable tracing to a Common Trace Format stream. + +config TRACING_CTF_TIMESTAMP + bool "Enable CTF internal timestamp" + default y + help + Timestamp prefix will be added to the beginning of CTF + event internally. + +config TRACING_TEST + bool "Tracing for test usage" + depends on TRACING + help + Enable tracing for testing kinds of format purpose. It must + implement the tracing hooks defined in tracing_test.h + + +source "subsys/tracing/Kconfig.segger" diff --git a/subsys/debug/Kconfig.segger b/subsys/tracing/Kconfig.segger similarity index 100% rename from subsys/debug/Kconfig.segger rename to subsys/tracing/Kconfig.segger diff --git a/subsys/debug/tracing/cpu_stats.c b/subsys/tracing/cpu_stats.c similarity index 100% rename from subsys/debug/tracing/cpu_stats.c rename to subsys/tracing/cpu_stats.c diff --git a/subsys/debug/tracing/ctf/CMakeLists.txt b/subsys/tracing/ctf/CMakeLists.txt similarity index 100% rename from subsys/debug/tracing/ctf/CMakeLists.txt rename to subsys/tracing/ctf/CMakeLists.txt diff --git a/subsys/debug/tracing/ctf/ctf_top.c b/subsys/tracing/ctf/ctf_top.c similarity index 100% rename from subsys/debug/tracing/ctf/ctf_top.c rename to subsys/tracing/ctf/ctf_top.c diff --git a/subsys/debug/tracing/ctf/ctf_top.h b/subsys/tracing/ctf/ctf_top.h similarity index 100% rename from subsys/debug/tracing/ctf/ctf_top.h rename to subsys/tracing/ctf/ctf_top.h diff --git a/subsys/debug/tracing/ctf/tsdl/metadata b/subsys/tracing/ctf/tsdl/metadata similarity index 100% rename from subsys/debug/tracing/ctf/tsdl/metadata rename to subsys/tracing/ctf/tsdl/metadata diff --git a/subsys/debug/tracing/include/SEGGER_SYSVIEW_Zephyr.h b/subsys/tracing/include/SEGGER_SYSVIEW_Zephyr.h similarity index 100% rename from subsys/debug/tracing/include/SEGGER_SYSVIEW_Zephyr.h rename to subsys/tracing/include/SEGGER_SYSVIEW_Zephyr.h diff --git a/subsys/debug/tracing/include/tracing_backend.h b/subsys/tracing/include/tracing_backend.h similarity index 100% rename from subsys/debug/tracing/include/tracing_backend.h rename to subsys/tracing/include/tracing_backend.h diff --git a/subsys/debug/tracing/include/tracing_buffer.h b/subsys/tracing/include/tracing_buffer.h similarity index 100% rename from subsys/debug/tracing/include/tracing_buffer.h rename to subsys/tracing/include/tracing_buffer.h diff --git a/subsys/debug/tracing/include/tracing_core.h b/subsys/tracing/include/tracing_core.h similarity index 100% rename from subsys/debug/tracing/include/tracing_core.h rename to subsys/tracing/include/tracing_core.h diff --git a/subsys/debug/tracing/include/tracing_cpu_stats.h b/subsys/tracing/include/tracing_cpu_stats.h similarity index 100% rename from subsys/debug/tracing/include/tracing_cpu_stats.h rename to subsys/tracing/include/tracing_cpu_stats.h diff --git a/subsys/debug/tracing/include/tracing_ctf.h b/subsys/tracing/include/tracing_ctf.h similarity index 100% rename from subsys/debug/tracing/include/tracing_ctf.h rename to subsys/tracing/include/tracing_ctf.h diff --git a/subsys/debug/tracing/include/tracing_format_common.h b/subsys/tracing/include/tracing_format_common.h similarity index 100% rename from subsys/debug/tracing/include/tracing_format_common.h rename to subsys/tracing/include/tracing_format_common.h diff --git a/subsys/debug/tracing/include/tracing_sysview.h b/subsys/tracing/include/tracing_sysview.h similarity index 100% rename from subsys/debug/tracing/include/tracing_sysview.h rename to subsys/tracing/include/tracing_sysview.h diff --git a/subsys/debug/tracing/include/tracing_test.h b/subsys/tracing/include/tracing_test.h similarity index 100% rename from subsys/debug/tracing/include/tracing_test.h rename to subsys/tracing/include/tracing_test.h diff --git a/subsys/debug/tracing/sysview.c b/subsys/tracing/sysview.c similarity index 100% rename from subsys/debug/tracing/sysview.c rename to subsys/tracing/sysview.c diff --git a/subsys/debug/tracing/sysview/SYSVIEW_Zephyr.txt b/subsys/tracing/sysview/SYSVIEW_Zephyr.txt similarity index 100% rename from subsys/debug/tracing/sysview/SYSVIEW_Zephyr.txt rename to subsys/tracing/sysview/SYSVIEW_Zephyr.txt diff --git a/subsys/debug/tracing/sysview_config.c b/subsys/tracing/sysview_config.c similarity index 100% rename from subsys/debug/tracing/sysview_config.c rename to subsys/tracing/sysview_config.c diff --git a/subsys/debug/tracing/tracing_backend_posix.c b/subsys/tracing/tracing_backend_posix.c similarity index 100% rename from subsys/debug/tracing/tracing_backend_posix.c rename to subsys/tracing/tracing_backend_posix.c diff --git a/subsys/debug/tracing/tracing_backend_uart.c b/subsys/tracing/tracing_backend_uart.c similarity index 100% rename from subsys/debug/tracing/tracing_backend_uart.c rename to subsys/tracing/tracing_backend_uart.c diff --git a/subsys/debug/tracing/tracing_backend_usb.c b/subsys/tracing/tracing_backend_usb.c similarity index 100% rename from subsys/debug/tracing/tracing_backend_usb.c rename to subsys/tracing/tracing_backend_usb.c diff --git a/subsys/debug/tracing/tracing_buffer.c b/subsys/tracing/tracing_buffer.c similarity index 100% rename from subsys/debug/tracing/tracing_buffer.c rename to subsys/tracing/tracing_buffer.c diff --git a/subsys/debug/tracing/tracing_core.c b/subsys/tracing/tracing_core.c similarity index 100% rename from subsys/debug/tracing/tracing_core.c rename to subsys/tracing/tracing_core.c diff --git a/subsys/debug/tracing/tracing_format_async.c b/subsys/tracing/tracing_format_async.c similarity index 100% rename from subsys/debug/tracing/tracing_format_async.c rename to subsys/tracing/tracing_format_async.c diff --git a/subsys/debug/tracing/tracing_format_common.c b/subsys/tracing/tracing_format_common.c similarity index 100% rename from subsys/debug/tracing/tracing_format_common.c rename to subsys/tracing/tracing_format_common.c diff --git a/subsys/debug/tracing/tracing_format_sync.c b/subsys/tracing/tracing_format_sync.c similarity index 100% rename from subsys/debug/tracing/tracing_format_sync.c rename to subsys/tracing/tracing_format_sync.c