return (**c) != 0;
}
-static uae_u32 readint (TCHAR **c);
-static uae_u32 readbin (TCHAR **c);
-static uae_u32 readhex (TCHAR **c);
+static uae_u32 readint(TCHAR **c, bool *err);
+static uae_u32 readbin(TCHAR **c, bool *err);
+static uae_u32 readhex(TCHAR **c, bool *err);
static const TCHAR *debugoper[] = {
_T("=="),
}
-static uae_u32 readnum (TCHAR **c, int *size, TCHAR def)
+static uae_u32 readnum(TCHAR **c, int *size, TCHAR def, bool *err)
{
uae_u32 val;
- if (checkvaltype (c, &val, size, def))
+ if (err) {
+ *err = 0;
+ }
+ if (checkvaltype(c, &val, size, def)) {
return val;
+ }
+ if (err) {
+ *err = 1;
+ }
return 0;
}
-static uae_u32 readint (TCHAR **c)
+static uae_u32 readint(TCHAR **c, bool *err)
{
int size;
- return readnum (c, &size, '!');
+ return readnum(c, &size, '!', err);
}
-static uae_u32 readhex (TCHAR **c)
+static uae_u32 readhex(TCHAR **c, bool *err)
{
int size;
- return readnum (c, &size, '$');
+ return readnum(c, &size, '$', err);
}
-static uae_u32 readbin (TCHAR **c)
+static uae_u32 readbin(TCHAR **c, bool *err)
{
int size;
- return readnum (c, &size, '%');
+ return readnum(c, &size, '%', err);
}
-static uae_u32 readint (TCHAR **c, int *size)
+static uae_u32 readint(TCHAR **c, int *size, bool *err)
{
- return readnum (c, size, '!');
+ return readnum(c, size, '!', err);
}
-static uae_u32 readhex (TCHAR **c, int *size)
+static uae_u32 readhex(TCHAR **c, int *size, bool *err)
{
- return readnum (c, size, '$');
+ return readnum(c, size, '$', err);
}
static size_t next_string (TCHAR **c, TCHAR *out, int max, int forceupper)
return _tcslen (out);
}
-static void converter (TCHAR **c)
+static void converter(TCHAR **c)
{
- uae_u32 v = readint (c);
+ bool err;
+ uae_u32 v = readint(c, &err);
TCHAR s[100];
int i;
+ if (err) {
+ return;
+ }
for (i = 0; i < 32; i++)
s[i] = (v & (1 << (31 - i))) ? '1' : '0';
s[i] = 0;
}
}
if (more_params(c)) {
- maxlines = readint(c);
+ maxlines = readint(c, NULL);
}
} else {
- range = readint(c);
+ range = readint(c, NULL);
if (more_params(c)) {
- maxlines = readint(c);
+ maxlines = readint(c, NULL);
}
}
}
(*c)++;
debug_copper = 1|4;
if (more_params (c)) {
- debug_copper_pc = readhex (c);
+ debug_copper_pc = readhex(c, NULL);
console_out_f (_T("Copper breakpoint @0x%08x\n"), debug_copper_pc);
} else {
debug_copper &= ~4;
}
} else {
if (more_params(c)) {
- maddr = readhex(c);
+ maddr = readhex(c, NULL);
if (maddr == 1 || maddr == 2 || maddr == 3)
maddr = get_copper_address(maddr);
else if (maddr == 0)
selected_cop_set = curr_cop_set ^ 1;
}
- if (more_params (c))
- lines = readhex (c);
+ if (more_params(c))
+ lines = readhex(c, NULL);
else
lines = 20;
(*c)++;
}
if (more_params(c))
- maxdiff = readint(c);
+ maxdiff = readint(c, NULL);
if (!memtmp || v == 'S') {
first = 1;
uae_u32 val, memcnt, prevmemcnt;
int i, count, vcnt, memsize;
uaecptr addr, end;
+ bool err;
memsize = 0;
addr = 0xffffffff;
return;
}
if (first)
- val = readint (c, &size);
+ val = readint(c, &size, &err);
else
- val = readint (c);
+ val = readint(c, &err);
+ if (err) {
+ return;
+ }
if (vlist == NULL) {
listsize = memsize;
int v;
ignore_ws(c);
- v = readint(c);
+ v = readint(c, NULL);
smc_free();
smc_size = 1 << 24;
if (currprefs.z3fastmem[0].size)
int num;
struct memwatch_node *mwn;
TCHAR nc, *cp;
+ bool err;
if (!memwatch_enabled) {
initialize_memwatch (0);
if (illgdebug) {
ignore_ws (c);
if (more_params (c)) {
- uae_u32 addr = readhex (c);
+ uae_u32 addr = readhex(c, NULL);
uae_u32 len = 1;
if (more_params (c))
- len = readhex (c);
+ len = readhex(c, NULL);
console_out_f (_T("Cleared logging addresses %08X - %08X\n"), addr, addr + len);
while (len > 0) {
addr &= 0xffffff;
return;
}
*c = cp;
- num = readint (c);
+ num = readint(c, NULL);
if (num < 0 || num >= MEMWATCH_TOTAL)
return;
mwn = &mwnodes[num];
memwatch_setup ();
return;
}
- mwn->addr = readhex (c);
+ mwn->addr = readhex(c, NULL);
mwn->size = 1;
mwn->rwi = 7;
mwn->val_enabled = 0;
mwn->reportonly = false;
ignore_ws (c);
if (more_params (c)) {
- mwn->size = readhex (c);
+ mwn->size = readhex(c, NULL);
ignore_ws (c);
if (more_params (c)) {
TCHAR *cs = *c;
next_char(c);
mwn->pc = readhex(c, NULL);
}
- if (_totupper(**c) == 'M') {
+ if (nc == 'M') {
mwn->modval_written = 1;
- } else if (_totupper(**c) == 'C') {
+ }
+ if (nc == 'C') {
mwn->mustchange = 1;
- } else if (_totupper(**c) == 'V') {
- next_char(c);
- mwn->val = readhex(c, &mwn->val_size);
+ }
+ if (nc == 'V') {
+ mwn->val = readhex(c, &mwn->val_size, &err);
mwn->val_enabled = 1;
}
if (!more_params(c))
static void copymem(TCHAR **c)
{
uae_u32 addr = 0, eaddr = 0, dst = 0;
+ bool err;
ignore_ws(c);
- if (!more_params (c))
+ if (!more_params(c))
+ return;
+ addr = readhex(c, &err);
+ if (err) {
return;
- addr = readhex (c);
+ }
ignore_ws (c);
- if (!more_params (c))
+ if (!more_params(c))
+ return;
+ eaddr = readhex(c, &err);
+ if (err) {
return;
- eaddr = readhex (c);
+ }
ignore_ws (c);
- if (!more_params (c))
+ if (!more_params(c))
return;
- dst = readhex (c);
+ dst = readhex(c, &err);
+ if (err) {
+ return;
+ }
if (addr >= eaddr)
return;
TCHAR cc;
int len = 1;
bool fillmode = false;
+ bool err;
if (**c == 'f') {
fillmode = true;
}
ignore_ws(c);
- addr = readhex (c);
+ addr = readhex(c, &err);
+ if (err) {
+ return;
+ }
ignore_ws (c);
if (fillmode) {
- if (!more_params (c))
+ if (!more_params(c))
return;
- eaddr = readhex(c);
- ignore_ws (c);
+ eaddr = readhex(c, &err);
+ if (err) {
+ return;
+ }
+ ignore_ws(c);
}
if (!more_params (c))
}
} else {
for (;;) {
+ bool err;
ignore_ws (c);
if (!more_params (c))
break;
- val = readhex (c, &len);
-
+ val = readhex(c, &len, &err);
+ if (err) {
+ goto end;
+ }
if (len == 4) {
- put_long (addr, val);
+ put_long(addr, val);
cc = 'L';
} else if (len == 2) {
- put_word (addr, val);
+ put_word(addr, val);
cc = 'W';
} else if (len == 1) {
- put_byte (addr, val);
+ put_byte(addr, val);
cc = 'B';
} else {
cc = peekchar(c);
break;
}
}
+end:
if (eaddr != 0xffffffff)
console_out_f(_T("Wrote data to %08x - %08x\n"), addrc, addr);
}
TCHAR nc = (*c)[0];
next_char(c);
if (more_params(c)) {
- int count = readint(c);
+ int count = readint(c, NULL);
if (nc == 's') {
if (more_params(c)) {
debug_vpos = count;
- debug_hpos = readint(c);
+ debug_hpos = readint(c, NULL);
if (debug_vpos == vpos && debug_hpos > current_hpos()) {
debug_vpos = -1;
count = debug_hpos - current_hpos();
TCHAR nc = _totupper((*c)[0]);
if (nc == 'N') {
next_char(c);
- bpcnt = readint(c);
+ bpcnt = readint(c, NULL);
}
}
if (more_params (c)) {
// bpnum register operation value1 [mask value2]
next_char(c);
if (more_params(c)) {
- int bpidx = readint(c);
+ int bpidx = readint(c, NULL);
if (more_params(c) && bpidx >= 0 && bpidx < BREAKPOINT_TOTAL) {
bpn = &bpnodes[bpidx];
bpn->cnt = bpcnt;
int operid = getoperidx(c);
if (more_params(c) && operid >= 0) {
bpn->oper = operid;
- bpn->value1 = readhex(c);
+ bpn->value1 = readhex(c, NULL);
bpn->enabled = 1;
if (more_params(c)) {
- bpn->mask = readhex(c);
+ bpn->mask = readhex(c, NULL);
if (more_params(c)) {
- bpn->value2 = readhex(c);
+ bpn->value2 = readhex(c, NULL);
}
}
console_out(_T("Breakpoint added.\n"));
}
} else {
if (more_params(c)) {
- trace_param[0] = readhex(c);
+ trace_param[0] = readhex(c, NULL);
if (more_params(c)) {
- trace_param[1] = readhex(c);
+ trace_param[1] = readhex(c, NULL);
}
if (more_params(c)) {
- trace_param[2] = readhex(c);
+ trace_param[2] = readhex(c, NULL);
}
} else {
trace_param[0] = 0x10000;
return 0;
} else if (nc == 'R' && (*c)[1] == 0) {
if (more_params(c)) {
- int bpnum = readint(c);
+ int bpnum = readint(c, NULL);
if (bpnum >= 0 && bpnum < BREAKPOINT_TOTAL) {
bpnodes[bpnum].enabled = 0;
console_out_f(_T("Breakpoint %d removed.\n"), bpnum);
return 0;
}
trace_mode = TRACE_RANGE_PC;
- trace_param[0] = readhex (c);
+ trace_param[0] = readhex(c, NULL);
if (more_params (c)) {
- trace_param[1] = readhex (c);
+ trace_param[1] = readhex(c, NULL);
return 1;
} else {
for (i = 0; i < BREAKPOINT_TOTAL; i++) {
static int process_breakpoint(TCHAR **c)
{
+ bool err;
processptr = 0;
xfree(processname);
processname = NULL;
next_string(c, pn, sizeof(pn) / sizeof(TCHAR), 0);
processname = ua(pn);
} else {
- processptr = readhex(c);
+ processptr = readhex(c, &err);
+ if (err) {
+ return 0;
+ }
}
trace_mode = TRACE_CHECKONLY;
return 1;
(*cc)++;
if (!more_params (cc))
goto S_argh;
- src2 = src = readhex (cc);
+ src2 = src = readhex(cc, NULL);
if (save) {
if (!more_params(cc))
goto S_argh;
}
len2 = len = -1;
if (more_params(cc)) {
- len2 = len = readhex (cc);
+ len2 = len = readhex(cc, NULL);
}
fp = uae_tfopen (name, save ? _T("wb") : _T("rb"));
if (fp == NULL) {
addr = 0xffffffff;
endaddr = lastaddr ();
if (more_params (cc)) {
- addr = readhex (cc);
+ addr = readhex(cc, NULL);
addr--;
if (more_params(cc)) {
- endaddr = readhex(cc);
+ endaddr = readhex(cc, NULL);
}
}
console_out_f (_T("Searching from %08X to %08X..\n"), addr + 1, endaddr);
console_out (_T("All debugtests disabled\n"));
return;
}
- val = readint (inptr);
+ val = readint(inptr, NULL);
if (more_params (inptr)) {
- val2 = readint (inptr);
+ val2 = readint(inptr, NULL);
if (val2 > 0)
val2 = 2;
}
int max = 2;
addr2 = 0;
- ignore_ws (inptr);
- addr = readhex (inptr);
- ignore_ws (inptr);
+ ignore_ws(inptr);
+ addr = readhex(inptr, NULL);
+ ignore_ws(inptr);
if (more_params (inptr))
- size = readhex (inptr);
+ size = readhex(inptr, NULL);
if (size != 1 && size != 2 && size != 4) {
addr2 = size;
- ignore_ws (inptr);
- if (more_params (inptr))
- size = readint (inptr);
+ ignore_ws(inptr);
+ if (more_params(inptr))
+ size = readint(inptr, NULL);
if (size != 1 && size != 2 && size != 4)
size = 1;
}
if (**inptr == 'd') {
(*inptr)++;
ignore_ws (inptr);
- disk_debug_logging = readint (inptr);
+ disk_debug_logging = readint(inptr, NULL);
console_out_f (_T("Disk logging level %d\n"), disk_debug_logging);
return;
}
disk_debug_mode |= DISK_DEBUG_PIO;
}
if (more_params(inptr))
- disk_debug_track = readint (inptr);
+ disk_debug_track = readint(inptr, NULL);
if (disk_debug_track < 0 || disk_debug_track > 2 * 83)
disk_debug_track = -1;
if (disk_debug_logging == 0)
uae_u32 ea, sea, dea;
uaecptr addr, end, end2;
int hits = 0;
+ bool err;
addr = 0xffffffff;
end = lastaddr ();
- ea = readhex (inptr);
+ ea = readhex(inptr, &err);
+ if (err) {
+ return;
+ }
if (more_params(inptr)) {
- addr = readhex (inptr);
+ addr = readhex(inptr, &err);
+ if (err) {
+ return;
+ }
addr--;
if (more_params(inptr)) {
- end = readhex(inptr);
+ end = readhex(inptr, &err);
+ if (err) {
+ return;
+ }
}
}
console_out_f (_T("Searching from %08X to %08X\n"), addr + 1, end);
else
c2 = 99;
}
- v = readhex (inptr);
+ v = readhex(inptr, NULL);
if (c1 == 'A' && c2 < 8)
regs.regs[8 + c2] = v;
else if (c1 == 'D' && c2 < 8)
{
TCHAR cmd, *inptr;
uaecptr addr;
+ bool err;
inptr = input;
if (*inptr == 'l') {
next_char (&inptr);
if (more_params (&inptr)) {
- debug_illegal_mask = readhex (&inptr);
+ debug_illegal_mask = readhex(&inptr, NULL);
if (more_params(&inptr))
- debug_illegal_mask |= ((uae_u64)readhex(&inptr)) << 32;
+ debug_illegal_mask |= ((uae_u64)readhex(&inptr, NULL)) << 32;
} else {
debug_illegal_mask = debug_illegal ? 0 : -1;
debug_illegal_mask &= ~((uae_u64)255 << 24); // mask interrupts
} else {
addr = 0xffffffff;
if (more_params (&inptr))
- addr = readhex (&inptr);
+ addr = readhex (&inptr, NULL);
dump_vectors (addr);
}
break;
debugmem_list_segment(1, addr);
} else {
if (more_params(&inptr)) {
- addr = readhex(&inptr);
+ addr = readhex(&inptr, NULL);
}
debugmem_list_segment(0, addr);
}
case 'a':
asmaddr = nxdis;
if (more_params(&inptr)) {
- asmaddr = readhex(&inptr);
+ asmaddr = readhex(&inptr, &err);
+ if (err) {
+ break;
+ }
if (more_params(&inptr)) {
uae_u16 asmout[16];
int inss = m68k_asm(inptr, asmout, asmaddr);
inptr++;
inputdevice_logging = 1 | 2;
if (more_params (&inptr))
- inputdevice_logging = readint (&inptr);
+ inputdevice_logging = readint(&inptr, NULL);
console_out_f (_T("Input logging level %d\n"), inputdevice_logging);
} else if (*inptr == 'm') {
memory_map_dump_2 (0);
extern void update_disassembly (uae_u32);
next_char (&inptr);
if (more_params (&inptr))
- update_disassembly (readhex (&inptr));
+ update_disassembly(readhex (&inptr, NULL));
#endif
} else {
uae_u32 daddr;
next_char(&inptr);
}
if (more_params (&inptr))
- daddr = readhex (&inptr);
+ daddr = readhex(&inptr, NULL);
else
daddr = nxdis;
if (more_params (&inptr))
- count = readhex (&inptr);
+ count = readhex(&inptr, NULL);
else
count = 10;
if (ppcmode) {
return true;
} else {
if (more_params(&inptr))
- trace_param[0] = readint(&inptr);
+ trace_param[0] = readint(&inptr, NULL);
if (trace_param[0] <= 0 || trace_param[0] > 10000)
trace_param[0] = 1;
trace_mode = TRACE_SKIP_INS;
case 'g':
if (more_params (&inptr)) {
- m68k_setpc (readhex (&inptr));
- fill_prefetch ();
+ uaecptr addr = readhex(&inptr, &err);
+ if (err) {
+ break;
+ }
+ m68k_setpc(addr);
+ fill_prefetch();
}
deactivate_debugger();
return true;
}
if (more_params(&inptr))
- count = readint (&inptr);
+ count = readint(&inptr, NULL);
else
count = 10;
if (count > 1000) {
break;
skip = count;
if (more_params (&inptr))
- skip = count - readint (&inptr);
+ skip = count - readint(&inptr, NULL);
temp = lasthist;
while (count-- > 0 && temp != firsthist) {
{
case 'a':
if (more_params (&inptr))
- audio_channel_mask = readhex (&inptr);
+ audio_channel_mask = readhex(&inptr, NULL);
console_out_f (_T("Audio mask = %02X\n"), audio_channel_mask);
break;
case 's':
if (more_params (&inptr))
- debug_sprite_mask = readhex (&inptr);
+ debug_sprite_mask = readhex(&inptr, NULL);
console_out_f (_T("Sprite mask: %02X\n"), debug_sprite_mask);
break;
case 'b':
- if (more_params (&inptr)) {
- debug_bpl_mask = readhex (&inptr) & 0xff;
- if (more_params (&inptr))
- debug_bpl_mask_one = readhex (&inptr) & 0xff;
+ if (more_params(&inptr)) {
+ debug_bpl_mask = readhex(&inptr, NULL) & 0xff;
+ if (more_params(&inptr))
+ debug_bpl_mask_one = readhex(&inptr, NULL) & 0xff;
notice_screen_contents_lost(0);
}
console_out_f (_T("Bitplane mask: %02X (%02X)\n"), debug_bpl_mask, debug_bpl_mask_one);
if (*inptr == 'g') {
extern void update_memdump (uae_u32);
next_char (&inptr);
- if (more_params (&inptr))
- update_memdump (readhex (&inptr));
+ if (more_params(&inptr)) {
+ uaecptr addr = readhex(&inptr, &err);
+ if (!err) {
+ update_memdump(addr);
+ }
+ }
break;
}
#endif
} else {
if (currprefs.mmu_model) {
if (more_params (&inptr))
- debug_mmu_mode = readint (&inptr);
+ debug_mmu_mode = readint(&inptr, NULL);
else
debug_mmu_mode = 0;
console_out_f (_T("MMU translation function code = %d\n"), debug_mmu_mode);
}
break;
}
+ err = false;
if (more_params (&inptr)) {
- maddr = readhex (&inptr);
+ maddr = readhex(&inptr, &err);
} else {
maddr = nxmem;
}
if (more_params (&inptr))
- lines = readhex (&inptr);
+ lines = readhex(&inptr, &err);
else
lines = 20;
- dumpmem (maddr, &nxmem, lines);
+ if (!err) {
+ dumpmem(maddr, &nxmem, lines);
+ }
}
break;
case 'v':
debug_heatmap = 1;
init_heatmap();
if (more_params(&inptr)) {
- v1 = readint(&inptr);
+ v1 = readint(&inptr, NULL);
if (v1 < 0) {
debug_heatmap = 2;
}
set_debug_colors();
inptr++;
if (more_params(&inptr)) {
- v1 = readint(&inptr);
- if (v1 >= 0 && v1 < DMARECORD_MAX) {
- v2 = readint(&inptr);
- if (v2 >= 0 && v2 <= DMARECORD_SUBITEMS) {
+ v1 = readint(&inptr, &err);
+ if (!err && v1 >= 0 && v1 < DMARECORD_MAX) {
+ v2 = readint(&inptr, &err);
+ if (!err && v2 >= 0 && v2 <= DMARECORD_SUBITEMS) {
if (more_params(&inptr)) {
- uae_u32 rgb = readhex(&inptr);
+ uae_u32 rgb = readhex(&inptr, NULL);
if (v2 == 0) {
for (int i = 0; i < DMARECORD_SUBITEMS; i++) {
debug_colors[v1].l[i] = rgb;
next_char(&inptr);
}
if (more_params (&inptr))
- v1 = readint (&inptr);
+ v1 = readint (&inptr, NULL);
if (more_params (&inptr))
- v2 = readint (&inptr);
+ v2 = readint (&inptr, NULL);
if (debug_dma && v1 >= 0 && v2 >= 0) {
decode_dma_record (v2, v1, cmd == 'v', nextcmd == 'l');
} else {
case 'U':
if (currprefs.mmu_model && more_params (&inptr)) {
int i;
- uaecptr addrl = readhex (&inptr);
+ uaecptr addrl = readhex(&inptr, NULL);
uaecptr addrp;
console_out_f (_T("%08X translates to:\n"), addrl);
for (i = 0; i < 4; i++) {