* [2SF] Used more up-to-date asmjit, despite the ugly looking code.
| 1 | 1 |
deleted file mode 100644 |
| ... | ... |
@@ -1,216 +0,0 @@ |
| 1 |
-/* Copyright (C) 2008 Guillaume Duhamel |
|
| 2 |
- Copyright (C) 2009-2010 DeSmuME team |
|
| 3 |
- |
|
| 4 |
- This file is part of DeSmuME |
|
| 5 |
- |
|
| 6 |
- DeSmuME is free software; you can redistribute it and/or modify |
|
| 7 |
- it under the terms of the GNU General Public License as published by |
|
| 8 |
- the Free Software Foundation; either version 2 of the License, or |
|
| 9 |
- (at your option) any later version. |
|
| 10 |
- |
|
| 11 |
- DeSmuME is distributed in the hope that it will be useful, |
|
| 12 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 13 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 14 |
- GNU General Public License for more details. |
|
| 15 |
- |
|
| 16 |
- You should have received a copy of the GNU General Public License |
|
| 17 |
- along with DeSmuME; if not, write to the Free Software |
|
| 18 |
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
| 19 |
-*/ |
|
| 20 |
- |
|
| 21 |
-#ifndef DEBUG_H |
|
| 22 |
-#define DEBUG_H |
|
| 23 |
- |
|
| 24 |
-#include <vector> |
|
| 25 |
-#include <iostream> |
|
| 26 |
-#include <bitset> |
|
| 27 |
-#include <cstdarg> |
|
| 28 |
- |
|
| 29 |
-#include "types.h" |
|
| 30 |
-#include "mem.h" |
|
| 31 |
-#include "emufile.h" |
|
| 32 |
- |
|
| 33 |
-struct DebugStatistics |
|
| 34 |
-{
|
|
| 35 |
- DebugStatistics(); |
|
| 36 |
- struct InstructionHits {
|
|
| 37 |
- InstructionHits(); |
|
| 38 |
- uint32_t thumb[1024]; |
|
| 39 |
- uint32_t arm[4096]; |
|
| 40 |
- } instructionHits[2]; //one for each cpu |
|
| 41 |
- |
|
| 42 |
- int32_t sequencerExecutionCounters[32]; |
|
| 43 |
- |
|
| 44 |
- void print(); |
|
| 45 |
- void printSequencerExecutionCounters(); |
|
| 46 |
-}; |
|
| 47 |
- |
|
| 48 |
-extern DebugStatistics DEBUG_statistics; |
|
| 49 |
- |
|
| 50 |
-void DEBUG_reset(); |
|
| 51 |
-void DEBUG_dumpMemory(EMUFILE* fp); |
|
| 52 |
- |
|
| 53 |
-struct armcpu_t; |
|
| 54 |
- |
|
| 55 |
-class Logger {
|
|
| 56 |
-protected: |
|
| 57 |
- void (*callback)(const Logger& logger, const char * format); |
|
| 58 |
- std::ostream * out; |
|
| 59 |
- unsigned int flags; |
|
| 60 |
- |
|
| 61 |
- static std::vector<Logger *> channels; |
|
| 62 |
- |
|
| 63 |
- static void fixSize(unsigned int channel); |
|
| 64 |
-public: |
|
| 65 |
- Logger(); |
|
| 66 |
- ~Logger(); |
|
| 67 |
- |
|
| 68 |
- void vprintf(const char * format, va_list l, const char * filename, unsigned int line); |
|
| 69 |
- void setOutput(std::ostream * o); |
|
| 70 |
- void setCallback(void (*cback)(const Logger& logger, const char * message)); |
|
| 71 |
- void setFlag(unsigned int flag); |
|
| 72 |
- |
|
| 73 |
- std::ostream& getOutput() const; |
|
| 74 |
- |
|
| 75 |
- static const int LINE = 1; |
|
| 76 |
- static const int FILE = 2; |
|
| 77 |
- |
|
| 78 |
- static void log(unsigned int channel, const char * file, unsigned int line, const char * format, ...); |
|
| 79 |
- static void log(unsigned int channel, const char * file, unsigned int line, std::ostream& os); |
|
| 80 |
- static void log(unsigned int channel, const char * file, unsigned int line, unsigned int flag); |
|
| 81 |
- static void log(unsigned int channel, const char * file, unsigned int line, void (*callback)(const Logger& logger, const char * message)); |
|
| 82 |
-}; |
|
| 83 |
- |
|
| 84 |
-#if defined(DEBUG) || defined(GPUDEBUG) || defined(DIVDEBUG) || defined(SQRTDEBUG) || defined(DMADEBUG) || defined(DEVELOPER) |
|
| 85 |
-#define LOGC(channel, ...) Logger::log(channel, __FILE__, __LINE__, __VA_ARGS__) |
|
| 86 |
-#else |
|
| 87 |
-#define LOGC(...) {}
|
|
| 88 |
-#endif |
|
| 89 |
- |
|
| 90 |
-#ifdef DEBUG |
|
| 91 |
-#define LOG(...) LOGC(0, __VA_ARGS__) |
|
| 92 |
-#else |
|
| 93 |
-#define LOG(...) {}
|
|
| 94 |
-#endif |
|
| 95 |
- |
|
| 96 |
-#ifdef GPUDEBUG |
|
| 97 |
-#define GPULOG(...) LOGC(1, __VA_ARGS__) |
|
| 98 |
-#else |
|
| 99 |
-#define GPULOG(...) {}
|
|
| 100 |
-#endif |
|
| 101 |
- |
|
| 102 |
-#ifdef DIVDEBUG |
|
| 103 |
-#define DIVLOG(...) LOGC(2, __VA_ARGS__) |
|
| 104 |
-#else |
|
| 105 |
-#define DIVLOG(...) {}
|
|
| 106 |
-#endif |
|
| 107 |
- |
|
| 108 |
-#ifdef SQRTDEBUG |
|
| 109 |
-#define SQRTLOG(...) LOGC(3, __VA_ARGS__) |
|
| 110 |
-#else |
|
| 111 |
-#define SQRTLOG(...) {}
|
|
| 112 |
-#endif |
|
| 113 |
- |
|
| 114 |
-#ifdef DMADEBUG |
|
| 115 |
-#define DMALOG(...) LOGC(4, __VA_ARGS__) |
|
| 116 |
-#else |
|
| 117 |
-#define DMALOG(...) {}
|
|
| 118 |
-#endif |
|
| 119 |
- |
|
| 120 |
-#ifdef CFLASHDEBUG |
|
| 121 |
-#define CFLASHLOG(...) LOGC(5, __VA_ARGS__) |
|
| 122 |
-#else |
|
| 123 |
-#define CFLASHLOG(...) {}
|
|
| 124 |
-#endif |
|
| 125 |
- |
|
| 126 |
-#ifdef UNTESTEDOPCODEDEBUG |
|
| 127 |
-#define UNTESTEDOPCODELOG(...) LOGC(6, __VA_ARGS__) |
|
| 128 |
-#else |
|
| 129 |
-#define UNTESTEDOPCODELOG(...) {}
|
|
| 130 |
-#endif |
|
| 131 |
- |
|
| 132 |
- |
|
| 133 |
-#ifdef DEVELOPER |
|
| 134 |
-#define PROGINFO(...) LOGC(7, __VA_ARGS__) |
|
| 135 |
-#else |
|
| 136 |
-#define PROGINFO(...) {}
|
|
| 137 |
-#endif |
|
| 138 |
- |
|
| 139 |
- |
|
| 140 |
-#define INFOC(channel, ...) Logger::log(channel, __FILE__, __LINE__, __VA_ARGS__) |
|
| 141 |
-#define INFO(...) INFOC(10, __VA_ARGS__) |
|
| 142 |
- |
|
| 143 |
-void IdeasLog(armcpu_t* cpu); |
|
| 144 |
-void NocashMessage(armcpu_t* cpu); |
|
| 145 |
- |
|
| 146 |
-enum EDEBUG_EVENT |
|
| 147 |
-{
|
|
| 148 |
- DEBUG_EVENT_READ=1, //read from arm9 or arm7 bus, including cpu prefetch |
|
| 149 |
- DEBUG_EVENT_WRITE=2, //write on arm9 or arm7 bus |
|
| 150 |
- DEBUG_EVENT_EXECUTE=4, //prefetch on arm9 or arm7, triggered after the read event |
|
| 151 |
- DEBUG_EVENT_ACL_EXCEPTION=8, //acl exception on arm9 |
|
| 152 |
-}; |
|
| 153 |
- |
|
| 154 |
-enum EDEBUG_NOTIFY |
|
| 155 |
-{
|
|
| 156 |
- DEBUG_NOTIFY_READ_BEYOND_END_OF_CART, |
|
| 157 |
- DEBUG_NOTIFY_MAX |
|
| 158 |
-}; |
|
| 159 |
- |
|
| 160 |
-class DebugNotify |
|
| 161 |
-{
|
|
| 162 |
-public: |
|
| 163 |
- void NextFrame(); |
|
| 164 |
- void ReadBeyondEndOfCart(uint32_t addr, uint32_t romsize); |
|
| 165 |
-private: |
|
| 166 |
- std::bitset<DEBUG_NOTIFY_MAX> pingBits; |
|
| 167 |
- std::bitset<DEBUG_NOTIFY_MAX> enableBits; |
|
| 168 |
- bool ping(EDEBUG_NOTIFY which); |
|
| 169 |
-}; |
|
| 170 |
- |
|
| 171 |
-extern DebugNotify DEBUG_Notify; |
|
| 172 |
-struct armcpu_t; |
|
| 173 |
- |
|
| 174 |
-//information about a debug event will be stuffed into here by the generator |
|
| 175 |
-struct TDebugEventData |
|
| 176 |
-{
|
|
| 177 |
- MMU_ACCESS_TYPE memAccessType; |
|
| 178 |
- uint32_t procnum, addr, size, val; |
|
| 179 |
- armcpu_t* cpu(); |
|
| 180 |
-}; |
|
| 181 |
- |
|
| 182 |
-extern TDebugEventData DebugEventData; |
|
| 183 |
- |
|
| 184 |
-//bits in here are set according to what debug handlers are installed? |
|
| 185 |
-//for now it is just a single bit |
|
| 186 |
-extern uint32_t debugFlag; |
|
| 187 |
- |
|
| 188 |
-inline bool CheckDebugEvent(EDEBUG_EVENT) |
|
| 189 |
-{
|
|
| 190 |
- //for now, debug events are only handled in dev+ builds |
|
| 191 |
-#ifndef DEVELOPER |
|
| 192 |
- return false; |
|
| 193 |
-#else |
|
| 194 |
- if(!debugFlag) return false; |
|
| 195 |
- |
|
| 196 |
- return true; |
|
| 197 |
-#endif |
|
| 198 |
-} |
|
| 199 |
- |
|
| 200 |
-void HandleDebugEvent_Read(); |
|
| 201 |
-void HandleDebugEvent_Write(); |
|
| 202 |
-void HandleDebugEvent_Execute(); |
|
| 203 |
-void HandleDebugEvent_ACL_Exception(); |
|
| 204 |
- |
|
| 205 |
-inline void HandleDebugEvent(EDEBUG_EVENT event) |
|
| 206 |
-{
|
|
| 207 |
- switch(event) |
|
| 208 |
- {
|
|
| 209 |
- case DEBUG_EVENT_READ: HandleDebugEvent_Read(); return; |
|
| 210 |
- case DEBUG_EVENT_WRITE: HandleDebugEvent_Write(); return; |
|
| 211 |
- case DEBUG_EVENT_EXECUTE: HandleDebugEvent_Execute(); return; |
|
| 212 |
- case DEBUG_EVENT_ACL_EXCEPTION: HandleDebugEvent_ACL_Exception(); return; |
|
| 213 |
- } |
|
| 214 |
-} |
|
| 215 |
- |
|
| 216 |
-#endif |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,216 @@ |
| 1 |
+/* Copyright (C) 2008 Guillaume Duhamel |
|
| 2 |
+ Copyright (C) 2009-2010 DeSmuME team |
|
| 3 |
+ |
|
| 4 |
+ This file is part of DeSmuME |
|
| 5 |
+ |
|
| 6 |
+ DeSmuME is free software; you can redistribute it and/or modify |
|
| 7 |
+ it under the terms of the GNU General Public License as published by |
|
| 8 |
+ the Free Software Foundation; either version 2 of the License, or |
|
| 9 |
+ (at your option) any later version. |
|
| 10 |
+ |
|
| 11 |
+ DeSmuME is distributed in the hope that it will be useful, |
|
| 12 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 13 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 14 |
+ GNU General Public License for more details. |
|
| 15 |
+ |
|
| 16 |
+ You should have received a copy of the GNU General Public License |
|
| 17 |
+ along with DeSmuME; if not, write to the Free Software |
|
| 18 |
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
| 19 |
+*/ |
|
| 20 |
+ |
|
| 21 |
+#ifndef DEBUG_H |
|
| 22 |
+#define DEBUG_H |
|
| 23 |
+ |
|
| 24 |
+#include <vector> |
|
| 25 |
+#include <iostream> |
|
| 26 |
+#include <bitset> |
|
| 27 |
+#include <cstdarg> |
|
| 28 |
+ |
|
| 29 |
+#include "types.h" |
|
| 30 |
+#include "mem.h" |
|
| 31 |
+#include "emufile.h" |
|
| 32 |
+ |
|
| 33 |
+struct DebugStatistics |
|
| 34 |
+{
|
|
| 35 |
+ DebugStatistics(); |
|
| 36 |
+ struct InstructionHits {
|
|
| 37 |
+ InstructionHits(); |
|
| 38 |
+ uint32_t thumb[1024]; |
|
| 39 |
+ uint32_t arm[4096]; |
|
| 40 |
+ } instructionHits[2]; //one for each cpu |
|
| 41 |
+ |
|
| 42 |
+ int32_t sequencerExecutionCounters[32]; |
|
| 43 |
+ |
|
| 44 |
+ void print(); |
|
| 45 |
+ void printSequencerExecutionCounters(); |
|
| 46 |
+}; |
|
| 47 |
+ |
|
| 48 |
+extern DebugStatistics DEBUG_statistics; |
|
| 49 |
+ |
|
| 50 |
+void DEBUG_reset(); |
|
| 51 |
+void DEBUG_dumpMemory(EMUFILE* fp); |
|
| 52 |
+ |
|
| 53 |
+struct armcpu_t; |
|
| 54 |
+ |
|
| 55 |
+class Logger {
|
|
| 56 |
+protected: |
|
| 57 |
+ void (*callback)(const Logger& logger, const char * format); |
|
| 58 |
+ std::ostream * out; |
|
| 59 |
+ unsigned int flags; |
|
| 60 |
+ |
|
| 61 |
+ static std::vector<Logger *> channels; |
|
| 62 |
+ |
|
| 63 |
+ static void fixSize(unsigned int channel); |
|
| 64 |
+public: |
|
| 65 |
+ Logger(); |
|
| 66 |
+ ~Logger(); |
|
| 67 |
+ |
|
| 68 |
+ void vprintf(const char * format, va_list l, const char * filename, unsigned int line); |
|
| 69 |
+ void setOutput(std::ostream * o); |
|
| 70 |
+ void setCallback(void (*cback)(const Logger& logger, const char * message)); |
|
| 71 |
+ void setFlag(unsigned int flag); |
|
| 72 |
+ |
|
| 73 |
+ std::ostream& getOutput() const; |
|
| 74 |
+ |
|
| 75 |
+ static const int LINE = 1; |
|
| 76 |
+ static const int FILE = 2; |
|
| 77 |
+ |
|
| 78 |
+ static void log(unsigned int channel, const char * file, unsigned int line, const char * format, ...); |
|
| 79 |
+ static void log(unsigned int channel, const char * file, unsigned int line, std::ostream& os); |
|
| 80 |
+ static void log(unsigned int channel, const char * file, unsigned int line, unsigned int flag); |
|
| 81 |
+ static void log(unsigned int channel, const char * file, unsigned int line, void (*callback)(const Logger& logger, const char * message)); |
|
| 82 |
+}; |
|
| 83 |
+ |
|
| 84 |
+#if defined(DEBUG) || defined(GPUDEBUG) || defined(DIVDEBUG) || defined(SQRTDEBUG) || defined(DMADEBUG) || defined(DEVELOPER) |
|
| 85 |
+#define LOGC(channel, ...) Logger::log(channel, __FILE__, __LINE__, __VA_ARGS__) |
|
| 86 |
+#else |
|
| 87 |
+#define LOGC(...) {}
|
|
| 88 |
+#endif |
|
| 89 |
+ |
|
| 90 |
+#ifdef DEBUG |
|
| 91 |
+#define LOG(...) LOGC(0, __VA_ARGS__) |
|
| 92 |
+#else |
|
| 93 |
+#define LOG(...) {}
|
|
| 94 |
+#endif |
|
| 95 |
+ |
|
| 96 |
+#ifdef GPUDEBUG |
|
| 97 |
+#define GPULOG(...) LOGC(1, __VA_ARGS__) |
|
| 98 |
+#else |
|
| 99 |
+#define GPULOG(...) {}
|
|
| 100 |
+#endif |
|
| 101 |
+ |
|
| 102 |
+#ifdef DIVDEBUG |
|
| 103 |
+#define DIVLOG(...) LOGC(2, __VA_ARGS__) |
|
| 104 |
+#else |
|
| 105 |
+#define DIVLOG(...) {}
|
|
| 106 |
+#endif |
|
| 107 |
+ |
|
| 108 |
+#ifdef SQRTDEBUG |
|
| 109 |
+#define SQRTLOG(...) LOGC(3, __VA_ARGS__) |
|
| 110 |
+#else |
|
| 111 |
+#define SQRTLOG(...) {}
|
|
| 112 |
+#endif |
|
| 113 |
+ |
|
| 114 |
+#ifdef DMADEBUG |
|
| 115 |
+#define DMALOG(...) LOGC(4, __VA_ARGS__) |
|
| 116 |
+#else |
|
| 117 |
+#define DMALOG(...) {}
|
|
| 118 |
+#endif |
|
| 119 |
+ |
|
| 120 |
+#ifdef CFLASHDEBUG |
|
| 121 |
+#define CFLASHLOG(...) LOGC(5, __VA_ARGS__) |
|
| 122 |
+#else |
|
| 123 |
+#define CFLASHLOG(...) {}
|
|
| 124 |
+#endif |
|
| 125 |
+ |
|
| 126 |
+#ifdef UNTESTEDOPCODEDEBUG |
|
| 127 |
+#define UNTESTEDOPCODELOG(...) LOGC(6, __VA_ARGS__) |
|
| 128 |
+#else |
|
| 129 |
+#define UNTESTEDOPCODELOG(...) {}
|
|
| 130 |
+#endif |
|
| 131 |
+ |
|
| 132 |
+ |
|
| 133 |
+#ifdef DEVELOPER |
|
| 134 |
+#define PROGINFO(...) LOGC(7, __VA_ARGS__) |
|
| 135 |
+#else |
|
| 136 |
+#define PROGINFO(...) {}
|
|
| 137 |
+#endif |
|
| 138 |
+ |
|
| 139 |
+ |
|
| 140 |
+#define INFOC(channel, ...) Logger::log(channel, __FILE__, __LINE__, __VA_ARGS__) |
|
| 141 |
+#define INFO(...) INFOC(10, __VA_ARGS__) |
|
| 142 |
+ |
|
| 143 |
+void IdeasLog(armcpu_t* cpu); |
|
| 144 |
+void NocashMessage(armcpu_t* cpu); |
|
| 145 |
+ |
|
| 146 |
+enum EDEBUG_EVENT |
|
| 147 |
+{
|
|
| 148 |
+ DEBUG_EVENT_READ=1, //read from arm9 or arm7 bus, including cpu prefetch |
|
| 149 |
+ DEBUG_EVENT_WRITE=2, //write on arm9 or arm7 bus |
|
| 150 |
+ DEBUG_EVENT_EXECUTE=4, //prefetch on arm9 or arm7, triggered after the read event |
|
| 151 |
+ DEBUG_EVENT_ACL_EXCEPTION=8, //acl exception on arm9 |
|
| 152 |
+}; |
|
| 153 |
+ |
|
| 154 |
+enum EDEBUG_NOTIFY |
|
| 155 |
+{
|
|
| 156 |
+ DEBUG_NOTIFY_READ_BEYOND_END_OF_CART, |
|
| 157 |
+ DEBUG_NOTIFY_MAX |
|
| 158 |
+}; |
|
| 159 |
+ |
|
| 160 |
+class DebugNotify |
|
| 161 |
+{
|
|
| 162 |
+public: |
|
| 163 |
+ void NextFrame(); |
|
| 164 |
+ void ReadBeyondEndOfCart(uint32_t addr, uint32_t romsize); |
|
| 165 |
+private: |
|
| 166 |
+ std::bitset<DEBUG_NOTIFY_MAX> pingBits; |
|
| 167 |
+ std::bitset<DEBUG_NOTIFY_MAX> enableBits; |
|
| 168 |
+ bool ping(EDEBUG_NOTIFY which); |
|
| 169 |
+}; |
|
| 170 |
+ |
|
| 171 |
+extern DebugNotify DEBUG_Notify; |
|
| 172 |
+struct armcpu_t; |
|
| 173 |
+ |
|
| 174 |
+//information about a debug event will be stuffed into here by the generator |
|
| 175 |
+struct TDebugEventData |
|
| 176 |
+{
|
|
| 177 |
+ MMU_ACCESS_TYPE memAccessType; |
|
| 178 |
+ uint32_t procnum, addr, size, val; |
|
| 179 |
+ armcpu_t* cpu(); |
|
| 180 |
+}; |
|
| 181 |
+ |
|
| 182 |
+extern TDebugEventData DebugEventData; |
|
| 183 |
+ |
|
| 184 |
+//bits in here are set according to what debug handlers are installed? |
|
| 185 |
+//for now it is just a single bit |
|
| 186 |
+extern uint32_t debugFlag; |
|
| 187 |
+ |
|
| 188 |
+inline bool CheckDebugEvent(EDEBUG_EVENT) |
|
| 189 |
+{
|
|
| 190 |
+ //for now, debug events are only handled in dev+ builds |
|
| 191 |
+#ifndef DEVELOPER |
|
| 192 |
+ return false; |
|
| 193 |
+#else |
|
| 194 |
+ if(!debugFlag) return false; |
|
| 195 |
+ |
|
| 196 |
+ return true; |
|
| 197 |
+#endif |
|
| 198 |
+} |
|
| 199 |
+ |
|
| 200 |
+void HandleDebugEvent_Read(); |
|
| 201 |
+void HandleDebugEvent_Write(); |
|
| 202 |
+void HandleDebugEvent_Execute(); |
|
| 203 |
+void HandleDebugEvent_ACL_Exception(); |
|
| 204 |
+ |
|
| 205 |
+inline void HandleDebugEvent(EDEBUG_EVENT event) |
|
| 206 |
+{
|
|
| 207 |
+ switch(event) |
|
| 208 |
+ {
|
|
| 209 |
+ case DEBUG_EVENT_READ: HandleDebugEvent_Read(); return; |
|
| 210 |
+ case DEBUG_EVENT_WRITE: HandleDebugEvent_Write(); return; |
|
| 211 |
+ case DEBUG_EVENT_EXECUTE: HandleDebugEvent_Execute(); return; |
|
| 212 |
+ case DEBUG_EVENT_ACL_EXCEPTION: HandleDebugEvent_ACL_Exception(); return; |
|
| 213 |
+ } |
|
| 214 |
+} |
|
| 215 |
+ |
|
| 216 |
+#endif |