Skip to content

Instantly share code, notes, and snippets.

@vaussard
Last active November 1, 2021 15:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vaussard/581d62032670f118947edb2b503a18c4 to your computer and use it in GitHub Desktop.
Save vaussard/581d62032670f118947edb2b503a18c4 to your computer and use it in GitHub Desktop.
define zephyr_show_thread
printf "State=%d; ", ((struct k_thread *)$arg0)->base.thread_state
printf "Prio=%d; ", ((struct k_thread *)$arg0)->base.prio
printf "Entry=%p; ", ((struct k_thread *)$arg0)->entry.pEntry
printf "PC=%p; ", *(((struct k_thread *)$arg0)->callee_saved.psp + 20)
printf "LR=%p; ", *(((struct k_thread *)$arg0)->callee_saved.psp + 24)
printf "PSP=%p; ", ((struct k_thread *)$arg0)->callee_saved.psp + 32
set $stack_start = ((struct k_thread *)$arg0)->stack_info.start
set $stack_size = ((struct k_thread *)$arg0)->stack_info.size
printf "Stack: %p <- %p (%u bytes)", $stack_start, $stack_start + $stack_size, $stack_size
end
define zephyr_list_threads
set $current_thread = _kernel.threads
set $idx = 0
while ($current_thread != 0)
printf "Thread %02d (%p) ", $idx, $current_thread
zephyr_show_thread $current_thread
if ($current_thread == _kernel->current)
printf " <- RUNNING"
end
printf "\n"
set $PC = *(((struct k_thread *)$current_thread)->callee_saved.psp + 20)
printf "\t"
info line *$PC
set $idx = $idx + 1
set $current_thread = $current_thread->next_thread
end
end
@vaussard
Copy link
Author

vaussard commented Apr 7, 2020

Enable CONFIG_THREAD_MONITOR and CONFIG_THREAD_STACK_INFO
Then run "zephyr_list_threads"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment