/** * Save/Restore snapshot of debugging session variables */ void DebugUI_MemorySnapShot_Capture(const char *path, bool bSave) { char *filename; filename = malloc(strlen(path) + strlen(".debug") + 1); assert(filename); strcpy(filename, path); strcat(filename, ".debug"); if (bSave) { /* save breakpoints as debugger input file */ BreakCond_Save(filename); } else { /* remove current CPU and DSP breakpoints */ BreakCond_Command("all", false); BreakCond_Command("all", true); if (File_Exists(filename)) { /* and parse back the saved breakpoints */ DebugUI_ParseFile(filename, true); } } free(filename); }
/** * Debugger user interface initialization. */ void DebugUI_Init(void) { const dbgcommand_t *cpucmd, *dspcmd; int cpucmds, dspcmds; /* already intialized? */ if (debugCommands) return; /* if you want disassembly or memdumping to start/continue from * specific address, you can set them in these functions. */ dspcmds = DebugDsp_Init(&dspcmd); cpucmds = DebugCpu_Init(&cpucmd); /* on first time copy the command structures to a single table */ debugCommands = ARRAYSIZE(uicommand); debugCommand = malloc(sizeof(dbgcommand_t) * (dspcmds + cpucmds + debugCommands)); assert(debugCommand); memcpy(debugCommand, uicommand, sizeof(dbgcommand_t) * debugCommands); memcpy(&debugCommand[debugCommands], cpucmd, sizeof(dbgcommand_t) * cpucmds); debugCommands += cpucmds; memcpy(&debugCommand[debugCommands], dspcmd, sizeof(dbgcommand_t) * dspcmds); debugCommands += dspcmds; if (parseFileName) DebugUI_ParseFile(parseFileName, true); }
/** * 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); } }
/** * Command: Read debugger commands from a file */ static int DebugUI_CommandsFromFile(int argc, char *argv[]) { if (argc == 2) DebugUI_ParseFile(argv[1], true); else DebugUI_PrintCmdHelp(argv[0]); return DEBUGGER_CMDDONE; }