mirror of
https://github.com/apache/nuttx.git
synced 2025-01-12 22:08:35 +08:00
gprof: move gprof function from sched to libbuiltin/libgcc
1. Enable interrupt gprof please config CONFIG_PROFILE_MINI 2. Enable instuction gprof please add compile opt "-pg" or config CONFIG_PROFILE_ALL Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
This commit is contained in:
parent
ac39d087f5
commit
bf93c7840a
21 changed files with 103 additions and 47 deletions
|
@ -120,7 +120,7 @@ if(CONFIG_SCHED_GCOV)
|
|||
add_compile_options(-fprofile-generate -ftest-coverage)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SCHED_GPROF_ALL)
|
||||
if(CONFIG_PROFILE_ALL)
|
||||
add_compile_options(-pg)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ if(CONFIG_SCHED_GCOV_ALL)
|
|||
add_compile_options(-fprofile-generate -ftest-coverage)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SCHED_GPROF_ALL)
|
||||
if(CONFIG_PROFILE_ALL)
|
||||
add_compile_options(-pg)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ if(CONFIG_SCHED_GCOV_ALL)
|
|||
add_compile_options(-fprofile-generate -ftest-coverage)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SCHED_GPROF_ALL)
|
||||
if(CONFIG_PROFILE_ALL)
|
||||
add_compile_options(-pg)
|
||||
endif()
|
||||
|
||||
|
@ -165,7 +165,7 @@ if(CONFIG_ARCH_INSTRUMENT_ALL)
|
|||
add_compile_options(-finstrument-functions)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SCHED_GPROF_ALL)
|
||||
if(CONFIG_PROFILE_ALL)
|
||||
add_compile_options(-pg)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ if(CONFIG_SCHED_GCOV_ALL)
|
|||
add_compile_options(-fprofile-generate -ftest-coverage)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SCHED_GPROF_ALL)
|
||||
if(CONFIG_PROFILE_ALL)
|
||||
add_compile_options(-pg)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -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_PROFILE_ALL),y)
|
||||
ARCHOPTIMIZATION += -pg
|
||||
endif
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ ifeq ($(CONFIG_ARCH_INSTRUMENT_ALL),y)
|
|||
ARCHOPTIMIZATION += -finstrument-functions
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SCHED_GPROF_ALL),y)
|
||||
ifeq ($(CONFIG_PROFILE_ALL),y)
|
||||
ARCHOPTIMIZATION += -pg
|
||||
endif
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ if(CONFIG_ARCH_INSTRUMENT_ALL)
|
|||
add_compile_options(-finstrument-functions)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SCHED_GPROF_ALL)
|
||||
if(CONFIG_PROFILE_ALL)
|
||||
add_compile_options(-pg)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -90,9 +90,9 @@ config SIM_UBSAN_DUMMY
|
|||
---help---
|
||||
Keep SIM_UBSAN compile time but disable runtime actions.
|
||||
|
||||
config SIM_GPROF
|
||||
config SIM_PROFILE
|
||||
bool "Enable gprof"
|
||||
depends on !SCHED_GPROF
|
||||
depends on PROFILE_NONE
|
||||
default n
|
||||
---help---
|
||||
Enable support gprof profiling tool.
|
||||
|
|
|
@ -144,7 +144,7 @@ ifeq ($(CONFIG_SCHED_GCOV),y)
|
|||
STDLIBS += -lgcov
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SIM_GPROF),y)
|
||||
ifneq ($(CONFIG_SIM_PROFILE)$(CONFIG_PROFILE_ALL),)
|
||||
HOSTCFLAGS += -pg
|
||||
endif
|
||||
|
||||
|
|
|
@ -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_PROFILE_ALL OR CONFIG_SIM_PROFILE)
|
||||
add_compile_options(-pg)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ ifeq ($(CONFIG_SCHED_GCOV_ALL),y)
|
|||
ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_SCHED_GPROF_ALL)$(CONFIG_SIM_GPROF),)
|
||||
ifneq ($(CONFIG_PROFILE_ALL)$(CONFIG_SIM_PROFILE),)
|
||||
ARCHOPTIMIZATION += -pg
|
||||
endif
|
||||
|
||||
|
|
|
@ -35,6 +35,39 @@ config COVERAGE_COMPILER_RT
|
|||
select LIB_COMPILER_RT
|
||||
default n
|
||||
|
||||
choice
|
||||
prompt "Builtin profile support"
|
||||
default PROFILE_NONE
|
||||
---help---
|
||||
Select the profile library
|
||||
|
||||
config PROFILE_MINI
|
||||
bool "Enable mini gprof profiling"
|
||||
select LIB_BUILTIN
|
||||
---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 you do this,
|
||||
please enable "CONFIG_FRAME_POINTER"
|
||||
|
||||
config PROFILE_NONE
|
||||
bool "None profile support"
|
||||
|
||||
endchoice
|
||||
|
||||
config PROFILE_ALL
|
||||
bool "Enable gprof call graph for all modules"
|
||||
depends on FRAME_POINTER && !PROFILE_NONE
|
||||
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.
|
||||
|
||||
config LIB_COMPILER_RT_VERSION
|
||||
string "Select LLVM Compiler-rt version"
|
||||
depends on LIB_COMPILER_RT
|
||||
|
|
|
@ -30,6 +30,8 @@ ifeq ($(CONFIG_LIB_COMPILER_RT),y)
|
|||
include compiler-rt/Make.defs
|
||||
endif
|
||||
|
||||
include libgcc/Make.defs
|
||||
|
||||
AOBJS = $(addprefix $(BINDIR)$(DELIM), $(ASRCS:.S=$(OBJEXT)))
|
||||
COBJS = $(addprefix $(BINDIR)$(DELIM), $(CSRCS:.c=$(OBJEXT)))
|
||||
CXXOBJS = $(addprefix $(BINDIR)$(DELIM), $(CXXSRCS:.cxx=$(OBJEXT)))
|
||||
|
|
24
libs/libbuiltin/libgcc/CMakeLists.txt
Normal file
24
libs/libbuiltin/libgcc/CMakeLists.txt
Normal file
|
@ -0,0 +1,24 @@
|
|||
# ##############################################################################
|
||||
# libs/libbuiltin/libgcc/CMakeLists.txt
|
||||
#
|
||||
# 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_PROFILE_MINI)
|
||||
nuttx_add_system_library(libgprof)
|
||||
target_sources(libgprof PRIVATE profile.c)
|
||||
endif()
|
28
libs/libbuiltin/libgcc/Make.defs
Normal file
28
libs/libbuiltin/libgcc/Make.defs
Normal file
|
@ -0,0 +1,28 @@
|
|||
############################################################################
|
||||
# libs/libbuiltin/libgcc/Make.defs
|
||||
#
|
||||
# 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_PROFILE_MINI),y)
|
||||
|
||||
CSRCS += profile.c
|
||||
|
||||
DEPPATH += --dep-path libgcc
|
||||
VPATH += :libgcc
|
||||
|
||||
endif
|
|
@ -1,5 +1,5 @@
|
|||
/****************************************************************************
|
||||
* sched/instrument/profile_monitor.c
|
||||
* libs/libbuiltin/libgcc/profile.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
|
@ -62,7 +62,7 @@ if(CONFIG_ARCH_SETJMP_H)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
if(CONFIG_SCHED_GPROF)
|
||||
if(CONFIG_PROFILE_MINI)
|
||||
list(APPEND SRCS gnu/mcount.S)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ ASRCS += arch_setjmp.S
|
|||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SCHED_GPROF),y)
|
||||
ifeq ($(CONFIG_PROFILE_MINI),y)
|
||||
ASRCS += mcount.S
|
||||
endif
|
||||
|
||||
|
|
|
@ -1368,29 +1368,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. If you do this,
|
||||
please enable "CONFIG_FRAME_POINTER"
|
||||
|
||||
config SCHED_GPROF_ALL
|
||||
bool "Enable gprof call graph for all modules"
|
||||
depends on FRAME_POINTER
|
||||
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"
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue