diff --git a/.gitignore b/.gitignore index f08b12a7f3..f2cabed024 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ *.wsp *.ddc *.dds +*.su *~ .depend /.config diff --git a/Kconfig b/Kconfig index 768d46d03d..a66f5ac162 100644 --- a/Kconfig +++ b/Kconfig @@ -1945,6 +1945,13 @@ config STACK_CANARIES Enabling this option can result in a significant increase in footprint and an associated decrease in performance. +config STACK_USAGE + bool "Generate stack usage information" + help + Generate an extra file that specifies the maximum amount of stack used, + on a per-function basis. Please use https://github.com/HBehrens/puncover + or tools/showstack.sh to generate the more useful report. + config ARCH_HAVE_HEAPCHECK bool default n diff --git a/arch/arm/src/common/Toolchain.defs b/arch/arm/src/common/Toolchain.defs index 4f2dedb4fa..019ea12e50 100644 --- a/arch/arm/src/common/Toolchain.defs +++ b/arch/arm/src/common/Toolchain.defs @@ -54,6 +54,10 @@ ifeq ($(CONFIG_STACK_CANARIES),y) ARCHOPTIMIZATION += -fstack-protector-all endif +ifeq ($(CONFIG_STACK_USAGE),y) + ARCHOPTIMIZATION += -fstack-usage +endif + ifeq ($(CONFIG_ARCH_COVERAGE_ALL),y) ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage endif diff --git a/arch/risc-v/src/common/Toolchain.defs b/arch/risc-v/src/common/Toolchain.defs index de253c1b64..4f219a096d 100644 --- a/arch/risc-v/src/common/Toolchain.defs +++ b/arch/risc-v/src/common/Toolchain.defs @@ -63,6 +63,10 @@ ifeq ($(CONFIG_STACK_CANARIES),y) ARCHOPTIMIZATION += -fstack-protector-all endif +ifeq ($(CONFIG_STACK_USAGE),y) + ARCHOPTIMIZATION += -fstack-usage +endif + ifeq ($(CONFIG_ARCH_COVERAGE_ALL),y) ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage endif diff --git a/arch/xtensa/src/lx6/Toolchain.defs b/arch/xtensa/src/lx6/Toolchain.defs index 3a58e527b7..609c69c9ec 100644 --- a/arch/xtensa/src/lx6/Toolchain.defs +++ b/arch/xtensa/src/lx6/Toolchain.defs @@ -75,6 +75,10 @@ ifeq ($(CONFIG_STACK_CANARIES),y) ARCHOPTIMIZATION += -fstack-protector-all endif +ifeq ($(CONFIG_STACK_USAGE),y) + ARCHOPTIMIZATION += -fstack-usage +endif + ifeq ($(CONFIG_ARCH_COVERAGE_ALL),y) ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage endif diff --git a/arch/xtensa/src/lx7/Toolchain.defs b/arch/xtensa/src/lx7/Toolchain.defs index fe46f33442..cb1ebc1445 100644 --- a/arch/xtensa/src/lx7/Toolchain.defs +++ b/arch/xtensa/src/lx7/Toolchain.defs @@ -75,6 +75,10 @@ ifeq ($(CONFIG_STACK_CANARIES),y) ARCHOPTIMIZATION += -fstack-protector-all endif +ifeq ($(CONFIG_STACK_USAGE),y) + ARCHOPTIMIZATION += -fstack-usage +endif + ifeq ($(CONFIG_ARCH_COVERAGE_ALL),y) ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage endif diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs index a13ec5d738..456f02f6d7 100644 --- a/boards/sim/sim/sim/scripts/Make.defs +++ b/boards/sim/sim/sim/scripts/Make.defs @@ -67,6 +67,10 @@ ifeq ($(CONFIG_STACK_CANARIES),y) ARCHOPTIMIZATION += -fstack-protector-all endif +ifeq ($(CONFIG_STACK_USAGE),y) + ARCHOPTIMIZATION += -fstack-usage +endif + ifeq ($(CONFIG_ARCH_COVERAGE_ALL),y) ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage endif