internal static void Send(AD7Engine engine, IDebugBoundBreakpoint2 boundBreakpoint) { AD7BreakpointEvent eventObject = new AD7BreakpointEvent(boundBreakpoint); engine.Send(eventObject, IID, null); }
private async Task ReadNamedPipeAsync() { string pipeID = pID.ToString(); using (NamedPipeServerStream pipeServer = new NamedPipeServerStream("luaPipeR" + pipeID, PipeDirection.In, 1, PipeTransmissionMode.Message, PipeOptions.Asynchronous)) { await Task.Factory.FromAsync((cb, state) => pipeServer.BeginWaitForConnection(cb, state), ar => pipeServer.EndWaitForConnection(ar), null); using (StreamReader pipeReader = new StreamReader(pipeServer)) { await TaskScheduler.Default; while (this.keepReadPipeOpen) { string command = await pipeReader.ReadLineAsync(); switch (command) { case "BreakpointHit": { debugThread.SourceFile = await pipeReader.ReadLineAsync(); debugThread.Line = uint.Parse(await pipeReader.ReadLineAsync()); debugThread.FuncName = await pipeReader.ReadLineAsync(); // Receive Callstack debugThread.FrameCount = int.Parse(await pipeReader.ReadLineAsync()); List <Frame> frames = new List <Frame>(debugThread.FrameCount); for (int stackLineIndex = 0; stackLineIndex < debugThread.FrameCount; stackLineIndex++) { string func = await pipeReader.ReadLineAsync(); string source = await pipeReader.ReadLineAsync(); string line = await pipeReader.ReadLineAsync(); frames.Add(new Frame(func, source, line)); } debugThread.StackFrames = frames; int numberToRead = int.Parse(await pipeReader.ReadLineAsync()); List <Variable> variables = new List <Variable>(numberToRead); for (int localIndex = 0; localIndex < numberToRead; localIndex++) { variables.Add(new Variable(await pipeReader.ReadLineAsync(), await pipeReader.ReadLineAsync(), await pipeReader.ReadLineAsync())); } debugThread.NumberOfLocals = numberToRead; debugThread.Locals = variables; AD7BreakpointEvent.Send(this, breakpointManager.GetBoundBreakpoint(debugThread.SourceFile + debugThread.Line)); break; } case "BreakpointBound": string fileandline = await pipeReader.ReadLineAsync(); AD7BoundBreakpoint boundbp = breakpointManager.GetBoundBreakpoint(fileandline); AD7BreakpointBoundEvent boundBreakpointEvent = new AD7BreakpointBoundEvent(boundbp); Send(boundBreakpointEvent, AD7BreakpointBoundEvent.IID, this); break; case "StepComplete": { debugThread.FrameCount = 1; debugThread.SourceFile = await pipeReader.ReadLineAsync(); debugThread.Line = uint.Parse(await pipeReader.ReadLineAsync()); debugThread.FuncName = await pipeReader.ReadLineAsync(); // Receive Callstack debugThread.FrameCount = int.Parse(await pipeReader.ReadLineAsync()); List <Frame> frames = new List <Frame>(debugThread.FrameCount); for (int stackLineIndex = 0; stackLineIndex < debugThread.FrameCount; stackLineIndex++) { string func = await pipeReader.ReadLineAsync(); string source = await pipeReader.ReadLineAsync(); string line = await pipeReader.ReadLineAsync(); frames.Add(new Frame(func, source, line)); } debugThread.StackFrames = frames; int numberToRead = int.Parse(await pipeReader.ReadLineAsync()); List <Variable> variables = new List <Variable>(numberToRead); for (int localIndex = 0; localIndex < numberToRead; localIndex++) { variables.Add(new Variable(await pipeReader.ReadLineAsync(), await pipeReader.ReadLineAsync(), await pipeReader.ReadLineAsync())); } debugThread.NumberOfLocals = numberToRead; debugThread.Locals = variables; Send(new AD7StepCompleteEvent(), AD7StepCompleteEvent.IID, this); break; } } } } } }