Added a tick-counting debugger command

This commit is contained in:
Lior Halphon 2016-09-16 11:58:31 +03:00
parent 43be91f032
commit 71d4ba21f2
3 changed files with 21 additions and 0 deletions

View File

@ -1185,6 +1185,21 @@ static bool backtrace(GB_gameboy_t *gb, char *arguments, const debugger_command_
return true; return true;
} }
static bool ticks(GB_gameboy_t *gb, char *arguments, const debugger_command_t *command)
{
STOPPED_ONLY
if (strlen(lstrip(arguments))) {
print_usage(gb, command);
return true;
}
GB_log(gb, "Ticks: %lu. (Resetting)\n", gb->debugger_ticks);
gb->debugger_ticks = 0;
return true;
}
static bool help(GB_gameboy_t *gb, char *arguments, const debugger_command_t *command); static bool help(GB_gameboy_t *gb, char *arguments, const debugger_command_t *command);
#define HELP_NEWLINE "\n " #define HELP_NEWLINE "\n "
@ -1198,6 +1213,7 @@ static const debugger_command_t commands[] = {
{"backtrace", 2, backtrace, "Display the current call stack"}, {"backtrace", 2, backtrace, "Display the current call stack"},
{"bt", 2, }, /* Alias */ {"bt", 2, }, /* Alias */
{"sld", 3, stack_leak_detection, "Like finish, but stops if a stack leak is detected. (Experimental)"}, {"sld", 3, stack_leak_detection, "Like finish, but stops if a stack leak is detected. (Experimental)"},
{"ticks", 2, ticks, "Display the number of CPU ticks since the last time 'ticks' was used. "},
{"registers", 1, registers, "Print values of processor registers and other important registers"}, {"registers", 1, registers, "Print values of processor registers and other important registers"},
{"cartridge", 2, mbc, "Displays information about the MBC and cartridge"}, {"cartridge", 2, mbc, "Displays information about the MBC and cartridge"},
{"mbc", 3, }, /* Alias */ {"mbc", 3, }, /* Alias */

View File

@ -409,6 +409,9 @@ typedef struct GB_gameboy_s {
GB_symbol_map_t *bank_symbols[0x200]; GB_symbol_map_t *bank_symbols[0x200];
GB_reversed_symbol_map_t reversed_symbol_map; GB_reversed_symbol_map_t reversed_symbol_map;
/* Ticks command */
unsigned long debugger_ticks;
/* Misc */ /* Misc */
bool turbo; bool turbo;
bool turbo_dont_skip; bool turbo_dont_skip;

View File

@ -53,6 +53,8 @@ void GB_advance_cycles(GB_gameboy_t *gb, uint8_t cycles)
} }
} }
gb->debugger_ticks += cycles;
if (gb->cgb_double_speed) { if (gb->cgb_double_speed) {
cycles >>=1; cycles >>=1;
} }