-
Notifications
You must be signed in to change notification settings - Fork 547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement stack usage analysis of tasks #525
Comments
|
I have added compile options -fstack-usage -fdump-rtl-expand to the SAME5x builds of all relevant projects. We can do this for the other configurations when the stack usage tool is working and we know that these options are needed by it. |
ToolsavstackThe columns of the output are:
stacklyzeinstrument functionRuntime: before and after each function call check the current stack usage. Compile the code with -finstrument-functions. Then define two functions in your code that roughly should get the current stack usage and operate on them: static unsigned long long max_stack_usage = 0;
void __cyg_profile_func_enter(void * this, void * call) __attribute__((no_instrument_function)) {
// get current stack usage using some hardware facility or intrisic function
// like __get_SP() on ARM with CMSIS
unsigned cur_stack_usage = __GET_CURRENT_STACK_POINTER() - __GET_BEGINNING_OF_STACK();
// use debugger to output current stack pointer
// for example semihosting on ARM
__DEBUGGER_TRANSFER_STACK_POINTER(cur_stack_usage);
// or you could store the max somewhere
// then just run the program
if (max_stack_usage < cur_stack_usage) {
max_stack_usage = max_stack_usage;
}
// you could also manually inspect with debugger
unsigned long long somelimit = 0x2000;
if (cur_stack_usage > somelimit) {
__BREAKPOINT();
}
}
void __cyg_profile_func_exit(void * this, void * call) __attribute__((no_instrument_function)) {
// well, nothing
} |
stacklyze doesn't seem to work very well with c++. Because of mangled names? |
|
following files are not created by build system but are needed. SAME5x_CAN_SDHC_USB_RTOS/src/SAME5x_C21/SAME5x/Vectors.su missing
SAME5x_CAN_SDHC_USB_RTOS/src/SAME5x_C21/SAME5x/hal/src/hal_atomic.su missing
SAME5x_CAN_SDHC_USB_RTOS/src/SAME5x_C21/SAME5x/hal/src/hal_flash.su missing
SAME5x_CAN_SDHC_USB_RTOS/src/SAME5x_C21/SAME5x/hal/src/hal_gpio.su missing
SAME5x_CAN_SDHC_USB_RTOS/src/SAME5x_C21/SAME5x/hal/src/hal_mac_async.su missing
SAME5x_CAN_SDHC_USB_RTOS/src/SAME5x_C21/SAME5x/hal/src/hal_rand_sync.su missing
SAME5x_CAN_SDHC_USB_RTOS/src/SAME5x_C21/SAME5x/hal/src/hal_sleep.su missing
SAME5x_CAN_SDHC_USB_RTOS/src/SAME5x_C21/SAME5x/hal/src/hal_usb_device.su missing
SAME5x_CAN_SDHC_USB_RTOS/src/SAME5x_C21/SAME5x/hal/src/hal_wdt.su missing
SAME5x_CAN_SDHC_USB_RTOS/src/SAME5x_C21/SAME5x/hal/utils/src/utils_assert.su missing
SAME5x_CAN_SDHC_USB_RTOS/src/SAME5x_C21/SAME5x/hal/utils/src/utils_event.su missing
SAME5x_CAN_SDHC_USB_RTOS/src/SAME5x_C21/SAME5x/hal/utils/src/utils_list.su missing
SAME5x_CAN_SDHC_USB_RTOS/src/SAME5x_C21/SAME5x/hpl/core/hpl_core_m4.su missing
SAME5x_CAN_SDHC_USB_RTOS/src/SAME5x_C21/SAME5x/hpl/gmac/hpl_gmac.su missing
SAME5x_CAN_SDHC_USB_RTOS/src/SAME5x_C21/SAME5x/hpl/nvmctrl/hpl_nvmctrl.su missing
SAME5x_CAN_SDHC_USB_RTOS/src/SAME5x_C21/SAME5x/hpl/usb/hpl_usb.su missing
SAME5x_CAN_SDHC_USB_RTOS/src/SAME5x_C21/SAME5x/hpl/wdt/hpl_wdt.su missing
SAME5x_CAN_SDHC_USB_RTOS/src/SAME5x_C21/SAME5x/usb/class/cdc/device/cdcdf_acm.su missing
SAME5x_CAN_SDHC_USB_RTOS/src/SAME5x_C21/SAME5x/usb/device/usbdc.su missing
SAME5x_CAN_SDHC_USB_RTOS/src/SAME5x_C21/SAME5x/usb/usb_protocol.su missing |
avstack
|
-Wstack-usage Warning Another useful compiler option is -Wstack-usage. With this option the compiler will issue a warning whenever the stack usage exceeds a given limit. |
interesting article about stack usage. https://mcuoneclipse.com/2015/08/21/gnu-static-stack-usage-analysis/ |
The text was updated successfully, but these errors were encountered: