diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 211f2dca..0e90b19b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -432,6 +432,7 @@ set(SRC_DRIVERS_SDL ${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/LuaControl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/CheatsConf.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/HexEditor.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/SymbolicDebug.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleDebugger.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleUtilities.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ConsoleVideoConf.cpp diff --git a/src/debug.h b/src/debug.h index ef21f4c1..a3772f32 100644 --- a/src/debug.h +++ b/src/debug.h @@ -59,6 +59,7 @@ typedef struct { //mbg merge 7/18/06 had to make this extern extern watchpointinfo watchpoint[65]; //64 watchpoints, + 1 reserved for step over +extern unsigned int debuggerPageSize; int getBank(int offs); int GetNesFileAddress(int A); int GetPRGAddress(int A); diff --git a/src/drivers/Qt/SymbolicDebug.cpp b/src/drivers/Qt/SymbolicDebug.cpp new file mode 100644 index 00000000..6b9ce82e --- /dev/null +++ b/src/drivers/Qt/SymbolicDebug.cpp @@ -0,0 +1,155 @@ +// SymbolicDebug.cpp +#include +#include +#include + +#include "../../types.h" +#include "../../fceu.h" +#include "../../debug.h" + +#include "Qt/SymbolicDebug.h" +#include "Qt/ConsoleUtilities.h" + +debugSymbolTable_t debugSymbolTable; + +//-------------------------------------------------------------- +// debugSymbolPage_t +//-------------------------------------------------------------- +debugSymbolPage_t::debugSymbolPage_t(void) +{ + pageNum = 0; + +} +//-------------------------------------------------------------- +debugSymbolPage_t::~debugSymbolPage_t(void) +{ + std::map ::iterator it; + + for (it=symMap.begin(); it!=symMap.end(); it++) + { + delete it->second; + } + symMap.clear(); +} +//-------------------------------------------------------------- +// debugSymbolTable_t +//-------------------------------------------------------------- +debugSymbolTable_t::debugSymbolTable_t(void) +{ + +} +//-------------------------------------------------------------- +debugSymbolTable_t::~debugSymbolTable_t(void) +{ + this->clear(); +} +//-------------------------------------------------------------- +void debugSymbolTable_t::clear(void) +{ + std::map ::iterator it; + + for (it=pageMap.begin(); it!=pageMap.end(); it++) + { + delete it->second; + } + pageMap.clear(); +} +//-------------------------------------------------------------- +static int generateNLFilenameForAddress(int address, char *NLfilename) +{ + int i; + const char *romFile; + + romFile = getRomFile(); + + if ( romFile == NULL ) + { + return -1; + } + i=0; + while ( romFile[i] != 0 ) + { + + if ( romFile[i] == '|' ) + { + NLfilename[i] = '.'; + } + else + { + NLfilename[i] = romFile[i]; + } + i++; + } + NLfilename[i] = 0; + + if (address < 0x8000) + { + // The NL file for the RAM addresses has the name nesrom.nes.ram.nl + strcat(NLfilename, ".ram.nl"); + } + else + { + int bank = getBank(address); + char stmp[64]; + #ifdef DW3_NL_0F_1F_HACK + if(bank == 0x0F) + bank = 0x1F; + #endif + sprintf( stmp, ".%X.nl", bank); + strcat(NLfilename, stmp ); + } + return 0; +} +//-------------------------------------------------------------- +int debugSymbolTable_t::loadFileNL( int addr ) +{ + FILE *fp; + char fileName[512], line[256]; + + printf("Looking to Load Debug Addr: $%04X \n", addr ); + + if ( generateNLFilenameForAddress( addr, fileName ) ) + { + return -1; + } + printf("Loading NL File: %s\n", fileName ); + + fp = ::fopen( fileName, "r" ); + + if ( fp == NULL ) + { + return -1; + } + while ( fgets( line, sizeof(line), fp ) != 0 ) + { + printf("%s", line ); + } + + ::fclose(fp); + + return 0; +} +//-------------------------------------------------------------- +int debugSymbolTable_t::loadGameSymbols(void) +{ + int nPages; + + this->clear(); + + loadFileNL( 0x0000 ); + + nPages = 1<<(15-debuggerPageSize); + + for(int i=0;i +#include +#include + +struct debugSymbol_t +{ + int addr; + std::string name; + std::string comment; + + debugSymbol_t(void) + { + addr = 0; + }; +}; + +struct debugSymbolPage_t +{ + int pageNum; + + debugSymbolPage_t(void); + ~debugSymbolPage_t(void); + + std::map symMap; +}; + +class debugSymbolTable_t +{ + + public: + debugSymbolTable_t(void); + ~debugSymbolTable_t(void); + + int loadFileNL( int addr ); + int loadGameSymbols(void); + + void clear(void); + + private: + std::map pageMap; + + +}; + +extern debugSymbolTable_t debugSymbolTable; + +//struct MemoryMappedRegister +//{ +// char* offset; +// char* name; +//}; + + + +#endif diff --git a/src/drivers/Qt/fceuWrapper.cpp b/src/drivers/Qt/fceuWrapper.cpp index 84eb5ae8..08faab7e 100644 --- a/src/drivers/Qt/fceuWrapper.cpp +++ b/src/drivers/Qt/fceuWrapper.cpp @@ -15,6 +15,7 @@ #include "Qt/nes_shm.h" #include "Qt/unix-netplay.h" #include "Qt/HexEditor.h" +#include "Qt/SymbolicDebug.h" #include "Qt/ConsoleWindow.h" #include "Qt/fceux_git_info.h" @@ -229,6 +230,8 @@ int LoadGame(const char *path) hexEditorLoadBookmarks(); + debugSymbolTable.loadGameSymbols(); + int state_to_load; g_config->getOption("SDL.AutoLoadState", &state_to_load); if (state_to_load >= 0 && state_to_load < 10){