Revision e5742249 core/src/aos_thread.c
core/src/aos_thread.c | ||
---|---|---|
91 | 91 |
{ |
92 | 92 |
aosDbgCheck(thread != NULL); |
93 | 93 |
|
94 |
size_t util; |
|
95 |
uint8_t* ptr = (uint8_t*)thread->wabase; |
|
96 |
|
|
97 |
while (*ptr == CH_DBG_STACK_FILL_VALUE && ptr < (uint8_t*)thread->wabase + aosThdGetStacksize(thread)) { |
|
98 |
++ptr; |
|
94 |
// iterator through the stack |
|
95 |
// note: since the stack is filled from top to bottom, the loop searches for the first irregular byte from the bottom (stack end). |
|
96 |
for (uint8_t* ptr = (uint8_t*)thread->wabase; ptr < (uint8_t*)thread->wabase + aosThdGetStacksize(thread); ++ptr) { |
|
97 |
if (*ptr != CH_DBG_STACK_FILL_VALUE) { |
|
98 |
return aosThdGetStacksize(thread) - (size_t)(--ptr - (uint8_t*)thread->wabase); |
|
99 |
} |
|
99 | 100 |
} |
100 |
util = aosThdGetStacksize(thread) - (ptr - (uint8_t*)thread->wabase); |
|
101 | 101 |
|
102 |
return util;
|
|
102 |
return 0;
|
|
103 | 103 |
} |
104 | 104 |
#endif /* (AMIROOS_CFG_DBG == true) && (CH_DBG_FILL_THREADS == TRUE) */ |
105 | 105 |
|
Also available in: Unified diff