summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/zephyr/modzephyr.c29
-rw-r--r--ports/zephyr/prj.conf5
2 files changed, 9 insertions, 25 deletions
diff --git a/ports/zephyr/modzephyr.c b/ports/zephyr/modzephyr.c
index d4ee610b2..71b44d7df 100644
--- a/ports/zephyr/modzephyr.c
+++ b/ports/zephyr/modzephyr.c
@@ -30,7 +30,7 @@
#include <stdio.h>
#include <zephyr.h>
-#include <debug/stack.h>
+#include <debug/thread_analyzer.h>
#include "modzephyr.h"
#include "py/runtime.h"
@@ -45,27 +45,12 @@ STATIC mp_obj_t mod_current_tid(void) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_current_tid_obj, mod_current_tid);
-#ifdef CONFIG_THREAD_STACK_INFO
-extern k_tid_t const _main_thread;
-extern k_tid_t const _idle_thread;
-
-static void thread_stack_dump(const struct k_thread *thread, void *user_data) {
- const char *th_name = k_thread_name_get((k_tid_t)thread);
-
- if (th_name == NULL) {
- static char tid[9];
- snprintf(tid, sizeof(tid), "%08x", (int)thread);
- th_name = tid;
- }
-
- stack_analyze(th_name, (char *)thread->stack_info.start, thread->stack_info.size);
-}
-
-STATIC mp_obj_t mod_stacks_analyze(void) {
- k_thread_foreach(thread_stack_dump, NULL);
+#ifdef CONFIG_THREAD_ANALYZER
+STATIC mp_obj_t mod_thread_analyze(void) {
+ thread_analyzer_print();
return mp_const_none;
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_stacks_analyze_obj, mod_stacks_analyze);
+STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_thread_analyze_obj, mod_thread_analyze);
#endif
#ifdef CONFIG_NET_SHELL
@@ -84,8 +69,8 @@ STATIC const mp_rom_map_elem_t mp_module_time_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_zephyr) },
{ MP_ROM_QSTR(MP_QSTR_is_preempt_thread), MP_ROM_PTR(&mod_is_preempt_thread_obj) },
{ MP_ROM_QSTR(MP_QSTR_current_tid), MP_ROM_PTR(&mod_current_tid_obj) },
- #ifdef CONFIG_THREAD_STACK_INFO
- { MP_ROM_QSTR(MP_QSTR_stacks_analyze), MP_ROM_PTR(&mod_stacks_analyze_obj) },
+ #ifdef CONFIG_THREAD_ANALYZER
+ { MP_ROM_QSTR(MP_QSTR_thread_analyze), MP_ROM_PTR(&mod_thread_analyze_obj) },
#endif
#ifdef CONFIG_NET_SHELL
diff --git a/ports/zephyr/prj.conf b/ports/zephyr/prj.conf
index 993dfdc26..e6ccdadcf 100644
--- a/ports/zephyr/prj.conf
+++ b/ports/zephyr/prj.conf
@@ -50,10 +50,9 @@ CONFIG_NET_DHCPV4=y
# Diagnostics and debugging
# Required for zephyr.stack_analyze()
-CONFIG_INIT_STACKS=y
-CONFIG_THREAD_MONITOR=y
+CONFIG_THREAD_ANALYZER=y
+CONFIG_THREAD_ANALYZER_USE_PRINTK=y
CONFIG_THREAD_NAME=y
-CONFIG_THREAD_STACK_INFO=y
# Required for usocket.pkt_get_info()
CONFIG_NET_BUF_POOL_USAGE=y