public static void WasExit() { bool wasExited = false; int? exitCode = null; bool wasTerminated = false; Func <string, bool> filter = (resJSON) => { if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "exited")) { wasExited = true; ExitedEvent exitedEvent = JsonConvert.DeserializeObject <ExitedEvent>(resJSON); exitCode = exitedEvent.body.exitCode; } if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "terminated")) { wasTerminated = true; } if (wasExited && exitCode == 0 && wasTerminated) { return(true); } return(false); }; if (!VSCodeDebugger.IsEventReceived(filter)) { throw new NetcoreDbgTestCore.ResultNotSuccessException(); } }
public void WasExit(string caller_trace) { bool wasExited = false; int? exitCode = null; bool wasTerminated = false; Func <string, bool> filter = (resJSON) => { if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "exited")) { wasExited = true; ExitedEvent exitedEvent = JsonConvert.DeserializeObject <ExitedEvent>(resJSON); exitCode = exitedEvent.body.exitCode; } if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "terminated")) { wasTerminated = true; } if (wasExited && exitCode == 0 && wasTerminated) { return(true); } return(false); }; Assert.True(VSCodeDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace); }
public void WasExit(string caller_trace) { bool wasExited = false; bool wasTerminated = false; Func <string, bool> filter = (resJSON) => { if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "exited")) { wasExited = true; ExitedEvent exitedEvent = JsonConvert.DeserializeObject <ExitedEvent>(resJSON); } if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "terminated")) { wasTerminated = true; } // we don't check exit code here, since Windows and Linux provide different exit code in case of unhandled exception if (wasExited && wasTerminated) { return(true); } return(false); }; Assert.True(VSCodeDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace); }
public void WasExceptionBreakpointHitInExternalCode(string caller_trace, string excCategory, string excMode, string excName, string extFrame) { Func <string, bool> filter = (resJSON) => { if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") && VSCodeDebugger.isResponseContainProperty(resJSON, "reason", "exception")) { threadId = Convert.ToInt32(VSCodeDebugger.GetResponsePropertyValue(resJSON, "threadId")); return(true); } return(false); }; Assert.True(VSCodeDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace); StackTraceRequest stackTraceRequest = new StackTraceRequest(); stackTraceRequest.arguments.threadId = threadId; stackTraceRequest.arguments.startFrame = 0; stackTraceRequest.arguments.levels = 20; var ret = VSCodeDebugger.Request(stackTraceRequest); Assert.True(ret.Success, @"__FILE__:__LINE__" + "\n" + caller_trace); StackTraceResponse stackTraceResponse = JsonConvert.DeserializeObject <StackTraceResponse>(ret.ResponseStr); if (stackTraceResponse.body.stackFrames[0].name == extFrame) { TestExceptionInfo(@"__FILE__:__LINE__" + "\n" + caller_trace, excCategory, excMode, excName); return; } throw new ResultNotSuccessException(@"__FILE__:__LINE__" + "\n" + caller_trace); }
public static void WasExit() { bool wasExited = false; int? exitCode = null; bool wasTerminated = false; Func <string, bool> filter = (resJSON) => { if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "exited")) { wasExited = true; ExitedEvent exitedEvent = JsonConvert.DeserializeObject <ExitedEvent>(resJSON); exitCode = exitedEvent.body.exitCode; } if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "terminated")) { wasTerminated = true; } // we don't check exit code here, since Windows and Linux provide different exit code in case of "disconnectRequest" usage if (wasExited && wasTerminated) { return(true); } return(false); }; if (!VSCodeDebugger.IsEventReceived(filter)) { throw new NetcoreDbgTestCore.ResultNotSuccessException(); } }
public void WasPaused(string caller_trace) { Func <string, bool> filter = (resJSON) => { if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") && VSCodeDebugger.isResponseContainProperty(resJSON, "reason", "pause")) { return(true); } return(false); }; Assert.True(VSCodeDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace); }
public void WasEntryPointHit(string caller_trace) { Func <string, bool> filter = (resJSON) => { if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") && VSCodeDebugger.isResponseContainProperty(resJSON, "reason", "entry")) { threadId = Convert.ToInt32(VSCodeDebugger.GetResponsePropertyValue(resJSON, "threadId")); return(true); } return(false); }; Assert.True(VSCodeDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace); }
public static void WasStopped(string Reason, Breakpoint breakpoint) { Func <string, bool> filter = (resJSON) => { if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") && VSCodeDebugger.isResponseContainProperty(resJSON, "reason", Reason)) { if (Reason == "breakpoint") { threadId = Convert.ToInt32(VSCodeDebugger.GetResponsePropertyValue(resJSON, "threadId")); } return(true); } return(false); }; if (!VSCodeDebugger.IsEventReceived(filter)) { throw new NetcoreDbgTestCore.ResultNotSuccessException(); } StackTraceRequest stackTraceRequest = new StackTraceRequest(); stackTraceRequest.arguments.threadId = threadId; stackTraceRequest.arguments.startFrame = 0; stackTraceRequest.arguments.levels = 20; var ret = VSCodeDebugger.Request(stackTraceRequest); Assert.True(ret.Success); Assert.Equal(BreakpointType.Line, breakpoint.Type); var lbp = (LineBreakpoint)breakpoint; StackTraceResponse stackTraceResponse = JsonConvert.DeserializeObject <StackTraceResponse>(ret.ResponseStr); foreach (var Frame in stackTraceResponse.body.stackFrames) { if (Frame.line == lbp.NumLine && Frame.source.name == lbp.FileName // NOTE this code works only with one source file && Frame.source.path == DebuggeeInfo.SourceFilesPath) { return; } } throw new NetcoreDbgTestCore.ResultNotSuccessException(); }
public void WasBreakpointHitWithProperThreadID(string caller_trace, string bpName) { Func <string, bool> filter = (resJSON) => { if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") && VSCodeDebugger.isResponseContainProperty(resJSON, "reason", "breakpoint")) { threadId = Convert.ToInt32(VSCodeDebugger.GetResponsePropertyValue(resJSON, "threadId")); return(true); } return(false); }; threadId = -1; Assert.True(VSCodeDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace); Assert.True(isThredInThreadsList(@"__FILE__:__LINE__" + "\n" + caller_trace, threadId), @"__FILE__:__LINE__" + "\n" + caller_trace); StackTraceRequest stackTraceRequest = new StackTraceRequest(); stackTraceRequest.arguments.threadId = threadId; stackTraceRequest.arguments.startFrame = 0; stackTraceRequest.arguments.levels = 20; var ret = VSCodeDebugger.Request(stackTraceRequest); Assert.True(ret.Success, @"__FILE__:__LINE__" + "\n" + caller_trace); Breakpoint breakpoint = ControlInfo.Breakpoints[bpName]; Assert.Equal(BreakpointType.Line, breakpoint.Type, @"__FILE__:__LINE__" + "\n" + caller_trace); var lbp = (LineBreakpoint)breakpoint; StackTraceResponse stackTraceResponse = JsonConvert.DeserializeObject <StackTraceResponse>(ret.ResponseStr); foreach (var Frame in stackTraceResponse.body.stackFrames) { if (Frame.line == lbp.NumLine && Frame.source.name == lbp.FileName // NOTE this code works only with one source file && Frame.source.path == ControlInfo.SourceFilesPath) { return; } } throw new ResultNotSuccessException(@"__FILE__:__LINE__" + "\n" + caller_trace); }
public static void WasPaused() { Func <string, bool> filter = (resJSON) => { if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") && VSCodeDebugger.isResponseContainProperty(resJSON, "reason", "pause")) { return(true); } return(false); }; if (!VSCodeDebugger.IsEventReceived(filter)) { throw new NetcoreDbgTestCore.ResultNotSuccessException(); } }
public static void WasEntryPointHit() { Func <string, bool> filter = (resJSON) => { if (VSCodeDebugger.isResponseContainProperty(resJSON, "event", "stopped") && VSCodeDebugger.isResponseContainProperty(resJSON, "reason", "entry")) { threadId = Convert.ToInt32(VSCodeDebugger.GetResponsePropertyValue(resJSON, "threadId")); return(true); } return(false); }; if (!VSCodeDebugger.IsEventReceived(filter)) { throw new NetcoreDbgTestCore.ResultNotSuccessException(); } }