Skip to content
Snippets Groups Projects
Commit 7159999e authored by Federico's avatar Federico
Browse files

Fix regression in MemoryProfiling::getCurrentFreeStack() caused by previous patch

parent 9b03c558
Branches
No related tags found
No related merge requests found
...@@ -107,7 +107,15 @@ unsigned int MemoryProfiling::getAbsoluteFreeStack() ...@@ -107,7 +107,15 @@ unsigned int MemoryProfiling::getAbsoluteFreeStack()
unsigned int MemoryProfiling::getCurrentFreeStack() unsigned int MemoryProfiling::getCurrentFreeStack()
{ {
unsigned int stackOccupiedByCtxsave=sysconf(ctxsaveOnStack); unsigned int stackOccupiedByCtxsave=sysconf(ctxsaveOnStack);
int *stack_ptr asm("sp"); #ifdef __ARM_EABI__
void *stack_ptr;
asm volatile("mov %0, sp" : "=r"(stack_ptr));
#else //__ARM_EABI__
//NOTE: __builtin_frame_address doesn't add the size of the current function
//frame, likely __builtin_stack_address would be better but GCC 9.2.0 does
//not have it
void *stack_ptr=__builtin_frame_address(0);
#endif //__ARM_EABI__
const unsigned int *walk=getStackBottom(); const unsigned int *walk=getStackBottom();
unsigned int freeStack=(reinterpret_cast<unsigned int>(stack_ptr) unsigned int freeStack=(reinterpret_cast<unsigned int>(stack_ptr)
- reinterpret_cast<unsigned int>(walk)); - reinterpret_cast<unsigned int>(walk));
......
...@@ -94,7 +94,15 @@ unsigned int MemoryProfiling::getAbsoluteFreeStack() ...@@ -94,7 +94,15 @@ unsigned int MemoryProfiling::getAbsoluteFreeStack()
unsigned int MemoryProfiling::getCurrentFreeStack() unsigned int MemoryProfiling::getCurrentFreeStack()
{ {
int *stack_ptr; #ifdef __ARM_EABI__
void *stack_ptr;
asm volatile("mov %0, sp" : "=r"(stack_ptr));
#else //__ARM_EABI__
//NOTE: __builtin_frame_address doesn't add the size of the current function
//frame, likely __builtin_stack_address would be better but GCC 9.2.0 does
//not have it
void *stack_ptr=__builtin_frame_address(0);
#endif //__ARM_EABI__
const unsigned int *walk=Thread::getStackBottom(); const unsigned int *walk=Thread::getStackBottom();
unsigned int freeStack=(reinterpret_cast<unsigned int>(stack_ptr) unsigned int freeStack=(reinterpret_cast<unsigned int>(stack_ptr)
- reinterpret_cast<unsigned int>(walk)); - reinterpret_cast<unsigned int>(walk));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment