tracing: add infrastructure for collection of tracing data
First, this commit adds user interface in tracing_format.h which can trace both string format and data format packet. Second, it adds method both for asynchronous and synchronous way. For asynchronous method, tracing packet will be buffered in tracing buffer first, tracing thread will output the stream data with the help of tracing backend when tracing thread get scheduled. Third, it adds UART and USB tracing backend for asynchronous tracing method, and adds POSIX tracing backend for synchronous tracing way. Also it can receive command from host to dynamically enable and disable tracing to have host capture tracing data conveniently. Signed-off-by: Wentong Wu <wentong.wu@intel.com>
This commit is contained in:
parent
6c218ac2c6
commit
8ccc04de6a
16 changed files with 1410 additions and 10 deletions
79
include/debug/tracing_format.h
Normal file
79
include/debug/tracing_format.h
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Intel corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef ZEPHYR_INCLUDE_TRACE_FORMAT_H
|
||||
#define ZEPHYR_INCLUDE_TRACE_FORMAT_H
|
||||
|
||||
#include <toolchain/common.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief A structure to represent tracing data format.
|
||||
*/
|
||||
typedef struct tracing_data {
|
||||
u8_t *data;
|
||||
u32_t length;
|
||||
} __packed tracing_data_t;
|
||||
|
||||
/**
|
||||
* @brief Macro to trace a message in string format.
|
||||
*/
|
||||
#define TRACING_STRING(fmt, ...) \
|
||||
do { \
|
||||
tracing_format_string(fmt, ##__VA_ARGS__); \
|
||||
} while (false)
|
||||
|
||||
/**
|
||||
* @brief Macro to format data to tracing data format.
|
||||
*/
|
||||
#define TRACING_FORMAT_DATA(x) \
|
||||
((struct tracing_data){.data = (u8_t *)&(x), .length = sizeof((x))})
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
void tracing_format_raw_data(u8_t *data, u32_t length);
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
void tracing_format_data(tracing_data_t *tracing_data_array, u32_t count);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -160,3 +160,10 @@
|
|||
KEEP(*(SORT_BY_NAME("._cfb_font.*")))
|
||||
__font_entry_end = .;
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
|
||||
SECTION_DATA_PROLOGUE(tracing_backends_sections,,)
|
||||
{
|
||||
_tracing_backend_list_start = .;
|
||||
KEEP(*("._tracing_backend.*"));
|
||||
_tracing_backend_list_end = .;
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue