Example #1
0
/** lc3_remove_break
  *
  * Removes the breakpoint from the list of breakpoints.
  * @param lc3_state lc3_state
  * @param symbol symbol to remove breakpoint from
  */
bool lc3_remove_break(lc3_state& state, const std::string& symbol)
{
    int addr = lc3_sym_lookup(state, symbol);
    if (addr == -1) return true;

    return lc3_remove_break(state, addr);
}
Example #2
0
void do_delete(const std::string& symbol)
{
    lc3_remove_blackbox(state, symbol);
    lc3_remove_break(state, symbol);
    lc3_remove_watch(state, symbol);
    memory->Update();
}
Example #3
0
void do_delete(unsigned short address)
{
    lc3_remove_blackbox(state, address);
    lc3_remove_break(state, address);
    lc3_remove_watch(state, false, address);
    memory->Update();
}
Example #4
0
/** SetTemppoint
  *
  * Sets a temporary breakpoint
  */
void MemoryGrid::OnTemppoint(wxCommandEvent& event)
{
    int addr = -1;
    addr = GetSelectedRow();
    if (addr == -1) return;

    bool exist = lc3_add_break(state, (unsigned short) addr, "", "1", 1);
    if (exist) lc3_remove_break(state, (unsigned short) addr);
    Refresh(addr);
}
Example #5
0
/** lc3_break_test
  *
  * Tests if we have hit a breakpoint or a watchpoint.
  */
bool lc3_break_test(lc3_state& state, const lc3_state_change* changes)
{
    // Test for breakpoints
    if (state.breakpoints.find(state.pc) != state.breakpoints.end())
    {
        lc3_breakpoint_info& info = state.breakpoints[state.pc];
        if (info.enabled)
        {
            int boolean = 0;
            if (lc3_calculate(state, info.condition, boolean))
            {
                // Expression has an error...
                // TODO Restrict condition to 128 chars
                char buf[256];
                sprintf(buf, "Breakpoint: %s Error in Expression: %s", info.label.c_str(), info.condition.c_str());
                lc3_warning(state, buf);
            }
            else if (boolean)
            {
                // Halt
                state.halted = 1;
                info.hit_count++;
                // If we are concerned about the number of times and we have surpassed the max.
                if (info.max_hits >= 0 && info.hit_count >= info.max_hits)
                    // Time to delete
                    lc3_remove_break(state, state.pc);
            }
        }
    }

    // Test for watchpoints
    bool r7changed = state.regs[7] != changes->r7;
    // Have we modified a register or a memory address?
    if (changes->changes == LC3_REGISTER_CHANGE)
    {
        int reg = changes->location;
        if (state.reg_watchpoints.find(reg) != state.reg_watchpoints.end())
        {
            lc3_watchpoint_info& info = state.reg_watchpoints[reg];
            if (info.enabled)
            {
                int boolean = 0;
                if (lc3_calculate(state, info.condition, boolean))
                {
                    // Expression has an error...
                    // TODO Restrict condition to 128 chars and label to 32 chars
                    char buf[256];
                    sprintf(buf, "Watchpoint: %s Error in Expression: %s", info.label.c_str(), info.condition.c_str());
                    lc3_warning(state, buf);
                }
                else if (boolean)
                {
                    // Halt
                    state.halted = 1;
                    info.hit_count++;
                    // If we are concerned about the number of times and we have surpassed the max.
                    if (info.max_hits >= 0 && info.hit_count >= info.max_hits)
                        // Time to delete
                        lc3_remove_watch(state, true, reg);
                }
            }
        }
    }
    else if (changes->changes == LC3_MEMORY_CHANGE)
    {
        int mem = changes->location;
        if (state.mem_watchpoints.find(mem) != state.mem_watchpoints.end())
        {
            lc3_watchpoint_info& info = state.mem_watchpoints[mem];
            if (info.enabled)
            {
                int boolean = 0;
                if (lc3_calculate(state, info.condition, boolean))
                {
                    // Expression has an error...
                    // TODO Restrict condition to 128 chars and label to 32 chars
                    char buf[256];
                    sprintf(buf, "Watchpoint: %s Error in Expression: %s", info.label.c_str(), info.condition.c_str());
                    lc3_warning(state, buf);
                }
                else if (boolean)
                {
                    // Halt
                    state.halted = 1;
                    info.hit_count++;
                    // If we are concerned about the number of times and we have surpassed the max.
                    if (info.max_hits >= 0 && info.hit_count >= info.max_hits)
                        // Time to delete
                        lc3_remove_watch(state, false, mem);
                }
            }
        }
    }

    // Also handle r7 changes.
    if (r7changed)
    {
        int reg = 7;
        if (state.reg_watchpoints.find(reg) != state.reg_watchpoints.end())
        {
            lc3_watchpoint_info& info = state.reg_watchpoints[reg];
            if (info.enabled)
            {
                int boolean = 0;
                if (lc3_calculate(state, info.condition, boolean))
                {
                    // Expression has an error...
                    // TODO Restrict condition to 128 chars and label to 32 chars
                    char buf[256];
                    sprintf(buf, "Watchpoint: %s Error in Expression: %s", info.label.c_str(), info.condition.c_str());
                    lc3_warning(state, buf);
                }
                else if (boolean)
                {
                    // Halt
                    state.halted = 1;
                    info.hit_count++;
                    // If we are concerned about the number of times and we have surpassed the max.
                    if (info.max_hits >= 0 && info.hit_count >= info.max_hits)
                        // Time to delete
                        lc3_remove_watch(state, true, reg);
                }
            }
        }
    }

    return state.halted;
}