Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
instrumentation.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 Linaro
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_INSTRUMENTATION_INSTRUMENTATION_H_
8#define ZEPHYR_INCLUDE_INSTRUMENTATION_INSTRUMENTATION_H_
9
15
16#include <zephyr/kernel.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22#if !defined(__no_instrumentation__)
23#error "No toolchain support for __no_instrumentation__"
24#endif
25
38
45} __packed;
46
56 void *thread_id;
57#ifdef CONFIG_THREAD_NAME
59 char thread_name[CONFIG_THREAD_MAX_NAME_LEN];
60#endif
61} __packed;
62
69 void *callee;
70 void *caller;
72 union {
73 struct instr_event_context context; /* Context data */
74 /* Add more payloads here */
75 };
76} __packed;
77
84
91
99
105int instr_init(void);
106
113
119bool instr_enabled(void);
120
126int instr_enable(void);
127
134
141
148
155
162
169
174
179
187void instr_event_handler(enum instr_event_types opcode, void *func, void *caller);
188
195void instr_set_trigger_func(void *callee);
196
203void instr_set_stop_func(void *callee);
204
210
216
217#ifdef __cplusplus
218}
219#endif
220
224
225#endif /* ZEPHYR_INCLUDE_INSTRUMENTATION_INSTRUMENTATION_H_ */
void instr_set_stop_func(void *callee)
Given a function address, set it as the stopper function, i.e.
int instr_turn_off(void)
Turns off instrumentation (stop recording events).
void instr_dump_deltas_uart(void)
Dumps the delta accumulator array via UART (profiling).
bool instr_enabled(void)
Tells if instrumentation is enabled, i.e.
void instr_dump_buffer_uart(void)
Dumps the buffered contents via UART (tracing).
void * instr_get_stop_func(void)
Get the stopper function address.
bool instr_profile_enabled(void)
Tells if instrumentation can collect profile info.
bool instr_tracing_supported(void)
Checks if tracing feature is available.
instr_event_types
Instrumentation event record types.
Definition instrumentation.h:29
int instr_turn_on(void)
Turns on instrumentation (start recording events).
bool instr_initialized(void)
Tells if instrumentation subsystem is properly initialized.
bool instr_trace_enabled(void)
Tells if instrumentation can collect traces.
void instr_event_handler(enum instr_event_types opcode, void *func, void *caller)
Shared callback handler to process entry/exit events.
void * instr_get_trigger_func(void)
Get the trigger function address.
int instr_disable(void)
Disables instrumentation.
bool instr_fundamentals_initialized(void)
Checks if subsystem is ready to be initialized.
void instr_set_trigger_func(void *callee)
Given a function address, set it as the trigger function, i.e.
int instr_enable(void)
Enables instrumentation.
int instr_init(void)
Performs initialisation required by the system.
bool instr_profiling_supported(void)
Checks if profiling feature is available.
bool instr_turned_on(void)
Tells if instrumentation is turned on.
@ INSTR_EVENT_SCHED_OUT
Thread switched out scheduler event.
Definition instrumentation.h:34
@ INSTR_EVENT_NUM
Add more events above this one.
Definition instrumentation.h:35
@ INSTR_EVENT_INVALID
Invalid or no event generated after promotion.
Definition instrumentation.h:36
@ INSTR_EVENT_PROFILE
Profile events.
Definition instrumentation.h:32
@ INSTR_EVENT_EXIT
Callee exit event record, followed by instr_event.
Definition instrumentation.h:31
@ INSTR_EVENT_SCHED_IN
Thread switched in scheduler event.
Definition instrumentation.h:33
@ INSTR_EVENT_ENTRY
Callee entry event record, followed by instr_event.
Definition instrumentation.h:30
Public kernel APIs.
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Context-specific data of an event.
Definition instrumentation.h:50
void * thread_id
Thread ID (correlate values with thread lookup table).
Definition instrumentation.h:56
uint8_t mode
Arch-specific mode indicator (thread mode, interrupt mode, etc.).
Definition instrumentation.h:52
uint8_t cpu
CPU number.
Definition instrumentation.h:54
Header for the event records.
Definition instrumentation.h:42
enum instr_event_types type
Event type.
Definition instrumentation.h:44
Event records and associated payloads.
Definition instrumentation.h:67
struct instr_event_context context
Definition instrumentation.h:73
void * caller
Definition instrumentation.h:70
uint64_t timestamp
Definition instrumentation.h:71
struct instr_header header
Definition instrumentation.h:68
void * callee
Definition instrumentation.h:69