* Debugger: fixed Symbolic Debugging (Names and Comments display)

* Debugger: special strings (NMI/IRQ/etc) can be also used in "Seek To" field and Bookmarks
* updated docs

[[Split portion of a mixed commit.]]
This commit is contained in:
ansstuff 2012-09-06 15:00:27 +00:00
parent 7d6cd1f2ff
commit a0fc6b9680
6 changed files with 60 additions and 62 deletions

View File

@ -20,7 +20,7 @@ int vblankPixel = 0; //Used to calculate the pixels in vblank
int offsetStringToInt(unsigned int type, const char* offsetBuffer)
{
int offset = 0;
int offset = -1;
if (sscanf(offsetBuffer,"%4X",&offset) == EOF)
{

View File

@ -371,6 +371,13 @@ void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr) {
// PC pointer
if (addr > 0xFFFF) break;
// ################################## Start of SP CODE ###########################
if (symbDebugEnabled)
decorateAddress(addr, str);
// ################################## End of SP CODE ###########################
if (addr == X.PC)
strcat(str, ">");
else
@ -390,13 +397,12 @@ void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr) {
sprintf(chr, " :%04X", addr);
}
// ################################## Start of SP CODE ###########################
// Add address
strcat(str, chr);
strcat(str, ":");
decorateAddress(addr, str, chr, symbDebugEnabled);
// ################################## End of SP CODE ###########################
if ((size = opsize[GetMem(addr)]) == 0) {
if ((size = opsize[GetMem(addr)]) == 0)
{
sprintf(chr, "%02X UNDEFINED", GetMem(addr++));
strcat(str,chr);
}
@ -431,7 +437,7 @@ void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr) {
// ################################## End of SP CODE ###########################
strcat(strcat(str," "),a);
strcat(strcat(str," "), a);
}
strcat(str,"\r\n");
}
@ -1689,18 +1695,22 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
}
break;
case IDC_DEBUGGER_SEEK_TO:
{
//mbg merge 7/18/06 changed pausing check
if (FCEUI_EmulationPaused()) UpdateRegs(hwndDlg);
GetDlgItemText(hwndDlg,IDC_DEBUGGER_VAL_PCSEEK,str,5);
if (((ret = sscanf(str,"%4X",&tmp)) == EOF) || (ret != 1)) tmp = 0;
sprintf(str,"%04X",tmp);
SetDlgItemText(hwndDlg,IDC_DEBUGGER_VAL_PCSEEK,str);
Disassemble(hDebug, IDC_DEBUGGER_DISASSEMBLY, IDC_DEBUGGER_DISASSEMBLY_VSCR, tmp);
// "Address Bookmark Add" follows the address
sprintf(str,"%04X", si.nPos);
SetDlgItemText(hDebug, IDC_DEBUGGER_BOOKMARK, str);
tmp = offsetStringToInt(BT_C, str);
if (tmp != -1)
{
sprintf(str,"%04X", tmp);
SetDlgItemText(hwndDlg,IDC_DEBUGGER_VAL_PCSEEK,str);
Disassemble(hDebug, IDC_DEBUGGER_DISASSEMBLY, IDC_DEBUGGER_DISASSEMBLY_VSCR, tmp);
// "Address Bookmark Add" follows the address
sprintf(str,"%04X", si.nPos);
SetDlgItemText(hDebug, IDC_DEBUGGER_BOOKMARK, str);
}
break;
}
case IDC_DEBUGGER_BREAK_ON_BAD_OP: //Break on bad opcode
FCEUI_Debugger().badopbreak ^= 1;
break;

View File

@ -614,50 +614,44 @@ void loadNameFiles()
*
* @param addr Address of the currently processed line
* @param str Disassembly output string
* @param chr Address in string format
* @param decorate Flag that indicates whether label and comment should actually be added
**/
void decorateAddress(unsigned int addr, char* str, const char* chr, UINT decorate)
void decorateAddress(unsigned int addr, char* str)
{
if (decorate)
Name* n;
char temp_chr[40];
sprintf(temp_chr, "$%04X", addr);
if (addr < 0x8000)
{
Name* n;
// Search address definition node for a RAM address
n = searchNode(ramBankNames, temp_chr);
}
else
{
// Search address definition node for a ROM address
n = addr >= 0xC000 ? searchNode(lastBankNames, temp_chr) : searchNode(loadedBankNames, temp_chr);
}
if (addr < 0x8000)
// If a node was found there's a name or comment to add do so
if (n && (n->name || n->comment))
{
// Add name
if (n->name && *n->name)
{
// Search address definition node for a RAM address
n = searchNode(ramBankNames, chr);
strcat(str, "Name: ");
strcat(str, n->name);
strcat(str,"\r\n");
}
else
{
// Search address definition node for a ROM address
n = addr >= 0xC000 ? searchNode(lastBankNames, chr) : searchNode(loadedBankNames, chr);
}
// If a node was found there's a name or comment to add do so
if (n && (n->name || n->comment))
{
// Add name
if (n->name && *n->name)
{
strcat(str, "Name: ");
strcat(str, n->name);
strcat(str,"\r\n");
}
// Add comment
if (n->comment && *n->comment)
{
strcat(str, "Comment: ");
strcat(str, n->comment);
strcat(str, "\r\n");
}
// Add comment
if (n->comment && *n->comment)
{
strcat(str, "Comment: ");
strcat(str, n->comment);
strcat(str, "\r\n");
}
}
// Add address
strcat(str, chr);
strcat(str, ":");
}
/**
@ -671,11 +665,9 @@ unsigned int getBookmarkAddress(HWND hwnd, unsigned int index)
{
int n;
char buffer[5] = {0};
SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_GETTEXT, index, (LPARAM)buffer);
sscanf(buffer, "%x", &n);
n = offsetStringToInt(BT_C, buffer);
return n;
}
@ -730,21 +722,17 @@ void AddDebuggerBookmark2(HWND hwnd, char* buffer)
**/
void AddDebuggerBookmark(HWND hwnd)
{
int result;
unsigned int n;
char buffer[5] = {0};
GetDlgItemText(hwnd, IDC_DEBUGGER_BOOKMARK, buffer, 5);
result = sscanf(buffer, "%x", &n);
n = offsetStringToInt(BT_C, buffer);
// Make sure the offset is valid
if (result != 1 || n > 0xFFFF)
if (n == -1 || n > 0xFFFF)
{
MessageBox(hwnd, "Invalid offset", "Error", MB_OK | MB_ICONERROR);
return;
}
AddDebuggerBookmark2(hwnd, buffer);
}

View File

@ -36,7 +36,7 @@ extern int debuggerWasActive;
int checkCondition(const char* buffer, int num);
void loadNameFiles();
void decorateAddress(unsigned int addr, char* str, const char* chr, UINT);
void decorateAddress(unsigned int addr, char* str);
void replaceNames(Name* list, char* str);
void AddDebuggerBookmark(HWND hwnd);
void AddDebuggerBookmark2(HWND hwnd, char* buffer);

Binary file not shown.

Binary file not shown.