@@ -37,6 +37,12 @@ static bool prv_find_slot(size_t *idx, struct k_thread *desired_tcb) {
3737
3838// We intercept calls to arch_new_thread() so we can track when new tasks
3939// 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.
4046void __wrap_arch_new_thread (struct k_thread * thread , k_thread_stack_t * stack ,
4147 char * stack_ptr , k_thread_entry_t entry ,
4248 void * p1 , void * p2 , void * p3 );
@@ -56,6 +62,19 @@ void __wrap_arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
5662 __real_arch_new_thread (thread , stack , stack_ptr , entry , p1 , p2 , p3 );
5763}
5864
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+
5978MEMFAULT_WEAK
6079size_t memfault_platform_sanitize_address_range (void * start_addr , size_t desired_size ) {
6180 // NB: This only works for MCUs which have a contiguous RAM address range. (i.e Any MCU in the
0 commit comments