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

View File

@ -614,50 +614,44 @@ void loadNameFiles()
* *
* @param addr Address of the currently processed line * @param addr Address of the currently processed line
* @param str Disassembly output string * @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);
if (addr < 0x8000) }
{ else
// Search address definition node for a RAM address {
n = searchNode(ramBankNames, chr); // Search address definition node for a ROM address
} n = addr >= 0xC000 ? searchNode(lastBankNames, temp_chr) : searchNode(loadedBankNames, temp_chr);
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 address // If a node was found there's a name or comment to add do so
strcat(str, chr); if (n && (n->name || n->comment))
strcat(str, ":"); {
// 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");
}
}
} }
/** /**
@ -673,9 +667,7 @@ unsigned int getBookmarkAddress(HWND hwnd, unsigned int index)
char buffer[5] = {0}; char buffer[5] = {0};
SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_GETTEXT, index, (LPARAM)buffer); SendDlgItemMessage(hwnd, LIST_DEBUGGER_BOOKMARKS, LB_GETTEXT, index, (LPARAM)buffer);
n = offsetStringToInt(BT_C, buffer);
sscanf(buffer, "%x", &n);
return n; return n;
} }
@ -730,21 +722,17 @@ void AddDebuggerBookmark2(HWND hwnd, char* buffer)
**/ **/
void AddDebuggerBookmark(HWND hwnd) void AddDebuggerBookmark(HWND hwnd)
{ {
int result;
unsigned int n; unsigned int n;
char buffer[5] = {0}; char buffer[5] = {0};
GetDlgItemText(hwnd, IDC_DEBUGGER_BOOKMARK, buffer, 5); GetDlgItemText(hwnd, IDC_DEBUGGER_BOOKMARK, buffer, 5);
n = offsetStringToInt(BT_C, buffer);
result = sscanf(buffer, "%x", &n);
// Make sure the offset is valid // 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); MessageBox(hwnd, "Invalid offset", "Error", MB_OK | MB_ICONERROR);
return; return;
} }
AddDebuggerBookmark2(hwnd, buffer); AddDebuggerBookmark2(hwnd, buffer);
} }

View File

@ -36,7 +36,7 @@ extern int debuggerWasActive;
int checkCondition(const char* buffer, int num); int checkCondition(const char* buffer, int num);
void loadNameFiles(); 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 replaceNames(Name* list, char* str);
void AddDebuggerBookmark(HWND hwnd); void AddDebuggerBookmark(HWND hwnd);
void AddDebuggerBookmark2(HWND hwnd, char* buffer); void AddDebuggerBookmark2(HWND hwnd, char* buffer);

Binary file not shown.

Binary file not shown.