public void CalcAndCheckExpression(string caller_trace, string ExpectedResult, string expr) { var res = MIDebugger.Request("-var-create - * \"" + expr + "\""); Assert.Equal(MIResultClass.Done, res.Class, @"__FILE__:__LINE__" + "\n" + caller_trace); Assert.Equal(ExpectedResult, ((MIConst)res["value"]).CString, @"__FILE__:__LINE__" + "\n" + caller_trace); }
public void CreateAndCompareVar(string caller_trace, string variable, string val) { var res = MIDebugger.Request("-var-create - * \"" + variable + "\""); Assert.Equal(MIResultClass.Done, res.Class, @"__FILE__:__LINE__" + "\n" + caller_trace); Assert.Equal(val, ((MIConst)res["value"]).CString, @"__FILE__:__LINE__" + "\n" + caller_trace); }
public void CheckEnum(string caller_trace, string VarName, string ExpectedResult) { var result = MIDebugger.Request(String.Format("-var-create - * \"{0}\"", VarName)); Assert.Equal(MIResultClass.Done, result.Class, @"__FILE__:__LINE__" + "\n" + caller_trace); Assert.Equal(ExpectedResult, ((MIConst)result["value"]).CString, @"__FILE__:__LINE__" + "\n" + caller_trace); }
public void WasEntryPointHit(string caller_trace) { Func <MIOutOfBandRecord, bool> filter = (record) => { if (!IsStoppedEvent(record)) { return(false); } var output = ((MIAsyncRecord)record).Output; var reason = (MIConst)output["reason"]; if (reason.CString != "entry-point-hit") { return(false); } var frame = (MITuple)output["frame"]; var func = (MIConst)frame["func"]; if (func.CString == ControlInfo.TestName + ".Program.Main()") { return(true); } return(false); }; Assert.True(MIDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace); }
public static bool WasStep(LineBreakpoint lbp) { 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 line = ((MIConst)frame["line"]).Int; if (lbp.NumLine == line) { return(true); } return(false); }; return(MIDebugger.IsEventReceived(filter)); }
public void WasExceptionBreakpointHit(string caller_trace, string bpName) { var bp = (LineBreakpoint)ControlInfo.Breakpoints[bpName]; Func <MIOutOfBandRecord, bool> filter = (record) => { if (!IsStoppedEvent(record)) { return(false); } var output = ((MIAsyncRecord)record).Output; var reason = (MIConst)output["reason"]; if (reason.CString != "exception-received") { return(false); } var frame = (MITuple)output["frame"]; var fileName = (MIConst)(frame["file"]); var numLine = (MIConst)(frame["line"]); if (fileName.CString == bp.FileName && numLine.CString == bp.NumLine.ToString()) { return(true); } return(false); }; Assert.True(MIDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace); }
public void GetResultAsString(string caller_trace, string expr, out string strRes) { var res = MIDebugger.Request("-var-create - * \"" + expr + "\""); Assert.Equal(MIResultClass.Done, res.Class, @"__FILE__:__LINE__" + "\n" + caller_trace); strRes = ((MIConst)res["value"]).CString; }
public void CheckErrorAtRequest(string caller_trace, string Expression, string errMsgStart) { var res = MIDebugger.Request(String.Format("-var-create - * \"{0}\"", Expression)); Assert.Equal(MIResultClass.Error, res.Class, @"__FILE__:__LINE__" + "\n" + caller_trace); Assert.True(((MIConst)res["msg"]).CString.StartsWith(errMsgStart), @"__FILE__:__LINE__" + "\n" + caller_trace); }
public void WasStep(string caller_trace, string bpName) { var bp = (LineBreakpoint)ControlInfo.Breakpoints[bpName]; 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 line = ((MIConst)frame["line"]).Int; if (bp.NumLine == line) { return(true); } return(false); }; Assert.True(MIDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace); }
public void WasManualBreakpointHit(string caller_trace, string bp_fileName, int bp_line) { Func <MIOutOfBandRecord, bool> filter = (record) => { if (!IsStoppedEvent(record)) { return(false); } var output = ((MIAsyncRecord)record).Output; var reason = (MIConst)output["reason"]; if (reason.CString != "breakpoint-hit") { return(false); } var frame = (MITuple)output["frame"]; var fileName = (MIConst)frame["file"]; var line = ((MIConst)frame["line"]).Int; if (fileName.CString == bp_fileName && line == bp_line) { return(true); } return(false); }; Assert.True(MIDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace); }
public void WasFuncBreakpointWithIdHit(string caller_trace, string func_name, string id) { Func <MIOutOfBandRecord, bool> filter = (record) => { if (!IsStoppedEvent(record)) { return(false); } var output = ((MIAsyncRecord)record).Output; var reason = (MIConst)output["reason"]; if (reason.CString != "breakpoint-hit") { return(false); } var frame = (MITuple)output["frame"]; var funcName = ((MIConst)frame["func"]).CString; var bkptno = ((MIConst)output["bkptno"]).CString; if (funcName.EndsWith(func_name) && bkptno == id) { return(true); } return(false); }; Assert.True(MIDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace); }
public static void WasEntryPointHit() { Func <MIOutOfBandRecord, bool> filter = (record) => { if (!IsStoppedEvent(record)) { return(false); } var output = ((MIAsyncRecord)record).Output; var reason = (MIConst)output["reason"]; if (reason.CString != "entry-point-hit") { return(false); } var frame = (MITuple)(output["frame"]); var func = (MIConst)(frame["func"]); if (func.CString == DebuggeeInfo.TestName + ".Program.Main()") { return(true); } return(false); }; if (!MIDebugger.IsEventReceived(filter)) { throw new NetcoreDbgTestCore.ResultNotSuccessException(); } }
public static void WasEntryPointHit() { // TODO: Implement API for comfortable searching // of out-of-band records var records = MIDebugger.Receive(); foreach (MIOutOfBandRecord record in records) { if (!IsStoppedEvent(record)) { continue; } var output = ((MIAsyncRecord)record).Output; // Currently let's believe that all *stopped events have // a reason of stopping var reason = (MIConst)output["reason"]; if (reason.CString != "entry-point-hit") { continue; } var frame = (MITuple)(output["frame"]); var func = (MIConst)(frame["func"]); if (func.CString == DebuggeeInfo.TestName + ".Program.Main()") { return; } } throw new NetcoreDbgTestCore.ResultNotSuccessException(); }
public static void WasBreakpointHit(Breakpoint breakpoint) { var records = MIDebugger.Receive(); var bp = (LineBreakpoint)breakpoint; foreach (MIOutOfBandRecord record in records) { if (!IsStoppedEvent(record)) { continue; } var output = ((MIAsyncRecord)record).Output; var reason = (MIConst)output["reason"]; if (reason.CString != "breakpoint-hit") { continue; } var frame = (MITuple)(output["frame"]); var fileName = (MIConst)(frame["file"]); var numLine = (MIConst)(frame["line"]); if (fileName.CString == bp.FileName && numLine.CString == bp.NumLine.ToString()) { return; } } throw new NetcoreDbgTestCore.ResultNotSuccessException(); }
public static void WasExit() { var records = MIDebugger.Receive(); foreach (MIOutOfBandRecord record in records) { if (!IsStoppedEvent(record)) { continue; } var output = ((MIAsyncRecord)record).Output; var reason = (MIConst)output["reason"]; if (reason.CString != "exited") { continue; } var exitCode = (MIConst)output["exit-code"]; if (exitCode.CString == "0") { return; } else { throw new NetcoreDbgTestCore.ResultNotSuccessException(); } } throw new NetcoreDbgTestCore.ResultNotSuccessException(); }
public static void WasExit() { Func <MIOutOfBandRecord, bool> filter = (record) => { if (!IsStoppedEvent(record)) { return(false); } var output = ((MIAsyncRecord)record).Output; var reason = (MIConst)output["reason"]; if (reason.CString != "exited") { return(false); } // we don't check exit code here, since Windows and Linux provide different exit code in case of "-gdb-exit" usage return(true); }; if (!MIDebugger.IsEventReceived(filter)) { throw new NetcoreDbgTestCore.ResultNotSuccessException(); } }
public static void WasStep(Breakpoint breakpoint) { var bp = (LineBreakpoint)breakpoint; 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 line = ((MIConst)frame["line"]).Int; if (bp.NumLine == line) { return(true); } return(false); }; if (!MIDebugger.IsEventReceived(filter)) { throw new NetcoreDbgTestCore.ResultNotSuccessException(); } }
public static void WasExit(int ExitCode) { Func <MIOutOfBandRecord, bool> filter = (record) => { if (!IsStoppedEvent(record)) { return(false); } var output = ((MIAsyncRecord)record).Output; var reason = (MIConst)output["reason"]; if (reason.CString != "exited") { return(false); } var exitCode = (MIConst)output["exit-code"]; if (exitCode.CString == ExitCode.ToString()) { return(true); } return(false); }; if (!MIDebugger.IsEventReceived(filter)) { throw new NetcoreDbgTestCore.ResultNotSuccessException(); } }
public void WasExceptionBreakpointHitInExternalCode(string caller_trace, string excCategory, string excStage, string excName) { Func <MIOutOfBandRecord, bool> filter = (record) => { if (!IsStoppedEvent(record)) { return(false); } var output = ((MIAsyncRecord)record).Output; var reason = (MIConst)output["reason"]; var category = (MIConst)output["exception-category"]; var stage = (MIConst)output["exception-stage"]; var name = (MIConst)output["exception-name"]; if (reason.CString != "exception-received" || category.CString != excCategory || stage.CString != excStage || name.CString != excName) { return(false); } var frame = (MITuple)output["frame"]; var func = (MIConst)(frame["func"]); if (func.CString == "[External Code]") { return(true); } return(false); }; Assert.True(MIDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace); }
public static string GetBreakpointHitId(Breakpoint bp) { string Result = "-1"; var bpLine = ((LineBreakpoint)bp).NumLine.ToString(); Func <MIOutOfBandRecord, bool> filter = (record) => { if (!IsStoppedEvent(record)) { return(false); } var output = ((MIAsyncRecord)record).Output; var reason = (MIConst)output["reason"]; if (reason.CString != "breakpoint-hit") { return(false); } var frame = (MITuple)(output["frame"]); var line = (MIConst)(frame["line"]); if (bpLine == line.CString) { Result = ((MIConst)output["bkptno"]).CString; return(true); } return(false); }; MIDebugger.IsEventReceived(filter); return(Result); }
public static void WasFuncBreakpointHit(string func_name, string id) { Func <MIOutOfBandRecord, bool> filter = (record) => { if (!IsStoppedEvent(record)) { return(false); } var output = ((MIAsyncRecord)record).Output; var reason = (MIConst)output["reason"]; if (reason.CString != "breakpoint-hit") { return(false); } var frame = (MITuple)(output["frame"]); var funcName = ((MIConst)frame["func"]).CString; var bkptno = ((MIConst)output["bkptno"]).CString; if (funcName.EndsWith(func_name) && bkptno == id) { return(true); } return(false); }; if (!MIDebugger.IsEventReceived(filter)) { throw new NetcoreDbgTestCore.ResultNotSuccessException(); } }
public void WasExit(string caller_trace) { Func <MIOutOfBandRecord, bool> filter = (record) => { if (!IsStoppedEvent(record)) { return(false); } var output = ((MIAsyncRecord)record).Output; var reason = (MIConst)output["reason"]; if (reason.CString != "exited") { return(false); } var exitCode = (MIConst)output["exit-code"]; if (exitCode.CString == "0") { return(true); } return(false); }; Assert.True(MIDebugger.IsEventReceived(filter), @"__FILE__:__LINE__" + "\n" + caller_trace); }
public static void CreateAndCompareVar(string variable, string val) { var res = MIDebugger.Request("-var-create - * \"" + variable + "\""); Assert.Equal(MIResultClass.Done, res.Class); Assert.Equal(val, ((MIConst)res["value"]).CString); }
public static bool DoStepTo(string lbpName) { var lbp = (LineBreakpoint)DebuggeeInfo.Breakpoints[lbpName]; Assert.Equal(MIResultClass.Running, MIDebugger.Request("-exec-next").Class); return(WasStep(lbp)); }
public static string CalcExpression(string expr, int token) { var res = MIDebugger.Request(token.ToString() + "-var-create - * \"" + expr + "\""); Assert.Equal(MIResultClass.Done, res.Class); return(((MIConst)res["value"]).CString); }
public void CheckVar(string caller_trace, string varName) { // varName is equal to it value; var res = MIDebugger.Request("-var-create - * \"" + varName + "\""); if (res.Class != MIResultClass.Done || ((MIConst)res["value"]).String != "\"" + varName + "\"") { throw new ResultNotSuccessException(@"__FILE__:__LINE__" + "\n" + caller_trace); } }
public string GetAndCheckValue(string caller_trace, string ExpectedResult, string ExpectedType, string Expression) { var res = MIDebugger.Request(String.Format("-var-create - * \"{0}\"", Expression)); Assert.Equal(MIResultClass.Done, res.Class, @"__FILE__:__LINE__" + "\n" + caller_trace); Assert.Equal(Expression, ((MIConst)res["exp"]).CString, @"__FILE__:__LINE__" + "\n" + caller_trace); Assert.Equal(ExpectedType, ((MIConst)res["type"]).CString, @"__FILE__:__LINE__" + "\n" + caller_trace); Assert.Equal(ExpectedResult, ((MIConst)res["value"]).CString, @"__FILE__:__LINE__" + "\n" + caller_trace); return(((MIConst)res["name"]).CString); }
public static void Prepare() { Assert.Equal(MIResultClass.Done, MIDebugger.Request("-file-exec-and-symbols " + DebuggeeInfo.CorerunPath).Class); Assert.Equal(MIResultClass.Done, MIDebugger.Request("-exec-arguments " + DebuggeeInfo.TargetAssemblyPath).Class); Assert.Equal(MIResultClass.Running, MIDebugger.Request("-exec-run").Class); }
public static void EnableBreakpoint(string bpName) { Breakpoint bp = DebuggeeInfo.Breakpoints[bpName]; Assert.Equal(BreakpointType.Line, bp.Type); var lbp = (LineBreakpoint)bp; Assert.Equal(MIResultClass.Done, MIDebugger.Request("-break-insert -f " + lbp.FileName + ":" + lbp.NumLine).Class); }
public void EnableBreakpoint(string caller_trace, string bpName) { Breakpoint bp = ControlInfo.Breakpoints[bpName]; Assert.Equal(BreakpointType.Line, bp.Type, @"__FILE__:__LINE__" + "\n" + caller_trace); var lbp = (LineBreakpoint)bp; Assert.Equal(MIResultClass.Done, MIDebugger.Request("-break-insert -f " + lbp.FileName + ":" + lbp.NumLine).Class, @"__FILE__:__LINE__" + "\n" + caller_trace); }