bool monitor_breakpoint_check_checkpoint(MEMSPACE mem, WORD addr, break_list_t *list) { break_list_t *ptr; breakpoint_t *bp; bool result = FALSE; MON_ADDR temp; const char *type; ptr = search_checkpoint_list(list, addr); while (ptr && mon_is_in_range(ptr->brkpt->start_addr, ptr->brkpt->end_addr, addr)) { bp = ptr->brkpt; ptr = ptr->next; if (bp && bp->enabled==e_ON) { /* If condition test fails, skip this checkpoint */ if (bp->condition) { if (!mon_evaluate_conditional(bp->condition)) { continue; } } /* Check if the user specified some ignores */ if (bp->ignore_count) { bp->ignore_count--; continue; } bp->hit_count++; result = TRUE; temp = new_addr(mem, (monitor_cpu_type.mon_register_get_val)(mem, e_PC)); if (bp->trace) { type = "Trace"; result = FALSE; } else if (bp->watch_load) type = "Watch-load"; else if (bp->watch_store) type = "Watch-store"; else type = "Break"; /*archdep_open_monitor_console(&mon_input, &mon_output);*/ mon_out("#%d (%s) ", bp->brknum, type); mon_disassemble_instr(temp); if (bp->command) { mon_out("Executing: %s\n", bp->command); parse_and_execute_line(bp->command); } if (bp->temporary) mon_breakpoint_delete_checkpoint(bp->brknum); } } return result; }
void mon_breakpoint_delete_checkpoint(int brknum) { int i; breakpoint_t *bp = NULL; MEMSPACE mem; if (brknum == -1) { /* Add user confirmation here. */ mon_out("Deleting all breakpoints\n"); for (i = 1; i < breakpoint_count; i++) { bp = find_checkpoint(i); if (bp) mon_breakpoint_delete_checkpoint(i); } } else if (!(bp = find_checkpoint(brknum))) { mon_out("#%d not a valid breakpoint\n", brknum); return; } else { mem = addr_memspace(bp->start_addr); if (!(bp->watch_load) && !(bp->watch_store)) { remove_checkpoint_from_list(&(breakpoints[mem]), bp); if (!any_breakpoints(mem)) { monitor_mask[mem] &= ~MI_BREAK; if (!monitor_mask[mem]) interrupt_monitor_trap_off(mon_interfaces[mem]->int_status); } } else { if (bp->watch_load) remove_checkpoint_from_list(&(watchpoints_load[mem]), bp); if (bp->watch_store) remove_checkpoint_from_list(&(watchpoints_store[mem]), bp); if (!any_watchpoints(mem)) { monitor_mask[mem] &= ~MI_WATCH; mon_interfaces[mem]->toggle_watchpoints_func(0, mon_interfaces[mem]->context); if (!monitor_mask[mem]) interrupt_monitor_trap_off(mon_interfaces[mem]->int_status); } } } if (bp != NULL) { mon_delete_conditional(bp->condition); if (bp->command) lib_free(bp->command); } }
bool mon_breakpoint_check_checkpoint(MEMSPACE mem, unsigned int addr, unsigned int lastpc, MEMORY_OP op) { checkpoint_list_t *ptr; checkpoint_t *cp; checkpoint_list_t *list; monitor_cpu_type_t *monitor_cpu; bool must_stop = FALSE; MON_ADDR instpc; const char *op_str; const char *action_str; monitor_cpu = monitor_cpu_for_memspace[mem]; switch (op) { case e_load: list = watchpoints_load[mem]; op_str = "load"; instpc = new_addr(mem, lastpc); break; case e_store: list = watchpoints_store[mem]; op_str = "store"; instpc = new_addr(mem, lastpc); break; default: /* e_exec */ list = breakpoints[mem]; op_str = "exec"; instpc = new_addr(mem, (monitor_cpu->mon_register_get_val)(mem, e_PC)); break; } ptr = search_checkpoint_list(list, addr); while (ptr && mon_is_in_range(ptr->checkpt->start_addr, ptr->checkpt->end_addr, addr)) { cp = ptr->checkpt; ptr = ptr->next; if (cp && cp->enabled==e_ON) { /* If condition test fails, skip this checkpoint */ if (cp->condition) { if (!mon_evaluate_conditional(cp->condition)) { continue; } } /* Check if the user specified some ignores */ if (cp->ignore_count) { cp->ignore_count--; continue; } cp->hit_count++; if (cp->stop) { must_stop = TRUE; action_str = "Stop on"; } else { action_str = "Trace"; } mon_out("#%d (%s %5s %04x) ", cp->checknum, action_str, op_str, addr); if (mon_interfaces[mem]->get_line_cycle != NULL) { unsigned int line, cycle; int half_cycle; mon_interfaces[mem]->get_line_cycle(&line, &cycle, &half_cycle); if (half_cycle==-1) mon_out(" %03i %03i\n", line, cycle); else mon_out(" %03i %03i %i\n", line, cycle, half_cycle); } else { mon_out("\n"); } mon_disassemble_with_regdump(mem, instpc); if (cp->command) { mon_out("Executing: %s\n", cp->command); parse_and_execute_line(cp->command); } if (cp->temporary) { mon_breakpoint_delete_checkpoint(cp->checknum); } } } return must_stop; }