getMaxUsedStack() - stack usage reseach mini progress
This commit is contained in:
parent
b13da10a67
commit
6e57cae396
|
@ -101,6 +101,7 @@ typedef unsigned int time_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stack debugging
|
* Stack debugging
|
||||||
|
* See also getMaxUsedStack()
|
||||||
*/
|
*/
|
||||||
int getRemainingStack(thread_t *otp);
|
int getRemainingStack(thread_t *otp);
|
||||||
|
|
||||||
|
|
|
@ -39,3 +39,16 @@ efitime_t Overflow64Counter::update(uint32_t value) {
|
||||||
return state.highBits + state.lowBits;
|
return state.highBits + state.lowBits;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int getMaxUsedStack(uint8_t *ptr, int size) {
|
||||||
|
/**
|
||||||
|
* maximum used stack size total stack buffer size minus position of first modified byte
|
||||||
|
*/
|
||||||
|
int used = 0;
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
if (ptr[i] != CH_DBG_STACK_FILL_VALUE) {
|
||||||
|
return size - i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -17,6 +17,10 @@ typedef struct {
|
||||||
} State64;
|
} State64;
|
||||||
|
|
||||||
void updateAndSet(State64 *state, uint32_t value);
|
void updateAndSet(State64 *state, uint32_t value);
|
||||||
|
/**
|
||||||
|
* @return for a given stack memory region returns how much stack was ever used
|
||||||
|
*/
|
||||||
|
int getMaxUsedStack(uint8_t *ptr, int size);
|
||||||
|
|
||||||
class Overflow64Counter
|
class Overflow64Counter
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue