oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
trace.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 Kamil Lulko <kamil.lulko@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 *
6 * This file is part of oveRTOS.
7 */
8
23#ifndef OVE_TRACE_H
24#define OVE_TRACE_H
25
26#include <stdint.h>
27
28#include "ove_config.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34/* Record kind (top-level classification). */
35enum {
36 OVE_TRACE_KIND_STATE = 1,
37 OVE_TRACE_KIND_MARK = 2,
38};
39
40/* MARK primitive types — high nibble of record.code. */
41enum {
42 OVE_TRACE_PRIM_MUTEX = 1,
43 OVE_TRACE_PRIM_SEM = 2,
44 OVE_TRACE_PRIM_EVENT = 3,
45 OVE_TRACE_PRIM_CV = 4,
46 OVE_TRACE_PRIM_QUEUE = 5,
47 OVE_TRACE_PRIM_USER = 15,
48};
49
50/* MARK actions — low nibble of record.code. */
51enum {
52 OVE_TRACE_ACT_WAIT_ENTER = 1,
53 OVE_TRACE_ACT_WAIT_EXIT = 2,
54 OVE_TRACE_ACT_POST = 3,
55 OVE_TRACE_ACT_USER = 4,
56};
57
58#ifdef CONFIG_OVE_TRACE_STREAM
59
70void ove_trace_emit_state(uintptr_t thread_handle, int old_state, int new_state);
71
81void ove_trace_emit_mark(uintptr_t thread_handle, uint8_t prim, uint8_t act, uintptr_t object);
82
93
94#else
95
96static inline void ove_trace_emit_state(uintptr_t t, int o, int n)
97{
98 (void)t;
99 (void)o;
100 (void)n;
101}
102
103static inline void ove_trace_emit_mark(uintptr_t t, uint8_t p, uint8_t a, uintptr_t o)
104{
105 (void)t;
106 (void)p;
107 (void)a;
108 (void)o;
109}
110
111static inline uintptr_t ove_backend_thread_current_handle(void)
112{
113 return 0;
114}
115
116#endif /* CONFIG_OVE_TRACE_STREAM */
117
118#ifdef CONFIG_OVE_TRACE_MARKERS
119#define OVE_TRACE_MARK(thread, prim, act, obj) \
120 ove_trace_emit_mark((uintptr_t)(thread), (prim), (act), (uintptr_t)(obj))
121#define OVE_TRACE_MARK_CURRENT(prim, act, obj) \
122 ove_trace_emit_mark(ove_backend_thread_current_handle(), (prim), (act), (uintptr_t)(obj))
123#else
124#define OVE_TRACE_MARK(thread, prim, act, obj) ((void)0)
125#define OVE_TRACE_MARK_CURRENT(prim, act, obj) ((void)0)
126#endif
127
128#ifdef __cplusplus
129}
130#endif
131
132#endif /* OVE_TRACE_H */
uintptr_t ove_backend_thread_current_handle(void)
Return the current thread's stable handle, or 0 if none.
void ove_trace_emit_mark(uintptr_t thread_handle, uint8_t prim, uint8_t act, uintptr_t object)
Emit a sync-primitive marker.
void ove_trace_emit_state(uintptr_t thread_handle, int old_state, int new_state)
Emit a thread state transition.