zephyr/subsys/tracing/tracing_format_async.c
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

77 lines
1.5 KiB
C

/*
* Copyright (c) 2019 Intel corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#define DISABLE_SYSCALL_TRACING
#include <tracing_core.h>
#include <tracing_buffer.h>
#include <tracing_format_common.h>
void tracing_format_string(const char *str, ...)
{
va_list args;
bool put_success, before_put_is_empty;
if (!is_tracing_enabled() || is_tracing_thread()) {
return;
}
va_start(args, str);
TRACING_LOCK();
before_put_is_empty = tracing_buffer_is_empty();
put_success = tracing_format_string_put(str, args);
TRACING_UNLOCK();
va_end(args);
if (put_success) {
tracing_trigger_output(before_put_is_empty);
} else {
tracing_packet_drop_handle();
}
}
void tracing_format_raw_data(uint8_t *data, uint32_t length)
{
bool put_success, before_put_is_empty;
if (!is_tracing_enabled() || is_tracing_thread()) {
return;
}
TRACING_LOCK();
before_put_is_empty = tracing_buffer_is_empty();
put_success = tracing_format_raw_data_put(data, length);
TRACING_UNLOCK();
if (put_success) {
tracing_trigger_output(before_put_is_empty);
} else {
tracing_packet_drop_handle();
}
}
void tracing_format_data(tracing_data_t *tracing_data_array, uint32_t count)
{
bool put_success, before_put_is_empty;
if (!is_tracing_enabled() || is_tracing_thread()) {
return;
}
TRACING_LOCK();
before_put_is_empty = tracing_buffer_is_empty();
put_success = tracing_format_data_put(tracing_data_array, count);
TRACING_UNLOCK();
if (put_success) {
tracing_trigger_output(before_put_is_empty);
} else {
tracing_packet_drop_handle();
}
}