@@ -37,6 +37,12 @@ static bool prv_find_slot(size_t *idx, struct k_thread *desired_tcb) {
37
37
38
38
// We intercept calls to arch_new_thread() so we can track when new tasks
39
39
// are created
40
+ //
41
+ // It would be nice to use '__builtin_types_compatible_p' and '__typeof__' to
42
+ // enforce strict abi matching in the wrapped functions, but the target
43
+ // functions are declared in private zephyr ./kernel/include files, which are
44
+ // not really supposed to be accessed from user code and would require some
45
+ // dubious path hacks to get to.
40
46
void __wrap_arch_new_thread (struct k_thread * thread , k_thread_stack_t * stack ,
41
47
char * stack_ptr , k_thread_entry_t entry ,
42
48
void * p1 , void * p2 , void * p3 );
@@ -56,6 +62,19 @@ void __wrap_arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
56
62
__real_arch_new_thread (thread , stack , stack_ptr , entry , p1 , p2 , p3 );
57
63
}
58
64
65
+ void __wrap_z_thread_abort (struct k_thread * thread );
66
+ void __real_z_thread_abort (struct k_thread * thread );
67
+
68
+ void __wrap_z_thread_abort (struct k_thread * thread ) {
69
+ size_t idx = 0 ;
70
+ const bool slot_found = prv_find_slot (& idx , thread );
71
+ if (slot_found ) {
72
+ s_task_tcbs [idx ] = EMPTY_SLOT ;
73
+ }
74
+
75
+ __real_z_thread_abort (thread );
76
+ }
77
+
59
78
MEMFAULT_WEAK
60
79
size_t memfault_platform_sanitize_address_range (void * start_addr , size_t desired_size ) {
61
80
// NB: This only works for MCUs which have a contiguous RAM address range. (i.e Any MCU in the
0 commit comments