delete nixprof

This commit is contained in:
Flyinghead 2020-11-22 17:37:27 +01:00
parent fd16c7f28f
commit 2a5b303b70
13 changed files with 1 additions and 429 deletions

View File

@ -650,7 +650,6 @@ target_sources(${PROJECT_NAME} PRIVATE
core/input/mapping.h)
target_sources(${PROJECT_NAME} PRIVATE
core/linux/nixprof/nixprof.cpp
core/linux/common.cpp)
if(NOT WIN32)

View File

@ -202,10 +202,6 @@
#define FEAT_DSPREC DYNAREC_NONE
#endif
#if defined(TARGET_NO_NIXPROF)
#define FEAT_HAS_NIXPROF 0
#endif
#if defined(TARGET_NO_COREIO_HTTP)
#define FEAT_HAS_COREIO_HTTP 0
#endif
@ -236,12 +232,6 @@
#endif
#endif
#ifndef FEAT_HAS_NIXPROF
#ifndef _WIN32
#define FEAT_HAS_NIXPROF 1
#endif
#endif
#ifndef FEAT_HAS_COREIO_HTTP
#define FEAT_HAS_COREIO_HTTP 1
#endif

View File

@ -58,10 +58,6 @@ else
RZDCY_MODULES += rend/norend/
endif
ifndef NO_NIXPROF
RZDCY_MODULES += linux/nixprof/
endif
ifdef FOR_ANDROID
RZDCY_MODULES += android/ deps/libandroid/ linux/
endif

View File

@ -38,10 +38,6 @@
#include <sys/soundcard.h>
#endif
#if FEAT_HAS_NIXPROF
#include "profiler/profiler.h"
#endif
#if defined(USE_JOYSTICK)
/* legacy joystick input */
static int joystick_fd = -1; // Joystick file descriptor
@ -327,9 +323,6 @@ int main(int argc, char* argv[])
if (reicast_init(argc, argv))
die("Reicast initialization failed\n");
#if FEAT_HAS_NIXPROF
install_prof_handler(1);
#endif
rend_thread(NULL);
#ifdef TARGET_PANDORA

View File

@ -13,9 +13,6 @@
#include "hw/maple/maple_devs.h"
#include "emulator.h"
#if FEAT_HAS_NIXPROF
#include "profiler/profiler.h"
#endif
#include "x11_keyboard.h"
#if defined(TARGET_PANDORA)
@ -256,25 +253,12 @@ void input_x11_handle()
// TODO Move this to bindable keys or in the gui menu
if (x11_keyboard_input)
{
#if 1
if (e.xkey.keycode == KEY_F10)
{
// Dump the next frame into a file
dump_frame_switch = e.type == KeyPress;
}
else
#elif FEAT_HAS_NIXPROF
if (e.type == KeyRelease && e.xkey.keycode == KEY_F10)
{
if (sample_Switch(3000)) {
INFO_LOG(COMMON, "Starting profiling");
} else {
INFO_LOG(COMMON, "Stopping profiling");
}
}
else
#endif
if (e.type == KeyPress && e.xkey.keycode == KEY_F11)
else if (e.type == KeyPress && e.xkey.keycode == KEY_F11)
{
x11_fullscreen = !x11_fullscreen;
x11_window_set_fullscreen(x11_fullscreen);

View File

@ -1,337 +0,0 @@
#include "types.h"
#if FEAT_HAS_NIXPROF
#include "cfg/cfg.h"
#include <cinttypes>
#include <cstdio>
#include <cstdlib>
#include <pthread.h>
#include <unistd.h>
#include <sys/types.h>
#include <memory.h>
#include <csignal>
//#include <sys/ucontext.h>
//#include <execinfo.h>
#include <sys/syscall.h>
#include <sys/stat.h>
#include <poll.h>
#include <termios.h>
//#include <curses.h>
#include <fcntl.h>
#include <semaphore.h>
#include <cstdarg>
#include <sys/param.h>
#include <sys/mman.h>
#include <sys/time.h>
#include "hw/sh4/dyna/blockmanager.h"
#include <set>
#include "deps/libelf/elf.h"
#include "profiler/profiler.h"
#include "linux/context.h"
/**
@file CallStack_Android.h
@brief Getting the callstack under Android
@author Peter Holtwick
*/
#include <unwind.h>
#include <cstring>
static int tick_count=0;
static pthread_t proft;
static pthread_t thread[2];
static void* prof_address[2];
static u32 prof_wait;
static u8* syms_ptr;
static int syms_len;
void sample_Syms(u8* data,u32 len)
{
syms_ptr=data;
syms_len=len;
}
void prof_handler (int sn, siginfo_t * si, void *ctxr)
{
rei_host_context_t ctx;
context_from_segfault(&ctx, ctxr);
int thd=-1;
if (pthread_self()==thread[0]) thd=0;
else if (pthread_self()==thread[1]) thd=1;
else return;
prof_address[thd] = (void*)ctx.pc;
}
void install_prof_handler(int id)
{
struct sigaction act, segv_oact;
memset(&act, 0, sizeof(act));
act.sa_sigaction = prof_handler;
sigemptyset(&act.sa_mask);
act.sa_flags = SA_SIGINFO | SA_RESTART;
sigaction(SIGPROF, &act, &segv_oact);
thread[id]=pthread_self();
}
static void prof_head(FILE* out, const char* type, const char* name)
{
fprintf(out,"==xx==xx==\n%s:%s\n",type,name);
}
static void prof_head(FILE* out, const char* type, int d)
{
fprintf(out,"==xx==xx==\n%s:%d\n",type,d);
}
static void elf_syms(FILE* out,const char* libfile)
{
struct stat statbuf;
printf("LIBFILE \"%s\"\n", libfile);
int fd = open(libfile, O_RDONLY, 0);
if (!fd)
{
printf("Failed to open file \"%s\"\n", libfile);
return;
}
if (fstat(fd, &statbuf) < 0)
{
printf("Failed to fstat file \"%s\"\n", libfile);
return;
}
{
void* data = mmap(0, statbuf.st_size, PROT_READ, MAP_SHARED, fd, 0);
close(fd);
if (data == (void*)-1)
{
printf("Failed to mmap file \"%s\"\n", libfile);
return;
}
//printf("MMap: %08p, %08X\n",data,statbuf.st_size);
int dynsym=-1;
int dynstr=-1;
int strtab=-1;
int symtab=-1;
if (elf_checkFile(data)>=0)
{
unsigned scnt = elf_getNumSections(data);
for (int si=0;si<scnt;si++)
{
uint32_t section_type = elf_getSectionType(data, si);
uint64_t section_link = elf_getSectionLink(data, si);
switch (section_type) {
case SHT_DYNSYM:
fprintf(stderr, "DYNSYM");
dynsym = si;
if (section_link < scnt)
dynstr = section_link;
break;
case SHT_SYMTAB:
fprintf(stderr, "SYMTAB");
symtab = si;
if (section_link < scnt)
strtab = section_link;
break;
default:
break;;
}
}
}
else
{
printf("Invalid elf file\n");
}
// Use SHT_SYMTAB if available insteaf of SHT_DYNSYM
// (there is more info here):
if (symtab >= 0 && strtab >= 0)
{
dynsym = symtab;
dynstr = strtab;
}
if (dynsym >= 0)
{
prof_head(out,"libsym",libfile);
// printf("Found dymsym %d, and dynstr %d!\n",dynsym,dynstr);
elf_symbol* sym=(elf_symbol*)elf_getSection(data,dynsym);
elf64_symbol* sym64 = (elf64_symbol*) sym;
bool elf32 = ((struct Elf32_Header*)data)->e_ident[EI_CLASS] == ELFCLASS32;
size_t symbol_size = elf32 ? sizeof(elf_symbol) : sizeof(elf64_symbol);
int symcnt = elf_getSectionSize(data,dynsym) / symbol_size;
for (int i=0; i < symcnt; i++)
{
uint64_t st_value = elf32 ? sym[i].st_value : sym64[i].st_value;
uint32_t st_name = elf32 ? sym[i].st_name : sym64[i].st_name;
uint16_t st_shndx = elf32 ? sym[i].st_shndx : sym64[i].st_shndx;
uint16_t st_type = (elf32 ? sym[i].st_info : sym64[i].st_info) & 0xf;
uint64_t st_size = elf32 ? sym[i].st_size : sym64[i].st_size;
if (st_type == STT_FUNC && st_value && st_name && st_shndx)
{
char* name=(char*)elf_getSection(data,dynstr);// sym[i].st_shndx
// printf("Symbol %d: %s, %08" PRIx64 ", % " PRIi64 " bytes\n",
// i, name + st_name, st_value, st_size);
//PRIx64 & friends not in android ndk (yet?)
fprintf(out,"%08x %d %s\n", (int)st_value, (int)st_size, name + st_name);
}
}
}
else
{
printf("No dynsym\n");
}
munmap(data,statbuf.st_size);
}
}
static volatile bool prof_run;
// This is not used:
static int str_ends_with(const char * str, const char * suffix)
{
if (str == NULL || suffix == NULL)
return 0;
size_t str_len = strlen(str);
size_t suffix_len = strlen(suffix);
if (suffix_len > str_len)
return 0;
return 0 == strncmp(str + str_len - suffix_len, suffix, suffix_len);
}
void sh4_jitsym(FILE* out);
static void* profiler_main(void *ptr)
{
FILE* prof_out;
char line[512];
sprintf(line, "/%d.reprof", tick_count);
std::string logfile = get_writable_data_path(line);
printf("Profiler thread logging to -> %s\n", logfile.c_str());
prof_out = fopen(logfile.c_str(), "wb");
if (!prof_out)
{
printf("Failed to open profiler file\n");
return 0;
}
std::set<std::string> libs;
prof_head(prof_out, "vaddr", "");
FILE* maps = fopen("/proc/self/maps", "r");
while (!feof(maps))
{
fgets(line, 512, maps);
fputs(line, prof_out);
if (strstr(line, ".so"))
{
char file[512];
file[0] = 0;
sscanf(line, "%*x-%*x %*s %*x %*x:%*x %*d %s\n", file);
if (strlen(file))
libs.insert(file);
}
}
//Write map file
prof_head(prof_out, ".map", "");
fwrite(syms_ptr, 1, syms_len, prof_out);
//write exports from .so's
for (std::set<std::string>::iterator it = libs.begin(); it != libs.end(); it++)
{
elf_syms(prof_out, it->c_str());
}
//Write shrec syms file !
prof_head(prof_out, "jitsym", "SH4");
#if FEAT_SHREC != DYNAREC_NONE
sh4_jitsym(prof_out);
#endif
//Write arm7rec syms file ! -> to do
//prof_head(prof_out,"jitsym","ARM7");
prof_head(prof_out, "samples", prof_wait);
do
{
tick_count++;
// printf("Sending SIGPROF %08X %08X\n",thread[0],thread[1]);
for (int i = 0; i < 2; i++) pthread_kill(thread[i], SIGPROF);
// printf("Sent SIGPROF\n");
usleep(prof_wait);
// fwrite(&prof_address[0],1,sizeof(prof_address[0])*2,prof_out);
fprintf(prof_out, "%p %p\n", prof_address[0], prof_address[1]);
if (!(tick_count % 10000))
{
printf("Profiler: %d ticks, flushing ..\n", tick_count);
fflush(prof_out);
}
} while (prof_run);
fclose(maps);
fclose(prof_out);
return 0;
}
bool sample_Switch(int freq)
{
if (prof_run) {
sample_Stop();
} else {
sample_Start(freq);
}
return prof_run;
}
void sample_Start(int freq)
{
if (prof_run)
return;
prof_wait = 1000000 / freq;
printf("sampling profiler: starting %d Hz %d wait\n", freq, prof_wait);
prof_run = true;
pthread_create(&proft, NULL, profiler_main, 0);
}
void sample_Stop()
{
if (prof_run)
{
prof_run = false;
pthread_join(proft, NULL);
}
printf("sampling profiler: stopped\n");
}
#endif

View File

@ -639,10 +639,6 @@ bool dc_is_running()
#ifndef TARGET_DISPFRAME
void* dc_run(void*)
{
#if FEAT_HAS_NIXPROF
install_prof_handler(0);
#endif
InitAudio();
if (settings.dynarec.Enable)

View File

@ -144,10 +144,3 @@ struct profiler_cfg
};
extern profiler_cfg prof;
void install_prof_handler(int id);
void sample_Start(int freq);
void sample_Stop();
bool sample_Switch(int freq);
void sample_Syms(u8* data,u32 len);

View File

@ -322,30 +322,11 @@ JNIEXPORT jint JNICALL Java_com_reicast_emulator_emu_JNIdc_send(JNIEnv *env,jobj
#endif
}
}
else if (cmd==1)
{
if (param==0)
sample_Stop();
else
sample_Start(param);
}
else if (cmd==2)
{
}
return 0;
}
JNIEXPORT jint JNICALL Java_com_reicast_emulator_emu_JNIdc_data(JNIEnv *env, jobject obj, jint id, jbyteArray d)
{
if (id==1)
{
INFO_LOG(DYNAREC, "Loading symtable (%p,%p,%d,%p)",env,obj,id,d);
jsize len=env->GetArrayLength(d);
u8* syms=(u8*)malloc((size_t)len);
INFO_LOG(DYNAREC, "Loading symtable to %8s, %d",syms,len);
env->GetByteArrayRegion(d,0,len,(jbyte*)syms);
sample_Syms(syms, (size_t)len);
}
return 0;
}

View File

@ -86,10 +86,6 @@ void MakeCurrentThreadRealTime()
-(void)emuThread
{
// #if !TARGET_OS_SIMULATOR
install_prof_handler(1);
// #endif
char *Args[3];
const char *P;

View File

@ -26,7 +26,6 @@
84967C9F1B8F492C005F1140 /* pngwtran.c in Sources */ = {isa = PBXBuildFile; fileRef = 84967C8D1B8F492C005F1140 /* pngwtran.c */; };
84967CA01B8F492C005F1140 /* pngwutil.c in Sources */ = {isa = PBXBuildFile; fileRef = 84967C8E1B8F492C005F1140 /* pngwutil.c */; };
8497BCBF1A41A0E900EFB9ED /* common.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8497BCBC1A41A0E900EFB9ED /* common.cpp */; };
8497BCC01A41A0E900EFB9ED /* nixprof.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8497BCBD1A41A0E900EFB9ED /* nixprof.cpp */; };
8497BCCF1A41BFD800EFB9ED /* coreio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8497BCCD1A41BFD800EFB9ED /* coreio.cpp */; };
849C0D621B072C07008BAAA4 /* context.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 849C0D601B072C07008BAAA4 /* context.cpp */; };
849C0D661B072CF8008BAAA4 /* reios.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 849C0D641B072CF8008BAAA4 /* reios.cpp */; };
@ -262,7 +261,6 @@
84967C8D1B8F492C005F1140 /* pngwtran.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pngwtran.c; sourceTree = "<group>"; };
84967C8E1B8F492C005F1140 /* pngwutil.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pngwutil.c; sourceTree = "<group>"; };
8497BCBC1A41A0E900EFB9ED /* common.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = common.cpp; sourceTree = "<group>"; };
8497BCBD1A41A0E900EFB9ED /* nixprof.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = nixprof.cpp; path = nixprof/nixprof.cpp; sourceTree = "<group>"; };
8497BCCD1A41BFD800EFB9ED /* coreio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = coreio.cpp; sourceTree = "<group>"; };
8497BCCE1A41BFD800EFB9ED /* coreio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = coreio.h; sourceTree = "<group>"; };
849C0D601B072C07008BAAA4 /* context.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = context.cpp; sourceTree = "<group>"; };
@ -653,7 +651,6 @@
849C0D601B072C07008BAAA4 /* context.cpp */,
849C0D611B072C07008BAAA4 /* context.h */,
8497BCBC1A41A0E900EFB9ED /* common.cpp */,
8497BCBD1A41A0E900EFB9ED /* nixprof.cpp */,
);
path = linux;
sourceTree = "<group>";
@ -1574,7 +1571,6 @@
9C7A3B5918C81A4F0070BB5F /* SWRevealViewController.m in Sources */,
9C7A3B0F18C806E00070BB5F /* maple_cfg.cpp in Sources */,
87FA52E91B8CE18600CEFC32 /* PadViewController.m in Sources */,
8497BCC01A41A0E900EFB9ED /* nixprof.cpp in Sources */,
9C7A3AE118C806E00070BB5F /* zip_set_file_comment.c in Sources */,
84967C9A1B8F492C005F1140 /* pngrutil.c in Sources */,
9C7A3AC718C806E00070BB5F /* zip_error_get_sys_type.c in Sources */,

View File

@ -149,7 +149,6 @@
84B7BF5F1B72720200F9733F /* ioctl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84B7BE4B1B72720100F9733F /* ioctl.cpp */; };
84B7BF611B72720200F9733F /* common.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84B7BE651B72720100F9733F /* common.cpp */; };
84B7BF621B72720200F9733F /* context.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84B7BE661B72720100F9733F /* context.cpp */; };
84B7BF631B72720200F9733F /* nixprof.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84B7BE691B72720100F9733F /* nixprof.cpp */; };
84B7BF661B72720200F9733F /* nullDC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84B7BE6E1B72720200F9733F /* nullDC.cpp */; };
84B7BF671B72720200F9733F /* audiobackend_alsa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84B7BE701B72720200F9733F /* audiobackend_alsa.cpp */; };
84B7BF681B72720200F9733F /* audiobackend_directsound.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84B7BE731B72720200F9733F /* audiobackend_directsound.cpp */; };
@ -607,7 +606,6 @@
84B7BE651B72720100F9733F /* common.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = common.cpp; sourceTree = "<group>"; };
84B7BE661B72720100F9733F /* context.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = context.cpp; sourceTree = "<group>"; };
84B7BE671B72720100F9733F /* context.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = context.h; sourceTree = "<group>"; };
84B7BE691B72720100F9733F /* nixprof.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = nixprof.cpp; sourceTree = "<group>"; };
84B7BE6E1B72720200F9733F /* nullDC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = nullDC.cpp; path = ../../../core/nullDC.cpp; sourceTree = "<group>"; };
84B7BE701B72720200F9733F /* audiobackend_alsa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = audiobackend_alsa.cpp; sourceTree = "<group>"; };
84B7BE711B72720200F9733F /* audiobackend_alsa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = audiobackend_alsa.h; sourceTree = "<group>"; };
@ -1701,21 +1699,12 @@
84B7BE651B72720100F9733F /* common.cpp */,
84B7BE661B72720100F9733F /* context.cpp */,
84B7BE671B72720100F9733F /* context.h */,
84B7BE681B72720100F9733F /* nixprof */,
AEF2564722886A2E00348550 /* posix_vmem.cpp */,
);
name = linux;
path = ../../../core/linux;
sourceTree = "<group>";
};
84B7BE681B72720100F9733F /* nixprof */ = {
isa = PBXGroup;
children = (
84B7BE691B72720100F9733F /* nixprof.cpp */,
);
path = nixprof;
sourceTree = "<group>";
};
84B7BE6F1B72720200F9733F /* oslib */ = {
isa = PBXGroup;
children = (
@ -2799,7 +2788,6 @@
84B7BF4B1B72720200F9733F /* cpg.cpp in Sources */,
AE2A2D8021D6851E004B308D /* 7zDec.c in Sources */,
AE649BFA218C552500EF4A81 /* float.c in Sources */,
84B7BF631B72720200F9733F /* nixprof.cpp in Sources */,
AE649C24218C553A00EF4A81 /* Alloc.c in Sources */,
AED73E602348E45000ECDB64 /* glslang_tab.cpp in Sources */,
AEE62768220D7B4400EC7E89 /* cue.cpp in Sources */,
@ -2981,7 +2969,6 @@
GCC_FAST_MATH = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
TARGET_NO_NIXPROF,
TARGET_NO_COREIO_HTTP,
TARGET_NO_OPENMP,
ENABLE_MODEM,
@ -3036,7 +3023,6 @@
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_FAST_MATH = YES;
GCC_PREPROCESSOR_DEFINITIONS = (
TARGET_NO_NIXPROF,
TARGET_NO_COREIO_HTTP,
TARGET_NO_OPENMP,
ENABLE_MODEM,

View File

@ -287,7 +287,6 @@ endif
undefine USE_EVDEV
undefine USE_UDEV
undefine FOR_LINUX
NO_NIXPROF := 1
FOR_WINDOWS := 1
USE_VULKAN ?= 1
else