Added initial framework for symbolic debug feature in Qt port.
This commit is contained in:
parent
d1f689ef61
commit
f442404149
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -0,0 +1,155 @@
|
|||
// SymbolicDebug.cpp
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#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 <int, debugSymbol_t*>::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 <int, debugSymbolPage_t*>::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<nPages;i++)
|
||||
{
|
||||
int pageIndexAddress = 0x8000 + (1<<debuggerPageSize)*i;
|
||||
|
||||
// Find out which bank is loaded at the page index
|
||||
//cb = getBank(pageIndexAddress);
|
||||
|
||||
loadFileNL( pageIndexAddress );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
//--------------------------------------------------------------
|
|
@ -0,0 +1,60 @@
|
|||
// SymbolicDebug.h
|
||||
//
|
||||
#ifndef __SYMBOLIC_DEBUG_H__
|
||||
#define __SYMBOLIC_DEBUG_H__
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
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 <int, debugSymbol_t*> symMap;
|
||||
};
|
||||
|
||||
class debugSymbolTable_t
|
||||
{
|
||||
|
||||
public:
|
||||
debugSymbolTable_t(void);
|
||||
~debugSymbolTable_t(void);
|
||||
|
||||
int loadFileNL( int addr );
|
||||
int loadGameSymbols(void);
|
||||
|
||||
void clear(void);
|
||||
|
||||
private:
|
||||
std::map <int, debugSymbolPage_t*> pageMap;
|
||||
|
||||
|
||||
};
|
||||
|
||||
extern debugSymbolTable_t debugSymbolTable;
|
||||
|
||||
//struct MemoryMappedRegister
|
||||
//{
|
||||
// char* offset;
|
||||
// char* name;
|
||||
//};
|
||||
|
||||
|
||||
|
||||
#endif
|
|
@ -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){
|
||||
|
|
Loading…
Reference in New Issue