2020-02-06 11:59:54 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Intel corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2020-02-06 22:14:51 +08:00
|
|
|
#ifndef ZEPHYR_INCLUDE_TRACING_TRACING_FORMAT_H
|
|
|
|
#define ZEPHYR_INCLUDE_TRACING_TRACING_FORMAT_H
|
2020-02-06 11:59:54 +08:00
|
|
|
|
|
|
|
#include <toolchain/common.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
2021-11-05 20:21:25 +08:00
|
|
|
* @brief Tracing format APIs
|
|
|
|
* @defgroup subsys_tracing_format_apis Tracing format APIs
|
|
|
|
* @ingroup subsys_tracing
|
|
|
|
* @{
|
2020-02-06 11:59:54 +08:00
|
|
|
*/
|
2021-11-05 20:21:25 +08:00
|
|
|
|
|
|
|
/** @brief A structure to represent tracing data format. */
|
2020-02-06 11:59:54 +08:00
|
|
|
typedef struct tracing_data {
|
2020-05-28 00:26:57 +08:00
|
|
|
uint8_t *data;
|
|
|
|
uint32_t length;
|
2020-02-06 11:59:54 +08:00
|
|
|
} __packed tracing_data_t;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Macro to trace a message in string format.
|
2021-11-05 20:21:25 +08:00
|
|
|
*
|
|
|
|
* @param fmt The format string.
|
|
|
|
* @param ... The format arguments.
|
2020-02-06 11:59:54 +08:00
|
|
|
*/
|
|
|
|
#define TRACING_STRING(fmt, ...) \
|
|
|
|
do { \
|
|
|
|
tracing_format_string(fmt, ##__VA_ARGS__); \
|
|
|
|
} while (false)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Macro to format data to tracing data format.
|
2021-11-05 20:21:25 +08:00
|
|
|
*
|
|
|
|
* @param x Data field.
|
2020-02-06 11:59:54 +08:00
|
|
|
*/
|
|
|
|
#define TRACING_FORMAT_DATA(x) \
|
2020-05-28 00:26:57 +08:00
|
|
|
((struct tracing_data){.data = (uint8_t *)&(x), .length = sizeof((x))})
|
2020-02-06 11:59:54 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Macro to trace a message in tracing data format.
|
|
|
|
*
|
|
|
|
* All the parameters should be struct tracing_data.
|
|
|
|
*/
|
|
|
|
#define TRACING_DATA(...) \
|
|
|
|
do { \
|
|
|
|
struct tracing_data arg[] = {__VA_ARGS__}; \
|
|
|
|
\
|
|
|
|
tracing_format_data(arg, sizeof(arg) / \
|
|
|
|
sizeof(struct tracing_data)); \
|
|
|
|
} while (false)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Tracing a message in string format.
|
|
|
|
*
|
|
|
|
* @param str String to format.
|
|
|
|
* @param ... Variable length arguments.
|
|
|
|
*/
|
|
|
|
void tracing_format_string(const char *str, ...);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Tracing a message in raw data format.
|
|
|
|
*
|
|
|
|
* @param data Raw data to be traced.
|
|
|
|
* @param length Raw data length.
|
|
|
|
*/
|
2020-05-28 00:26:57 +08:00
|
|
|
void tracing_format_raw_data(uint8_t *data, uint32_t length);
|
2020-02-06 11:59:54 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Tracing a message in tracing data format.
|
|
|
|
*
|
|
|
|
* @param tracing_data_array Tracing_data format data array to be traced.
|
|
|
|
* @param count Tracing_data array data count.
|
|
|
|
*/
|
2020-05-28 00:26:57 +08:00
|
|
|
void tracing_format_data(tracing_data_t *tracing_data_array, uint32_t count);
|
2020-02-06 11:59:54 +08:00
|
|
|
|
2021-11-05 20:21:25 +08:00
|
|
|
/** @} */ /* end of subsys_tracing_format_apis */
|
|
|
|
|
2020-02-06 11:59:54 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-11-05 20:21:25 +08:00
|
|
|
#endif /* ZEPHYR_INCLUDE_TRACING_TRACING_FORMAT_H */
|