shell: show IRQ stack information
This is placeholder code; better kernel support for dumping exception/interrupt related stacks is forthcoming. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
7cb8f5c61e
commit
22b9167acb
1 changed files with 28 additions and 0 deletions
|
@ -131,12 +131,40 @@ static void shell_stack_dump(const struct k_thread *thread, void *user_data)
|
||||||
size, unused, size - unused, size, pcnt);
|
size, unused, size - unused, size, pcnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern K_THREAD_STACK_DEFINE(_interrupt_stack, CONFIG_ISR_STACK_SIZE);
|
||||||
|
|
||||||
static int cmd_kernel_stacks(const struct shell *shell,
|
static int cmd_kernel_stacks(const struct shell *shell,
|
||||||
size_t argc, char **argv)
|
size_t argc, char **argv)
|
||||||
{
|
{
|
||||||
|
u8_t *buf;
|
||||||
|
size_t size, unused = 0;
|
||||||
|
|
||||||
ARG_UNUSED(argc);
|
ARG_UNUSED(argc);
|
||||||
ARG_UNUSED(argv);
|
ARG_UNUSED(argv);
|
||||||
k_thread_foreach(shell_stack_dump, (void *)shell);
|
k_thread_foreach(shell_stack_dump, (void *)shell);
|
||||||
|
|
||||||
|
/* Placeholder logic for interrupt stack until we have better
|
||||||
|
* kernel support, including dumping all IRQ stacks for SMP systems
|
||||||
|
* and hooks to dump arch-specific exception-related stack buffers.
|
||||||
|
*
|
||||||
|
* For now, dump data for the first IRQ stack defined in init.c
|
||||||
|
*/
|
||||||
|
buf = Z_THREAD_STACK_BUFFER(_interrupt_stack);
|
||||||
|
size = K_THREAD_STACK_SIZEOF(_interrupt_stack);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < K_THREAD_STACK_SIZEOF(_interrupt_stack); i++) {
|
||||||
|
if (buf[i] == 0xAAU) {
|
||||||
|
unused++;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
shell_print(shell,
|
||||||
|
"%p IRQ 0 (real size %zu):\tunused %zu\tusage %zu / %zu (%zu %%)",
|
||||||
|
_interrupt_stack, size, unused, size - unused, size,
|
||||||
|
((size - unused) * 100U) / size);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue