forked from nuttx/nuttx-update
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)
|
add_compile_options(-fprofile-generate -ftest-coverage)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_SCHED_GPROF_ALL)
|
if(CONFIG_PROFILE_ALL)
|
||||||
add_compile_options(-pg)
|
add_compile_options(-pg)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ if(CONFIG_SCHED_GCOV_ALL)
|
||||||
add_compile_options(-fprofile-generate -ftest-coverage)
|
add_compile_options(-fprofile-generate -ftest-coverage)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_SCHED_GPROF_ALL)
|
if(CONFIG_PROFILE_ALL)
|
||||||
add_compile_options(-pg)
|
add_compile_options(-pg)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ if(CONFIG_SCHED_GCOV_ALL)
|
||||||
add_compile_options(-fprofile-generate -ftest-coverage)
|
add_compile_options(-fprofile-generate -ftest-coverage)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_SCHED_GPROF_ALL)
|
if(CONFIG_PROFILE_ALL)
|
||||||
add_compile_options(-pg)
|
add_compile_options(-pg)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ if(CONFIG_ARCH_INSTRUMENT_ALL)
|
||||||
add_compile_options(-finstrument-functions)
|
add_compile_options(-finstrument-functions)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_SCHED_GPROF_ALL)
|
if(CONFIG_PROFILE_ALL)
|
||||||
add_compile_options(-pg)
|
add_compile_options(-pg)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ if(CONFIG_SCHED_GCOV_ALL)
|
||||||
add_compile_options(-fprofile-generate -ftest-coverage)
|
add_compile_options(-fprofile-generate -ftest-coverage)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_SCHED_GPROF_ALL)
|
if(CONFIG_PROFILE_ALL)
|
||||||
add_compile_options(-pg)
|
add_compile_options(-pg)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ ifneq ($(CONFIG_STACK_USAGE_WARNING),0)
|
||||||
ARCHOPTIMIZATION += -Wstack-usage=$(CONFIG_STACK_USAGE_WARNING)
|
ARCHOPTIMIZATION += -Wstack-usage=$(CONFIG_STACK_USAGE_WARNING)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_SCHED_GPROF_ALL),y)
|
ifeq ($(CONFIG_PROFILE_ALL),y)
|
||||||
ARCHOPTIMIZATION += -pg
|
ARCHOPTIMIZATION += -pg
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ ifeq ($(CONFIG_ARCH_INSTRUMENT_ALL),y)
|
||||||
ARCHOPTIMIZATION += -finstrument-functions
|
ARCHOPTIMIZATION += -finstrument-functions
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_SCHED_GPROF_ALL),y)
|
ifeq ($(CONFIG_PROFILE_ALL),y)
|
||||||
ARCHOPTIMIZATION += -pg
|
ARCHOPTIMIZATION += -pg
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ if(CONFIG_ARCH_INSTRUMENT_ALL)
|
||||||
add_compile_options(-finstrument-functions)
|
add_compile_options(-finstrument-functions)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_SCHED_GPROF_ALL)
|
if(CONFIG_PROFILE_ALL)
|
||||||
add_compile_options(-pg)
|
add_compile_options(-pg)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -90,9 +90,9 @@ config SIM_UBSAN_DUMMY
|
||||||
---help---
|
---help---
|
||||||
Keep SIM_UBSAN compile time but disable runtime actions.
|
Keep SIM_UBSAN compile time but disable runtime actions.
|
||||||
|
|
||||||
config SIM_GPROF
|
config SIM_PROFILE
|
||||||
bool "Enable gprof"
|
bool "Enable gprof"
|
||||||
depends on !SCHED_GPROF
|
depends on PROFILE_NONE
|
||||||
default n
|
default n
|
||||||
---help---
|
---help---
|
||||||
Enable support gprof profiling tool.
|
Enable support gprof profiling tool.
|
||||||
|
|
|
@ -144,7 +144,7 @@ ifeq ($(CONFIG_SCHED_GCOV),y)
|
||||||
STDLIBS += -lgcov
|
STDLIBS += -lgcov
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_SIM_GPROF),y)
|
ifneq ($(CONFIG_SIM_PROFILE)$(CONFIG_PROFILE_ALL),)
|
||||||
HOSTCFLAGS += -pg
|
HOSTCFLAGS += -pg
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ if(CONFIG_SCHED_GCOV_ALL)
|
||||||
add_compile_options(-fprofile-generate -ftest-coverage)
|
add_compile_options(-fprofile-generate -ftest-coverage)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_SCHED_GPROF_ALL OR CONFIG_SIM_GPROF)
|
if(CONFIG_PROFILE_ALL OR CONFIG_SIM_PROFILE)
|
||||||
add_compile_options(-pg)
|
add_compile_options(-pg)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ ifeq ($(CONFIG_SCHED_GCOV_ALL),y)
|
||||||
ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage
|
ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(CONFIG_SCHED_GPROF_ALL)$(CONFIG_SIM_GPROF),)
|
ifneq ($(CONFIG_PROFILE_ALL)$(CONFIG_SIM_PROFILE),)
|
||||||
ARCHOPTIMIZATION += -pg
|
ARCHOPTIMIZATION += -pg
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,39 @@ config COVERAGE_COMPILER_RT
|
||||||
select LIB_COMPILER_RT
|
select LIB_COMPILER_RT
|
||||||
default n
|
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
|
config LIB_COMPILER_RT_VERSION
|
||||||
string "Select LLVM Compiler-rt version"
|
string "Select LLVM Compiler-rt version"
|
||||||
depends on LIB_COMPILER_RT
|
depends on LIB_COMPILER_RT
|
||||||
|
|
|
@ -30,6 +30,8 @@ ifeq ($(CONFIG_LIB_COMPILER_RT),y)
|
||||||
include compiler-rt/Make.defs
|
include compiler-rt/Make.defs
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
include libgcc/Make.defs
|
||||||
|
|
||||||
AOBJS = $(addprefix $(BINDIR)$(DELIM), $(ASRCS:.S=$(OBJEXT)))
|
AOBJS = $(addprefix $(BINDIR)$(DELIM), $(ASRCS:.S=$(OBJEXT)))
|
||||||
COBJS = $(addprefix $(BINDIR)$(DELIM), $(CSRCS:.c=$(OBJEXT)))
|
COBJS = $(addprefix $(BINDIR)$(DELIM), $(CSRCS:.c=$(OBJEXT)))
|
||||||
CXXOBJS = $(addprefix $(BINDIR)$(DELIM), $(CXXSRCS:.cxx=$(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
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
|
@ -62,7 +62,7 @@ if(CONFIG_ARCH_SETJMP_H)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_SCHED_GPROF)
|
if(CONFIG_PROFILE_MINI)
|
||||||
list(APPEND SRCS gnu/mcount.S)
|
list(APPEND SRCS gnu/mcount.S)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ ASRCS += arch_setjmp.S
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_SCHED_GPROF),y)
|
ifeq ($(CONFIG_PROFILE_MINI),y)
|
||||||
ASRCS += mcount.S
|
ASRCS += mcount.S
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -1368,29 +1368,6 @@ config SCHED_GCOV_ALL
|
||||||
Enable gcov profiling for all code, it will instrument
|
Enable gcov profiling for all code, it will instrument
|
||||||
all code, which will cause a large performance penalty for the code.
|
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
|
endmenu
|
||||||
|
|
||||||
menu "Files and I/O"
|
menu "Files and I/O"
|
||||||
|
|
|
@ -26,8 +26,4 @@ if(NOT "${CONFIG_SCHED_STACK_RECORD}" STREQUAL "0")
|
||||||
list(APPEND SRCS stack_monitor.c)
|
list(APPEND SRCS stack_monitor.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_SCHED_GPROF)
|
|
||||||
list(APPEND SRCS profile_monitor.c)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_sources(sched PRIVATE ${SRCS})
|
target_sources(sched PRIVATE ${SRCS})
|
||||||
|
|
|
@ -26,10 +26,6 @@ ifneq ($(CONFIG_SCHED_STACK_RECORD),0)
|
||||||
CSRCS += stack_monitor.c
|
CSRCS += stack_monitor.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_SCHED_GPROF),y)
|
|
||||||
CSRCS += profile_monitor.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Include instrument build support
|
# Include instrument build support
|
||||||
|
|
||||||
DEPPATH += --dep-path instrument
|
DEPPATH += --dep-path instrument
|
||||||
|
|
Loading…
Reference in a new issue