private void NetHandler_PausedEvent(object sender, PausedEventArgs e) { this.BeginInvoke((MethodInvoker) delegate { statusLabel.Text = "Connected. Paused."; UpdatePauseInfo(e.PauseInfo); }); }
public static void HandlePacket(byte[] data) { Debug.WriteLine("HandlePacket"); BinaryReader rdr = new BinaryReader(new MemoryStream(data)); var size = rdr.ReadUInt32(); var cmd = (PacketCmd)rdr.ReadUInt16(); var reqId = rdr.ReadUInt16(); if (cmd == PacketCmd.BpHit) { ResetDataCache(); currentlyPaused = true; var e = new BpHitEventArgs(); e.coreId = rdr.ReadUInt32(); e.PauseInfo = readDebugPauseInfo(rdr); BpHitEvent.Invoke(null, e); } else if (cmd == PacketCmd.CoreStepped) { ResetDataCache(); currentlyPaused = true; var e = new CoreSteppedEventArgs(); e.coreId = rdr.ReadUInt32(); e.PauseInfo = readDebugPauseInfo(rdr); CoreSteppedEvent.Invoke(null, e); } else if (cmd == PacketCmd.Paused) { ResetDataCache(); currentlyPaused = true; var e = new PausedEventArgs(); e.PauseInfo = readDebugPauseInfo(rdr); PausedEvent.Invoke(null, e); } else if (cmd == PacketCmd.ReadMemRes) { var address = rdr.ReadUInt32(); var numBytes = rdr.ReadUInt64(); var bytes = rdr.ReadBytes((int)numBytes); cacheMutex.WaitOne(); var pageIdx = address / GetMemoryPageSize(); var page = memDict[pageIdx]; if (page != null) { page.data = bytes; var waiters = page.waiters; page.waiters = new List <DoneNotif>(); waiters.ForEach((DoneNotif i) => { i(); }); } cacheMutex.ReleaseMutex(); } else if (cmd == PacketCmd.DisasmRes) { var address = rdr.ReadUInt32(); var numInstrs = rdr.ReadUInt64(); var instrs = new string[numInstrs]; for (var i = 0; i < (int)numInstrs; ++i) { instrs[i] = readString(rdr); } cacheMutex.WaitOne(); var pageIdx = address / GetInstrPageSize(); var page = instrDict[pageIdx]; if (page != null) { page.data = instrs; var waiters = page.waiters; page.waiters = new List <DoneNotif>(); waiters.ForEach((DoneNotif i) => { i(); }); } cacheMutex.ReleaseMutex(); } else if (cmd == PacketCmd.GetTraceRes) { var e = new GetTraceEventArgs(); e.ThreadId = rdr.ReadUInt32(); var numTraces = rdr.ReadUInt64(); e.Info = new DebugTraceEntry[numTraces]; for (ulong i = 0; i < numTraces; ++i) { e.Info[i] = readDebugTraceEntry(rdr); } GetTraceEvent.Invoke(null, e); } else { Debug.WriteLine(data); } }