Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
thread_analyzer.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 - 2020 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef __STACK_SIZE_ANALYZER_H
8#define __STACK_SIZE_ANALYZER_H
9
10#include <stddef.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
25
30 const char *name;
32 size_t stack_size;
34 size_t stack_used;
35
36#ifdef CONFIG_THREAD_RUNTIME_STATS
37 unsigned int utilization;
38#ifdef CONFIG_SCHED_THREAD_USAGE
40#endif
41#endif
42
43#ifdef CONFIG_THREAD_ANALYZER_STACK_SAFETY
44 uint32_t stack_safety;
45#endif
46
47#ifdef CONFIG_THREAD_ANALYZER_PRIV_STACK_USAGE
49 size_t priv_stack_size;
50
52 size_t priv_stack_used;
53#endif
54};
55
57
58/* No stack safety issues detected */
59#define THREAD_ANALYZE_STACK_SAFETY_NO_ISSUES 0
60
61/* Unused stack space is below the defined threshold */
62#define THREAD_ANALYZE_STACK_SAFETY_THRESHOLD_EXCEEDED 1
63
64/* No unused stack space is left */
65#define THREAD_ANALYZE_STACK_SAFETY_AT_LIMIT 2
66
67/* Stack overflow detected */
68#define THREAD_ANALYZE_STACK_SAFETY_OVERFLOW 3
69
78typedef void (*thread_analyzer_stack_safety_handler)(struct k_thread *thread,
79 size_t unused_space,
80 uint32_t *stack_issue);
81
91
92
93
100typedef void (*thread_analyzer_cb)(struct thread_analyzer_info *info);
101
112void thread_analyzer_run(thread_analyzer_cb cb, unsigned int cpu);
113
123void thread_analyzer_print(unsigned int cpu);
124
126
127#ifdef __cplusplus
128}
129#endif
130
131#endif /* __STACK_SIZE_ANALYZER_H */
void thread_analyzer_stack_safety_handler_set(thread_analyzer_stack_safety_handler handler)
Change the thread analyzer stack safety callback function.
void thread_analyzer_print(unsigned int cpu)
Run the thread analyzer and print stack size statistics.
void(* thread_analyzer_cb)(struct thread_analyzer_info *info)
Thread analyzer stack size callback function.
Definition thread_analyzer.h:100
void(* thread_analyzer_stack_safety_handler)(struct k_thread *thread, size_t unused_space, uint32_t *stack_issue)
Thread analyzer stack safety callback function.
Definition thread_analyzer.h:78
void thread_analyzer_run(thread_analyzer_cb cb, unsigned int cpu)
Run the thread analyzer and provide information to the callback.
struct k_thread_runtime_stats k_thread_runtime_stats_t
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Thread Structure.
Definition thread.h:263
Definition thread_analyzer.h:26
const char * name
The name of the thread or stringified address of the thread handle if name is not set.
Definition thread_analyzer.h:30
size_t stack_used
Stack size in used.
Definition thread_analyzer.h:34
size_t stack_size
The total size of the stack.
Definition thread_analyzer.h:32