private void FireBreakpointEvent(int bpt) { // bpt equal to -1 means we're stepping if ((bpt == -1) || (BreakpointHit == null)) { return; } m64p_breakpoint breakpoint = new m64p_breakpoint(); m64pDebugBreakpointCommand(m64p_dbg_bkp_command.M64P_BKP_CMD_GET_STRUCT, (uint)bpt, ref breakpoint); BreakType type = BreakType.Execute; if (CheckBreakpointFlag(ref breakpoint, m64p_dbg_bkp_flags.M64P_BPT_FLAG_READ)) { type = BreakType.Read; } else if (CheckBreakpointFlag(ref breakpoint, m64p_dbg_bkp_flags.M64P_BPT_FLAG_WRITE)) { type = BreakType.Write; } BreakpointHit(breakpoint.address, type); }
/* TODO: Support address masks and null address */ public void SetBreakpoint(BreakType type, uint?address) { m64p_breakpoint breakpoint = new m64p_breakpoint { address = address.Value, endaddr = address.Value + 0x03, flags = (uint)m64p_dbg_bkp_flags.M64P_BPT_FLAG_ENABLED }; switch (type) { case BreakType.Read: breakpoint.flags |= (uint)m64p_dbg_bkp_flags.M64P_BPT_FLAG_READ; break; case BreakType.Write: breakpoint.flags |= (uint)m64p_dbg_bkp_flags.M64P_BPT_FLAG_WRITE; break; case BreakType.Execute: breakpoint.flags |= (uint)m64p_dbg_bkp_flags.M64P_BPT_FLAG_EXEC; break; } m64pDebugBreakpointCommand(m64p_dbg_bkp_command.M64P_BKP_CMD_ADD_STRUCT, 0, ref breakpoint); }
public void RemoveBreakpoint(BreakType type, uint?address) { int index = 0; switch (type) { case BreakType.Read: index = m64pDebugBreakpointLookup(address.Value, 4, (uint)m64p_dbg_bkp_flags.M64P_BPT_FLAG_READ); break; case BreakType.Write: index = m64pDebugBreakpointLookup(address.Value, 4, (uint)m64p_dbg_bkp_flags.M64P_BPT_FLAG_WRITE); break; case BreakType.Execute: index = m64pDebugBreakpointLookup(address.Value, 4, (uint)m64p_dbg_bkp_flags.M64P_BPT_FLAG_EXEC); break; } m64p_breakpoint unused = new m64p_breakpoint(); m64pDebugBreakpointCommand(m64p_dbg_bkp_command.M64P_BKP_CMD_REMOVE_IDX, (uint)index, ref unused); }
private bool CheckBreakpointFlag(ref m64p_breakpoint bkp, m64p_dbg_bkp_flags flag) { return((bkp.flags & (uint)flag) != 0); }