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>
This commit is contained in:
Tom Burdick 2021-10-13 12:16:39 -05:00 committed by Anas Nashif
commit 97dc88bb6d
15 changed files with 533 additions and 172 deletions

View file

@ -4,6 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/
/* Disable syscall tracing for all calls from this compilation unit to avoid
* undefined symbols as the macros are not expanded recursively
*/
#define DISABLE_SYSCALL_TRACING
#include <sys/util.h>
#include <sys/atomic.h>
#include <sys/__assert.h>
@ -123,7 +128,7 @@ static struct usb_ep_cfg_data ep_cfg[] = {
};
USBD_CFG_DATA_DEFINE(primary, tracing_backend_usb)
struct usb_cfg_data tracing_backend_usb_config = {
struct usb_cfg_data tracing_backend_usb_config = {
.usb_device_description = NULL,
.interface_descriptor = &dev_desc.if0,
.cb_usb_status = dev_status_cb,