diff --git a/desmume/src/MMU_timing.h b/desmume/src/MMU_timing.h index 74e418277..2f45cccc1 100644 --- a/desmume/src/MMU_timing.h +++ b/desmume/src/MMU_timing.h @@ -29,6 +29,7 @@ #include "MMU.h" #include "cp15.h" #include "readwrite.h" +#include "debug.h" #include "NDSSystem.h" //////////////////////////////////////////////////////////////// @@ -318,6 +319,14 @@ FORCEINLINE u32 _MMU_accesstime(u32 addr, bool sequential) // by reading 32 bytes... c += 8 * M32*2; } + + if(CheckDebugEvent(DEBUG_EVENT_CACHE_MISS)) + { + DebugEventData.addr = addr; + DebugEventData.size = READSIZE; + HandleDebugEvent(DEBUG_EVENT_CACHE_MISS); + } + return c; #elif defined(ACCOUNT_FOR_NON_SEQUENTIAL_ACCESS) // this is the closest approximation I could find diff --git a/desmume/src/debug.cpp b/desmume/src/debug.cpp index d83814b35..ac1c40d64 100644 --- a/desmume/src/debug.cpp +++ b/desmume/src/debug.cpp @@ -43,6 +43,7 @@ u32 debugFlag; //DEBUG CONFIGURATION const bool debug_acl = false; +const bool debug_cacheMiss = false; static bool acl_check_access(u32 adr, u32 access) { @@ -102,6 +103,16 @@ void HandleDebugEvent_Execute() acl_check_access(DebugEventData.addr,CP15_ACCESS_EXECUTE); } +void HandleDebugEvent_CacheMiss() +{ + if(!debug_cacheMiss) return; + extern int currFrameCounter; + if(currFrameCounter<200) return; + static FILE* outf = NULL; + if(!outf) outf = fopen("c:\\miss.txt","wb"); + fprintf(outf,"%05d,%08X,%d\n",currFrameCounter,DebugEventData.addr,DebugEventData.size); +} + //------------------------------------------------ DebugStatistics DEBUG_statistics; diff --git a/desmume/src/debug.h b/desmume/src/debug.h index 6b20a3e92..4f474191f 100644 --- a/desmume/src/debug.h +++ b/desmume/src/debug.h @@ -147,8 +147,9 @@ enum EDEBUG_EVENT { DEBUG_EVENT_READ=1, //read from arm9 or arm7 bus, including cpu prefetch DEBUG_EVENT_WRITE=2, //write on arm9 or arm7 bus - DEBUG_EVENT_EXECUTE=4, //prefetch on arm9 or arm7, triggered after the read event - DEBUG_EVENT_ACL_EXCEPTION=8, //acl exception on arm9 + DEBUG_EVENT_EXECUTE=3, //prefetch on arm9 or arm7, triggered after the read event + DEBUG_EVENT_ACL_EXCEPTION=4, //acl exception on arm9 + DEBUG_EVENT_CACHE_MISS=5, //cache miss on arm9 }; enum EDEBUG_NOTIFY @@ -201,6 +202,7 @@ void HandleDebugEvent_Read(); void HandleDebugEvent_Write(); void HandleDebugEvent_Execute(); void HandleDebugEvent_ACL_Exception(); +void HandleDebugEvent_CacheMiss(); inline void HandleDebugEvent(EDEBUG_EVENT event) { @@ -210,6 +212,7 @@ inline void HandleDebugEvent(EDEBUG_EVENT event) case DEBUG_EVENT_WRITE: HandleDebugEvent_Write(); return; case DEBUG_EVENT_EXECUTE: HandleDebugEvent_Execute(); return; case DEBUG_EVENT_ACL_EXCEPTION: HandleDebugEvent_ACL_Exception(); return; + case DEBUG_EVENT_CACHE_MISS: HandleDebugEvent_CacheMiss(); return; } }