kernel: overhaul unused stack measurement
The existing stack_analyze APIs had some problems: 1. Not properly namespaced 2. Accepted the stack object as a parameter, yet the stack object does not contain the necessary information to get the associated buffer region, the thread object is needed for this 3. Caused a crash on certain platforms that do not allow inspection of unused stack space for the currently running thread 4. No user mode access 5. Separately passed in thread name We deprecate these functions and add a new API k_thread_stack_space_get() which addresses all of these issues. A helper API log_stack_usage() also added which resembles STACK_ANALYZE() in functionality. Fixes: #17852 Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
f02fdd2d7b
commit
efc5fe07a2
16 changed files with 229 additions and 46 deletions
|
@ -362,17 +362,19 @@ uint32_t osThreadGetStackSize(osThreadId_t thread_id)
|
|||
uint32_t osThreadGetStackSpace(osThreadId_t thread_id)
|
||||
{
|
||||
struct cv2_thread *tid = (struct cv2_thread *)thread_id;
|
||||
u32_t size = tid->z_thread.stack_info.size;
|
||||
u32_t unused = 0U;
|
||||
size_t unused;
|
||||
int ret;
|
||||
|
||||
__ASSERT(tid, "");
|
||||
__ASSERT(is_cmsis_rtos_v2_thread(tid), "");
|
||||
__ASSERT(!k_is_in_isr(), "");
|
||||
|
||||
unused = stack_unused_space_get((char *)tid->z_thread.stack_info.start,
|
||||
size);
|
||||
ret = k_thread_stack_space_get(&tid->z_thread, &unused);
|
||||
if (ret != 0) {
|
||||
unused = 0;
|
||||
}
|
||||
|
||||
return unused;
|
||||
return (uint32_t)unused;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue