Linux debugging
Check our new training course
Linux debugging, tracing, profiling & perf. analysis
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
/* * Copyright (c) 2020 Lexmark International, Inc. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. * * SPDX-License-Identifier: Apache-2.0 */ #include <tracing_user.h> #include <kernel_internal.h> #include <zephyr/kernel_structs.h> #include <ksched.h> static int nested_interrupts[CONFIG_MP_NUM_CPUS]; void __weak sys_trace_thread_create_user(struct k_thread *thread) {} void __weak sys_trace_thread_abort_user(struct k_thread *thread) {} void __weak sys_trace_thread_suspend_user(struct k_thread *thread) {} void __weak sys_trace_thread_resume_user(struct k_thread *thread) {} void __weak sys_trace_thread_name_set_user(struct k_thread *thread) {} void __weak sys_trace_thread_switched_in_user(struct k_thread *thread) {} void __weak sys_trace_thread_switched_out_user(struct k_thread *thread) {} void __weak sys_trace_thread_info_user(struct k_thread *thread) {} void __weak sys_trace_thread_sched_ready_user(struct k_thread *thread) {} void __weak sys_trace_thread_pend_user(struct k_thread *thread) {} void __weak sys_trace_thread_priority_set_user(struct k_thread *thread, int prio) {} void __weak sys_trace_isr_enter_user(int nested_interrupts) {} void __weak sys_trace_isr_exit_user(int nested_interrupts) {} void __weak sys_trace_idle_user(void) {} void sys_trace_thread_create(struct k_thread *thread) { sys_trace_thread_create_user(thread); } void sys_trace_thread_abort(struct k_thread *thread) { sys_trace_thread_abort_user(thread); } void sys_trace_thread_suspend(struct k_thread *thread) { sys_trace_thread_suspend_user(thread); } void sys_trace_thread_resume(struct k_thread *thread) { sys_trace_thread_resume_user(thread); } void sys_trace_thread_name_set(struct k_thread *thread) { sys_trace_thread_name_set_user(thread); } void sys_trace_k_thread_switched_in(void) { /* FIXME: Limitation of the current x86 EFI cosnole implementation. */ #if !defined(CONFIG_X86_EFI_CONSOLE) && !defined(CONFIG_UART_CONSOLE) unsigned int key = irq_lock(); __ASSERT_NO_MSG(nested_interrupts[_current_cpu->id] == 0); /* Can't use k_current_get as thread base and z_tls_current might be incorrect */ sys_trace_thread_switched_in_user(z_current_get()); irq_unlock(key); #endif } void sys_trace_k_thread_switched_out(void) { #if !defined(CONFIG_X86_EFI_CONSOLE) && !defined(CONFIG_UART_CONSOLE) unsigned int key = irq_lock(); __ASSERT_NO_MSG(nested_interrupts[_current_cpu->id] == 0); /* Can't use k_current_get as thread base and z_tls_current might be incorrect */ sys_trace_thread_switched_out_user(z_current_get()); irq_unlock(key); #endif } void sys_trace_thread_info(struct k_thread *thread) { sys_trace_thread_info_user(thread); } void sys_trace_thread_sched_priority_set(struct k_thread *thread, int prio) { sys_trace_thread_priority_set_user(thread, prio); } void sys_trace_thread_sched_ready(struct k_thread *thread) { sys_trace_thread_sched_ready_user(thread); } void sys_trace_thread_pend(struct k_thread *thread) { sys_trace_thread_pend_user(thread); } void sys_trace_isr_enter(void) { unsigned int key = irq_lock(); _cpu_t *curr_cpu = _current_cpu; sys_trace_isr_enter_user(nested_interrupts[curr_cpu->id]); nested_interrupts[curr_cpu->id]++; irq_unlock(key); } void sys_trace_isr_exit(void) { unsigned int key = irq_lock(); _cpu_t *curr_cpu = _current_cpu; nested_interrupts[curr_cpu->id]--; sys_trace_isr_exit_user(nested_interrupts[curr_cpu->id]); irq_unlock(key); } void sys_trace_idle(void) { sys_trace_idle_user(); }