static void Main(string[] args) { Label.Checkpoint("init", "finish", (Object context) => { Context Context = (Context)context; Context.Prepare(@"__FILE__:__LINE__"); Context.WasEntryPointHit(@"__FILE__:__LINE__"); var res = Context.MIDebugger.Request("-handshake init"); Assert.Equal(MIResultClass.Done, res.Class, @"__FILE__:__LINE__"); MIConst request = (MIConst)res["request"]; // actually we don't need to calculate response at all, just check request Assert.Equal("\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\"", request.ToString(), @"__FILE__:__LINE__"); // netcoredbg should accept any response Assert.Equal(MIResultClass.Done, Context.MIDebugger.Request("-handshake response bla-bla-bla").Class, @"__FILE__:__LINE__"); Context.Continue(@"__FILE__:__LINE__"); }); Console.WriteLine("Hello World!"); Label.Checkpoint("finish", "", (Object context) => { Context Context = (Context)context; Context.WasExit(@"__FILE__:__LINE__"); Context.DebuggerExit(@"__FILE__:__LINE__"); }); }
private MIStreamRecord ParseStreamRecord(string response, int beginIndex, out int endIndex) { MIStreamRecordClass streamRecordClass = ParseStreamRecordClass(response, beginIndex, out endIndex); MIConst constant = ParseConst(response, endIndex, out endIndex); return(new MIStreamRecord(streamRecordClass, constant)); }
public static bool IsStoppedThreadInList(MIList threads, MIConst threadId) { var threadsArray = threads.ToArray(); foreach (var thread in threadsArray) { if (((MIConst)((MITuple)thread)["id"]).CString == threadId.CString && ((MIConst)((MITuple)thread)["state"]).CString == "stopped") { return(true); } ; } return(false); }
public static MIConst WasStep(string stepName) { MIConst Result = new MIConst("-1"); var bp = (LineBreakpoint)DebuggeeInfo.Breakpoints[stepName]; Func <MIOutOfBandRecord, bool> filter = (record) => { if (!IsStoppedEvent(record)) { return(false); } var output = ((MIAsyncRecord)record).Output; var reason = (MIConst)output["reason"]; if (reason.CString != "end-stepping-range") { return(false); } var frame = (MITuple)(output["frame"]); var numLine = (MIConst)(frame["line"]); if (numLine.CString == bp.NumLine.ToString()) { Result = (MIConst)output["thread-id"]; return(true); } return(false); }; if (MIDebugger.IsEventReceived(filter)) { return(Result); } throw new NetcoreDbgTestCore.ResultNotSuccessException(); }
static void Main(string[] args) { Label.Checkpoint("init", "test_steps", () => { Context.Prepare(); Context.WasEntryPointHit(); Assert.Equal(MIResultClass.Running, Context.MIDebugger.Request("4-exec-step").Class); }); Console.WriteLine("Hello World!"); Label.Breakpoint("STEP1"); Label.Checkpoint("test_steps", "finish", () => { MIConst threadId = Context.WasStep("STEP1"); // test for "thread-info" var res = Context.MIDebugger.Request("5-thread-info"); Assert.Equal(MIResultClass.Done, res.Class); Assert.True(Context.IsStoppedThreadInList((MIList)res["threads"], threadId)); Assert.Equal(MIResultClass.Running, Context.MIDebugger.Request("6-exec-step").Class); Context.WasStep("STEP2"); Assert.Equal(MIResultClass.Running, Context.MIDebugger.Request("7-exec-step").Class); Context.WasStep("STEP3"); Context.Continue(); }); func_test(); Label.Breakpoint("STEP2"); Label.Checkpoint("finish", "", () => { Context.WasExit(); Context.DebuggerExit(); }); }