--- previous/src/debug/breakcond.c 2018/04/24 19:28:01 1.1.1.3 +++ previous/src/debug/breakcond.c 2018/04/24 19:32:06 1.1.1.4 @@ -19,8 +19,6 @@ const char BreakCond_fileid[] = "Hatari #include "main.h" #include "file.h" #include "m68000.h" -#include "memorySnapShot.h" -#include "nextMemory.h" #include "str.h" #include "screen.h" /* for defines needed by video.h */ #include "video.h" /* for Hatari video variable addresses */ @@ -34,7 +32,6 @@ const char BreakCond_fileid[] = "Hatari #include "symbols.h" #include "68kDisass.h" - /* set to 1 to enable parsing function tracing / debug output */ #define DEBUG 0 @@ -61,11 +58,6 @@ typedef enum { VALUE_TYPE_REG32 = 32 } value_t; -static inline bool is_register_type(value_t vtype) { - /* type used for CPU/DSP registers */ - return (vtype == VALUE_TYPE_REG16 || vtype == VALUE_TYPE_REG32); -} - typedef struct { bool is_indirect; char dsp_space; /* DSP has P, X, Y address spaces, zero if not DSP */ @@ -175,27 +167,19 @@ static void _spaces(void) /* ------------- breakpoint condition checking, internals ------------- */ /** - * Return value from given DSP memory space/address - */ -static Uint32 BreakCond_ReadDspMemory(Uint32 addr, const bc_value_t *bc_value) -{ - return 0; -} - -/** * Return value of given size read from given ST memory address */ -static Uint32 BreakCond_ReadSTMemory(Uint32 addr, const bc_value_t *bc_value) +static Uint32 BreakCond_ReadNeXTMemory(Uint32 addr, const bc_value_t *bc_value) { switch (bc_value->bits) { case 32: - return NEXTMemory_ReadLong(addr); + return DBGMemory_ReadLong(addr); case 16: - return NEXTMemory_ReadWord(addr); + return DBGMemory_ReadWord(addr); case 8: - return NEXTMemory_ReadByte(addr); + return DBGMemory_ReadByte(addr); default: - fprintf(stderr, "ERROR: unknown ST address size %d!\n", bc_value->bits); + fprintf(stderr, "ERROR: unknown address size %d!\n", bc_value->bits); abort(); } } @@ -227,7 +211,7 @@ static Uint32 BreakCond_GetValue(const b abort(); } if (bc_value->is_indirect) { - value = BreakCond_ReadSTMemory(value, bc_value); + value = BreakCond_ReadNeXTMemory(value, bc_value); } return (value & bc_value->mask); } @@ -402,129 +386,6 @@ typedef struct { const char *constraints; } var_addr_t; -/* Accessor functions for calculated Hatari values */ -static Uint32 GetLineCycles(void) -{ - int dummy1, dummy2, lcycles; - Video_GetPosition(&dummy1, &dummy2 , &lcycles); - return lcycles; -} -static Uint32 GetFrameCycles(void) -{ - int dummy1, dummy2, fcycles; - Video_GetPosition(&fcycles, &dummy1, &dummy2); - return fcycles; -} - -/* helpers for TOS OS call opcode accessor functions */ -#define INVALID_OPCODE 0xFFFFu - -static inline Uint16 getLineOpcode(Uint8 line) -{ - Uint32 pc; - Uint16 instr; - pc = M68000_GetPC(); - instr = NEXTMemory_ReadWord(pc); - /* for opcode X, Line-A = 0xA00X, Line-F = 0xF00X */ - if ((instr >> 12) == line) { - return instr & 0xFF; - } - return INVALID_OPCODE; -} -static inline bool isTrap(Uint8 trap) -{ - Uint32 pc; - Uint16 instr; - pc = M68000_GetPC(); - instr = NEXTMemory_ReadWord(pc); - return (instr == (Uint16)0x4e40u + trap); -} -static inline Uint16 getControlOpcode(void) -{ - /* Control[] address from D1, opcode in Control[0] */ - return NEXTMemory_ReadWord(NEXTMemory_ReadLong(Regs[REG_D1])); -} -static inline Uint16 getStackOpcode(void) -{ - return NEXTMemory_ReadWord(Regs[REG_A7]); -} - -/* Actual TOS OS call opcode accessor functions */ -static Uint32 GetLineAOpcode(void) -{ - return getLineOpcode(0xA); -} -static Uint32 GetLineFOpcode(void) -{ - return getLineOpcode(0xF); -} -static Uint32 GetGemdosOpcode(void) -{ - if (isTrap(1)) { - return getStackOpcode(); - } - return INVALID_OPCODE; -} -static Uint32 GetBiosOpcode(void) -{ - if (isTrap(13)) { - return getStackOpcode(); - } - return INVALID_OPCODE; -} -static Uint32 GetXbiosOpcode(void) -{ - if (isTrap(14)) { - return getStackOpcode(); - } - return INVALID_OPCODE; -} -static Uint32 GetAesOpcode(void) -{ - if (isTrap(2)) { - Uint16 d0 = Regs[REG_D0]; - if (d0 == 0xC8) { - return getControlOpcode(); - } else if (d0 == 0xC9) { - /* same as appl_yield() */ - return 0x11; - } - } - return INVALID_OPCODE; -} -static Uint32 GetVdiOpcode(void) -{ - if (isTrap(2)) { - Uint16 d0 = Regs[REG_D0]; - if (d0 == 0x73) { - return getControlOpcode(); - } else if (d0 == 0xFFFE) { - /* -2 = vq_[v]gdos() */ - return 0xFFFE; - } - } - return INVALID_OPCODE; -} - -/* sorted by variable name so that this can be bisected */ -static const var_addr_t hatari_vars[] = { - { "AesOpcode", (Uint32*)GetAesOpcode, VALUE_TYPE_FUNCTION32, 16, "by default FFFF" }, - { "BiosOpcode", (Uint32*)GetBiosOpcode, VALUE_TYPE_FUNCTION32, 16, "by default FFFF" }, - { "BSS", (Uint32*)DebugInfo_GetBSS, VALUE_TYPE_FUNCTION32, 0, "invalid before Desktop is up" }, - { "DATA", (Uint32*)DebugInfo_GetDATA, VALUE_TYPE_FUNCTION32, 0, "invalid before Desktop is up" }, - { "FrameCycles", (Uint32*)GetFrameCycles, VALUE_TYPE_FUNCTION32, 0, NULL }, - { "GemdosOpcode", (Uint32*)GetGemdosOpcode, VALUE_TYPE_FUNCTION32, 16, "by default FFFF" }, - { "LineAOpcode", (Uint32*)GetLineAOpcode, VALUE_TYPE_FUNCTION32, 16, "by default FFFF" }, - { "LineCycles", (Uint32*)GetLineCycles, VALUE_TYPE_FUNCTION32, 0, "is always divisable by 4" }, - { "LineFOpcode", (Uint32*)GetLineFOpcode, VALUE_TYPE_FUNCTION32, 16, "by default FFFF" }, - { "TEXT", (Uint32*)DebugInfo_GetTEXT, VALUE_TYPE_FUNCTION32, 0, "invalid before Desktop is up" }, -// { "VBL", (Uint32*)&nVBLs, VALUE_TYPE_VAR32, sizeof(nVBLs)*8, NULL }, - { "VdiOpcode", (Uint32*)GetVdiOpcode, VALUE_TYPE_FUNCTION32, 16, "by default FFFF" }, - { "XbiosOpcode", (Uint32*)GetXbiosOpcode, VALUE_TYPE_FUNCTION32, 16, "by default FFFF" } - -}; - - /** * Readline match callback for CPU variable/symbol name completion. * STATE = 0 -> different text from previous one. @@ -532,14 +393,14 @@ static const var_addr_t hatari_vars[] = */ char *BreakCond_MatchCpuVariable(const char *text, int state) { + /* static int i, len; - const char *name; if (!state) { - /* first match */ + // first match len = strlen(text); i = 0; - } + }*/ /* next match */ // while (i < ARRAYSIZE(hatari_vars)) { // name = hatari_vars[i++].name; @@ -607,8 +468,10 @@ bool BreakCond_GetHatariVariable(const c // if (!BreakCond_ParseVariable(name, &bc_value)) { // return false; // } - bc_value.mask = 0xffffffff; - bc_value.is_indirect = false; + bc_value.mask = 0xffffffff; + bc_value.is_indirect = false; + bc_value.valuetype = VALUE_TYPE_NUMBER; + bc_value.value.number = 0; *value = BreakCond_GetValue(&bc_value); return true; } @@ -1496,8 +1359,6 @@ int BreakCond_MatchCpuExpression(int pos */ static void BreakCond_Help(void) { - Uint32 value; - int i; fputs( " condition = [.mode] [& ] [.mode]\n" "\n" @@ -1741,6 +1602,6 @@ bool BreakAddr_Command(char *args, bool /* on success, show on what instruction it was added */ uaecptr dummy; - m68k_disasm(stderr, (uaecptr)addr, &dummy, 1); + m68k_disasm((uaecptr)addr, &dummy, 1); return true; }