diff --git a/Kconfig b/Kconfig index e0c25e23ed..4a79672630 100644 --- a/Kconfig +++ b/Kconfig @@ -1919,6 +1919,14 @@ config DEBUG_SYMBOLS ---help--- Build with debug symbols (needed for use with a debugger). +config FRAME_POINTER + bool "Compile the NuttX with frame pointers" + default n + ---help--- + If you say Y here the resulting NuttX image will be slightly + larger and slower, but it gives very useful debugging information + in case of bugs. + endmenu # Debug Options config ARCH_HAVE_CUSTOMOPT diff --git a/arch/arm/src/arm/Toolchain.defs b/arch/arm/src/arm/Toolchain.defs index 4d2bf17ef5..251a7b0bd4 100644 --- a/arch/arm/src/arm/Toolchain.defs +++ b/arch/arm/src/arm/Toolchain.defs @@ -67,6 +67,12 @@ else MAXOPTIMIZATION ?= -Os endif +ifeq ($(CONFIG_FRAME_POINTER),y) + MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls +else + MAXOPTIMIZATION += -fomit-frame-pointer +endif + # NuttX buildroot under Linux or Cygwin ifeq ($(CONFIG_ARM_TOOLCHAIN),BUILDROOT) diff --git a/arch/arm/src/armv6-m/Toolchain.defs b/arch/arm/src/armv6-m/Toolchain.defs index 4880564271..7cd8874a3b 100644 --- a/arch/arm/src/armv6-m/Toolchain.defs +++ b/arch/arm/src/armv6-m/Toolchain.defs @@ -61,6 +61,12 @@ else MAXOPTIMIZATION ?= -Os endif +ifeq ($(CONFIG_FRAME_POINTER),y) + MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls +else + MAXOPTIMIZATION += -fomit-frame-pointer +endif + # NuttX buildroot under Linux or Cygwin ifeq ($(CONFIG_ARMV6M_TOOLCHAIN),BUILDROOT) diff --git a/arch/arm/src/armv7-a/Toolchain.defs b/arch/arm/src/armv7-a/Toolchain.defs index ced1d0d10b..215d6469fc 100644 --- a/arch/arm/src/armv7-a/Toolchain.defs +++ b/arch/arm/src/armv7-a/Toolchain.defs @@ -79,6 +79,12 @@ else MAXOPTIMIZATION ?= -Os endif +ifeq ($(CONFIG_FRAME_POINTER),y) + MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls +else + MAXOPTIMIZATION += -fomit-frame-pointer +endif + ifeq ($(CONFIG_ENDIAN_BIG),y) TARGET_ARCH := armeb else diff --git a/arch/arm/src/armv7-m/Toolchain.defs b/arch/arm/src/armv7-m/Toolchain.defs index 58b52073df..b63e6dd279 100644 --- a/arch/arm/src/armv7-m/Toolchain.defs +++ b/arch/arm/src/armv7-m/Toolchain.defs @@ -75,6 +75,12 @@ else MAXOPTIMIZATION ?= -Os endif +ifeq ($(CONFIG_FRAME_POINTER),y) + MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls +else + MAXOPTIMIZATION += -fomit-frame-pointer +endif + # Parametrization for ARCHCPUFLAGS ifeq ($(CONFIG_ARCH_CORTEXM4),y) diff --git a/arch/arm/src/armv7-r/Toolchain.defs b/arch/arm/src/armv7-r/Toolchain.defs index 4af6d187fa..d0df68d58f 100644 --- a/arch/arm/src/armv7-r/Toolchain.defs +++ b/arch/arm/src/armv7-r/Toolchain.defs @@ -61,6 +61,12 @@ else MAXOPTIMIZATION ?= -Os endif +ifeq ($(CONFIG_FRAME_POINTER),y) + MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls +else + MAXOPTIMIZATION += -fomit-frame-pointer +endif + ifeq ($(CONFIG_ENDIAN_BIG),y) TARGET_ARCH := armeb else diff --git a/arch/arm/src/armv8-m/Toolchain.defs b/arch/arm/src/armv8-m/Toolchain.defs index aa0df4ff65..58df2f5509 100644 --- a/arch/arm/src/armv8-m/Toolchain.defs +++ b/arch/arm/src/armv8-m/Toolchain.defs @@ -75,6 +75,12 @@ else MAXOPTIMIZATION ?= -Os endif +ifeq ($(CONFIG_FRAME_POINTER),y) + MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls +else + MAXOPTIMIZATION += -fomit-frame-pointer +endif + # Parametrization for ARCHCPUFLAGS ifeq ($(CONFIG_ARCH_CORTEXM23),y) TOOLCHAIN_MTUNE := -mtune=cortex-m23 diff --git a/arch/arm/src/rtl8720c/Toolchain.defs b/arch/arm/src/rtl8720c/Toolchain.defs index 9be75a7644..0c8bba6169 100644 --- a/arch/arm/src/rtl8720c/Toolchain.defs +++ b/arch/arm/src/rtl8720c/Toolchain.defs @@ -43,7 +43,7 @@ ifeq ($(CONFIG_STACK_CANARIES),y) endif ifneq ($(CONFIG_DEBUG_NOOPT),y) - ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer + ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce ARCHOPTIMIZATION += -ffunction-sections -fdata-sections ifneq ($(CONFIG_ARMV8M_STACKCHECK),y) #ARCHOPTIMIZATION += -flto -fuse-linker-plugin diff --git a/arch/mips/src/mips32/Toolchain.defs b/arch/mips/src/mips32/Toolchain.defs index c148e572f0..5512d2bcc2 100644 --- a/arch/mips/src/mips32/Toolchain.defs +++ b/arch/mips/src/mips32/Toolchain.defs @@ -259,6 +259,12 @@ ifeq ($(CONFIG_MIPS32_TOOLCHAIN),PINGUINOW) LDSCRIPT = mips-elf-debug.ld endif +ifeq ($(CONFIG_FRAME_POINTER),y) + MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls +else + MAXOPTIMIZATION += -fomit-frame-pointer +endif + # Default toolchain CC = $(CROSSDEV)gcc diff --git a/arch/risc-v/src/rv32im/Toolchain.defs b/arch/risc-v/src/rv32im/Toolchain.defs index 9283a55f48..d3d628d524 100644 --- a/arch/risc-v/src/rv32im/Toolchain.defs +++ b/arch/risc-v/src/rv32im/Toolchain.defs @@ -53,6 +53,12 @@ else MAXOPTIMIZATION ?= -Os endif +ifeq ($(CONFIG_FRAME_POINTER),y) + MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls +else + MAXOPTIMIZATION += -fomit-frame-pointer +endif + # Generic GNU RVG toolchain ifeq ($(CONFIG_RISCV_TOOLCHAIN),GNU_RVG) diff --git a/arch/risc-v/src/rv64gc/Toolchain.defs b/arch/risc-v/src/rv64gc/Toolchain.defs index 07e659a103..4217ec3354 100644 --- a/arch/risc-v/src/rv64gc/Toolchain.defs +++ b/arch/risc-v/src/rv64gc/Toolchain.defs @@ -53,6 +53,12 @@ else MAXOPTIMIZATION ?= -Os endif +ifeq ($(CONFIG_FRAME_POINTER),y) + MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls +else + MAXOPTIMIZATION += -fomit-frame-pointer +endif + # Generic GNU RVG toolchain ifeq ($(CONFIG_RISCV_TOOLCHAIN),GNU_RVG) diff --git a/arch/sim/Kconfig b/arch/sim/Kconfig index f5d29e32d5..617a849112 100644 --- a/arch/sim/Kconfig +++ b/arch/sim/Kconfig @@ -61,7 +61,7 @@ config SIM_CYGWIN_DECORATED config SIM_ASAN bool "Address Sanitizer" default n - depends on MM_CUSTOMIZE_MANAGER + depends on MM_CUSTOMIZE_MANAGER && FRAME_POINTER ---help--- AddressSanitizer (ASan) is a fast compiler-based tool for detecting memory bugs in native code. @@ -69,6 +69,7 @@ config SIM_ASAN config SIM_UBSAN bool "Undefined Behaviour Sanitizer" default n + depends on FRAME_POINTER ---help--- Compile-time instrumentation is used to detect various undefined behaviours at runtime. diff --git a/arch/xtensa/src/lx6/Toolchain.defs b/arch/xtensa/src/lx6/Toolchain.defs index 0a99d7f749..d5e767aefb 100644 --- a/arch/xtensa/src/lx6/Toolchain.defs +++ b/arch/xtensa/src/lx6/Toolchain.defs @@ -49,6 +49,12 @@ else MAXOPTIMIZATION ?= -Os endif +ifeq ($(CONFIG_FRAME_POINTER),y) + MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls +else + MAXOPTIMIZATION += -fomit-frame-pointer +endif + # Default toolchain ifeq ($(CONFIG_XTENSA_TOOLCHAIN_XCC), y) CC = $(CROSSDEV)xcc diff --git a/arch/xtensa/src/lx7/Toolchain.defs b/arch/xtensa/src/lx7/Toolchain.defs index 1c39d64128..e36bf8ffa1 100644 --- a/arch/xtensa/src/lx7/Toolchain.defs +++ b/arch/xtensa/src/lx7/Toolchain.defs @@ -29,7 +29,6 @@ # reliable code generation. # - ifeq ($(CONFIG_XTENSA_TOOLCHAIN_XCC), y) CROSSDEV = xt- endif @@ -50,6 +49,12 @@ else MAXOPTIMIZATION := -Os endif +ifeq ($(CONFIG_FRAME_POINTER),y) + MAXOPTIMIZATION += -fno-omit-frame-pointer -fno-optimize-sibling-calls +else + MAXOPTIMIZATION += -fomit-frame-pointer +endif + # Default toolchain ifeq ($(CONFIG_XTENSA_TOOLCHAIN_XCC), y) CC = $(CROSSDEV)xcc