arch/x86_64: Add gprof

add gprof tool

Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
This commit is contained in:
liwenxiang1
2025-01-07 15:59:56 +08:00
committed by Xiang Xiao
parent b1373857b7
commit 2645e06c86
4 changed files with 80 additions and 0 deletions
+4
View File
@@ -77,6 +77,10 @@ ifeq ($(CONFIG_ARCH_INSTRUMENT_ALL),y)
ARCHOPTIMIZATION += -finstrument-functions
endif
ifeq ($(CONFIG_PROFILE_ALL),y)
ARCHOPTIMIZATION += -pg
endif
ARCHCFLAGS += -fno-common -Wno-attributes
ARCHCXXFLAGS += -fno-common -Wno-attributes -nostdinc++
+4
View File
@@ -78,4 +78,8 @@ if(CONFIG_X86_64_STRNCMP)
list(APPEND SRCS arch_strncmp.S)
endif()
if(CONFIG_PROFILE_MINI)
list(APPEND SRCS gnu/mcount.S)
endif()
target_sources(c PRIVATE ${SRCS})
+9
View File
@@ -76,5 +76,14 @@ ifeq ($(CONFIG_X86_64_STRNCMP),y)
ASRCS += arch_strncmp.S
endif
ifeq ($(CONFIG_PROFILE_MINI),y)
ASRCS += mcount.S
endif
ifeq ($(CONFIG_ARCH_TOOLCHAIN_GNU),y)
DEPPATH += --dep-path machine/x86_64/gnu
VPATH += :machine/x86_64/gnu
endif
DEPPATH += --dep-path machine/x86_64
VPATH += :machine/x86_64
+63
View File
@@ -0,0 +1,63 @@
/****************************************************************************
* libs/libc/machine/x86_64/gnu/mcount.S
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
.globl mcount
.type mcount, @function
mcount:
/* Allocate space for 7 registers */
subq $56, %rsp
movq %rax, (%rsp)
movq %rcx, 8(%rsp)
movq %rdx, 16(%rsp)
movq %rsi, 24(%rsp)
movq %rdi, 32(%rsp)
movq %r8, 40(%rsp)
movq %r9, 48(%rsp)
movq 56(%rsp),%rsi
/* Get frompc via the fp */
movq 8(%rbp), %rdi
/* Jump to mcount_internal */
call mcount_internal
/* Pop the saved registers. Please note that `mcount' has no
return value.
*/
movq 48(%rsp),%r9
movq 40(%rsp),%r8
movq 32(%rsp),%rdi
movq 24(%rsp),%rsi
movq 16(%rsp),%rdx
movq 8(%rsp), %rcx
movq (%rsp), %rax
addq $56, %rsp
ret