Skip to content

Commit 9ad292a

Browse files
authored
Merge pull request #12466 from jeromecoutant/PR_METRIC
MBED_STACK_STATS_ENABLED : Add stack_name information in greentea metrics
2 parents 1bf9303 + 2df428b commit 9ad292a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

features/frameworks/greentea-client/source/greentea_metrics.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ typedef struct {
3838
uint32_t entry;
3939
uint32_t stack_size;
4040
uint32_t max_stack;
41+
const char *stack_name;
4142
} thread_info_t;
4243

4344
// Mutex to protect "buf"
@@ -60,6 +61,7 @@ static void enqeue_thread_info(osThreadId_t id);
6061
static void deque_and_print_thread_info(void);
6162

6263
// sprintf uses a lot of stack so use these instead
64+
static uint32_t print_str(char *buf, const char *value);
6365
static uint32_t print_hex(char *buf, uint32_t value);
6466
static uint32_t print_dec(char *buf, uint32_t value);
6567
#endif
@@ -160,6 +162,7 @@ static void enqeue_thread_info(osThreadId_t id)
160162
thread_info.entry = (uint32_t)id;
161163
thread_info.stack_size = osThreadGetStackSize(id);
162164
thread_info.max_stack = thread_info.stack_size - osThreadGetStackSpace(id);
165+
thread_info.stack_name = osThreadGetName(id);
163166
queue->push(thread_info);
164167
}
165168

@@ -170,6 +173,10 @@ static void deque_and_print_thread_info()
170173
MBED_ASSERT(ret);
171174
uint32_t pos = 0;
172175
buf[pos++] = '\"';
176+
pos += print_str(buf + pos, thread_info.stack_name);
177+
buf[pos++] = '\"';
178+
buf[pos++] = ',';
179+
buf[pos++] = '\"';
173180
pos += print_hex(buf + pos, thread_info.entry);
174181
buf[pos++] = '\"';
175182
buf[pos++] = ',';
@@ -180,6 +187,16 @@ static void deque_and_print_thread_info()
180187
greentea_send_kv("__thread_info", buf);
181188
}
182189

190+
static uint32_t print_str(char *buf, const char *value)
191+
{
192+
uint32_t pos = 0;
193+
for (pos = 0; pos < strlen(value); pos++) {
194+
buf[pos] = value[pos];
195+
}
196+
return pos;
197+
}
198+
199+
183200
static uint32_t print_hex(char *buf, uint32_t value)
184201
{
185202
uint32_t pos = 0;

0 commit comments

Comments
 (0)