Skip to content
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

gprof: Move gprof to libc #14683

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arch/arm/src/cmake/armclang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ if(CONFIG_SCHED_GCOV)
add_compile_options(-fprofile-generate -ftest-coverage)
endif()

if(CONFIG_SCHED_GPROF_ALL)
if(CONFIG_LIB_GPROF_ALL)
add_compile_options(-pg)
endif()

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/cmake/clang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ if(CONFIG_SCHED_GCOV_ALL)
add_compile_options(-fprofile-generate -ftest-coverage)
endif()

if(CONFIG_SCHED_GPROF_ALL)
if(CONFIG_LIB_GPROF_ALL)
add_compile_options(-pg)
endif()

Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/cmake/gcc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ if(CONFIG_SCHED_GCOV_ALL)
add_compile_options(-fprofile-generate -ftest-coverage)
endif()

if(CONFIG_SCHED_GPROF_ALL)
if(CONFIG_LIB_GPROF_ALL)
add_compile_options(-pg)
endif()

Expand Down Expand Up @@ -165,7 +165,7 @@ if(CONFIG_ARCH_INSTRUMENT_ALL)
add_compile_options(-finstrument-functions)
endif()

if(CONFIG_SCHED_GPROF_ALL)
if(CONFIG_LIB_GPROF_ALL)
add_compile_options(-pg)
endif()

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/cmake/ghs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ if(CONFIG_SCHED_GCOV_ALL)
add_compile_options(-fprofile-generate -ftest-coverage)
endif()

if(CONFIG_SCHED_GPROF_ALL)
if(CONFIG_LIB_GPROF_ALL)
add_compile_options(-pg)
endif()

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/common/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ ifneq ($(CONFIG_STACK_USAGE_WARNING),0)
ARCHOPTIMIZATION += -Wstack-usage=$(CONFIG_STACK_USAGE_WARNING)
endif

ifeq ($(CONFIG_SCHED_GPROF_ALL),y)
ifeq ($(CONFIG_LIB_GPROF_ALL),y)
ARCHOPTIMIZATION += -pg
endif

Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/src/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ ifeq ($(CONFIG_ARCH_INSTRUMENT_ALL),y)
ARCHOPTIMIZATION += -finstrument-functions
endif

ifeq ($(CONFIG_SCHED_GPROF_ALL),y)
ifeq ($(CONFIG_LIB_GPROF_ALL),y)
ARCHOPTIMIZATION += -pg
endif

Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/src/cmake/Toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ if(CONFIG_ARCH_INSTRUMENT_ALL)
add_compile_options(-finstrument-functions)
endif()

if(CONFIG_SCHED_GPROF_ALL)
if(CONFIG_LIB_GPROF_ALL)
add_compile_options(-pg)
endif()

Expand Down
2 changes: 1 addition & 1 deletion arch/sim/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ config SIM_UBSAN_DUMMY

config SIM_GPROF
bool "Enable gprof"
depends on !SCHED_GPROF
depends on !LIB_GPROF
default n
---help---
Enable support gprof profiling tool.
Expand Down
2 changes: 1 addition & 1 deletion arch/sim/src/cmake/Toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ if(CONFIG_SCHED_GCOV_ALL)
add_compile_options(-fprofile-generate -ftest-coverage)
endif()

if(CONFIG_SCHED_GPROF_ALL OR CONFIG_SIM_GPROF)
if(CONFIG_LIB_GPROF_ALL OR CONFIG_SIM_GPROF)
add_compile_options(-pg)
endif()

Expand Down
2 changes: 1 addition & 1 deletion boards/sim/sim/sim/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ ifeq ($(CONFIG_SCHED_GCOV_ALL),y)
ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage
endif

ifneq ($(CONFIG_SCHED_GPROF_ALL)$(CONFIG_SIM_GPROF),)
ifneq ($(CONFIG_LIB_GPROF_ALL)$(CONFIG_SIM_GPROF),)
ARCHOPTIMIZATION += -pg
endif

Expand Down
1 change: 1 addition & 0 deletions libs/libc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ source "libs/libc/pthread/Kconfig"
source "libs/libc/dlfcn/Kconfig"
source "libs/libc/modlib/Kconfig"
source "libs/libc/gdbstub/Kconfig"
source "libs/libc/gprof/Kconfig"
source "libs/libc/grp/Kconfig"
source "libs/libc/pwd/Kconfig"
source "libs/libc/locale/Kconfig"
Expand Down
1 change: 1 addition & 0 deletions libs/libc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ include fixedmath/Make.defs
include gdbstub/Make.defs
include grp/Make.defs
include gnssutils/Make.defs
include gprof/Make.defs
include hex2bin/Make.defs
include inttypes/Make.defs
include libgen/Make.defs
Expand Down
25 changes: 25 additions & 0 deletions libs/libc/gprof/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# ##############################################################################
# libs/libc/gprof/CMakeLists.txt
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################

if(CONFIG_LIB_GPROF)
target_sources(c PRIVATE profile_monitor.c)
endif()
29 changes: 29 additions & 0 deletions libs/libc/gprof/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

config LIB_GPROF
bool "Enable gprof profiling"
default n
---help---
Enable gprof profiling support. This will cause the compiler to
generate additional code to support profiling. This will also
cause the linker to include the gmon.out file in the final
executable.
Add the "-pg" parameter to the Makefile when compiling to obtain
the function call graph of the specified module.

if LIB_GPROF

config LIB_GPROF_ALL
bool "Enable gprof call graph for all modules"
depends on FRAME_POINTER
default n
---help---
Enable gprof profiling for all code, it will instrument
all code, which will cause a large performance penalty for the code.
You can add the '-pg' parameter to the specified module in the
makefile to only analyze the content of the module.

endif # LIB_GPROF
34 changes: 34 additions & 0 deletions libs/libc/gprof/Make.defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
############################################################################
# libs/libc/gprof/Make.defs
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################

ifeq ($(CONFIG_LIB_GPROF),y)

# Add the internal C files to the build

CSRCS += profile_monitor.c

# Add the userfs directory to the build

DEPPATH += --dep-path gprof
VPATH += :gprof

endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* sched/instrument/profile_monitor.c
* libs/libc/gprof/profile_monitor.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand Down
2 changes: 1 addition & 1 deletion libs/libc/machine/arm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ if(CONFIG_ARCH_SETJMP_H)
endif()
endif()

if(CONFIG_SCHED_GPROF)
if(CONFIG_LIB_GPROF)
list(APPEND SRCS gnu/mcount.S)
endif()

Expand Down
2 changes: 1 addition & 1 deletion libs/libc/machine/arm/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ASRCS += arch_setjmp.S
endif
endif

ifeq ($(CONFIG_SCHED_GPROF),y)
ifeq ($(CONFIG_LIB_GPROF),y)
ASRCS += mcount.S
endif

Expand Down
21 changes: 0 additions & 21 deletions sched/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1363,27 +1363,6 @@ config SCHED_GCOV_ALL
Enable gcov profiling for all code, it will instrument
all code, which will cause a large performance penalty for the code.

config SCHED_GPROF
bool "Enable gprof profiling"
default n
---help---
Enable gprof profiling support. This will cause the compiler to
generate additional code to support profiling. This will also
cause the linker to include the gmon.out file in the final
executable.
Add the "-pg" parameter to the Makefile when compiling to obtain
the function call graph of the specified module.

config SCHED_GPROF_ALL
bool "Enable gprof call graph for all modules"
depends on SCHED_GPROF
default n
---help---
Enable gprof profiling for all code, it will instrument
all code, which will cause a large performance penalty for the code.
You can add the '-pg' parameter to the specified module in the
makefile to only analyze the content of the module.

endmenu

menu "Files and I/O"
Expand Down
4 changes: 0 additions & 4 deletions sched/instrument/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,4 @@ if(NOT "${CONFIG_SCHED_STACK_RECORD}" STREQUAL "0")
list(APPEND SRCS stack_monitor.c)
endif()

if(CONFIG_SCHED_GPROF)
list(APPEND SRCS profile_monitor.c)
endif()

target_sources(sched PRIVATE ${SRCS})
4 changes: 0 additions & 4 deletions sched/instrument/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ ifneq ($(CONFIG_SCHED_STACK_RECORD),0)
CSRCS += stack_monitor.c
endif

ifeq ($(CONFIG_SCHED_GPROF),y)
CSRCS += profile_monitor.c
endif

# Include instrument build support

DEPPATH += --dep-path instrument
Expand Down
Loading