使用RT-Thread的过程中发现常常进assert,发现是在某个线程调用mutex时挂死的,所以想在rt_thread_self里检测是从哪个线程进来的。
但打印出来有的时候是空值,why?
除了可以通过看thread->name,还有办法可以达到看当前是在哪个线程的目的吗?
void rt_assert_handler(const char *ex_string, const char *func,
rt_size_t line) {
if (rt_assert_hook == RT_NULL) {
#ifdef RT_USING_MODULE
if (dlmodule_self()) {
/* close assertion module */
dlmodule_exit(-1);
} else
#endif /*RT_USING_MODULE*/
{
rt_thread_t cur_thread = rt_thread_self();
rt_kprintf("assertion thread: %s\n", cur_thread->name);
// rt_kprintf("(%s) assertion failed at function:%s, line number:%d \n",
// ex_string, func, line);
while (dummy == 0)
;
}
} else {
rt_assert_hook(ex_string, func, line);
}
}
打印输出: