Skip to content

Commit 8c8974f

Browse files
committed
tracing: ctf: thread extended
Signed-off-by: Anas Nashif <[email protected]>
1 parent 13bacc4 commit 8c8974f

File tree

4 files changed

+580
-33
lines changed

4 files changed

+580
-33
lines changed

subsys/tracing/ctf/ctf_top.c

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,169 @@ void sys_trace_k_thread_name_set(struct k_thread *thread, int ret)
187187

188188
}
189189

190+
/* Thread Extended Functions */
191+
void sys_trace_k_thread_foreach_enter(void)
192+
{
193+
ctf_top_thread_foreach_enter();
194+
}
195+
196+
void sys_trace_k_thread_foreach_exit(void)
197+
{
198+
ctf_top_thread_foreach_exit();
199+
}
200+
201+
void sys_trace_k_thread_foreach_unlocked_enter(void)
202+
{
203+
ctf_top_thread_foreach_unlocked_enter();
204+
}
205+
206+
void sys_trace_k_thread_foreach_unlocked_exit()
207+
{
208+
ctf_top_thread_foreach_unlocked_exit();
209+
}
210+
211+
void sys_trace_k_thread_heap_assign(struct k_thread *thread, struct k_heap *heap)
212+
{
213+
ctf_top_thread_heap_assign(
214+
(uint32_t)(uintptr_t)thread,
215+
(uint32_t)(uintptr_t)heap
216+
);
217+
}
218+
219+
void sys_trace_k_thread_join_enter(struct k_thread *thread, k_timeout_t timeout)
220+
{
221+
ctf_top_thread_join_enter(
222+
(uint32_t)(uintptr_t)thread,
223+
(uint32_t)timeout.ticks
224+
);
225+
}
226+
227+
void sys_trace_k_thread_join_blocking(struct k_thread *thread, k_timeout_t timeout)
228+
{
229+
ctf_top_thread_join_blocking(
230+
(uint32_t)(uintptr_t)thread,
231+
(uint32_t)timeout.ticks
232+
);
233+
}
234+
235+
void sys_trace_k_thread_join_exit(struct k_thread *thread, k_timeout_t timeout, int ret)
236+
{
237+
ctf_top_thread_join_exit(
238+
(uint32_t)(uintptr_t)thread,
239+
(uint32_t)timeout.ticks,
240+
(int32_t)ret
241+
);
242+
}
243+
244+
void sys_trace_k_thread_msleep_enter(int32_t ms)
245+
{
246+
ctf_top_thread_msleep_enter(ms);
247+
}
248+
249+
void sys_trace_k_thread_msleep_exit(int32_t ms, int ret)
250+
{
251+
ctf_top_thread_msleep_exit(ms, (int32_t)ret);
252+
}
253+
254+
void sys_trace_k_thread_usleep_enter(int32_t us)
255+
{
256+
ctf_top_thread_usleep_enter(us);
257+
}
258+
259+
void sys_trace_k_thread_usleep_exit(int32_t us, int ret)
260+
{
261+
ctf_top_thread_usleep_exit(us, (int32_t)ret);
262+
}
263+
264+
void sys_trace_k_thread_busy_wait_enter(uint32_t usec_to_wait)
265+
{
266+
ctf_top_thread_busy_wait_enter(usec_to_wait);
267+
}
268+
269+
void sys_trace_k_thread_busy_wait_exit(uint32_t usec_to_wait)
270+
{
271+
ctf_top_thread_busy_wait_exit(usec_to_wait);
272+
}
273+
274+
void sys_trace_k_thread_yield(void)
275+
{
276+
ctf_top_thread_yield();
277+
}
278+
279+
void sys_trace_k_thread_suspend_exit(struct k_thread *thread)
280+
{
281+
ctf_bounded_string_t name = { "unknown" };
282+
283+
_get_thread_name(thread, &name);
284+
ctf_top_thread_suspend_exit((uint32_t)(uintptr_t)thread, name);
285+
}
286+
287+
void sys_trace_k_thread_sched_lock(void)
288+
{
289+
ctf_top_thread_sched_lock();
290+
}
291+
292+
void sys_trace_k_thread_sched_unlock(void)
293+
{
294+
ctf_top_thread_sched_unlock();
295+
}
296+
297+
void sys_trace_k_thread_sched_wakeup(struct k_thread *thread)
298+
{
299+
ctf_bounded_string_t name = { "unknown" };
300+
301+
_get_thread_name(thread, &name);
302+
ctf_top_thread_sched_wakeup((uint32_t)(uintptr_t)thread, name);
303+
}
304+
305+
void sys_trace_k_thread_sched_abort(struct k_thread *thread)
306+
{
307+
ctf_bounded_string_t name = { "unknown" };
308+
309+
_get_thread_name(thread, &name);
310+
ctf_top_thread_sched_abort((uint32_t)(uintptr_t)thread, name);
311+
}
312+
313+
void sys_trace_k_thread_sched_priority_set(struct k_thread *thread, int prio)
314+
{
315+
ctf_bounded_string_t name = { "unknown" };
316+
317+
_get_thread_name(thread, &name);
318+
ctf_top_thread_sched_priority_set((uint32_t)(uintptr_t)thread, (int8_t)prio, name);
319+
}
320+
321+
void sys_trace_k_thread_sched_ready(struct k_thread *thread)
322+
{
323+
ctf_bounded_string_t name = { "unknown" };
324+
325+
_get_thread_name(thread, &name);
326+
ctf_top_thread_sched_ready((uint32_t)(uintptr_t)thread, name);
327+
}
328+
329+
void sys_trace_k_thread_sched_pend(struct k_thread *thread)
330+
{
331+
ctf_bounded_string_t name = { "unknown" };
332+
333+
_get_thread_name(thread, &name);
334+
ctf_top_thread_sched_pend((uint32_t)(uintptr_t)thread, name);
335+
}
336+
337+
void sys_trace_k_thread_sched_resume(struct k_thread *thread)
338+
{
339+
ctf_bounded_string_t name = { "unknown" };
340+
341+
_get_thread_name(thread, &name);
342+
ctf_top_thread_sched_resume((uint32_t)(uintptr_t)thread, name);
343+
}
344+
345+
void sys_trace_k_thread_sched_suspend(struct k_thread *thread)
346+
{
347+
ctf_bounded_string_t name = { "unknown" };
348+
349+
_get_thread_name(thread, &name);
350+
ctf_top_thread_sched_suspend((uint32_t)(uintptr_t)thread, name);
351+
}
352+
190353
void sys_trace_isr_enter(void)
191354
{
192355
ctf_top_isr_enter();

subsys/tracing/ctf/ctf_top.h

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,33 @@ typedef enum {
290290
CTF_EVENT_POLL_SIGNAL_CHECK = 0xD3,
291291
CTF_EVENT_POLL_SIGNAL_RAISE = 0xD4,
292292

293+
/* Thread Extended */
294+
CTF_EVENT_THREAD_FOREACH_ENTER = 0xD5,
295+
CTF_EVENT_THREAD_FOREACH_EXIT = 0xD6,
296+
CTF_EVENT_THREAD_FOREACH_UNLOCKED_ENTER = 0xD7,
297+
CTF_EVENT_THREAD_FOREACH_UNLOCKED_EXIT = 0xD8,
298+
CTF_EVENT_THREAD_HEAP_ASSIGN = 0xD9,
299+
CTF_EVENT_THREAD_JOIN_ENTER = 0xDA,
300+
CTF_EVENT_THREAD_JOIN_BLOCKING = 0xDB,
301+
CTF_EVENT_THREAD_JOIN_EXIT = 0xDC,
302+
CTF_EVENT_THREAD_MSLEEP_ENTER = 0xDD,
303+
CTF_EVENT_THREAD_MSLEEP_EXIT = 0xDE,
304+
CTF_EVENT_THREAD_USLEEP_ENTER = 0xDF,
305+
CTF_EVENT_THREAD_USLEEP_EXIT = 0xE0,
306+
CTF_EVENT_THREAD_BUSY_WAIT_ENTER = 0xE1,
307+
CTF_EVENT_THREAD_BUSY_WAIT_EXIT = 0xE2,
308+
CTF_EVENT_THREAD_YIELD = 0xE3,
309+
CTF_EVENT_THREAD_SUSPEND_EXIT = 0xE4,
310+
CTF_EVENT_THREAD_SCHED_LOCK = 0xE5,
311+
CTF_EVENT_THREAD_SCHED_UNLOCK = 0xE6,
312+
CTF_EVENT_THREAD_SCHED_WAKEUP = 0xE7,
313+
CTF_EVENT_THREAD_SCHED_ABORT = 0xE8,
314+
CTF_EVENT_THREAD_SCHED_PRIORITY_SET = 0xE9,
315+
CTF_EVENT_THREAD_SCHED_READY = 0xEA,
316+
CTF_EVENT_THREAD_SCHED_PEND = 0xEB,
317+
CTF_EVENT_THREAD_SCHED_RESUME = 0xEC,
318+
CTF_EVENT_THREAD_SCHED_SUSPEND = 0xED,
319+
293320
} ctf_event_t;
294321

295322
typedef struct {
@@ -397,6 +424,132 @@ static inline void ctf_top_thread_wakeup(uint32_t thread_id, ctf_bounded_string_
397424
thread_id, name);
398425
}
399426

427+
/* Thread Extended Functions */
428+
static inline void ctf_top_thread_foreach_enter()
429+
{
430+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_FOREACH_ENTER));
431+
}
432+
433+
static inline void ctf_top_thread_foreach_exit()
434+
{
435+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_FOREACH_EXIT));
436+
}
437+
438+
static inline void ctf_top_thread_foreach_unlocked_enter()
439+
{
440+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_FOREACH_UNLOCKED_ENTER));
441+
}
442+
443+
static inline void ctf_top_thread_foreach_unlocked_exit()
444+
{
445+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_FOREACH_UNLOCKED_EXIT));
446+
}
447+
448+
static inline void ctf_top_thread_heap_assign(uint32_t thread_id, uint32_t heap_id)
449+
{
450+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_HEAP_ASSIGN), thread_id, heap_id);
451+
}
452+
453+
static inline void ctf_top_thread_join_enter(uint32_t thread_id, uint32_t timeout)
454+
{
455+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_JOIN_ENTER), thread_id, timeout);
456+
}
457+
458+
static inline void ctf_top_thread_join_blocking(uint32_t thread_id, uint32_t timeout)
459+
{
460+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_JOIN_BLOCKING), thread_id, timeout);
461+
}
462+
463+
static inline void ctf_top_thread_join_exit(uint32_t thread_id, uint32_t timeout, int32_t ret)
464+
{
465+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_JOIN_EXIT), thread_id, timeout, ret);
466+
}
467+
468+
static inline void ctf_top_thread_msleep_enter(int32_t ms)
469+
{
470+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_MSLEEP_ENTER), ms);
471+
}
472+
473+
static inline void ctf_top_thread_msleep_exit(int32_t ms, int32_t ret)
474+
{
475+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_MSLEEP_EXIT), ms, ret);
476+
}
477+
478+
static inline void ctf_top_thread_usleep_enter(int32_t us)
479+
{
480+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_USLEEP_ENTER), us);
481+
}
482+
483+
static inline void ctf_top_thread_usleep_exit(int32_t us, int32_t ret)
484+
{
485+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_USLEEP_EXIT), us, ret);
486+
}
487+
488+
static inline void ctf_top_thread_busy_wait_enter(uint32_t usec_to_wait)
489+
{
490+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_BUSY_WAIT_ENTER), usec_to_wait);
491+
}
492+
493+
static inline void ctf_top_thread_busy_wait_exit(uint32_t usec_to_wait)
494+
{
495+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_BUSY_WAIT_EXIT), usec_to_wait);
496+
}
497+
498+
static inline void ctf_top_thread_yield(void)
499+
{
500+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_YIELD));
501+
}
502+
503+
static inline void ctf_top_thread_suspend_exit(uint32_t thread_id, ctf_bounded_string_t name)
504+
{
505+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_SUSPEND_EXIT), thread_id, name);
506+
}
507+
508+
static inline void ctf_top_thread_sched_lock(void)
509+
{
510+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_SCHED_LOCK));
511+
}
512+
513+
static inline void ctf_top_thread_sched_unlock(void)
514+
{
515+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_SCHED_UNLOCK));
516+
}
517+
518+
static inline void ctf_top_thread_sched_wakeup(uint32_t thread_id, ctf_bounded_string_t name)
519+
{
520+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_SCHED_WAKEUP), thread_id, name);
521+
}
522+
523+
static inline void ctf_top_thread_sched_abort(uint32_t thread_id, ctf_bounded_string_t name)
524+
{
525+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_SCHED_ABORT), thread_id, name);
526+
}
527+
528+
static inline void ctf_top_thread_sched_priority_set(uint32_t thread_id, int8_t prio, ctf_bounded_string_t name)
529+
{
530+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_SCHED_PRIORITY_SET), thread_id, prio, name);
531+
}
532+
533+
static inline void ctf_top_thread_sched_ready(uint32_t thread_id, ctf_bounded_string_t name)
534+
{
535+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_SCHED_READY), thread_id, name);
536+
}
537+
538+
static inline void ctf_top_thread_sched_pend(uint32_t thread_id, ctf_bounded_string_t name)
539+
{
540+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_SCHED_PEND), thread_id, name);
541+
}
542+
543+
static inline void ctf_top_thread_sched_resume(uint32_t thread_id, ctf_bounded_string_t name)
544+
{
545+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_SCHED_RESUME), thread_id, name);
546+
}
547+
548+
static inline void ctf_top_thread_sched_suspend(uint32_t thread_id, ctf_bounded_string_t name)
549+
{
550+
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_SCHED_SUSPEND), thread_id, name);
551+
}
552+
400553
static inline void ctf_top_isr_enter(void)
401554
{
402555
CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_ISR_ENTER));

0 commit comments

Comments
 (0)