Zephyr Project API 4.4.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
12
13#ifndef ZEPHYR_INCLUDE_INSTRUMENTATION_INSTRUMENTATION_H_
14#define ZEPHYR_INCLUDE_INSTRUMENTATION_INSTRUMENTATION_H_
15
21
22#include <zephyr/kernel.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28#if !defined(__no_instrumentation__)
29#error "No toolchain support for __no_instrumentation__"
30#endif
31
44
51} __packed;
52
62 void *thread_id;
63#ifdef CONFIG_THREAD_NAME
65 char thread_name[CONFIG_THREAD_MAX_NAME_LEN];
66#endif
67} __packed;
68
77 void *callee;
79 void *caller;
83 union {
85 /* Add more payloads here */
86 };
87} __packed;
88
95
102
109
117
123int instr_init(void);
124
131
137bool instr_enabled(void);
138
144int instr_enable(void);
145
152
159
166
173
180
187
192
197
205void instr_event_handler(enum instr_event_types opcode, void *func, void *caller);
206
213void instr_set_trigger_func(void *callee);
214
221void instr_set_stop_func(void *callee);
222
228
234
235#ifdef __cplusplus
236}
237#endif
238
242
243#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:35
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_dynamic_trigger_supported(void)
Checks if dynamic trigger configuration feature is available.
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:40
@ INSTR_EVENT_NUM
Add more events above this one.
Definition instrumentation.h:41
@ INSTR_EVENT_INVALID
Invalid or no event generated after promotion.
Definition instrumentation.h:42
@ INSTR_EVENT_PROFILE
Profile events.
Definition instrumentation.h:38
@ INSTR_EVENT_EXIT
Callee exit event record, followed by instr_event.
Definition instrumentation.h:37
@ INSTR_EVENT_SCHED_IN
Thread switched in scheduler event.
Definition instrumentation.h:39
@ INSTR_EVENT_ENTRY
Callee entry event record, followed by instr_event.
Definition instrumentation.h:36
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:56
void * thread_id
Thread ID (correlate values with thread lookup table).
Definition instrumentation.h:62
uint8_t mode
Arch-specific mode indicator (thread mode, interrupt mode, etc.).
Definition instrumentation.h:58
uint8_t cpu
CPU number.
Definition instrumentation.h:60
Header for the event records.
Definition instrumentation.h:48
enum instr_event_types type
Event type.
Definition instrumentation.h:50
Event records and associated payloads.
Definition instrumentation.h:73
struct instr_event_context context
Context data.
Definition instrumentation.h:84
void * caller
Address of the caller of the function the event was generated for.
Definition instrumentation.h:79
uint64_t timestamp
Time the event was generated, in nanoseconds.
Definition instrumentation.h:81
struct instr_header header
Record header.
Definition instrumentation.h:75
void * callee
Address of the function the event was generated for.
Definition instrumentation.h:77