From 54ea697bd0657d83a12ef56f016eb513e7c66562 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 2 May 2020 20:02:33 +0300 Subject: [PATCH] Debugger updates. --- cfgfile.cpp | 6 +++++- debug.cpp | 28 +++++++++++++++++++++++++++- include/options.h | 1 + include/sysdeps.h | 1 + od-win32/win32gui.cpp | 3 ++- od-win32/writelog.cpp | 5 +++++ 6 files changed, 41 insertions(+), 3 deletions(-) diff --git a/cfgfile.cpp b/cfgfile.cpp index 3fc021e2..01c788ca 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -2621,7 +2621,8 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write_bool (f, _T("rtg_nocustom"), p->picasso96_nocustom); cfgfile_write (f, _T("rtg_modes"), _T("0x%x"), p->picasso96_modeflags); - cfgfile_write_bool (f, _T("log_illegal_mem"), p->illegal_mem); + cfgfile_write_bool(f, _T("debug_mem"), p->debug_mem); + cfgfile_write_bool(f, _T("log_illegal_mem"), p->illegal_mem); #if 0 if (p->catweasel >= 100) @@ -3341,6 +3342,7 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) || cfgfile_yesno(option, value, _T("sound_volcnt"), &p->sound_volcnt) || cfgfile_yesno(option, value, _T("sound_stereo_swap_paula"), &p->sound_stereo_swap_paula) || cfgfile_yesno(option, value, _T("sound_stereo_swap_ahi"), &p->sound_stereo_swap_ahi) + || cfgfile_yesno(option, value, _T("debug_mem"), &p->debug_mem) || cfgfile_yesno(option, value, _T("log_illegal_mem"), &p->illegal_mem) || cfgfile_yesno(option, value, _T("filesys_no_fsdb"), &p->filesys_no_uaefsdb) || cfgfile_yesno(option, value, _T("gfx_monochrome"), &p->gfx_grayscale) @@ -8144,6 +8146,8 @@ static void buildin_default_prefs (struct uae_prefs *p) p->mountitems = 0; + p->debug_mem = false; + target_default_options (p, 1); cfgfile_compatibility_romtype(p); } diff --git a/debug.cpp b/debug.cpp index 7246695a..9ca68419 100644 --- a/debug.cpp +++ b/debug.cpp @@ -3716,6 +3716,7 @@ static void memwatch (TCHAR **c) mwn->reg = 0xffffffff; mwn->frozen = 0; mwn->modval_written = 0; + mwn->mustchange = 0; mwn->bus_error = 0; ignore_ws (c); if (more_params (c)) { @@ -7227,6 +7228,7 @@ struct dsprintfstack }; static dsprintfstack debugsprintf_stack[DEBUGSPRINTF_SIZE]; static uae_u16 debugsprintf_latch, debugsprintf_latched; +static uae_u32 debugsprintf_cycles, debugsprintf_cycles_set; static void read_bstring(char *out, int max, uae_u32 addr) { @@ -7267,6 +7269,20 @@ static void read_string(char *out, int max, uae_u32 addr) } } +static char *parse_custom(char *p, char *d) +{ + if (!strcmp(p, "CYCLES")) { + if (debugsprintf_cycles_set) { + uae_u32 c = (get_cycles() - debugsprintf_cycles) / CYCLE_UNIT; + sprintf(d, "%u", c); + } else { + strcpy(d, "-"); + } + d += strlen(d); + } + return d; +} + static void debug_sprintf_do(uae_u32 s) { int cnt = 0; @@ -7307,6 +7323,14 @@ static void debug_sprintf_do(uae_u32 s) sprintf(d, "%d", stack->val); } else if (cn == 'u') { sprintf(d, "%u", stack->val); + } else if (cn == '[') { + char *next = strchr(p, ']'); + if (next) { + p++; + *next = 0; + d = parse_custom(p, d); + p = next + 1; + } } else { d[0] = '?'; d[1] = 0; @@ -7325,7 +7349,7 @@ static void debug_sprintf_do(uae_u32 s) bool debug_sprintf(uaecptr addr, uae_u32 val, int size) { - if (currprefs.uaeboard < 2) + if (!currprefs.debug_mem) return false; uae_u32 v = val; @@ -7351,6 +7375,8 @@ bool debug_sprintf(uaecptr addr, uae_u32 val, int size) debug_sprintf_do(v); debugsprintf_cnt = 0; debugsprintf_latched = 0; + debugsprintf_cycles = get_cycles(); + debugsprintf_cycles_set = 1; } else { if (debugsprintf_cnt < DEBUGSPRINTF_SIZE) { debugsprintf_stack[debugsprintf_cnt].val = v; diff --git a/include/options.h b/include/options.h index cd2ccb1a..76e930f4 100644 --- a/include/options.h +++ b/include/options.h @@ -474,6 +474,7 @@ struct uae_prefs { TCHAR config_window_title[256]; bool illegal_mem; + bool debug_mem; bool use_serial; bool serial_demand; bool serial_hwctsrts; diff --git a/include/sysdeps.h b/include/sysdeps.h index 59970088..94d4c31f 100644 --- a/include/sysdeps.h +++ b/include/sysdeps.h @@ -456,6 +456,7 @@ extern void logging_init (void); extern FILE *log_open (const TCHAR *name, int append, int bootlog, TCHAR*); extern void log_close (FILE *f); extern TCHAR *write_log_get_ts(void); +extern bool is_console_open(void); extern bool use_long_double; diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index 824816cb..28b1e54a 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -4647,7 +4647,7 @@ static const struct miscentry misclist[] = { { 0, 1, _T("Native on-screen display"), NULL, &workprefs.leds_on_screen, STATUSLINE_CHIPSET, STATUSLINE_CHIPSET }, { 0, 1, _T("RTG on-screen display"), NULL, &workprefs.leds_on_screen, STATUSLINE_RTG, STATUSLINE_RTG }, { 0, 0, _T("Create winuaelog.txt log"), &workprefs.win32_logfile }, - { 0, 0, _T("Log illegal memory accesses"), &workprefs.illegal_mem }, + { 0, 1, _T("Log illegal memory accesses"), &workprefs.illegal_mem }, { 0, 0, _T("Blank unused displays"), &workprefs.win32_blankmonitors }, { 0, 0, _T("Start mouse uncaptured"), &workprefs.win32_start_uncaptured }, { 0, 0, _T("Start minimized"), &workprefs.win32_start_minimized }, @@ -4661,6 +4661,7 @@ static const struct miscentry misclist[] = { { 0, 1, _T("Warn when attempting to close window"), &workprefs.win32_warn_exit }, { 0, 1, _T("Power led dims when audio filter is disabled"), NULL, &workprefs.power_led_dim, 128, 0 }, { 0, 1, _T("Automatically capture mouse when window is activated"), &workprefs.win32_capture_always }, + { 0, 0, _T("Debug memory space"), &workprefs.debug_mem }, { 0, NULL } }; diff --git a/od-win32/writelog.cpp b/od-win32/writelog.cpp index 0ff3395e..2110eb6a 100644 --- a/od-win32/writelog.cpp +++ b/od-win32/writelog.cpp @@ -75,6 +75,11 @@ int always_flush_log = 0; /* console functions for debugger */ +bool is_console_open(void) +{ + return consoleopen; +} + static HWND myGetConsoleWindow (void) { return GetConsoleWindow (); -- 2.47.3