* Tracer: added "Log Cycles count" and "Log Instructions count" options

This commit is contained in:
ansstuff 2013-04-16 16:12:45 +00:00
parent f63e190e35
commit acc1a07c1e
7 changed files with 180 additions and 146 deletions

View File

@ -441,14 +441,14 @@ int skipdebug; //deleteme
int numWPs;
// for CPU cycles and Instructions counters
unsigned long int total_cycles_base = 0;
unsigned long int delta_cycles_base = 0;
uint64 total_cycles_base = 0;
uint64 delta_cycles_base = 0;
bool break_on_cycles = false;
unsigned long int break_cycles_limit = 0;
unsigned long int total_instructions = 0;
unsigned long int delta_instructions = 0;
uint64 break_cycles_limit = 0;
uint64 total_instructions = 0;
uint64 delta_instructions = 0;
bool break_on_instructions = false;
unsigned long int break_instructions_limit = 0;
uint64 break_instructions_limit = 0;
static DebuggerState dbgstate;
@ -456,12 +456,12 @@ DebuggerState &FCEUI_Debugger() { return dbgstate; }
void ResetDebugStatisticsCounters()
{
total_cycles_base = delta_cycles_base = timestampbase + timestamp;
total_cycles_base = delta_cycles_base = timestampbase + (uint64)timestamp;
total_instructions = delta_instructions = 0;
}
void ResetDebugStatisticsDeltaCounters()
{
delta_cycles_base = timestampbase + timestamp;
delta_cycles_base = timestampbase + (uint64)timestamp;
delta_instructions = 0;
}
void IncrementInstructionsCounters()
@ -510,7 +510,7 @@ static void breakpoint(uint8 *opcode, uint16 A, int size) {
uint8 stackop=0;
uint8 stackopstartaddr,stackopendaddr;
if (break_on_cycles && (timestampbase + timestamp - total_cycles_base > break_cycles_limit))
if (break_on_cycles && ((timestampbase + (uint64)timestamp - total_cycles_base) > break_cycles_limit))
BreakHit(BREAK_TYPE_CYCLES_EXCEED, true);
if (break_on_instructions && (total_instructions > break_instructions_limit))
BreakHit(BREAK_TYPE_INSTRUCTIONS_EXCEED, true);

View File

@ -54,14 +54,14 @@ extern int vblankScanLines;
extern int vblankPixel;
extern bool DebuggerWasUpdated;
extern unsigned long int total_cycles_base;
extern unsigned long int delta_cycles_base;
extern uint64 total_cycles_base;
extern uint64 delta_cycles_base;
extern bool break_on_cycles;
extern unsigned long int break_cycles_limit;
extern unsigned long int total_instructions;
extern unsigned long int delta_instructions;
extern uint64 break_cycles_limit;
extern uint64 total_instructions;
extern uint64 delta_instructions;
extern bool break_on_instructions;
extern unsigned long int break_instructions_limit;
extern uint64 break_instructions_limit;
extern void ResetDebugStatisticsCounters();
extern void ResetDebugStatisticsDeltaCounters();
@ -111,8 +111,8 @@ void UpdateOtherDebuggingDialogs()
void RestoreSize(HWND hwndDlg)
{
//If the dialog dimensions are changed those changes need to be reflected here. - adelikat
const int DEFAULT_WIDTH = 815; //Original width
const int DEFAULT_HEIGHT = 559; //Original height
const int DEFAULT_WIDTH = 820; //Original width
const int DEFAULT_HEIGHT = 560; //Original height
SetWindowPos(hwndDlg,HWND_TOP,DbgPosX,DbgPosY,DEFAULT_WIDTH,DEFAULT_HEIGHT,SWP_SHOWWINDOW);
}
@ -783,25 +783,25 @@ void UpdateDebugger(bool jump_to_pc)
SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_PPUPIXEL, str2);
// update counters
unsigned long int counter_value = timestampbase + timestamp - total_cycles_base;
uint64 counter_value = timestampbase + (uint64)timestamp - total_cycles_base;
if (counter_value < 0) // sanity check
{
ResetDebugStatisticsCounters();
counter_value = 0;
}
sprintf(str, "%lu", counter_value);
sprintf(str, "%llu", counter_value);
SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_CYCLES_COUNT, str);
counter_value = timestampbase + timestamp - delta_cycles_base;
counter_value = timestampbase + (long)timestamp - delta_cycles_base;
if (counter_value < 0) // sanity check
{
ResetDebugStatisticsCounters();
counter_value = 0;
}
sprintf(str, "(+%lu)", counter_value);
sprintf(str, "(+%llu)", counter_value);
SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_CYCLES_COUNT2, str);
sprintf(str, "%lu", total_instructions);
sprintf(str, "%llu", total_instructions);
SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_INSTRUCTIONS_COUNT, str);
sprintf(str, "(+%lu)", delta_instructions);
sprintf(str, "(+%llu)", delta_instructions);
SetDlgItemText(hDebug, IDC_DEBUGGER_VAL_INSTRUCTIONS_COUNT2, str);
UpdateBreakpointsCaption();
@ -1708,7 +1708,7 @@ BOOL CALLBACK DebuggerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
i = GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA;
if (i < 0)
{
for (i *= -si.nPage; i > 0; i--)
for (i *= -(int)si.nPage; i > 0; i--)
{
si.nPos = InstructionDown(si.nPos);
if ((si.nPos + (int)si.nPage) > si.nMax)

View File

@ -29,9 +29,9 @@
#include "../../debug.h"
extern bool break_on_cycles;
extern unsigned long int break_cycles_limit;
extern uint64 break_cycles_limit;
extern bool break_on_instructions;
extern unsigned long int break_instructions_limit;
extern uint64 break_instructions_limit;
extern char symbDebugEnabled;

View File

@ -1082,44 +1082,44 @@ BEGIN
PUSHBUTTON "<",MEMW_EXPANDCOLLAPSE,1,259,11,10
END
DEBUGGER DIALOGEX 54, 74, 541, 321
DEBUGGER DIALOGEX 54, 74, 545, 322
STYLE DS_SETFONT | DS_3DLOOK | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "6502 Debugger"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
EDITTEXT IDC_DEBUGGER_DISASSEMBLY,15,5,318,300,ES_MULTILINE | ES_NOHIDESEL | ES_READONLY | WS_HSCROLL
SCROLLBAR IDC_DEBUGGER_DISASSEMBLY_VSCR,334,5,11,300,SBS_VERT
GROUPBOX "Status Flags",401,433,140,103,35,WS_TABSTOP
CONTROL "N",IDC_DEBUGGER_FLAG_N,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,439,149,18,12
CONTROL "V",IDC_DEBUGGER_FLAG_V,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,464,149,18,12
CONTROL "U",IDC_DEBUGGER_FLAG_U,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,488,149,18,12
CONTROL "B",IDC_DEBUGGER_FLAG_B,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,512,149,18,12
CONTROL "D",IDC_DEBUGGER_FLAG_D,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,439,161,18,12
CONTROL "I",IDC_DEBUGGER_FLAG_I,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,464,161,18,12
CONTROL "Z",IDC_DEBUGGER_FLAG_Z,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,488,161,18,12
CONTROL "C",IDC_DEBUGGER_FLAG_C,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,512,161,18,12
GROUPBOX "Breakpoints",IDC_DEBUGGER_BREAKPOINTS,433,2,103,138,WS_TABSTOP
LISTBOX IDC_DEBUGGER_BP_LIST,437,11,95,96,LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL
PUSHBUTTON "Add",IDC_DEBUGGER_BP_ADD,437,109,31,15
PUSHBUTTON "Delete",IDC_DEBUGGER_BP_DEL,470,109,31,15,WS_DISABLED
PUSHBUTTON "Edit",IDC_DEBUGGER_BP_EDIT,502,109,31,15,WS_DISABLED
PUSHBUTTON "Run",IDC_DEBUGGER_RUN,350,5,38,14
PUSHBUTTON "Step Into",IDC_DEBUGGER_STEP_IN,391,5,39,14
PUSHBUTTON "Step Out",IDC_DEBUGGER_STEP_OUT,350,21,38,14
PUSHBUTTON "Step Over",IDC_DEBUGGER_STEP_OVER,391,21,39,14
LTEXT "A:",IDC_STATIC,350,92,10,8
LTEXT "X:",65534,377,92,10,8
LTEXT "Y:",65533,405,92,10,8
LTEXT "PC:",65532,350,74,13,8
EDITTEXT IDC_DEBUGGER_VAL_A,358,90,15,12,ES_UPPERCASE | ES_WANTRETURN
EDITTEXT IDC_DEBUGGER_VAL_X,386,90,15,12,ES_UPPERCASE | ES_WANTRETURN
EDITTEXT IDC_DEBUGGER_VAL_Y,414,90,15,12,ES_UPPERCASE | ES_WANTRETURN
EDITTEXT IDC_DEBUGGER_VAL_PC,362,72,25,12,ES_UPPERCASE | ES_WANTRETURN
GROUPBOX "Stack",IDC_DEBUGGER_VAL_S,349,104,80,71,WS_TABSTOP
EDITTEXT IDC_DEBUGGER_STACK_CONTENTS,353,113,72,58,ES_MULTILINE | ES_UPPERCASE | ES_NOHIDESEL | ES_READONLY | WS_VSCROLL
PUSHBUTTON "Seek PC",IDC_DEBUGGER_SEEK_PC,391,71,39,14
PUSHBUTTON "Seek To:",IDC_DEBUGGER_SEEK_TO,350,54,38,14
EDITTEXT IDC_DEBUGGER_VAL_PCSEEK,391,55,38,12,ES_UPPERCASE | ES_WANTRETURN
EDITTEXT IDC_DEBUGGER_DISASSEMBLY,15,5,318,301,ES_MULTILINE | ES_NOHIDESEL | ES_READONLY | WS_HSCROLL
SCROLLBAR IDC_DEBUGGER_DISASSEMBLY_VSCR,334,5,11,301,SBS_VERT
GROUPBOX "Status Flags",401,434,140,106,35,WS_TABSTOP
CONTROL "N",IDC_DEBUGGER_FLAG_N,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,440,149,18,12
CONTROL "V",IDC_DEBUGGER_FLAG_V,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,466,149,18,12
CONTROL "U",IDC_DEBUGGER_FLAG_U,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,491,149,18,12
CONTROL "B",IDC_DEBUGGER_FLAG_B,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,516,149,18,12
CONTROL "D",IDC_DEBUGGER_FLAG_D,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,440,161,18,12
CONTROL "I",IDC_DEBUGGER_FLAG_I,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,466,161,18,12
CONTROL "Z",IDC_DEBUGGER_FLAG_Z,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,491,161,18,12
CONTROL "C",IDC_DEBUGGER_FLAG_C,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,516,161,18,12
GROUPBOX "Breakpoints",IDC_DEBUGGER_BREAKPOINTS,434,2,106,138,WS_TABSTOP
LISTBOX IDC_DEBUGGER_BP_LIST,438,11,98,96,LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL
PUSHBUTTON "Add",IDC_DEBUGGER_BP_ADD,438,109,31,15
PUSHBUTTON "Delete",IDC_DEBUGGER_BP_DEL,472,109,31,15,WS_DISABLED
PUSHBUTTON "Edit",IDC_DEBUGGER_BP_EDIT,505,109,31,15,WS_DISABLED
PUSHBUTTON "Run",IDC_DEBUGGER_RUN,351,5,38,14
PUSHBUTTON "Step Into",IDC_DEBUGGER_STEP_IN,392,5,39,14
PUSHBUTTON "Step Out",IDC_DEBUGGER_STEP_OUT,351,21,38,14
PUSHBUTTON "Step Over",IDC_DEBUGGER_STEP_OVER,392,21,39,14
LTEXT "A:",IDC_STATIC,351,92,9,8
LTEXT "X:",65534,378,92,9,8
LTEXT "Y:",65533,406,92,9,8
LTEXT "PC:",65532,351,74,13,8
EDITTEXT IDC_DEBUGGER_VAL_A,359,90,15,12,ES_UPPERCASE | ES_WANTRETURN
EDITTEXT IDC_DEBUGGER_VAL_X,387,90,15,12,ES_UPPERCASE | ES_WANTRETURN
EDITTEXT IDC_DEBUGGER_VAL_Y,415,90,15,12,ES_UPPERCASE | ES_WANTRETURN
EDITTEXT IDC_DEBUGGER_VAL_PC,363,72,25,12,ES_UPPERCASE | ES_WANTRETURN
GROUPBOX "Stack",IDC_DEBUGGER_VAL_S,349,104,81,71,WS_TABSTOP
EDITTEXT IDC_DEBUGGER_STACK_CONTENTS,353,113,73,58,ES_MULTILINE | ES_UPPERCASE | ES_NOHIDESEL | ES_READONLY | WS_VSCROLL
PUSHBUTTON "Seek PC",IDC_DEBUGGER_SEEK_PC,392,71,39,14
PUSHBUTTON "Seek To:",IDC_DEBUGGER_SEEK_TO,351,54,38,14
EDITTEXT IDC_DEBUGGER_VAL_PCSEEK,392,55,38,12,ES_UPPERCASE | ES_WANTRETURN
LTEXT "PPU:",65531,353,179,17,10
LTEXT "Sprite:",65530,353,191,20,10
LTEXT "Scanline:",IDC_STATIC,353,203,31,8
@ -1129,76 +1129,78 @@ BEGIN
EDITTEXT IDC_DEBUGGER_VAL_SLINE,384,203,14,10,ES_UPPERCASE | ES_READONLY | ES_WANTRETURN | NOT WS_BORDER,WS_EX_TRANSPARENT
EDITTEXT IDC_DEBUGGER_VAL_PPUPIXEL,373,216,14,10,ES_UPPERCASE | ES_READONLY | ES_WANTRETURN | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT
GROUPBOX "",IDC_DEBUGGER_VAL_S2,349,174,51,53,WS_TABSTOP
EDITTEXT IDC_DEBUGGER_VAL_CYCLES_COUNT,443,179,46,10,ES_NOHIDESEL | ES_READONLY | ES_WANTRETURN | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT
EDITTEXT IDC_DEBUGGER_VAL_CYCLES_COUNT2,490,179,51,10,ES_READONLY | ES_WANTRETURN | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT
EDITTEXT IDC_DEBUGGER_VAL_INSTRUCTIONS_COUNT,442,204,46,10,ES_NOHIDESEL | ES_READONLY | ES_WANTRETURN | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT
EDITTEXT IDC_DEBUGGER_VAL_INSTRUCTIONS_COUNT2,490,204,51,10,ES_READONLY | ES_WANTRETURN | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT
CONTROL "",IDC_DEBUGGER_ADDR_LINE,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,4,308,341,11
EDITTEXT IDC_DEBUGGER_VAL_CYCLES_COUNT,443,179,47,10,ES_NOHIDESEL | ES_READONLY | ES_WANTRETURN | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT
EDITTEXT IDC_DEBUGGER_VAL_CYCLES_COUNT2,491,179,54,10,ES_READONLY | ES_WANTRETURN | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT
EDITTEXT IDC_DEBUGGER_VAL_INSTRUCTIONS_COUNT,442,204,47,10,ES_NOHIDESEL | ES_READONLY | ES_WANTRETURN | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT
EDITTEXT IDC_DEBUGGER_VAL_INSTRUCTIONS_COUNT2,490,204,55,10,ES_READONLY | ES_WANTRETURN | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_TRANSPARENT
CONTROL "",IDC_DEBUGGER_ADDR_LINE,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,4,309,341,11
CONTROL "Break on Bad Opcodes",IDC_DEBUGGER_BREAK_ON_BAD_OP,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,439,126,90,10
CONTROL "Symbolic debug",IDC_DEBUGGER_ENABLE_SYMBOLIC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,470,261,62,10
PUSHBUTTON "Reload Symbols",IDC_DEBUGGER_RELOAD_SYMS,470,272,62,14
GROUPBOX "Address Bookmarks",45535,349,228,113,76
LISTBOX LIST_DEBUGGER_BOOKMARKS,353,238,74,63,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
EDITTEXT IDC_DEBUGGER_BOOKMARK,430,238,28,14,ES_AUTOHSCROLL
PUSHBUTTON "Add",IDC_DEBUGGER_BOOKMARK_ADD,429,255,30,14
PUSHBUTTON "Delete",IDC_DEBUGGER_BOOKMARK_DEL,429,271,30,14
PUSHBUTTON "Rom Patcher",IDC_DEBUGGER_ROM_PATCHER,470,288,62,14
CONTROL "",IDC_DEBUGGER_ICONTRAY,"Static",SS_BLACKFRAME,4,5,11,300
PUSHBUTTON "",IDC_DEBUGGER_RESTORESIZE,349,307,13,10
LTEXT "Default window size",IDC_STATIC,364,308,68,9
PUSHBUTTON "Run Line",IDC_DEBUGGER_RUN_LINE,350,37,38,14
PUSHBUTTON "128 Lines",IDC_DEBUGGER_RUN_FRAME2,391,37,39,14
CONTROL ".DEB files",DEBUGLOADDEB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,489,306,46,13
CONTROL "Auto-open",DEBUGAUTOLOAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,438,306,47,13
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,440,126,94,10
CONTROL "Symbolic debug",IDC_DEBUGGER_ENABLE_SYMBOLIC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,473,261,62,10
PUSHBUTTON "Reload Symbols",IDC_DEBUGGER_RELOAD_SYMS,472,272,64,14
GROUPBOX "Address Bookmarks",45535,349,228,115,78
LISTBOX LIST_DEBUGGER_BOOKMARKS,353,238,76,64,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
EDITTEXT IDC_DEBUGGER_BOOKMARK,432,238,28,14,ES_AUTOHSCROLL
PUSHBUTTON "Add",IDC_DEBUGGER_BOOKMARK_ADD,431,256,30,14
PUSHBUTTON "Delete",IDC_DEBUGGER_BOOKMARK_DEL,431,272,30,14
PUSHBUTTON "Rom Patcher",IDC_DEBUGGER_ROM_PATCHER,472,288,64,14
CONTROL "",IDC_DEBUGGER_ICONTRAY,"Static",SS_BLACKFRAME,4,5,11,301
PUSHBUTTON "",IDC_DEBUGGER_RESTORESIZE,349,308,13,10
LTEXT "Default window size",IDC_STATIC,364,309,68,9
PUSHBUTTON "Run Line",IDC_DEBUGGER_RUN_LINE,351,37,38,14
PUSHBUTTON "128 Lines",IDC_DEBUGGER_RUN_FRAME2,392,37,39,14
CONTROL ".DEB files",DEBUGLOADDEB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,491,307,46,13
CONTROL "Auto-open",DEBUGAUTOLOAD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,439,307,47,13
LTEXT "CPU cycles:",IDC_STATIC,403,179,39,8
PUSHBUTTON "Reset counters",IDC_DEBUGGER_RESET_COUNTERS,467,229,68,14
CONTROL "Break when exceed",IDC_DEBUGGER_BREAK_ON_CYCLES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,404,191,77,10
EDITTEXT IDC_DEBUGGER_CYCLES_EXCEED,482,190,53,12,ES_UPPERCASE | ES_NOHIDESEL | ES_WANTRETURN | ES_NUMBER
LTEXT "Instructions:",IDC_STATIC,403,204,40,8
PUSHBUTTON "Reset counters",IDC_DEBUGGER_RESET_COUNTERS,470,229,68,14
CONTROL "Break when exceed",IDC_DEBUGGER_BREAK_ON_CYCLES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,405,191,78,10
EDITTEXT IDC_DEBUGGER_CYCLES_EXCEED,484,190,55,12,ES_UPPERCASE | ES_NOHIDESEL | ES_WANTRETURN | ES_NUMBER
LTEXT "Instructions:",IDC_STATIC,403,204,39,8
CONTROL "Break when exceed",IDC_DEBUGGER_BREAK_ON_INSTRUCTIONS,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,404,216,77,10
EDITTEXT IDC_DEBUGGER_INSTRUCTIONS_EXCEED,482,215,53,12,ES_UPPERCASE | ES_NOHIDESEL | ES_WANTRETURN | ES_NUMBER
GROUPBOX "",IDC_STATIC,466,241,70,64
CONTROL "ROM offsets",IDC_DEBUGGER_ROM_OFFSETS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,470,249,62,10
PUSHBUTTON "Name",IDC_DEBUGGER_BOOKMARK_NAME,429,287,30,14
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,405,216,78,10
EDITTEXT IDC_DEBUGGER_INSTRUCTIONS_EXCEED,484,215,55,12,ES_UPPERCASE | ES_NOHIDESEL | ES_WANTRETURN | ES_NUMBER
GROUPBOX "",IDC_STATIC,468,241,72,65
CONTROL "ROM offsets",IDC_DEBUGGER_ROM_OFFSETS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,473,249,62,10
PUSHBUTTON "Name",IDC_DEBUGGER_BOOKMARK_NAME,431,288,30,14
END
TRACER DIALOGEX 65527, 65513, 403, 332
TRACER DIALOGEX 65527, 65513, 403, 339
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Trace Logger"
FONT 8, "MS Sans Serif", 400, 0, 0x0
BEGIN
SCROLLBAR IDC_SCRL_TRACER_LOG,389,4,10,169,SBS_VERT
EDITTEXT IDC_TRACER_LOG,4,4,384,169,ES_MULTILINE | ES_NOHIDESEL | ES_READONLY | WS_HSCROLL
CONTROL "Log last",IDC_RADIO_LOG_LAST,"Button",BS_AUTORADIOBUTTON | BS_LEFT,17,195,38,10
CONTROL "Log to File",IDC_RADIO_LOG_TO_FILE,"Button",BS_AUTORADIOBUTTON | BS_LEFT,17,214,49,10
LTEXT "lines to this window",106,109,195,72,10
PUSHBUTTON "Start Logging",IDC_BTN_START_STOP_LOGGING,181,176,67,14,BS_CENTER | BS_VCENTER
COMBOBOX IDC_TRACER_LOG_SIZE,57,193,48,127,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
GROUPBOX "Extra Log Options",109,12,232,378,53
CONTROL "Log last",IDC_RADIO_LOG_LAST,"Button",BS_AUTORADIOBUTTON | BS_LEFT,18,195,38,10
CONTROL "Log to File",IDC_RADIO_LOG_TO_FILE,"Button",BS_AUTORADIOBUTTON | BS_LEFT,18,213,48,10
LTEXT "lines to this window",106,110,195,72,10
PUSHBUTTON "Start Logging",IDC_BTN_START_STOP_LOGGING,177,176,67,14,BS_CENTER | BS_VCENTER
COMBOBOX IDC_TRACER_LOG_SIZE,58,193,48,127,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
GROUPBOX "Log Options",109,12,230,378,69
CONTROL "Log state of A, X, Y and S registers",IDC_CHECK_LOG_REGISTERS,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,18,243,126,10
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,19,242,126,10
CONTROL "Log Processor Status flags",IDC_CHECK_LOG_PROCESSOR_STATUS,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,148,243,104,10
PUSHBUTTON "Browse...",IDC_BTN_LOG_BROWSE,66,212,45,14,BS_CENTER | BS_VCENTER
LTEXT "",IDC_TRACER_STATS,121,213,246,12
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,149,242,104,10
PUSHBUTTON "Browse...",IDC_BTN_LOG_BROWSE,67,211,46,14,BS_CENTER | BS_VCENTER
LTEXT "",IDC_TRACER_STATS,121,212,246,13
CONTROL "Only log newly mapped code",IDC_CHECK_LOG_NEW_INSTRUCTIONS,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,18,298,107,10
GROUPBOX "Extra Log Options that work with the Code/Data Logger",113,12,287,378,39
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,19,315,111,10
GROUPBOX "Extra Log Options that work with the Code/Data Logger",113,12,302,378,30
CONTROL "Only log code that accesses newly mapped data",IDC_CHECK_LOG_NEW_DATA,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,18,311,169,10
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,149,315,171,10
CONTROL "Automatically update Window while logging",IDC_CHECK_LOG_UPDATE_WINDOW,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,202,195,156,10
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,203,195,160,10
CONTROL "Use Stack Pointer for code tabbing (nesting visualization)",IDC_CHECK_CODE_TABBING,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,148,270,197,10
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,149,283,197,10
CONTROL "To the left from disassembly text",IDC_CHECK_LOG_STATUSES_TO_THE_LEFT,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,261,243,119,10
CONTROL "Log current Frame number",IDC_CHECK_LOG_FRAME_NUMBER,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,18,256,102,10
CONTROL "Symbolic trace",IDC_CHECK_SYMBOLIC_TRACING,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,18,270,72,10
CONTROL "Log emulator messages",IDC_CHECK_LOG_MESSAGES,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,148,256,94,10
CONTROL "Log breakpoint hits",IDC_CHECK_LOG_BREAKPOINTS,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,261,256,82,10
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,262,242,119,10
CONTROL "Log Frames count",IDC_CHECK_LOG_FRAMES_COUNT,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,19,255,102,10
CONTROL "Symbolic trace",IDC_CHECK_SYMBOLIC_TRACING,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,19,283,72,10
CONTROL "Log emulator messages",IDC_CHECK_LOG_MESSAGES,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,19,268,94,10
CONTROL "Log breakpoint hits",IDC_CHECK_LOG_BREAKPOINTS,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,149,268,82,10
CONTROL "Log Cycles count",IDC_CHECK_LOG_CYCLES_COUNT,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,149,255,102,10
CONTROL "Log Instructions count",IDC_CHECK_LOG_INSTRUCTIONS_COUNT,
"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_TABSTOP,262,255,102,10
END
ADDBP DIALOGEX 66, 83, 196, 130

View File

@ -162,6 +162,10 @@
#define CHEAT_CONTEXT_GOTOINHEXEDITOR 119
#define IDC_DEBUGGER_BREAK_ON_INSTRUCTIONS 119
#define IDC_CHECK_LOG_FRAME_NUMBER 119
#define IDC_CHECK_LOG_FRAMES_COUNT 119
#define IDC_CHECK_LOG_CYCLES_COUNT 120
#define IDC_CHECK_LOG_FRAME_NUMBER3 121
#define IDC_CHECK_LOG_INSTRUCTIONS_COUNT 121
#define CHECK_SOUND_8BIT 122
#define IDD_DIALOG3 123
#define IDC_CHECK_SYMBOLIC_TRACING 123

View File

@ -43,6 +43,9 @@ using namespace std;
//#define LOG_SKIP_UNMAPPED 4
//#define LOG_ADD_PERIODS 8
extern uint64 total_cycles_base;
extern uint64 total_instructions;
// ################################## Start of SP CODE ###########################
#include "debuggersp.h"
@ -75,6 +78,7 @@ 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_result[LOG_LINE_MAX_LEN] = {0};
char str_temp[LOG_LINE_MAX_LEN] = {0};
char* tracer_decoration_name;
char* tracer_decoration_comment;
@ -147,7 +151,9 @@ BOOL CALLBACK TracerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
CheckDlgButton(hwndDlg, IDC_CHECK_LOG_NEW_INSTRUCTIONS, (logging_options & LOG_NEW_INSTRUCTIONS) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_LOG_NEW_DATA, (logging_options & LOG_NEW_DATA) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_LOG_STATUSES_TO_THE_LEFT, (logging_options & LOG_TO_THE_LEFT) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_LOG_FRAME_NUMBER, (logging_options & LOG_FRAME_NUMBER) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_LOG_FRAMES_COUNT, (logging_options & LOG_FRAMES_COUNT) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_LOG_CYCLES_COUNT, (logging_options & LOG_CYCLES_COUNT) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_LOG_INSTRUCTIONS_COUNT, (logging_options & LOG_INSTRUCTIONS_COUNT) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_LOG_MESSAGES, (logging_options & LOG_MESSAGES) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_LOG_BREAKPOINTS, (logging_options & LOG_BREAKPOINTS) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHECK_SYMBOLIC_TRACING, (logging_options & LOG_SYMBOLIC) ? BST_CHECKED : BST_UNCHECKED);
@ -195,9 +201,17 @@ BOOL CALLBACK TracerCallB(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
logging_options ^= LOG_TO_THE_LEFT;
CheckDlgButton(hwndDlg, IDC_CHECK_LOG_STATUSES_TO_THE_LEFT, (logging_options & LOG_TO_THE_LEFT) ? BST_CHECKED : BST_UNCHECKED);
break;
case IDC_CHECK_LOG_FRAME_NUMBER:
logging_options ^= LOG_FRAME_NUMBER;
CheckDlgButton(hwndDlg, IDC_CHECK_LOG_FRAME_NUMBER, (logging_options & LOG_FRAME_NUMBER) ? BST_CHECKED : BST_UNCHECKED);
case IDC_CHECK_LOG_FRAMES_COUNT:
logging_options ^= LOG_FRAMES_COUNT;
CheckDlgButton(hwndDlg, IDC_CHECK_LOG_FRAMES_COUNT, (logging_options & LOG_FRAMES_COUNT) ? BST_CHECKED : BST_UNCHECKED);
break;
case IDC_CHECK_LOG_CYCLES_COUNT:
logging_options ^= LOG_CYCLES_COUNT;
CheckDlgButton(hwndDlg, IDC_CHECK_LOG_CYCLES_COUNT, (logging_options & LOG_CYCLES_COUNT) ? BST_CHECKED : BST_UNCHECKED);
break;
case IDC_CHECK_LOG_INSTRUCTIONS_COUNT:
logging_options ^= LOG_INSTRUCTIONS_COUNT;
CheckDlgButton(hwndDlg, IDC_CHECK_LOG_INSTRUCTIONS_COUNT, (logging_options & LOG_INSTRUCTIONS_COUNT) ? BST_CHECKED : BST_UNCHECKED);
break;
case IDC_CHECK_LOG_MESSAGES:
logging_options ^= LOG_MESSAGES;
@ -360,8 +374,8 @@ void FCEUD_TraceInstruction(uint8 *opcode, int size)
olddatacount = datacount;
if(unloggedlines > 0)
{
sprintf(str_temp, "(%d lines skipped)", unloggedlines);
OutputLogLine(str_temp);
sprintf(str_result, "(%d lines skipped)", unloggedlines);
OutputLogLine(str_result);
unloggedlines = 0;
}
} else
@ -473,13 +487,23 @@ void FCEUD_TraceInstruction(uint8 *opcode, int size)
str_disassembly[LOG_DISASSEMBLY_MAX_LEN - 1] = 0;
}
// Start filling the str_temp line: Frame number, AXYS state, Processor status, Tabs, Address, Data, Disassembly
if (logging_options & LOG_FRAME_NUMBER)
// Start filling the str_temp line: Frame count, Cycles count, Instructions count, AXYS state, Processor status, Tabs, Address, Data, Disassembly
if (logging_options & LOG_FRAMES_COUNT)
{
sprintf(str_temp, "%06u: ", currFrameCounter);
sprintf(str_result, "f%-6u ", currFrameCounter);
} else
{
str_temp[0] = 0;
str_result[0] = 0;
}
if (logging_options & LOG_CYCLES_COUNT)
{
sprintf(str_temp, "c%-11llu ", (timestampbase + (uint64)timestamp - total_cycles_base));
strcat(str_result, str_temp);
}
if (logging_options & LOG_INSTRUCTIONS_COUNT)
{
sprintf(str_temp, "i%-11llu ", total_instructions);
strcat(str_result, str_temp);
}
if (logging_options & LOG_REGISTERS)
@ -505,9 +529,9 @@ void FCEUD_TraceInstruction(uint8 *opcode, int size)
if (logging_options & LOG_TO_THE_LEFT)
{
if (logging_options & LOG_REGISTERS)
strcat(str_temp, str_axystate);
strcat(str_result, str_axystate);
if (logging_options & LOG_PROCESSOR_STATUS)
strcat(str_temp, str_procstatus);
strcat(str_result, str_procstatus);
}
if (logging_options & LOG_CODE_TABBING)
@ -517,26 +541,26 @@ void FCEUD_TraceInstruction(uint8 *opcode, int size)
for (int i = 0; i < spaces; i++)
str_tabs[i] = ' ';
str_tabs[spaces] = 0;
strcat(str_temp, str_tabs);
strcat(str_result, str_tabs);
} else if (logging_options & LOG_TO_THE_LEFT)
{
strcat(str_temp, " ");
strcat(str_result, " ");
}
sprintf(str_address, "$%04X:", addr);
strcat(str_temp, str_address);
strcat(str_temp, str_data);
strcat(str_temp, str_disassembly);
strcat(str_result, str_address);
strcat(str_result, str_data);
strcat(str_result, str_disassembly);
if (!(logging_options & LOG_TO_THE_LEFT))
{
if (logging_options & LOG_REGISTERS)
strcat(str_temp, str_axystate);
strcat(str_result, str_axystate);
if (logging_options & LOG_PROCESSOR_STATUS)
strcat(str_temp, str_procstatus);
strcat(str_result, str_procstatus);
}
OutputLogLine(str_temp);
OutputLogLine(str_result);
return;
}

View File

@ -5,14 +5,18 @@
#define LOG_NEW_INSTRUCTIONS 4
#define LOG_NEW_DATA 8
#define LOG_TO_THE_LEFT 16
#define LOG_FRAME_NUMBER 32
#define LOG_FRAMES_COUNT 32
#define LOG_MESSAGES 64
#define LOG_BREAKPOINTS 128
#define LOG_SYMBOLIC 256
#define LOG_CODE_TABBING 512
#define LOG_CYCLES_COUNT 1024
#define LOG_INSTRUCTIONS_COUNT 2048
#define LOG_LINE_MAX_LEN 128
// Frame number - 7+1 symbols
#define LOG_LINE_MAX_LEN 150
// Frames count - 1+6+1 symbols
// Cycles count - 1+11+1 symbols
// Instructions count - 1+11+1 symbols
// AXYS state - 20
// Processor status - 11
// Tabs - 31
@ -21,7 +25,7 @@
// Disassembly - 35
// EOL (/0) - 1
// ------------------------
// 122 symbols total
// 148 symbols total
#define LOG_AXYSTATE_MAX_LEN 21
#define LOG_PROCSTATUS_MAX_LEN 12
#define LOG_TABS_MASK 31