File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include "mbed_stats.h"
2
+ #include <string.h>
3
+
4
+ #if MBED_CONF_RTOS_PRESENT
5
+ #include "cmsis_os.h"
6
+ #endif
7
+
8
+ // note: mbed_stats_heap_get defined in mbed_alloc_wrappers.cpp
9
+
10
+ void mbed_stats_stack_get (mbed_stats_stack_t * stats )
11
+ {
12
+ memset (stats , 0 , sizeof (mbed_stats_stack_t ));
13
+
14
+ #if MBED_STACK_STATS_ENABLED && MBED_CONF_RTOS_PRESENT
15
+ osThreadEnumId enumid = _osThreadsEnumStart ();
16
+ osThreadId threadid ;
17
+
18
+ while ((threadid = _osThreadEnumNext (enumid ))) {
19
+ osEvent e ;
20
+
21
+ e = _osThreadGetInfo (threadid , osThreadInfoStackMax );
22
+ if (e .status == osOK ) {
23
+ stats -> max_size += (uint32_t )e .value .p ;
24
+ }
25
+
26
+ e = _osThreadGetInfo (threadid , osThreadInfoStackSize );
27
+ if (e .status == osOK ) {
28
+ stats -> reserved_size += (uint32_t )e .value .p ;
29
+ }
30
+
31
+ stats -> stack_cnt += 1 ;
32
+ }
33
+ #elif MBED_STACK_STATS_ENABLED
34
+ #warning Stack statistics are not supported without the rtos.
35
+ #endif
36
+ }
37
+
Original file line number Diff line number Diff line change 18
18
*/
19
19
#ifndef MBED_STATS_H
20
20
#define MBED_STATS_H
21
+ #include <stdint.h>
21
22
22
23
#ifdef __cplusplus
23
24
extern "C" {
@@ -36,6 +37,17 @@ typedef struct {
36
37
*/
37
38
void mbed_stats_heap_get (mbed_stats_heap_t * stats );
38
39
40
+ typedef struct {
41
+ uint32_t max_size ; /**< Sum of the maximum number of bytes used in each stack. */
42
+ uint32_t reserved_size ; /**< Current number of bytes allocated for all stacks. */
43
+ uint32_t stack_cnt ; /**< Number of stacks currently allocated. */
44
+ } mbed_stats_stack_t ;
45
+
46
+ /**
47
+ * Fill the passed in structure with stack stats.
48
+ */
49
+ void mbed_stats_stack_get (mbed_stats_stack_t * stats );
50
+
39
51
#ifdef __cplusplus
40
52
}
41
53
#endif
You can’t perform that action at this time.
0 commit comments