Example #1
0
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;
}
Example #2
0
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;
}