File tree Expand file tree Collapse file tree 2 files changed +42
-2
lines changed Expand file tree Collapse file tree 2 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -30,8 +30,40 @@ void mbed_stats_stack_get(mbed_stats_stack_t *stats)
30
30
31
31
stats -> stack_cnt += 1 ;
32
32
}
33
- #elif MBED_STACK_STATS_ENABLED
34
- #warning Stack statistics are not supported without the rtos.
35
33
#endif
36
34
}
37
35
36
+ size_t mbed_stats_stack_get_each (mbed_stats_stack_t * stats , size_t count )
37
+ {
38
+ memset (stats , 0 , count * sizeof (mbed_stats_stack_t ));
39
+ size_t i = 0 ;
40
+
41
+ #if MBED_STACK_STATS_ENABLED && MBED_CONF_RTOS_PRESENT
42
+ osThreadEnumId enumid = _osThreadsEnumStart ();
43
+ osThreadId threadid ;
44
+
45
+ while ((threadid = _osThreadEnumNext (enumid )) && i < count ) {
46
+ osEvent e ;
47
+
48
+ e = _osThreadGetInfo (threadid , osThreadInfoStackMax );
49
+ if (e .status == osOK ) {
50
+ stats [i ].max_size = (uint32_t )e .value .p ;
51
+ }
52
+
53
+ e = _osThreadGetInfo (threadid , osThreadInfoStackSize );
54
+ if (e .status == osOK ) {
55
+ stats [i ].reserved_size = (uint32_t )e .value .p ;
56
+ }
57
+
58
+ stats [i ].thread_id = (uint32_t )threadid ;
59
+ stats [i ].stack_cnt = 1 ;
60
+ i += 1 ;
61
+ }
62
+ #endif
63
+
64
+ return i ;
65
+ }
66
+
67
+ #if MBED_STACK_STATS_ENABLED && !MBED_CONF_RTOS_PRESENT
68
+ #warning Stack statistics are currently not supported without the rtos.
69
+ #endif
Original file line number Diff line number Diff line change 19
19
#ifndef MBED_STATS_H
20
20
#define MBED_STATS_H
21
21
#include <stdint.h>
22
+ #include <stddef.h>
22
23
23
24
#ifdef __cplusplus
24
25
extern "C" {
@@ -39,6 +40,7 @@ typedef struct {
39
40
void mbed_stats_heap_get (mbed_stats_heap_t * stats );
40
41
41
42
typedef struct {
43
+ uint32_t thread_id ; /**< Identifier for thread that owns the stack. */
42
44
uint32_t max_size ; /**< Sum of the maximum number of bytes used in each stack. */
43
45
uint32_t reserved_size ; /**< Current number of bytes allocated for all stacks. */
44
46
uint32_t stack_cnt ; /**< Number of stacks currently allocated. */
@@ -49,6 +51,12 @@ typedef struct {
49
51
*/
50
52
void mbed_stats_stack_get (mbed_stats_stack_t * stats );
51
53
54
+ /**
55
+ * Fill the passed array of stat structures with the stack stats
56
+ * for each available stack.
57
+ */
58
+ size_t mbed_stats_stack_get_each (mbed_stats_stack_t * stats , size_t count );
59
+
52
60
#ifdef __cplusplus
53
61
}
54
62
#endif
You can’t perform that action at this time.
0 commit comments