Updates to debug symbol loader.

This commit is contained in:
Matthew Budd 2020-09-15 22:53:36 -04:00
parent b37fb45172
commit c62dfd464f
4 changed files with 55 additions and 25 deletions

View File

@ -792,7 +792,7 @@ void ConsoleDebugger::openDebugSymbolEditWindow( int addr )
if ( addr < 0x8000 )
{
bank = 0;
bank = -1;
}
else
{

View File

@ -47,8 +47,8 @@ struct dbg_asm_entry_t
dbg_asm_entry_t(void)
{
addr = 0; bank = 0; rom = -1;
size = 0; line = 0; type = ASM_TEXT;
addr = 0; bank = -1; rom = -1;
size = 0; line = 0; type = ASM_TEXT;
for (int i=0; i<3; i++)
{

View File

@ -6,6 +6,9 @@
#include "../../types.h"
#include "../../fceu.h"
#include "../../debug.h"
#include "../../driver.h"
#include "../../cart.h"
#include "../../ines.h"
#include "Qt/SymbolicDebug.h"
#include "Qt/ConsoleUtilities.h"
@ -17,7 +20,7 @@ debugSymbolTable_t debugSymbolTable;
//--------------------------------------------------------------
debugSymbolPage_t::debugSymbolPage_t(void)
{
pageNum = 0;
pageNum = -1;
}
//--------------------------------------------------------------
@ -92,7 +95,11 @@ int debugSymbolPage_t::save(void)
}
stmp[i] = 0;
if ( pageNum > 0 )
if ( pageNum < 0 )
{
strcat( stmp, ".ram.nl" );
}
else
{
char suffix[32];
@ -100,10 +107,6 @@ int debugSymbolPage_t::save(void)
strcat( stmp, suffix );
}
else
{
strcat( stmp, ".ram.nl" );
}
fp = fopen( stmp, "w" );
@ -203,6 +206,25 @@ void debugSymbolTable_t::clear(void)
}
//--------------------------------------------------------------
int generateNLFilenameForAddress(int address, char *NLfilename)
{
int bank;
if (address < 0x8000)
{
bank = -1;
}
else
{
bank = getBank(address);
#ifdef DW3_NL_0F_1F_HACK
if(bank == 0x0F)
bank = 0x1F;
#endif
}
return generateNLFilenameForBank( bank, NLfilename );
}
//--------------------------------------------------------------
int generateNLFilenameForBank(int bank, char *NLfilename)
{
int i;
const char *romFile;
@ -229,14 +251,13 @@ int generateNLFilenameForAddress(int address, char *NLfilename)
}
NLfilename[i] = 0;
if (address < 0x8000)
if (bank < 0)
{
// 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)
@ -248,7 +269,7 @@ int generateNLFilenameForAddress(int address, char *NLfilename)
return 0;
}
//--------------------------------------------------------------
int debugSymbolTable_t::loadFileNL( int addr )
int debugSymbolTable_t::loadFileNL( int bank )
{
FILE *fp;
int i, j, ofs, lineNum = 0, literal = 0;
@ -257,9 +278,9 @@ int debugSymbolTable_t::loadFileNL( int addr )
debugSymbolPage_t *page = NULL;
debugSymbol_t *sym = NULL;
printf("Looking to Load Debug Addr: $%04X \n", addr );
printf("Looking to Load Debug Bank: $%X \n", bank );
if ( generateNLFilenameForAddress( addr, fileName ) )
if ( generateNLFilenameForBank( bank, fileName ) )
{
return -1;
}
@ -273,10 +294,8 @@ int debugSymbolTable_t::loadFileNL( int addr )
}
page = new debugSymbolPage_t;
if ( addr >= 0x8000 )
{
page->pageNum = getBank( addr );
}
page->pageNum = bank;
pageMap[ page->pageNum ] = page;
while ( fgets( line, sizeof(line), fp ) != 0 )
@ -454,23 +473,33 @@ int debugSymbolTable_t::loadFileNL( int addr )
//--------------------------------------------------------------
int debugSymbolTable_t::loadGameSymbols(void)
{
int nPages;
int nPages, pageSize, romSize = 0x10000;
this->save();
this->clear();
loadFileNL( 0x0000 );
if ( GameInfo != NULL )
{
romSize = 16 + CHRsize[0] + PRGsize[0];
}
nPages = 1<<(15-debuggerPageSize);
loadFileNL( -1 );
pageSize = (1<<debuggerPageSize);
//nPages = 1<<(15-debuggerPageSize);
nPages = romSize / pageSize;
printf("RomSize: %i NumPages: %i \n", romSize, nPages );
for(int i=0;i<nPages;i++)
{
int pageIndexAddress = 0x8000 + (1<<debuggerPageSize)*i;
//int pageIndexAddress = 0x8000 + (1<<debuggerPageSize)*i;
//int pageIndexAddress = pageSize*i;
// Find out which bank is loaded at the page index
//cb = getBank(pageIndexAddress);
printf("Loading Page Offset: $%06X\n", pageSize*i );
loadFileNL( pageIndexAddress );
loadFileNL( i );
}
print();

View File

@ -70,6 +70,7 @@ extern debugSymbolTable_t debugSymbolTable;
//};
int generateNLFilenameForBank(int bank, char *NLfilename);
int generateNLFilenameForAddress(int address, char *NLfilename);
#endif