Make prof to work in a transparent way

This commit is contained in:
Francisco Javier Trujillo Mata
2024-07-14 11:27:09 +02:00
parent 8e122ce65b
commit ea9d5cf9cd
6 changed files with 22 additions and 29 deletions

View File

@@ -21,11 +21,12 @@ make -j $(getconf _NPROCESSORS_ONLN)
## Install pspsdk
make install
## gcc needs to include libcglue libpthreadglue libpsputility libpsprtc libpspnet_inet libpspnet_resolver libpspsdk libpspmodinfo libpspuser libpspkernel
## gcc needs to include libcglue libpthreadglue libpspprof libpsputility libpsprtc libpspnet_inet libpspnet_resolver libpspsdk libpspmodinfo libpspuser libpspkernel
## from pspsdk to be able to build executables, because they are part of the standard libraries
cd "$PSPDEV/psp/lib"
ln -sf "../sdk/lib/libcglue.a" "libcglue.a" || { exit 1; }
ln -sf "../sdk/lib/libpthreadglue.a" "libpthreadglue.a" || { exit 1; }
ln -sf "../sdk/lib/libpspprof.a" "libpspprof.a" || { exit 1; }
ln -sf "../sdk/lib/libpsputility.a" "libpsputility.a" || { exit 1; }
ln -sf "../sdk/lib/libpsprtc.a" "libpsprtc.a" || { exit 1; }
ln -sf "../sdk/lib/libpspnet_inet.a" "libpspnet_inet.a" || { exit 1; }

View File

@@ -32,7 +32,14 @@ GLUE_OBJS = __dummy_passwd.o __psp_heap_blockid.o __psp_free_heap.o _fork.o _wai
openat.o renameat.o fchmodat.o fstatat.o mkdirat.o faccessat.o fchownat.o linkat.o readlinkat.o unlinkat.o \
realpath.o
INIT_OBJS = __libpthreadglue_init.o __libcglue_init.o __libcglue_deinit.o _exit.o abort.o exit.o
INIT_OBJS = \
__libpthreadglue_init.o \
__libcglue_init.o \
__gprof_cleanup.o \
__libcglue_deinit.o \
_exit.o \
abort.o \
exit.o
LOCK_OBJS = \
__lock___sfp_recursive_mutex.o \

View File

@@ -31,6 +31,14 @@ void __locks_deinit();
extern int sce_newlib_nocreate_thread_in_start __attribute__((weak));
#ifdef F___gprof_cleanup
/* Note: This function is being called from _exit and it is overrided when compiling with -pg */
__attribute__((weak))
void __gprof_cleanup() {}
#else
void __gprof_cleanup();
#endif
#if defined(F___libpthreadglue_init) && !defined(PSP_WITHOUT_PTHREAD)
/* Note: This function is being called from __libcglue_init.
* It is a weak function because can be override by user program
@@ -95,6 +103,7 @@ void __libcglue_deinit();
__attribute__((__noreturn__))
void _exit (int __status)
{
__gprof_cleanup();
__libcglue_deinit();
if (&sce_newlib_nocreate_thread_in_start != NULL) {

View File

@@ -11,7 +11,7 @@ CFLAGS = @PSPSDK_CFLAGS@ -std=gnu99 -Wall -Wmissing-prototypes
CCASFLAGS = $(CFLAGS) -I$(top_srcdir)/src/base -I$(top_srcdir)/src/kernel
libpspprofincludedir = @PSPSDK_INCLUDEDIR@
libpspprofinclude_HEADERS = pspprof.h
libpspprofinclude_HEADERS =
lib_LIBRARIES = libpspprof.a
libpspprof_a_SOURCES = prof.c mcount.s

View File

@@ -78,7 +78,7 @@ extern int _ftext;
extern int _etext;
/* forward declarations */
void gprof_cleanup(void);
void __gprof_cleanup(void);
void __mcount(unsigned int, unsigned int);
static SceUInt timer_handler(SceUID uid, SceKernelSysClock *c1, SceKernelSysClock *c2, void *common);
@@ -156,7 +156,7 @@ static void initialize()
Called from atexit() handler; will dump out a host:gmon.out file
with all collected information.
*/
void gprof_cleanup()
void __gprof_cleanup()
{
FILE *fp;
int i;

View File

@@ -1,24 +0,0 @@
/*
* PSP Software Development Kit - https://github.com/pspdev
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspprof.h - Prototypes for the profiler library
*
* Copyright (c) 2006 Urchin
*
*/
#ifndef __PSPPROF_H__
#define __PSPPROF_H__
#ifdef __cplusplus
extern "C" {
#endif
void gprof_cleanup();
#ifdef __cplusplus
}
#endif
#endif /* __PSPPROF_H__ */