Fixed Tracer, changed Symbolic Names and Comments display
This commit is contained in:
parent
07fa1f268f
commit
572ac98f02
|
@ -86,7 +86,9 @@ bool debuggerSaveLoadDEBFiles = true;
|
|||
bool debuggerDisplayROMoffsets = false;
|
||||
|
||||
char debug_str[35000] = {0};
|
||||
char debug_str_decoration[NL_MAX_MULTILINE_COMMENT_LEN + NL_MAX_NAME_LEN + 10] = {0};
|
||||
char* debug_decoration_name;
|
||||
char* debug_decoration_comment;
|
||||
char debug_str_decoration_comment[NL_MAX_MULTILINE_COMMENT_LEN + 2] = {0};
|
||||
|
||||
// this is used to keep track of addresses that lines of Disassembly window correspont to
|
||||
std::vector<unsigned int> disassembly_addresses;
|
||||
|
@ -390,21 +392,34 @@ void Disassemble(HWND hWnd, int id, int scrollid, unsigned int addr)
|
|||
if (symbDebugEnabled)
|
||||
{
|
||||
// Insert Name and Comment lines if needed
|
||||
debug_str_decoration[0] = 0;
|
||||
decorateAddress(addr, debug_str_decoration);
|
||||
if (debug_str_decoration[0])
|
||||
debug_decoration_name = 0;
|
||||
debug_decoration_comment = 0;
|
||||
decorateAddress(addr, &debug_decoration_name, &debug_decoration_comment);
|
||||
if (debug_decoration_name)
|
||||
{
|
||||
// divide the str_decoration into strings (Name, Comment1, Comment2, ...)
|
||||
char* start_pos = debug_str_decoration;
|
||||
char* end_pos = strstr(debug_str_decoration, "\r");
|
||||
strcat(debug_str, debug_decoration_name);
|
||||
strcat(debug_str, ": \r\n");
|
||||
// we added one line to the disassembly window
|
||||
disassembly_addresses.push_back(addr);
|
||||
i++;
|
||||
}
|
||||
if (debug_decoration_comment)
|
||||
{
|
||||
// make a copy
|
||||
strcpy(debug_str_decoration_comment, debug_decoration_comment);
|
||||
strcat(debug_str_decoration_comment, "\r\n");
|
||||
debug_decoration_comment = debug_str_decoration_comment;
|
||||
// divide the debug_str_decoration_comment into strings (Comment1, Comment2, ...)
|
||||
char* end_pos = strstr(debug_decoration_comment, "\r");
|
||||
while (end_pos)
|
||||
{
|
||||
end_pos[0] = 0; // set \0 instead of \r
|
||||
strcat(debug_str, start_pos);
|
||||
strcat(debug_str, "// ");
|
||||
strcat(debug_str, debug_decoration_comment);
|
||||
strcat(debug_str, "\r\n");
|
||||
end_pos += 2;
|
||||
start_pos = end_pos;
|
||||
end_pos = strstr(end_pos, "\r");
|
||||
debug_decoration_comment = end_pos;
|
||||
end_pos = strstr(debug_decoration_comment, "\r");
|
||||
// we added one line to the disassembly window
|
||||
disassembly_addresses.push_back(addr);
|
||||
i++;
|
||||
|
|
|
@ -40,6 +40,7 @@ extern char LoadedRomFName[2048];
|
|||
char NLfilename[2048];
|
||||
char symbDebugEnabled = 0;
|
||||
int debuggerWasActive = 0;
|
||||
char temp_chr[40] = {0};
|
||||
|
||||
extern BOOL CALLBACK nameBookmarkCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
extern char bookmarkDescription[];
|
||||
|
@ -600,16 +601,12 @@ void loadNameFiles()
|
|||
}
|
||||
|
||||
/**
|
||||
* Adds label and comment to an offset in the disassembly output string
|
||||
* Returns pointers to name and comment to an offset in the disassembly output string
|
||||
*
|
||||
* @param addr Address of the currently processed line
|
||||
* @param str Disassembly output string
|
||||
**/
|
||||
void decorateAddress(unsigned int addr, char* str)
|
||||
void decorateAddress(unsigned int addr, char** str_name, char** str_comment)
|
||||
{
|
||||
Name* n;
|
||||
|
||||
char temp_chr[40];
|
||||
sprintf(temp_chr, "$%04X", addr);
|
||||
|
||||
if (addr < 0x8000)
|
||||
|
@ -622,24 +619,15 @@ void decorateAddress(unsigned int addr, char* str)
|
|||
n = addr >= 0xC000 ? searchNode(lastBankNames, temp_chr) : searchNode(loadedBankNames, temp_chr);
|
||||
}
|
||||
|
||||
// If a node was found there's a name or comment to add do so
|
||||
if (n && (n->name || n->comment))
|
||||
if (n)
|
||||
{
|
||||
// Add name
|
||||
// Return pointer to name
|
||||
if (n->name && *n->name)
|
||||
{
|
||||
strcat(str, "Name: ");
|
||||
strcat(str, n->name);
|
||||
strcat(str,"\r\n");
|
||||
}
|
||||
*str_name = n->name;
|
||||
|
||||
// Add comment
|
||||
// Return pointer to comment
|
||||
if (n->comment && *n->comment)
|
||||
{
|
||||
strcat(str, "Comment: ");
|
||||
strcat(str, n->comment);
|
||||
strcat(str, "\r\n");
|
||||
}
|
||||
*str_comment = n->comment;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ extern int debuggerWasActive;
|
|||
|
||||
int checkCondition(const char* buffer, int num);
|
||||
void loadNameFiles();
|
||||
void decorateAddress(unsigned int addr, char* str);
|
||||
void decorateAddress(unsigned int addr, char** str_name, char** str_comment);
|
||||
void replaceNames(Name* list, char* str);
|
||||
void AddDebuggerBookmark(HWND hwnd);
|
||||
void AddDebuggerBookmark2(HWND hwnd, unsigned int addr);
|
||||
|
|
|
@ -76,7 +76,10 @@ int tracelogbufusedsize;
|
|||
char str_axystate[LOG_AXYSTATE_MAX_LEN] = {0}, str_procstatus[LOG_PROCSTATUS_MAX_LEN] = {0};
|
||||
char str_tabs[LOG_TABS_MASK+1] = {0}, str_address[LOG_ADDRESS_MAX_LEN] = {0}, str_data[LOG_DATA_MAX_LEN] = {0}, str_disassembly[LOG_DISASSEMBLY_MAX_LEN] = {0};
|
||||
char str_temp[LOG_LINE_MAX_LEN] = {0};
|
||||
char str_decoration[NL_MAX_MULTILINE_COMMENT_LEN + NL_MAX_NAME_LEN + 10] = {0};
|
||||
char* tracer_decoration_name;
|
||||
char* tracer_decoration_comment;
|
||||
char str_decoration[NL_MAX_MULTILINE_COMMENT_LEN + 2] = {0};
|
||||
char str_decoration_comment[NL_MAX_MULTILINE_COMMENT_LEN + 2] = {0};
|
||||
|
||||
bool log_old_emu_paused = true; // thanks to this flag the window only updates once after the game is paused
|
||||
extern bool JustFrameAdvanced;
|
||||
|
@ -385,7 +388,7 @@ void FCEUD_TraceInstruction(uint8 *opcode, int size)
|
|||
case 1:
|
||||
{
|
||||
sprintf(str_data, "%02X ", opcode[0]);
|
||||
a = Disassemble(addr, opcode);
|
||||
a = Disassemble(addr + 1, opcode);
|
||||
// special case: an RTS opcode
|
||||
if (opcode[0] == 0x60)
|
||||
{
|
||||
|
@ -399,11 +402,11 @@ void FCEUD_TraceInstruction(uint8 *opcode, int size)
|
|||
}
|
||||
case 2:
|
||||
sprintf(str_data, "%02X %02X ", opcode[0],opcode[1]);
|
||||
a = Disassemble(addr, opcode);
|
||||
a = Disassemble(addr + 2, opcode);
|
||||
break;
|
||||
case 3:
|
||||
sprintf(str_data, "%02X %02X %02X ", opcode[0],opcode[1],opcode[2]);
|
||||
a = Disassemble(addr, opcode);
|
||||
a = Disassemble(addr + 3, opcode);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -412,20 +415,32 @@ void FCEUD_TraceInstruction(uint8 *opcode, int size)
|
|||
if (logging_options & LOG_SYMBOLIC)
|
||||
{
|
||||
// Insert Name and Comment lines if needed
|
||||
str_decoration[0] = 0;
|
||||
decorateAddress(addr, str_decoration);
|
||||
if (str_decoration[0])
|
||||
tracer_decoration_name = 0;
|
||||
tracer_decoration_comment = 0;
|
||||
decorateAddress(addr, &tracer_decoration_name, &tracer_decoration_comment);
|
||||
if (tracer_decoration_name)
|
||||
{
|
||||
// divide the str_decoration into strings (Name, Comment1, Comment2, ...)
|
||||
char* start_pos = str_decoration;
|
||||
char* end_pos = strstr(str_decoration, "\r");
|
||||
strcpy(str_decoration, tracer_decoration_name);
|
||||
strcat(str_decoration, ": ");
|
||||
OutputLogLine(str_decoration, true);
|
||||
}
|
||||
if (tracer_decoration_comment)
|
||||
{
|
||||
// make a copy
|
||||
strcpy(str_decoration_comment, tracer_decoration_comment);
|
||||
strcat(str_decoration_comment, "\r\n");
|
||||
tracer_decoration_comment = str_decoration_comment;
|
||||
// divide the str_decoration_comment into strings (Comment1, Comment2, ...)
|
||||
char* end_pos = strstr(tracer_decoration_comment, "\r");
|
||||
while (end_pos)
|
||||
{
|
||||
end_pos[0] = 0; // set \0 instead of \r
|
||||
OutputLogLine(start_pos, true);
|
||||
strcpy(str_decoration, "// ");
|
||||
strcat(str_decoration, tracer_decoration_comment);
|
||||
OutputLogLine(str_decoration, true);
|
||||
end_pos += 2;
|
||||
start_pos = end_pos;
|
||||
end_pos = strstr(end_pos, "\r");
|
||||
tracer_decoration_comment = end_pos;
|
||||
end_pos = strstr(tracer_decoration_comment, "\r");
|
||||
}
|
||||
}
|
||||
replaceNames(ramBankNames, a);
|
||||
|
@ -601,8 +616,11 @@ void UpdateLogText(void)
|
|||
int i, j;
|
||||
char str[3000];
|
||||
str[0] = 0;
|
||||
int last_line = tracesi.nPos + tracesi.nPage;
|
||||
if (last_line > tracesi.nMax)
|
||||
last_line = tracesi.nMax;
|
||||
|
||||
for(i = tracesi.nPos;i < std::min(tracesi.nMax,tracesi.nPos+21);i++)
|
||||
for(i = tracesi.nPos; i < last_line; i++)
|
||||
{
|
||||
j = i;
|
||||
if(tracelogbufusedsize == tracelogbufsize)
|
||||
|
|
Loading…
Reference in New Issue