Introduce STACK_GUARD_MARGIN in all variants
Create a gap between the BSS and the stack guard. Set this gap (STACK_GUARD_MARGIN) to 32 bytes in all variants. The gap serves two purposes: - Detect a stack overflow earlier (falsely triggering in overtight situations is OK!), so that we can hopefully avoid smashing the heap and have a clean view during the dump. - Reserve spack space itself for the stack dumping machinery, which is going to grow the stack even further. Remove get_stack_guard_test_value() which was unused.
This commit is contained in:
parent
9663653671
commit
f18d4757c6
@ -48,24 +48,16 @@ void SdFatUtil::set_stack_guard()
|
|||||||
{
|
{
|
||||||
uint32_t *stack_guard;
|
uint32_t *stack_guard;
|
||||||
|
|
||||||
stack_guard = (uint32_t*)&__bss_end;
|
stack_guard = (uint32_t*)(&__bss_end + STACK_GUARD_MARGIN);
|
||||||
*stack_guard = STACK_GUARD_TEST_VALUE;
|
*stack_guard = STACK_GUARD_TEST_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SdFatUtil::test_stack_integrity()
|
bool SdFatUtil::test_stack_integrity()
|
||||||
{
|
{
|
||||||
uint32_t* stack_guard = (uint32_t*)&__bss_end;
|
uint32_t* stack_guard = (uint32_t*)(&__bss_end + STACK_GUARD_MARGIN);
|
||||||
return (*stack_guard == STACK_GUARD_TEST_VALUE);
|
return (*stack_guard == STACK_GUARD_TEST_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t SdFatUtil::get_stack_guard_test_value()
|
|
||||||
{
|
|
||||||
uint32_t* stack_guard;
|
|
||||||
uint32_t output;
|
|
||||||
stack_guard = (uint32_t*)&__bss_end;
|
|
||||||
output = *stack_guard;
|
|
||||||
return(output);
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
/** %Print a string in flash memory.
|
/** %Print a string in flash memory.
|
||||||
*
|
*
|
||||||
|
@ -41,7 +41,6 @@ namespace SdFatUtil {
|
|||||||
void SerialPrintln_P(PGM_P str);
|
void SerialPrintln_P(PGM_P str);
|
||||||
void set_stack_guard();
|
void set_stack_guard();
|
||||||
bool test_stack_integrity();
|
bool test_stack_integrity();
|
||||||
uint32_t get_stack_guard_test_value();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace SdFatUtil; // NOLINT
|
using namespace SdFatUtil; // NOLINT
|
||||||
|
@ -418,6 +418,7 @@ THERMISTORS SETTINGS
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define STACK_GUARD_TEST_VALUE 0xA2A2
|
#define STACK_GUARD_TEST_VALUE 0xA2A2
|
||||||
|
#define STACK_GUARD_MARGIN 32
|
||||||
|
|
||||||
#define MAX_BED_TEMP_CALIBRATION 50
|
#define MAX_BED_TEMP_CALIBRATION 50
|
||||||
#define MAX_HOTEND_TEMP_CALIBRATION 50
|
#define MAX_HOTEND_TEMP_CALIBRATION 50
|
||||||
|
@ -407,6 +407,7 @@ THERMISTORS SETTINGS
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define STACK_GUARD_TEST_VALUE 0xA2A2
|
#define STACK_GUARD_TEST_VALUE 0xA2A2
|
||||||
|
#define STACK_GUARD_MARGIN 32
|
||||||
|
|
||||||
#define MAX_BED_TEMP_CALIBRATION 50
|
#define MAX_BED_TEMP_CALIBRATION 50
|
||||||
#define MAX_HOTEND_TEMP_CALIBRATION 50
|
#define MAX_HOTEND_TEMP_CALIBRATION 50
|
||||||
|
@ -469,6 +469,7 @@
|
|||||||
#define TEMP_SENSOR_PINDA 1
|
#define TEMP_SENSOR_PINDA 1
|
||||||
|
|
||||||
#define STACK_GUARD_TEST_VALUE 0xA2A2
|
#define STACK_GUARD_TEST_VALUE 0xA2A2
|
||||||
|
#define STACK_GUARD_MARGIN 32
|
||||||
|
|
||||||
#define MAX_BED_TEMP_CALIBRATION 50
|
#define MAX_BED_TEMP_CALIBRATION 50
|
||||||
#define MAX_HOTEND_TEMP_CALIBRATION 50
|
#define MAX_HOTEND_TEMP_CALIBRATION 50
|
||||||
|
@ -470,6 +470,7 @@
|
|||||||
#define TEMP_SENSOR_PINDA 1
|
#define TEMP_SENSOR_PINDA 1
|
||||||
|
|
||||||
#define STACK_GUARD_TEST_VALUE 0xA2A2
|
#define STACK_GUARD_TEST_VALUE 0xA2A2
|
||||||
|
#define STACK_GUARD_MARGIN 32
|
||||||
|
|
||||||
#define MAX_BED_TEMP_CALIBRATION 50
|
#define MAX_BED_TEMP_CALIBRATION 50
|
||||||
#define MAX_HOTEND_TEMP_CALIBRATION 50
|
#define MAX_HOTEND_TEMP_CALIBRATION 50
|
||||||
|
@ -469,6 +469,7 @@
|
|||||||
#define TEMP_SENSOR_PINDA 1
|
#define TEMP_SENSOR_PINDA 1
|
||||||
|
|
||||||
#define STACK_GUARD_TEST_VALUE 0xA2A2
|
#define STACK_GUARD_TEST_VALUE 0xA2A2
|
||||||
|
#define STACK_GUARD_MARGIN 32
|
||||||
|
|
||||||
#define MAX_BED_TEMP_CALIBRATION 50
|
#define MAX_BED_TEMP_CALIBRATION 50
|
||||||
#define MAX_HOTEND_TEMP_CALIBRATION 50
|
#define MAX_HOTEND_TEMP_CALIBRATION 50
|
||||||
|
@ -470,6 +470,7 @@
|
|||||||
#define TEMP_SENSOR_PINDA 1
|
#define TEMP_SENSOR_PINDA 1
|
||||||
|
|
||||||
#define STACK_GUARD_TEST_VALUE 0xA2A2
|
#define STACK_GUARD_TEST_VALUE 0xA2A2
|
||||||
|
#define STACK_GUARD_MARGIN 32
|
||||||
|
|
||||||
#define MAX_BED_TEMP_CALIBRATION 50
|
#define MAX_BED_TEMP_CALIBRATION 50
|
||||||
#define MAX_HOTEND_TEMP_CALIBRATION 50
|
#define MAX_HOTEND_TEMP_CALIBRATION 50
|
||||||
|
@ -598,6 +598,7 @@
|
|||||||
#define TEMP_SENSOR_AMBIENT 2000
|
#define TEMP_SENSOR_AMBIENT 2000
|
||||||
|
|
||||||
#define STACK_GUARD_TEST_VALUE 0xA2A2
|
#define STACK_GUARD_TEST_VALUE 0xA2A2
|
||||||
|
#define STACK_GUARD_MARGIN 32
|
||||||
|
|
||||||
#define MAX_BED_TEMP_CALIBRATION 50
|
#define MAX_BED_TEMP_CALIBRATION 50
|
||||||
#define MAX_HOTEND_TEMP_CALIBRATION 50
|
#define MAX_HOTEND_TEMP_CALIBRATION 50
|
||||||
|
@ -602,6 +602,7 @@
|
|||||||
#define TEMP_SENSOR_AMBIENT 2000
|
#define TEMP_SENSOR_AMBIENT 2000
|
||||||
|
|
||||||
#define STACK_GUARD_TEST_VALUE 0xA2A2
|
#define STACK_GUARD_TEST_VALUE 0xA2A2
|
||||||
|
#define STACK_GUARD_MARGIN 32
|
||||||
|
|
||||||
#define MAX_BED_TEMP_CALIBRATION 50
|
#define MAX_BED_TEMP_CALIBRATION 50
|
||||||
#define MAX_HOTEND_TEMP_CALIBRATION 50
|
#define MAX_HOTEND_TEMP_CALIBRATION 50
|
||||||
|
Loading…
Reference in New Issue
Block a user