Assert.Equal(MIResultClass.Running, MIDebugger.Request("-exec-run").Class);
}
- public static bool IsStoppedEvent(MIOutOfBandRecord record)
+ static bool IsStoppedEvent(MIOutOfBandRecord record)
{
if (record.Type != MIOutOfBandRecordType.Async) {
return false;
public static void WasEntryPointHit()
{
- // TODO: Implement API for comfortable searching
- // of out-of-band records
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
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;
+ return false;
}
var frame = (MITuple)(output["frame"]);
var func = (MIConst)(frame["func"]);
if (func.CString == DebuggeeInfo.TestName + ".Program.Main()") {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void WasBreakpointHit(Breakpoint breakpoint)
{
- var records = MIDebugger.Receive();
var bp = (LineBreakpoint)breakpoint;
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "breakpoint-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
if (fileName.CString == bp.FileName &&
numLine.CString == bp.NumLine.ToString()) {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void WasExit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "exited") {
- continue;
+ return false;
}
var exitCode = (MIConst)output["exit-code"];
if (exitCode.CString == "0") {
- return;
- } else {
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void DebuggerExit()
{
class Context
{
- public static bool IsStoppedEvent(MIOutOfBandRecord record)
+ static bool IsStoppedEvent(MIOutOfBandRecord record)
{
if (record.Type != MIOutOfBandRecordType.Async) {
return false;
public static void WasEntryPointHit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
-
var reason = (MIConst)output["reason"];
+
if (reason.CString != "entry-point-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
var func = (MIConst)(frame["func"]);
if (func.CString == DebuggeeInfo.TestName + ".Program.Main()") {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void WasBreakpointHit(Breakpoint breakpoint, string id)
{
- var records = MIDebugger.Receive();
var bp = (LineBreakpoint)breakpoint;
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "breakpoint-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
if (numLine == bp.NumLine.ToString() &&
bkptno == id) {
- return;
- }
- }
+ return true;
+ }
+
+ return false;
+ };
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void WasFuncBreakpointHit(string func_name, string id)
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "breakpoint-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
if (funcName.EndsWith(func_name) &&
bkptno == id) {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void WasExit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "exited") {
- continue;
+ return false;
}
var exitCode = (MIConst)output["exit-code"];
if (exitCode.CString == "0") {
- return;
- } else {
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void DebuggerExit()
{
public static void WasEntryPointHit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
-
var reason = (MIConst)output["reason"];
if (reason.CString != "entry-point-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
var func = (MIConst)(frame["func"]);
if (func.CString == DebuggeeInfo.TestName + ".Program.Main()") {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
- public static bool IsStoppedEvent(MIOutOfBandRecord record)
+ static bool IsStoppedEvent(MIOutOfBandRecord record)
{
if (record.Type != MIOutOfBandRecordType.Async) {
return false;
public static void WasExit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "exited") {
- continue;
+ return false;
}
var exitCode = (MIConst)output["exit-code"];
if (exitCode.CString == "0") {
- return;
- } else {
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void DebuggerExit()
{
public static void WasEntryPointHit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
+
if (reason.CString != "entry-point-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
var func = (MIConst)(frame["func"]);
if (func.CString == DebuggeeInfo.TestName + ".Program.Main()") {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static bool IsValidFrame(MIResult frame, string bpName, int level)
public static bool WasStep(LineBreakpoint lbp)
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "end-stepping-range") {
- continue;
+ return false;
}
var frame = (MITuple)output["frame"];
if (lbp.NumLine == line) {
return true;
}
- }
- return false;
+ return false;
+ };
+
+ return MIDebugger.IsEventReceived(filter);
}
public static void WasExit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "exited") {
- continue;
+ return false;
}
var exitCode = (MIConst)output["exit-code"];
if (exitCode.CString == "0") {
- return;
- } else {
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void DebuggerExit()
Assert.Equal(MIResultClass.Exit, Context.MIDebugger.Request("-gdb-exit").Class);
}
- public static bool IsStoppedEvent(MIOutOfBandRecord record)
+ static bool IsStoppedEvent(MIOutOfBandRecord record)
{
if (record.Type != MIOutOfBandRecordType.Async) {
return false;
Label.Checkpoint("test_steps", "try_catch", () => {
Assert.True(Context.DoStepTo("STEP1"));
Assert.True(Context.DoStepTo("TRY1"));
- Assert.True(Context.DoStepTo("TRY1"));
+ Assert.True(Context.DoStepTo("TRY2"));
Assert.True(Context.DoStepTo("TRY3"));
Assert.True(Context.DoStepTo("CATCH1"));
Assert.True(Context.DoStepTo("CATCH2"));
\r
public static void WasEntryPointHit()\r
{\r
- var records = MIDebugger.Receive();\r
-\r
- foreach (MIOutOfBandRecord record in records) {\r
+ Func<MIOutOfBandRecord, bool> filter = (record) => {\r
if (!IsStoppedEvent(record)) {\r
- continue;\r
+ return false;\r
}\r
\r
var output = ((MIAsyncRecord)record).Output;\r
var reason = (MIConst)output["reason"];\r
+\r
if (reason.CString != "entry-point-hit") {\r
- continue;\r
+ return false;\r
}\r
\r
var frame = (MITuple)(output["frame"]);\r
var func = (MIConst)(frame["func"]);\r
if (func.CString == DebuggeeInfo.TestName + ".Program.Main()") {\r
- return;\r
+ return true;\r
}\r
- }\r
\r
- throw new NetcoreDbgTestCore.ResultNotSuccessException();\r
+ return false;\r
+ };\r
+\r
+ if (!MIDebugger.IsEventReceived(filter))\r
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();\r
}\r
\r
public static void EnableBreakpoint(string bpName)\r
\r
public static void WasBreakpointHit(Breakpoint breakpoint)\r
{\r
- var records = MIDebugger.Receive();\r
var bp = (LineBreakpoint)breakpoint;\r
\r
- foreach (MIOutOfBandRecord record in records) {\r
+ Func<MIOutOfBandRecord, bool> filter = (record) => {\r
if (!IsStoppedEvent(record)) {\r
- continue;\r
+ return false;\r
}\r
\r
var output = ((MIAsyncRecord)record).Output;\r
var reason = (MIConst)output["reason"];\r
\r
if (reason.CString != "breakpoint-hit") {\r
- continue;\r
+ return false;\r
}\r
\r
var frame = (MITuple)(output["frame"]);\r
\r
if (fileName.CString == bp.FileName &&\r
numLine.CString == bp.NumLine.ToString()) {\r
- return;\r
+ return true;\r
}\r
- }\r
\r
- throw new NetcoreDbgTestCore.ResultNotSuccessException();\r
+ return false;\r
+ };\r
+\r
+ if (!MIDebugger.IsEventReceived(filter))\r
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();\r
}\r
\r
public static void WasExceptionBreakpointHit(Breakpoint breakpoint)\r
{\r
- var records = MIDebugger.Receive();\r
var bp = (LineBreakpoint)breakpoint;\r
- // should check only the last one event\r
- MIOutOfBandRecord record = records[records.Length - 1];\r
\r
- if (!IsStoppedEvent(record)) {\r
- throw new NetcoreDbgTestCore.ResultNotSuccessException();\r
- }\r
+ Func<MIOutOfBandRecord, bool> filter = (record) => {\r
+ if (!IsStoppedEvent(record)) {\r
+ return false;\r
+ }\r
\r
- var output = ((MIAsyncRecord)record).Output;\r
- var reason = (MIConst)output["reason"];\r
+ var output = ((MIAsyncRecord)record).Output;\r
+ var reason = (MIConst)output["reason"];\r
\r
- if (reason.CString != "exception-received") {\r
- throw new NetcoreDbgTestCore.ResultNotSuccessException();\r
- }\r
+ if (reason.CString != "exception-received") {\r
+ return false;\r
+ }\r
\r
- var frame = (MITuple)(output["frame"]);\r
- var fileName = (MIConst)(frame["file"]);\r
- var numLine = (MIConst)(frame["line"]);\r
+ var frame = (MITuple)(output["frame"]);\r
+ var fileName = (MIConst)(frame["file"]);\r
+ var numLine = (MIConst)(frame["line"]);\r
\r
- if (fileName.CString == bp.FileName &&\r
- numLine.CString == bp.NumLine.ToString()) {\r
- return;\r
- }\r
+ if (fileName.CString == bp.FileName &&\r
+ numLine.CString == bp.NumLine.ToString()) {\r
+ return true;\r
+ }\r
\r
- throw new NetcoreDbgTestCore.ResultNotSuccessException();\r
+ return false;\r
+ };\r
+\r
+ if (!MIDebugger.IsEventReceived(filter))\r
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();\r
}\r
\r
public static void WasExit()\r
{\r
- var records = MIDebugger.Receive();\r
-\r
- foreach (MIOutOfBandRecord record in records) {\r
+ Func<MIOutOfBandRecord, bool> filter = (record) => {\r
if (!IsStoppedEvent(record)) {\r
- continue;\r
+ return false;\r
}\r
\r
var output = ((MIAsyncRecord)record).Output;\r
var reason = (MIConst)output["reason"];\r
\r
if (reason.CString != "exited") {\r
- continue;\r
+ return false;\r
}\r
\r
var exitCode = (MIConst)output["exit-code"];\r
\r
if (exitCode.CString == "0") {\r
- return;\r
- } else {\r
- throw new NetcoreDbgTestCore.ResultNotSuccessException();\r
+ return true;\r
}\r
- }\r
\r
- throw new NetcoreDbgTestCore.ResultNotSuccessException();\r
+ return false;\r
+ };\r
+\r
+ if (!MIDebugger.IsEventReceived(filter))\r
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();\r
}\r
\r
public static void DebuggerExit()\r
Assert.Equal(MIResultClass.Exit, Context.MIDebugger.Request("-gdb-exit").Class);\r
}\r
\r
- public static bool IsStoppedEvent(MIOutOfBandRecord record)\r
+ static bool IsStoppedEvent(MIOutOfBandRecord record)\r
{\r
if (record.Type != MIOutOfBandRecordType.Async) {\r
return false;\r
Assert.Equal(MIResultClass.Running, MIDebugger.Request("-exec-run").Class);
}
- public static bool IsStoppedEvent(MIOutOfBandRecord record)
+ static bool IsStoppedEvent(MIOutOfBandRecord record)
{
if (record.Type != MIOutOfBandRecordType.Async) {
return false;
public static void WasEntryPointHit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
-
var reason = (MIConst)output["reason"];
if (reason.CString != "entry-point-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
var func = (MIConst)(frame["func"]);
if (func.CString == DebuggeeInfo.TestName + ".Program.Main()") {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void DebuggerExit()
Assert.Equal(MIResultClass.Running, MIDebugger.Request("-exec-run").Class);
}
- public static bool IsStoppedEvent(MIOutOfBandRecord record)
+ static bool IsStoppedEvent(MIOutOfBandRecord record)
{
if (record.Type != MIOutOfBandRecordType.Async) {
return false;
public static void WasEntryPointHit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
-
var reason = (MIConst)output["reason"];
if (reason.CString != "entry-point-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
var func = (MIConst)(frame["func"]);
if (func.CString == DebuggeeInfo.TestName + ".Program.Main()") {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void WasBreakpointHit(Breakpoint breakpoint)
{
- var records = MIDebugger.Receive();
var bp = (LineBreakpoint)breakpoint;
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "breakpoint-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
if (fileName.CString == bp.FileName &&
numLine.CString == bp.NumLine.ToString()) {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void WasExit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "exited") {
- continue;
+ return false;
}
var exitCode = (MIConst)output["exit-code"];
if (exitCode.CString == "0") {
- return;
- } else {
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void DebuggerExit()
public static void WasStep(Breakpoint breakpoint)
{
- var records = MIDebugger.Receive();
var bp = (LineBreakpoint)breakpoint;
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "end-stepping-range") {
- continue;
+ return false;
}
var frame = (MITuple)output["frame"];
var line = ((MIConst)frame["line"]).Int;
if (bp.NumLine == line) {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void Continue()
Assert.Equal(MIResultClass.Running, MIDebugger.Request("-exec-run").Class);
}
- public static bool IsStoppedEvent(MIOutOfBandRecord record)
+ static bool IsStoppedEvent(MIOutOfBandRecord record)
{
if (record.Type != MIOutOfBandRecordType.Async) {
return false;
public static void WasEntryPointHit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
-
var reason = (MIConst)output["reason"];
if (reason.CString != "entry-point-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
var func = (MIConst)(frame["func"]);
if (func.CString == DebuggeeInfo.TestName + ".Program.Main()") {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void DebuggerExit()
public static void WasEntryPointHit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
+
if (reason.CString != "entry-point-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
var func = (MIConst)(frame["func"]);
if (func.CString == DebuggeeInfo.TestName + ".Program.Main()") {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static string GetBreakpointHitId(Breakpoint bp)
{
- var records = MIDebugger.Receive();
+ string Result = "-1";
var bpLine = ((LineBreakpoint)bp).NumLine.ToString();
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "breakpoint-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
var line = (MIConst)(frame["line"]);
if (bpLine == line.CString) {
- return ((MIConst)output["bkptno"]).CString;
+ Result = ((MIConst)output["bkptno"]).CString;
+ return true;
}
- }
- return "-1";
+ return false;
+ };
+
+ MIDebugger.IsEventReceived(filter);
+
+ return Result;
}
public static void WasExit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "exited") {
- continue;
+ return false;
}
var exitCode = (MIConst)output["exit-code"];
if (exitCode.CString == "0") {
- return;
- } else {
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void DebuggerExit()
Assert.Equal(MIResultClass.Exit, Context.MIDebugger.Request("-gdb-exit").Class);
}
- public static bool IsStoppedEvent(MIOutOfBandRecord record)
+ static bool IsStoppedEvent(MIOutOfBandRecord record)
{
if (record.Type != MIOutOfBandRecordType.Async) {
return false;
Assert.Equal(MIResultClass.Running, MIDebugger.Request("-exec-run").Class);
}
- public static bool IsStoppedEvent(MIOutOfBandRecord record)
+ static bool IsStoppedEvent(MIOutOfBandRecord record)
{
if (record.Type != MIOutOfBandRecordType.Async) {
return false;
public static void WasEntryPointHit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
-
var reason = (MIConst)output["reason"];
if (reason.CString != "entry-point-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
var func = (MIConst)(frame["func"]);
if (func.CString == DebuggeeInfo.TestName + ".Program.Main()") {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void WasExit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "exited") {
- continue;
+ return false;
}
var exitCode = (MIConst)output["exit-code"];
if (exitCode.CString == "0") {
- return;
- } else {
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void Continue()
Assert.Equal(MIResultClass.Running, MIDebugger.Request("-exec-run").Class);
}
- public static bool IsStoppedEvent(MIOutOfBandRecord record)
+ static bool IsStoppedEvent(MIOutOfBandRecord record)
{
if (record.Type != MIOutOfBandRecordType.Async) {
return false;
public static void WasEntryPointHit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
-
var reason = (MIConst)output["reason"];
if (reason.CString != "entry-point-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
var func = (MIConst)(frame["func"]);
if (func.CString == DebuggeeInfo.TestName + ".Program.Main()") {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void WasExit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "exited") {
- continue;
+ return false;
}
var exitCode = (MIConst)output["exit-code"];
if (exitCode.CString == "0") {
- return;
- } else {
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void DebuggerExit()
{
public static void WasEntryPointHit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
+
if (reason.CString != "entry-point-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
var func = (MIConst)(frame["func"]);
if (func.CString == DebuggeeInfo.TestName + ".Program.Main()") {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void WasBreakpointHit(Breakpoint breakpoint)
{
- var records = MIDebugger.Receive();
var bp = (LineBreakpoint)breakpoint;
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "breakpoint-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
if (fileName.CString == bp.FileName &&
numLine.CString == bp.NumLine.ToString()) {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void WasExit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "exited") {
- continue;
+ return false;
}
var exitCode = (MIConst)output["exit-code"];
if (exitCode.CString == "0") {
- return;
- } else {
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void DebuggerExit()
public static void WasEntryPointHit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
+
if (reason.CString != "entry-point-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
var func = (MIConst)(frame["func"]);
if (func.CString == DebuggeeInfo.TestName + ".Program.Main()") {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
- public static void WasBreakpointHit(Breakpoint bp)
+ public static void WasBreakpointHit(Breakpoint breakpoint)
{
- var records = MIDebugger.Receive();
- var bpLine = ((LineBreakpoint)bp).NumLine.ToString();
+ var bp = (LineBreakpoint)breakpoint;
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
+
if (reason.CString != "breakpoint-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
- var line = (MIConst)(frame["line"]);
+ var fileName = (MIConst)(frame["file"]);
+ var numLine = (MIConst)(frame["line"]);
- if (bpLine == line.CString) {
- return;
+ if (fileName.CString == bp.FileName &&
+ numLine.CString == bp.NumLine.ToString()) {
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void WasExit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "exited") {
- continue;
+ return false;
}
var exitCode = (MIConst)output["exit-code"];
if (exitCode.CString == "0") {
- return;
- } else {
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void DebuggerExit()
Assert.Equal(MIResultClass.Exit, Context.MIDebugger.Request("-gdb-exit").Class);
}
- public static bool IsStoppedEvent(MIOutOfBandRecord record)
+ static bool IsStoppedEvent(MIOutOfBandRecord record)
{
if (record.Type != MIOutOfBandRecordType.Async) {
return false;
public static void WasEntryPointHit()
{
- // TODO: Implement API for comfortable searching
- // of out-of-band records
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
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;
+ return false;
}
var frame = (MITuple)(output["frame"]);
var func = (MIConst)(frame["func"]);
if (func.CString == DebuggeeInfo.TestName + ".Program.Main()") {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static MIConst WasStep(string stepName)
{
- var records = MIDebugger.Receive();
+ MIConst Result = new MIConst("-1");
var bp = (LineBreakpoint)DebuggeeInfo.Breakpoints[stepName];
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "end-stepping-range") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
var numLine = (MIConst)(frame["line"]);
if (numLine.CString == bp.NumLine.ToString()) {
- return (MIConst)output["thread-id"];
+ Result = (MIConst)output["thread-id"];
+ return true;
}
- }
+
+ return false;
+ };
+
+ if (MIDebugger.IsEventReceived(filter))
+ return Result;
throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void WasExit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "exited") {
- continue;
+ return false;
}
var exitCode = (MIConst)output["exit-code"];
if (exitCode.CString == "0") {
- return;
- } else {
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void DebuggerExit()
Assert.Equal(MIResultClass.Exit, Context.MIDebugger.Request("-gdb-exit").Class);
}
- public static bool IsStoppedEvent(MIOutOfBandRecord record)
+ static bool IsStoppedEvent(MIOutOfBandRecord record)
{
if (record.Type != MIOutOfBandRecordType.Async) {
return false;
{
class Context
{
- public static bool IsStoppedEvent(MIOutOfBandRecord record)
+ static bool IsStoppedEvent(MIOutOfBandRecord record)
{
if (record.Type != MIOutOfBandRecordType.Async) {
return false;
public static void WasBreakpointHit(Breakpoint breakpoint)
{
- var records = MIDebugger.Receive();
var bp = (LineBreakpoint)breakpoint;
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "breakpoint-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
if (fileName.CString == bp.FileName &&
numLine.CString == bp.NumLine.ToString()) {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void EnableBreakpoint(string bpName)
Assert.Equal(MIResultClass.Running, MIDebugger.Request("-exec-run").Class);
}
- public static bool IsStoppedEvent(MIOutOfBandRecord record)
+ static bool IsStoppedEvent(MIOutOfBandRecord record)
{
if (record.Type != MIOutOfBandRecordType.Async) {
return false;
public static void WasEntryPointHit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
-
var reason = (MIConst)output["reason"];
+
if (reason.CString != "entry-point-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
var func = (MIConst)(frame["func"]);
if (func.CString == DebuggeeInfo.TestName + ".Program.Main()") {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void WasBreakpointHit(Breakpoint breakpoint)
{
- var records = MIDebugger.Receive();
var bp = (LineBreakpoint)breakpoint;
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "breakpoint-hit") {
- continue;
+ return false;
}
var frame = (MITuple)(output["frame"]);
if (fileName.CString == bp.FileName &&
numLine.CString == bp.NumLine.ToString()) {
- return;
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void WasExit()
{
- var records = MIDebugger.Receive();
-
- foreach (MIOutOfBandRecord record in records) {
+ Func<MIOutOfBandRecord, bool> filter = (record) => {
if (!IsStoppedEvent(record)) {
- continue;
+ return false;
}
var output = ((MIAsyncRecord)record).Output;
var reason = (MIConst)output["reason"];
if (reason.CString != "exited") {
- continue;
+ return false;
}
var exitCode = (MIConst)output["exit-code"];
if (exitCode.CString == "0") {
- return;
- } else {
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return true;
}
- }
- throw new NetcoreDbgTestCore.ResultNotSuccessException();
+ return false;
+ };
+
+ if (!MIDebugger.IsEventReceived(filter))
+ throw new NetcoreDbgTestCore.ResultNotSuccessException();
}
public static void DebuggerExit()
+using System;
using System.Collections.Generic;
using NetcoreDbgTestCore;
using NetcoreDbgTestCore.MI;
public MIResultRecord Request(string command, int timeout = -1)
{
MIResultRecord resultRecord = null;
- EventsAddedOnLastRequest = false;
Logger.LogLine("> " + command);
Logger.LogLine("< " + line);
}
+ // we could get async record, in this case we could have two "(gdb)" prompts one by one
+ // NOTE in this case we have only one line response, that contain prompt only
+ if (MIParser.IsEnd(response[0]))
+ continue;
+
MIOutput output = MIParser.ParseOutput(response);
if (output.ResultRecord != null) {
resultRecord = output.ResultRecord;
break;
} else {
- OutOfBandRecords.AddRange(output.OutOfBandRecords);
- EventsAddedOnLastRequest = true;
+ foreach (var record in output.OutOfBandRecords) {
+ EventQueue.Enqueue(record);
+ }
}
}
return resultRecord;
}
- public MIOutOfBandRecord[] Receive(int timeout = -1)
+ void ReceiveEvents(int timeout = -1)
{
- if (EventsAddedOnLastRequest) {
- EventsAddedOnLastRequest = false;
- return OutOfBandRecords.ToArray();
- }
-
string[] response = Debuggee.DebuggerClient.Receive(timeout);
if (response == null) {
throw new MIParserException();
}
- OutOfBandRecords.AddRange(output.OutOfBandRecords);
+ foreach (var record in output.OutOfBandRecords) {
+ EventQueue.Enqueue(record);
+ }
+ }
+
+ public bool IsEventReceived(Func<MIOutOfBandRecord, bool> filter)
+ {
+ // check previously received events first
+ while (EventQueue.Count > 0) {
+ if (filter(EventQueue.Dequeue()))
+ return true;
+ }
+
+ // receive new events and check them
+ ReceiveEvents();
+ while (EventQueue.Count > 0) {
+ if (filter(EventQueue.Dequeue()))
+ return true;
+ }
- return OutOfBandRecords.ToArray();
+ return false;
}
- List<MIOutOfBandRecord> OutOfBandRecords = new List<MIOutOfBandRecord>();
+ Queue<MIOutOfBandRecord> EventQueue = new Queue<MIOutOfBandRecord>();
MIParser MIParser = new MIParser();
- bool EventsAddedOnLastRequest = false;
}
}
return response[i] == '^';
}
- private bool IsEnd(string response)
+ public bool IsEnd(string response)
{
return response == "(gdb)";
}