diff --git a/arch/posix/CMakeLists.txt b/arch/posix/CMakeLists.txt index ddae0a787dc..4dfcb9a2824 100644 --- a/arch/posix/CMakeLists.txt +++ b/arch/posix/CMakeLists.txt @@ -24,6 +24,10 @@ zephyr_compile_options($) zephyr_include_directories(${BOARD_DIR}) +if (CONFIG_GPROF) + zephyr_compile_options($) + zephyr_link_libraries($) +endif() if (CONFIG_ASAN) zephyr_compile_options($) zephyr_link_libraries($) diff --git a/cmake/compiler/gcc/compiler_flags.cmake b/cmake/compiler/gcc/compiler_flags.cmake index df242be4240..7c3284eb47d 100644 --- a/cmake/compiler/gcc/compiler_flags.cmake +++ b/cmake/compiler/gcc/compiler_flags.cmake @@ -177,6 +177,8 @@ set_compiler_property(PROPERTY imacros -imacros) # GCC compiler flags for sanitizing. set_compiler_property(PROPERTY sanitize_address -fsanitize=address) +set_compiler_property(PROPERTY gprof -pg) + set_compiler_property(PROPERTY sanitize_undefined -fsanitize=undefined) # GCC compiler flag for turning off thread-safe initialization of local statics diff --git a/cmake/linker/ld/gcc/linker_flags.cmake b/cmake/linker/ld/gcc/linker_flags.cmake index bd5d1d25298..7a2ffdf4c0c 100644 --- a/cmake/linker/ld/gcc/linker_flags.cmake +++ b/cmake/linker/ld/gcc/linker_flags.cmake @@ -10,5 +10,6 @@ endif() # ld/gcc linker flags for sanitizing. check_set_linker_property(TARGET linker APPEND PROPERTY sanitize_address -lasan) check_set_linker_property(TARGET linker APPEND PROPERTY sanitize_address -fsanitize=address) - check_set_linker_property(TARGET linker APPEND PROPERTY sanitize_undefined -fsanitize=undefined) + +check_set_linker_property(TARGET linker APPEND PROPERTY gprof -pg) diff --git a/subsys/debug/Kconfig b/subsys/debug/Kconfig index 550c3a7eac4..b9cea2fb456 100644 --- a/subsys/debug/Kconfig +++ b/subsys/debug/Kconfig @@ -99,6 +99,13 @@ config DEBUG only disables optimization, more debugging variants can be selected from here to allow more debugging. +config GPROF + bool "Generate profiling information" + depends on ARCH_POSIX + help + Generate call graph profile data for the application that can be + analyzed with gprof + config ASAN bool "Build with address sanitizer" depends on ARCH_POSIX