Stack usage is still all over the place #1662
This commit is contained in:
parent
b20d7f7619
commit
c9a598af73
|
@ -119,18 +119,17 @@ static void sayHello(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CH_DBG_THREADS_PROFILING && CH_DBG_FILL_THREADS
|
#if CH_DBG_THREADS_PROFILING && CH_DBG_FILL_THREADS
|
||||||
static uintptr_t CountFreeStackSpace(const void* wabase)
|
int CountFreeStackSpace(const void* wabase) {
|
||||||
{
|
|
||||||
const uint8_t* stackBase = reinterpret_cast<const uint8_t*>(wabase);
|
const uint8_t* stackBase = reinterpret_cast<const uint8_t*>(wabase);
|
||||||
const uint8_t* stackUsage = stackBase;
|
const uint8_t* stackUsage = stackBase;
|
||||||
|
|
||||||
// thread stacks are filled with 0x55
|
// thread stacks are filled with CH_DBG_STACK_FILL_VALUE
|
||||||
// find out where that ends - that's the last thing we needed on the stack
|
// find out where that ends - that's the last thing we needed on the stack
|
||||||
while(*stackUsage == 0x55) {
|
while (*stackUsage == CH_DBG_STACK_FILL_VALUE) {
|
||||||
stackUsage++;
|
stackUsage++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return stackUsage - stackBase;
|
return (int)(stackUsage - stackBase);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -144,15 +143,15 @@ static void cmd_threads(void) {
|
||||||
|
|
||||||
scheduleMsg(&logger, "name\twabase\ttime\tfree stack");
|
scheduleMsg(&logger, "name\twabase\ttime\tfree stack");
|
||||||
|
|
||||||
while(tp) {
|
while (tp) {
|
||||||
uintptr_t freeBytes = CountFreeStackSpace(tp->wabase);
|
int freeBytes = CountFreeStackSpace(tp->wabase);
|
||||||
scheduleMsg(&logger, "%s\t%08x\t%lu\t%lu", tp->name, tp->wabase, tp->time, freeBytes);
|
scheduleMsg(&logger, "%s\t%08x\t%lu\t%d", tp->name, tp->wabase, tp->time, freeBytes);
|
||||||
|
|
||||||
tp = chRegNextThread(tp);
|
tp = chRegNextThread(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
uintptr_t isrSpace = CountFreeStackSpace(reinterpret_cast<void*>(0x20000000));
|
int isrSpace = CountFreeStackSpace(reinterpret_cast<void*>(0x20000000));
|
||||||
scheduleMsg(&logger, "isr\t0\t0\t%lu", isrSpace);
|
scheduleMsg(&logger, "isr\t0\t0\t%d", isrSpace);
|
||||||
|
|
||||||
#else // CH_DBG_THREADS_PROFILING && CH_DBG_FILL_THREADS
|
#else // CH_DBG_THREADS_PROFILING && CH_DBG_FILL_THREADS
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,8 @@ typedef unsigned int time_t;
|
||||||
* project-wide default thread stack size
|
* project-wide default thread stack size
|
||||||
* See also PORT_INT_REQUIRED_STACK
|
* See also PORT_INT_REQUIRED_STACK
|
||||||
* See getRemainingStack()
|
* See getRemainingStack()
|
||||||
* See getMaxUsedStack()
|
* See getMaxUsedStack() and CountFreeStackSpace()
|
||||||
|
* See "threadsinfo" command cmd_threads
|
||||||
*/
|
*/
|
||||||
#ifndef UTILITY_THREAD_STACK_SIZE
|
#ifndef UTILITY_THREAD_STACK_SIZE
|
||||||
#define UTILITY_THREAD_STACK_SIZE 400
|
#define UTILITY_THREAD_STACK_SIZE 400
|
||||||
|
|
|
@ -29,5 +29,6 @@ extern "C"
|
||||||
* See also getMaxUsedStack()
|
* See also getMaxUsedStack()
|
||||||
*/
|
*/
|
||||||
EXTERNC int getRemainingStack(thread_t *otp);
|
EXTERNC int getRemainingStack(thread_t *otp);
|
||||||
|
int CountFreeStackSpace(const void* wabase);
|
||||||
|
|
||||||
#define HAS_OS_ACCESS
|
#define HAS_OS_ACCESS
|
||||||
|
|
Loading…
Reference in New Issue