for dev+ builds, add logging of execution counts for each instruction.
This commit is contained in:
parent
96db719b0c
commit
d0bfdc0a02
|
@ -3767,6 +3767,11 @@ static char * OP_BL_THUMB(u32 adr, u32 i, char * txt)
|
|||
#define NOM_THUMB_TAB des_thumb_instructions_set
|
||||
#define TABDECL(x) x
|
||||
|
||||
TYPE_RETOUR (*CALLTYPE NOM_TAB[4096])(PARAMETRES)={
|
||||
#include "instruction_tabdef.inc"
|
||||
#include "thumb_tabdef.inc"
|
||||
};
|
||||
|
||||
TYPE_RETOUR (*CALLTYPE NOM_THUMB_TAB[1024])(PARAMETRES)={
|
||||
#include "thumb_tabdef.inc"
|
||||
};
|
||||
|
||||
|
|
|
@ -276,7 +276,7 @@ static void drawPad(double x, double y, double ratio) {
|
|||
|
||||
// touch pad
|
||||
{
|
||||
bool gameTouchOn = nds.isTouch;
|
||||
BOOL gameTouchOn = nds.isTouch;
|
||||
double gameTouchX = screenLeft+1 + (nds.touchX * 0.0625) * (screenRight - screenLeft - 2) / 256.0;
|
||||
double gameTouchY = screenTop+1 + (nds.touchY * 0.0625) * (screenBottom - screenTop - 2) / 192.0;
|
||||
bool physicalTouchOn = NDS_getRawUserInput().touch.isTouch;
|
||||
|
|
|
@ -2315,6 +2315,8 @@ void NDS_Reset()
|
|||
FILE* inf = 0;
|
||||
NDS_header * header = NDS_getROMHeader();
|
||||
|
||||
DEBUG_reset();
|
||||
|
||||
if (!header) return ;
|
||||
|
||||
nds_timer = 0;
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
Copyright (C) 2006 shash
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
Copyright (C) 2006-2007 shash
|
||||
Copyright (C) 2008-2009 DeSmuME team
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
|
@ -7775,7 +7772,9 @@ TEMPLATE static u32 FASTCALL OP_CDP()
|
|||
#define NOM_TAB arm_instructions_set_0
|
||||
#define TABDECL(x) x<0>
|
||||
|
||||
TYPE_RETOUR (*CALLTYPE NOM_TAB[4096])(PARAMETRES)={
|
||||
#include "instruction_tabdef.inc"
|
||||
};
|
||||
|
||||
#undef TYPE_RETOUR
|
||||
#undef PARAMETRES
|
||||
|
@ -7789,4 +7788,19 @@ TEMPLATE static u32 FASTCALL OP_CDP()
|
|||
#define NOM_TAB arm_instructions_set_1
|
||||
#define TABDECL(x) x<1>
|
||||
|
||||
TYPE_RETOUR (*CALLTYPE NOM_TAB[4096])(PARAMETRES)={
|
||||
#include "instruction_tabdef.inc"
|
||||
};
|
||||
|
||||
#undef TYPE_RETOUR
|
||||
#undef PARAMETRES
|
||||
#undef CALLTYPE
|
||||
#undef NOM_TAB
|
||||
#undef TABDECL
|
||||
|
||||
#define TABDECL(x) #x
|
||||
|
||||
char* arm_instruction_names[4096] = {
|
||||
#include "instruction_tabdef.inc"
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
Copyright (C) 2009 DeSmuME team
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
|
@ -27,6 +26,7 @@
|
|||
|
||||
extern u32 (FASTCALL* arm_instructions_set_0[4096])();
|
||||
extern u32 (FASTCALL* arm_instructions_set_1[4096])();
|
||||
extern char* arm_instruction_names[4096];
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
Copyright (C) 2009 DeSmuME team
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
|
@ -533,15 +532,17 @@ u32 armcpu_exec()
|
|||
)
|
||||
{
|
||||
if(PROCNUM==0) {
|
||||
#ifdef WANTASMLISTING
|
||||
char txt[128];
|
||||
des_arm_instructions_set[INSTRUCTION_INDEX(ARMPROC.instruction)](ARMPROC.instruct_adr,ARMPROC.instruction,txt);
|
||||
printf("%X: %X - %s\n", ARMPROC.instruct_adr,ARMPROC.instruction, txt);
|
||||
#endif
|
||||
#ifdef DEVELOPER
|
||||
DEBUG_statistics.instructionHits[0].arm[INSTRUCTION_INDEX(ARMPROC.instruction)]++;
|
||||
#endif
|
||||
cExecute = arm_instructions_set_0[INSTRUCTION_INDEX(ARMPROC.instruction)]();
|
||||
}
|
||||
else
|
||||
else {
|
||||
#ifdef DEVELOPER
|
||||
DEBUG_statistics.instructionHits[1].arm[INSTRUCTION_INDEX(ARMPROC.instruction)]++;
|
||||
#endif
|
||||
cExecute = arm_instructions_set_1[INSTRUCTION_INDEX(ARMPROC.instruction)]();
|
||||
}
|
||||
}
|
||||
else
|
||||
cExecute = 1; // If condition=false: 1S cycle
|
||||
|
@ -557,9 +558,18 @@ u32 armcpu_exec()
|
|||
}
|
||||
|
||||
if(PROCNUM==0)
|
||||
{
|
||||
#ifdef DEVELOPER
|
||||
DEBUG_statistics.instructionHits[0].thumb[ARMPROC.instruction>>6]++;
|
||||
#endif
|
||||
cExecute = thumb_instructions_set_0[ARMPROC.instruction>>6]();
|
||||
else
|
||||
}
|
||||
else {
|
||||
#ifdef DEVELOPER
|
||||
DEBUG_statistics.instructionHits[1].thumb[ARMPROC.instruction>>6]++;
|
||||
#endif
|
||||
cExecute = thumb_instructions_set_1[ARMPROC.instruction>>6]();
|
||||
}
|
||||
|
||||
#ifdef GDB_STUB
|
||||
if ( ARMPROC.post_ex_fn != NULL) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* Copyright (C) 2008 Guillaume Duhamel
|
||||
Copyright (C) 2009 DeSmuME team
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
|
@ -19,13 +20,116 @@
|
|||
|
||||
#include "debug.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include "MMU.h"
|
||||
#include "armcpu.h"
|
||||
#include "arm_instructions.h"
|
||||
#include "thumb_instructions.h"
|
||||
|
||||
std::vector<Logger *> Logger::channels;
|
||||
|
||||
DebugStatistics DEBUG_statistics;
|
||||
|
||||
DebugStatistics::DebugStatistics()
|
||||
{
|
||||
}
|
||||
|
||||
DebugStatistics::InstructionHits::InstructionHits()
|
||||
{
|
||||
memset(&arm,0,sizeof(arm));
|
||||
memset(&thumb,0,sizeof(thumb));
|
||||
}
|
||||
|
||||
|
||||
static DebugStatistics::InstructionHits combinedHits[2];
|
||||
|
||||
template<int proc, int which>
|
||||
static bool debugStatsSort(int num1, int num2) {
|
||||
if(which==0) {
|
||||
if(combinedHits[proc].arm[num2] == combinedHits[proc].arm[num1]) return false;
|
||||
if(combinedHits[proc].arm[num1] == 0xFFFFFFFF) return false;
|
||||
if(combinedHits[proc].arm[num2] == 0xFFFFFFFF) return true;
|
||||
return combinedHits[proc].arm[num2] < combinedHits[proc].arm[num1];
|
||||
}
|
||||
else {
|
||||
if(combinedHits[proc].thumb[num2] == combinedHits[proc].thumb[num1]) return false;
|
||||
if(combinedHits[proc].thumb[num1] == 0xFFFFFFFF) return false;
|
||||
if(combinedHits[proc].thumb[num2] == 0xFFFFFFFF) return true;
|
||||
return combinedHits[proc].thumb[num2] < combinedHits[proc].thumb[num1];
|
||||
}
|
||||
}
|
||||
|
||||
void DebugStatistics::print()
|
||||
{
|
||||
//consolidate opcodes with the same names
|
||||
for(int i=0;i<2;i++) {
|
||||
combinedHits[i] = DEBUG_statistics.instructionHits[i];
|
||||
|
||||
for(int j=0;j<4096;j++) {
|
||||
if(combinedHits[i].arm[j] == 0xFFFFFFFF)
|
||||
continue;
|
||||
std::string name = arm_instruction_names[j];
|
||||
for(int k=j+1;k<4096;k++) {
|
||||
if(combinedHits[i].arm[k] == 0xFFFFFFFF)
|
||||
continue;
|
||||
if(name == arm_instruction_names[k]) {
|
||||
//printf("combining %s with %d and %d\n",name.c_str(),combinedHits[i].arm[j],combinedHits[i].arm[k]);
|
||||
combinedHits[i].arm[j] += combinedHits[i].arm[k];
|
||||
combinedHits[i].arm[k] = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for(int j=0;j<1024;j++) {
|
||||
if(combinedHits[i].thumb[j] == 0xFFFFFFFF)
|
||||
continue;
|
||||
std::string name = thumb_instruction_names[j];
|
||||
for(int k=j+1;k<1024;k++) {
|
||||
if(combinedHits[i].thumb[k] == 0xFFFFFFFF)
|
||||
continue;
|
||||
if(name == thumb_instruction_names[k]) {
|
||||
//printf("combining %s with %d and %d\n",name.c_str(),combinedHits[i].arm[j],combinedHits[i].arm[k]);
|
||||
combinedHits[i].thumb[j] += combinedHits[i].thumb[k];
|
||||
combinedHits[i].thumb[k] = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
InstructionHits sorts[2];
|
||||
for(int i=0;i<2;i++) {
|
||||
for(int j=0;j<4096;j++) sorts[i].arm[j] = j;
|
||||
for(int j=0;j<1024;j++) sorts[i].thumb[j] = j;
|
||||
}
|
||||
std::sort(sorts[0].arm, sorts[0].arm+4096, debugStatsSort<0,0>);
|
||||
std::sort(sorts[0].thumb, sorts[0].thumb+1024, debugStatsSort<0,1>);
|
||||
std::sort(sorts[1].arm, sorts[1].arm+4096, debugStatsSort<1,0>);
|
||||
std::sort(sorts[1].thumb, sorts[1].thumb+1024, debugStatsSort<1,1>);
|
||||
|
||||
for(int i=0;i<2;i++) {
|
||||
printf("Top arm instructions for ARM%d:\n",7+i*2);
|
||||
for(int j=0;j<10;j++) {
|
||||
int val = sorts[i].arm[j];
|
||||
printf("%08d: %s\n", combinedHits[i].arm[val], arm_instruction_names[val]);
|
||||
}
|
||||
printf("Top thumb instructions for ARM%d:\n",7+i*2);
|
||||
for(int j=0;j<10;j++) {
|
||||
int val = sorts[i].thumb[j];
|
||||
printf("%08d: %s\n", combinedHits[i].thumb[val], thumb_instruction_names[val]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DEBUG_reset()
|
||||
{
|
||||
DEBUG_statistics = DebugStatistics();
|
||||
printf("DEBUG_reset: %08X",&DebugStatistics::print); //force a reference to this function
|
||||
}
|
||||
|
||||
static void defaultCallback(const Logger& logger, const char * message) {
|
||||
logger.getOutput() << message;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* Copyright (C) 2008 Guillaume Duhamel
|
||||
Copyright (C) 2009 DeSmuME team
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
|
@ -17,13 +18,31 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef LOGGER_H
|
||||
#define LOGGER_H
|
||||
#ifndef DEBUG_H
|
||||
#define DEBUG_H
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <cstdarg>
|
||||
|
||||
#include "types.h"
|
||||
|
||||
struct DebugStatistics
|
||||
{
|
||||
DebugStatistics();
|
||||
struct InstructionHits {
|
||||
InstructionHits();
|
||||
u32 thumb[1024];
|
||||
u32 arm[4096];
|
||||
} instructionHits[2]; //one for each cpu
|
||||
|
||||
void print();
|
||||
};
|
||||
|
||||
extern DebugStatistics DEBUG_statistics;
|
||||
|
||||
void DEBUG_reset();
|
||||
|
||||
struct armcpu_t;
|
||||
|
||||
class Logger {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
|
||||
Copyright (C) 2009 DeSmuME team
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
DeSmuME is free software; you can redistribute it and/or modify
|
||||
|
@ -19,7 +18,6 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
TYPE_RETOUR (*CALLTYPE NOM_TAB[4096])(PARAMETRES)={
|
||||
TABDECL( OP_AND_LSL_IMM), // 000 0000 0 0000
|
||||
TABDECL( OP_AND_LSL_REG), // 000 0000 0 0001
|
||||
TABDECL( OP_AND_LSR_IMM), // 000 0000 0 0010
|
||||
|
@ -4396,5 +4394,5 @@ TABDECL( OP_SWI),
|
|||
TABDECL( OP_SWI),
|
||||
TABDECL( OP_SWI),
|
||||
TABDECL( OP_SWI),
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -977,7 +977,9 @@ TEMPLATE static u32 FASTCALL OP_BL_THUMB()
|
|||
#define NOM_THUMB_TAB thumb_instructions_set_0
|
||||
#define TABDECL(x) x<0>
|
||||
|
||||
TYPE_RETOUR (* CALLTYPE NOM_THUMB_TAB[1024])(PARAMETRES)={
|
||||
#include "thumb_tabdef.inc"
|
||||
};
|
||||
|
||||
#undef TYPE_RETOUR
|
||||
#undef PARAMETRES
|
||||
|
@ -991,4 +993,19 @@ TEMPLATE static u32 FASTCALL OP_BL_THUMB()
|
|||
#define NOM_THUMB_TAB thumb_instructions_set_1
|
||||
#define TABDECL(x) x<1>
|
||||
|
||||
TYPE_RETOUR (* CALLTYPE NOM_THUMB_TAB[1024])(PARAMETRES)={
|
||||
#include "thumb_tabdef.inc"
|
||||
};
|
||||
|
||||
#undef TYPE_RETOUR
|
||||
#undef PARAMETRES
|
||||
#undef CALLTYPE
|
||||
#undef NOM_TAB
|
||||
#undef TABDECL
|
||||
|
||||
#define TABDECL(x) #x
|
||||
|
||||
char* thumb_instruction_names[1024] = {
|
||||
#include "thumb_tabdef.inc"
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
Copyright (C) 2009 DeSmuME team
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
|
@ -26,6 +25,7 @@
|
|||
|
||||
extern u32 (FASTCALL* thumb_instructions_set_0[1024])();
|
||||
extern u32 (FASTCALL* thumb_instructions_set_1[1024])();
|
||||
extern char* thumb_instruction_names[1024];
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* Copyright (C) 2006 yopyop
|
||||
yopyop156@ifrance.com
|
||||
yopyop156.ifrance.com
|
||||
Copyright (C) 2009 DeSmuME team
|
||||
|
||||
This file is part of DeSmuME
|
||||
|
||||
|
@ -19,7 +18,6 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
TYPE_RETOUR (* CALLTYPE NOM_THUMB_TAB[1024])(PARAMETRES)={
|
||||
TABDECL( OP_LSL_0), //00 0000 0000
|
||||
TABDECL( OP_LSL), //00 0000 0001
|
||||
TABDECL( OP_LSL), //00 0000 0010
|
||||
|
@ -1107,5 +1105,3 @@ TABDECL( OP_BL_THUMB), //11 1111 1100
|
|||
TABDECL( OP_BL_THUMB), //11 1111 1101
|
||||
TABDECL( OP_BL_THUMB), //11 1111 1110
|
||||
TABDECL( OP_BL_THUMB), //11 1111 1111
|
||||
}; //1089
|
||||
|
||||
|
|
|
@ -15,21 +15,18 @@ Global
|
|||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Debug|x64.Build.0 = Debug|x64
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Debug|x64.ActiveCfg = Debug|Win32
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Release FastBuild|Win32.ActiveCfg = Release FastBuild|Win32
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Release FastBuild|Win32.Build.0 = Release FastBuild|Win32
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Release FastBuild|x64.ActiveCfg = Release FastBuild|x64
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Release FastBuild|x64.Build.0 = Release FastBuild|x64
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Release FastBuild|x64.ActiveCfg = Release FastBuild|Win32
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Release|Win32.Build.0 = Release|Win32
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Release|x64.ActiveCfg = Release|x64
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Release|x64.Build.0 = Release|x64
|
||||
{9F5F72A1-D3A5-4918-B460-E076B16D10A9}.Release|x64.ActiveCfg = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
AMDCaProjectFile = D:\svn\desmume\trunk\desmume\src\windows\CodeAnalyst\DeSmuME_2005.caw
|
||||
AMDCaProjectFile = C:\svn\desmume3\trunk\desmume\src\windows\CodeAnalyst\DeSmuME_2005.caw
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<?xml version="1.0" encoding="shift_jis"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
|
@ -1330,6 +1330,10 @@
|
|||
RelativePath="..\GPU_osd.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\instruction_tabdef.inc"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\lua-engine.cpp"
|
||||
>
|
||||
|
@ -1506,6 +1510,10 @@
|
|||
RelativePath="..\thumb_instructions.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\thumb_tabdef.inc"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\types.h"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue