Patch new core debug symbol table into win port.

This commit is contained in:
harry 2023-02-04 07:25:39 -05:00
parent 5bdbdd61b1
commit fa7da51ccd
4 changed files with 45 additions and 4 deletions

View File

@ -38,6 +38,7 @@ debugSymbolPage_t::~debugSymbolPage_t(void)
//--------------------------------------------------------------
int debugSymbolPage_t::addSymbol( debugSymbol_t*sym )
{
// Check if symbol already is loaded by that name or offset
if ( symMap.count( sym->ofs ) || symNameMap.count( sym->name ) )
{
return -1;
@ -631,9 +632,23 @@ int debugSymbolTable_t::loadGameSymbols(void)
return 0;
}
int debugSymbolTable_t::addSymbolAtBankOffset(int bank, int ofs, const char *name, const char *comment)
{
int result = -1;
debugSymbol_t *sym = new debugSymbol_t(ofs, name, comment);
result = addSymbolAtBankOffset(bank, ofs, sym);
if (result)
{ // Symbol add failed
delete sym;
}
return result;
}
//--------------------------------------------------------------
int debugSymbolTable_t::addSymbolAtBankOffset( int bank, int ofs, debugSymbol_t *sym )
{
int result = -1;
debugSymbolPage_t *page;
std::map <int, debugSymbolPage_t*>::iterator it;
FCEU::autoScopedLock alock(cs);
@ -650,9 +665,9 @@ int debugSymbolTable_t::addSymbolAtBankOffset( int bank, int ofs, debugSymbol_t
{
page = it->second;
}
page->addSymbol( sym );
result = page->addSymbol( sym );
return 0;
return result;
}
//--------------------------------------------------------------
int debugSymbolTable_t::deleteSymbolAtBankOffset( int bank, int ofs )

View File

@ -17,11 +17,14 @@ struct debugSymbol_t
ofs = 0;
};
debugSymbol_t( int ofs, const char *name, const char *comment = NULL )
debugSymbol_t( int ofs, const char *name, const char *comment = nullptr )
{
this->ofs = ofs;
this->name.assign( name );
if (name)
{
this->name.assign(name);
}
if ( comment )
{
this->comment.assign( comment );
@ -101,6 +104,8 @@ class debugSymbolTable_t
int addSymbolAtBankOffset( int bank, int ofs, debugSymbol_t *sym );
int addSymbolAtBankOffset(int bank, int ofs, const char* name, const char* comment = nullptr);
int deleteSymbolAtBankOffset( int bank, int ofs );
private:

View File

@ -25,6 +25,7 @@
#include "../../fceu.h"
#include "../../ines.h"
#include "../../debug.h"
#include "../../debugsymboltable.h"
#include "../../conddebug.h"
#include <stdio.h>
@ -671,6 +672,16 @@ char* generateNLFilenameForAddress(uint16 address)
}
return NLfilename;
}
static int getRomPageIndexForAddress(uint16 address)
{
int page = -1;
if (address >= 0x8000)
{
page = RomPageIndexForAddress(address);
}
return page;
}
Name* getNamesPointerForAddress(uint16 address)
{
if(address >= 0x8000)
@ -1107,6 +1118,7 @@ void AddNewSymbolicName(uint16 newAddress, char* newOffset, char* newName, char*
if (*newName || *newComment)
{
int i = 0;
int bank = -1;
char* tmpNewOffset = (char*)malloc(strlen(newOffset) + 1);
strcpy(tmpNewOffset, newOffset);
uint16 tmpNewAddress = newAddress;
@ -1150,6 +1162,8 @@ void AddNewSymbolicName(uint16 newAddress, char* newOffset, char* newName, char*
node->next = 0;
setNamesPointerForAddress(tmpNewAddress, node);
debugSymbolTable.addSymbolAtBankOffset(getRomPageIndexForAddress(tmpNewAddress), tmpNewAddress, node->name, node->comment);
}
else
{
@ -1233,6 +1247,7 @@ void AddNewSymbolicName(uint16 newAddress, char* newOffset, char* newName, char*
newNode->next = 0;
node->next = newNode;
debugSymbolTable.addSymbolAtBankOffset(getRomPageIndexForAddress(tmpNewAddress), tmpNewAddress, newNode->name, newNode->comment);
break;
}
}
@ -1270,6 +1285,7 @@ void DeleteSymbolicName(uint16 address, int size)
prev = node;
node = node->next;
}
debugSymbolTable.deleteSymbolAtBankOffset(getRomPageIndexForAddress(tmpAddress), tmpAddress);
++tmpAddress;
} while (++i < size);
}

View File

@ -28,6 +28,7 @@
#include "../../cheat.h" //adelikat: For FCEU_LoadGameCheats()
#include "../../version.h"
#include "../../video.h" //adelikat: For ScreenshotAs Get/Set functions
#include "../../debugsymboltable.h"
#include "window.h"
#include "main.h"
#include "state.h"
@ -1073,6 +1074,7 @@ void CloseGame()
updateGameDependentMenus();
updateGameDependentMenusDebugger();
SetMainWindowText();
debugSymbolTable.clear();
}
}
@ -1153,6 +1155,9 @@ bool ALoad(const char *nameo, char* innerFilename, bool silent)
{
DoDebug(0);
}
// Clear and Load core debug symbol table
debugSymbolTable.clear();
debugSymbolTable.loadGameSymbols();
}
else
{