--- previous/src/debug/debugInfo.c 2018/04/24 19:25:10 1.1.1.1 +++ previous/src/debug/debugInfo.c 2018/04/24 19:33:58 1.1.1.4 @@ -11,91 +11,34 @@ const char DebugInfo_fileid[] = "Hatari #include #include +#include #include "main.h" #include "configuration.h" #include "debugInfo.h" #include "debugcpu.h" #include "debugui.h" #include "evaluate.h" +#include "file.h" #include "ioMem.h" #include "m68000.h" #include "nextMemory.h" +#include "screen.h" #include "video.h" - -/* ------------------------------------------------------------------ - * TOS information - */ -#define OS_SYSBASE 0x4F2 -#define OS_HEADER_SIZE 0x30 - -#define COOKIE_JAR 0x5A0 - -#define BASEPAGE_SIZE 0x100 - -#define GEM_MAGIC 0x87654321 -#define GEM_MUPB_SIZE 0xC - -#define RESET_MAGIC 0x31415926 -#define RESET_VALID 0x426 -#define RESET_VECTOR 0x42A - -#define COUNTRY_SPAIN 4 - -/** - * DebugInfo_GetSysbase: set osversion to given argument. - * return sysbase address on success and zero on failure. - */ -static Uint32 DebugInfo_GetSysbase(Uint16 *osversion) -{ - return 00; -} - -/** - * DebugInfo_CurrentBasepage: get currently running TOS program basepage - */ -static Uint32 DebugInfo_CurrentBasepage(void) -{ - return 0; -} - -/** - * DebugInfo_Basepage: show TOS process basepage information - * at given address. - */ -static void DebugInfo_Basepage(Uint32 basepage) -{ -} - -/** - * DebugInfo_OSHeader: display TOS OS Header - */ -static void DebugInfo_OSHeader(Uint32 dummy) -{ -} - - /* ------------------------------------------------------------------ * Next HW information */ +char* get_rtc_ram_info(void); + /** * DebugInfo_Rtc : display the Videl registers values. */ -static void DebugInfo_Rtc(Uint32 dummy) -{ - Screen_Draw(); +static void DebugInfo_Rtc(Uint32 dummy) { + Update_StatusBar(); fprintf(stdout,"%s",get_rtc_ram_info()); } -/** - * DebugInfo_Crossbar : display the Crossbar registers values. - */ -static void DebugInfo_Crossbar(Uint32 dummy) -{ -} - - /* ------------------------------------------------------------------ * CPU and DSP information wrappers */ @@ -131,8 +74,6 @@ static void DebugInfo_CpuMemDump(Uint32 DebugInfo_CallCommand(DebugCpu_MemDump, "memdump", arg); } -#if ENABLE_DSP_EMU - static void DebugInfo_DspRegister(Uint32 arg) { } @@ -166,8 +107,6 @@ static Uint32 DebugInfo_DspMemArgs(int a return ((Uint32)space<<16) | value; } -#endif /* ENABLE_DSP_EMU */ - static void DebugInfo_RegAddr(Uint32 arg) { @@ -208,6 +147,48 @@ static Uint32 DebugInfo_RegAddrArgs(int /* ------------------------------------------------------------------ + * wrappers for command to parse debugger input file + */ + +/* file name to be given before calling the Parse function, + * needs to be set separately as it's a host pointer which + * can be 64-bit i.e. may not fit into Uint32. + */ +static char *parse_filename; + +/** + * Parse and exec commands in the previously given debugger input file + */ +static void DebugInfo_FileParse(Uint32 dummy) +{ + if (parse_filename) { + DebugUI_ParseFile(parse_filename); + } else { + // fputs("ERROR: debugger input file name to parse isn't set!\n", stderr); + } +} + +/** + * Set which input file to parse. + * Return true if file exists, false on error + */ +static Uint32 DebugInfo_FileArgs(int argc, char *argv[]) +{ + if (argc != 1) { + return false; + } + if (!File_Exists(argv[0])) { + fprintf(stderr, "ERROR: given file '%s' doesn't exist!\n", argv[0]); + return false; + } + if (parse_filename) { + free(parse_filename); + } + parse_filename = strdup(argv[0]); + return true; +} + +/* ------------------------------------------------------------------ * Debugger & readline TAB completion integration */ @@ -216,15 +197,13 @@ static Uint32 DebugInfo_RegAddrArgs(int */ static void DebugInfo_Default(Uint32 dummy) { - int hbl, fcycles, lcycles; - Video_GetPosition(&fcycles, &hbl, &lcycles); - fprintf(stderr, "\nCPU=$%x, VBL=%d, FrameCycles=%d, HBL=%d, LineCycles=%d, DSP=", - M68000_GetPC(), 0, fcycles, hbl, lcycles); + fprintf(stderr, "\nCPU=$%x, DSP=", + M68000_GetPC()); fprintf(stderr, "N/A\n"); } static const struct { - /* whether callback is used only for locking */ + /* if overlaps with other functionality, list only for lock command */ bool lock; const char *name; void (*func)(Uint32 arg); @@ -232,23 +211,19 @@ static const struct { Uint32 (*args)(int argc, char *argv[]); const char *info; } infotable[] = { - { false,"basepage", DebugInfo_Basepage, NULL, "Show program basepage info at given
" }, - { false,"crossbar", DebugInfo_Crossbar, NULL, "Show Falcon crossbar HW register values" }, { true, "default", DebugInfo_Default, NULL, "Show default debugger entry information" }, { true, "disasm", DebugInfo_CpuDisAsm, NULL, "Disasm CPU from PC or given
" }, -#if ENABLE_DSP_EMU { true, "dspdisasm", DebugInfo_DspDisAsm, NULL, "Disasm DSP from given
" }, { true, "dspmemdump",DebugInfo_DspMemDump, DebugInfo_DspMemArgs, "Dump DSP memory from given
" }, - { true, "dspregs", DebugInfo_DspRegister,NULL, "Show DSP register values" }, -#endif + { true, "dspregs", DebugInfo_DspRegister,NULL, "Show DSP registers values" }, + { true, "file", DebugInfo_FileParse, DebugInfo_FileArgs, "Parse commands from given debugger input " }, { true, "memdump", DebugInfo_CpuMemDump, NULL, "Dump CPU memory from given
" }, - { false,"osheader", DebugInfo_OSHeader, NULL, "Show TOS OS header information" }, { true, "regaddr", DebugInfo_RegAddr, DebugInfo_RegAddrArgs, "Show from CPU/DSP address pointed by " }, - { true, "registers", DebugInfo_CpuRegister,NULL, "Show CPU register values" }, + { true, "registers", DebugInfo_CpuRegister,NULL, "Show CPU registers values" }, { false,"rtc", DebugInfo_Rtc, NULL, "Show Next's RTC registers" } }; -static int LockedFunction = 2; /* index for the "default" function */ +static int LockedFunction = 4; /* index for the "default" function */ static Uint32 LockedArgument; /**