comparison blastem.c @ 519:0b21a1a73fb7

Added step and step-over debugger commands. step-over is like next except it doesn't follow conditional branches to lower addresses. This makes it useful for advancing to the end of a loop. Also fixed a bug in next introduced by the refactor.
author Mike Pavone <pavone@retrodev.com>
date Sun, 09 Feb 2014 17:16:55 -0800
parents 775802dab98f
children fb39534b6604
comparison
equal deleted inserted replaced
518:775802dab98f 519:0b21a1a73fb7
1409 debugging = 0; 1409 debugging = 0;
1410 break; 1410 break;
1411 case 'd': 1411 case 'd':
1412 param = find_param(input_buf); 1412 param = find_param(input_buf);
1413 if (!param) { 1413 if (!param) {
1414 fputs("b command requires a parameter\n", stderr); 1414 fputs("d command requires a parameter\n", stderr);
1415 break; 1415 break;
1416 } 1416 }
1417 value = atoi(param); 1417 value = atoi(param);
1418 this_bp = find_breakpoint_idx(&breakpoints, value); 1418 this_bp = find_breakpoint_idx(&breakpoints, value);
1419 if (!*this_bp) { 1419 if (!*this_bp) {
1472 } else if(m68k_is_noncall_branch(&inst)) { 1472 } else if(m68k_is_noncall_branch(&inst)) {
1473 if (inst.op == M68K_BCC && inst.extra.cond != COND_TRUE) { 1473 if (inst.op == M68K_BCC && inst.extra.cond != COND_TRUE) {
1474 branch_f = after; 1474 branch_f = after;
1475 branch_t = m68k_branch_target(&inst, context->dregs, context->aregs); 1475 branch_t = m68k_branch_target(&inst, context->dregs, context->aregs);
1476 insert_breakpoint(context, branch_t, (uint8_t *)debugger); 1476 insert_breakpoint(context, branch_t, (uint8_t *)debugger);
1477 } else if(inst.op == M68K_BCC && inst.extra.cond != COND_FALSE) { 1477 } else if(inst.op == M68K_DBCC) {
1478 if ( inst.extra.cond == COND_FALSE) {
1479 if (context->dregs[inst.dst.params.regs.pri] & 0xFFFF) {
1480 after = m68k_branch_target(&inst, context->dregs, context->aregs);
1481 }
1482 } else {
1483 branch_t = after;
1484 branch_f = m68k_branch_target(&inst, context->dregs, context->aregs);
1485 insert_breakpoint(context, branch_f, (uint8_t *)debugger);
1486 }
1487 } else {
1488 after = m68k_branch_target(&inst, context->dregs, context->aregs);
1489 }
1490 }
1491 insert_breakpoint(context, after, (uint8_t *)debugger);
1492 debugging = 0;
1493 break;
1494 case 'o':
1495 if (inst.op == M68K_RTS) {
1496 after = (read_dma_value(context->aregs[7]/2) << 16) | read_dma_value(context->aregs[7]/2 + 1);
1497 } else if (inst.op == M68K_RTE || inst.op == M68K_RTR) {
1498 after = (read_dma_value((context->aregs[7]+2)/2) << 16) | read_dma_value((context->aregs[7]+2)/2 + 1);
1499 } else if(m68k_is_noncall_branch(&inst)) {
1500 if (inst.op == M68K_BCC && inst.extra.cond != COND_TRUE) {
1501 branch_t = m68k_branch_target(&inst, context->dregs, context->aregs);
1502 if (branch_t < after) {
1503 branch_t = 0;
1504 } else {
1505 branch_f = after;
1506 insert_breakpoint(context, branch_t, (uint8_t *)debugger);
1507 }
1508 } else if(inst.op == M68K_DBCC) {
1509 uint32_t target = m68k_branch_target(&inst, context->dregs, context->aregs);
1510 if (target > after) {
1511 if (inst.extra.cond == COND_FALSE) {
1512 after = target;
1513 } else {
1514 branch_f = target;
1515 branch_t = after;
1516 insert_breakpoint(context, branch_f, (uint8_t *)debugger);
1517 }
1518 }
1519 } else {
1520 after = m68k_branch_target(&inst, context->dregs, context->aregs);
1521 }
1522 }
1523 insert_breakpoint(context, after, (uint8_t *)debugger);
1524 debugging = 0;
1525 break;
1526 case 's':
1527 if (inst.op == M68K_RTS) {
1528 after = (read_dma_value(context->aregs[7]/2) << 16) | read_dma_value(context->aregs[7]/2 + 1);
1529 } else if (inst.op == M68K_RTE || inst.op == M68K_RTR) {
1530 after = (read_dma_value((context->aregs[7]+2)/2) << 16) | read_dma_value((context->aregs[7]+2)/2 + 1);
1531 } else if(m68k_is_branch(&inst)) {
1532 if (inst.op == M68K_BCC && inst.extra.cond != COND_TRUE) {
1533 branch_f = after;
1534 branch_t = m68k_branch_target(&inst, context->dregs, context->aregs);
1535 insert_breakpoint(context, branch_t, (uint8_t *)debugger);
1536 } else if(inst.op == M68K_DBCC && inst.extra.cond != COND_FALSE) {
1478 branch_t = after; 1537 branch_t = after;
1479 branch_f = m68k_branch_target(&inst, context->dregs, context->aregs); 1538 branch_f = m68k_branch_target(&inst, context->dregs, context->aregs);
1480 insert_breakpoint(context, branch_f, (uint8_t *)debugger); 1539 insert_breakpoint(context, branch_f, (uint8_t *)debugger);
1481 } else { 1540 } else {
1482 after = m68k_branch_target(&inst, context->dregs, context->aregs); 1541 after = m68k_branch_target(&inst, context->dregs, context->aregs);