mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 01:21:26 +08:00
libs: add gprof arm64 support
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
@@ -88,6 +88,10 @@ ifeq ($(CONFIG_ARCH_INSTRUMENT_ALL),y)
|
|||||||
ARCHOPTIMIZATION += -finstrument-functions
|
ARCHOPTIMIZATION += -finstrument-functions
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_SCHED_GPROF_ALL),y)
|
||||||
|
ARCHOPTIMIZATION += -pg
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_ARCH_FPU),y)
|
ifeq ($(CONFIG_ARCH_FPU),y)
|
||||||
ARCHCXXFLAGS += -D_LDBL_EQ_DBL
|
ARCHCXXFLAGS += -D_LDBL_EQ_DBL
|
||||||
ARCHCFLAGS += -D_LDBL_EQ_DBL
|
ARCHCFLAGS += -D_LDBL_EQ_DBL
|
||||||
|
|||||||
@@ -135,6 +135,10 @@ if(CONFIG_ARCH_INSTRUMENT_ALL)
|
|||||||
add_compile_options(-finstrument-functions)
|
add_compile_options(-finstrument-functions)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(CONFIG_SCHED_GPROF_ALL)
|
||||||
|
add_compile_options(-pg)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(CONFIG_ARCH_FPU)
|
if(CONFIG_ARCH_FPU)
|
||||||
add_compile_options(-D_LDBL_EQ_DBL)
|
add_compile_options(-D_LDBL_EQ_DBL)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -21,6 +21,13 @@
|
|||||||
#ifndef __INCLUDE_SYS_GMON_H
|
#ifndef __INCLUDE_SYS_GMON_H
|
||||||
#define __INCLUDE_SYS_GMON_H
|
#define __INCLUDE_SYS_GMON_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/compiler.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -46,6 +53,9 @@ void monstartup(unsigned long lowpc, unsigned long highpc);
|
|||||||
|
|
||||||
void _mcleanup(void);
|
void _mcleanup(void);
|
||||||
|
|
||||||
|
noinstrument_function
|
||||||
|
void mcount_internal(uintptr_t frompc, uintptr_t selfpc);
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* libs/libc/machine/arm64/gnu/mcount.c
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <sys/gmon.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static inline noinstrument_function void *strip_pac(void *p)
|
||||||
|
{
|
||||||
|
register void *ra asm ("x30") = (p);
|
||||||
|
asm ("hint 7 // xpaclri" : "+r"(ra));
|
||||||
|
return ra;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: _mcount
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This is the ARM64 mcount function. It is called by the profiling
|
||||||
|
* logic to record the call.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* frompc - The address of the calling instruction
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
noinstrument_function
|
||||||
|
void _mcount(void *frompc)
|
||||||
|
{
|
||||||
|
mcount_internal((uintptr_t)strip_pac(frompc),
|
||||||
|
(uintptr_t)return_address(0));
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user