zephyr/include/tracing/tracing_syscall.h
Tom Burdick 97dc88bb6d tracing: Automatic syscall tracing
When generating syscall wrappers, call a tracing macro with the id,
name, and all parameters of the syscall as params when entering and
leaving the syscall. This can be disabled in certain call sites
by defining DISABLE_SYSCALL_TRACING which is useful for certain
tracing implementations which require syscalls themselves to work.

Notably some syscalls *cannot* be automatically traced this way and
headers where exclusions are set are in the gen_syscall.py as notracing.

Includes a systemview and test format implementation.

Tested with systemview, usb, and uart backends with the string
formatter using the tracing sample app.

Debugging the trace wrapper can be aided by setting the TRACE_DIAGNOSTIC
env var and rebuilding from scratch, a warning is issued for every
instance a syscall is traced.

Automatically generating a name mapping for SYSVIEW_Zephyr.txt is a
future item as is documenting how to capture and use the tracing data
generated.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2021-10-23 20:45:17 -04:00

51 lines
1.2 KiB
C

/*
* Copyright (c) 2021 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_TRACING_SYSCALL_H_
#define ZEPHYR_INCLUDE_TRACING_SYSCALL_H_
#if defined CONFIG_SEGGER_SYSTEMVIEW
#include "tracing_sysview_syscall.h"
#elif defined CONFIG_TRACING_TEST
#include "tracing_test_syscall.h"
#else
/**
* @brief Syscall Tracing APIs
* @defgroup syscall_tracing_apis Syscall Tracing APIs
* @ingroup tracing_apis
* @{
*/
/**
* @brief Trace syscall entry
* @param id Syscall ID (as defined in the generated syscall_list.h)
* @param name Syscall name as a token (ex: k_thread_create)
* @param ... Other parameters passed to the syscall
*/
#define sys_port_trace_syscall_enter(id, name, ...)
/**
* @brief Trace syscall exit
* @param id Syscall ID (as defined in the generated syscall_list.h)
* @param name Syscall name as a token (ex: k_thread_create)
* @param ... Other parameters passed to the syscall, if the syscall has a return, the return value
* is the last parameter in the list
*/
#define sys_port_trace_syscall_exit(id, name, ...)
/**
* @}
*/ /* end of syscall_tracing_apis */
#endif
#endif /* ZEPHYR_INCLUDE_TRACING_SYSCALL_H_ */