예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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));
        }
예제 #6
0
        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);
        }
예제 #7
0
        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;
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }
예제 #11
0
        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);
        }
예제 #12
0
        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();
            }
        }
예제 #13
0
        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();
        }
예제 #14
0
        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();
        }
예제 #15
0
        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();
        }
예제 #16
0
        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();
            }
        }
예제 #17
0
        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();
            }
        }
예제 #18
0
        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();
            }
        }
예제 #19
0
        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);
        }
예제 #20
0
파일: Program.cs 프로젝트: wilvk/dotnet-sos
        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);
        }
예제 #21
0
        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();
            }
        }
예제 #22
0
        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);
        }
예제 #23
0
        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);
        }
예제 #24
0
        public static bool DoStepTo(string lbpName)
        {
            var lbp = (LineBreakpoint)DebuggeeInfo.Breakpoints[lbpName];

            Assert.Equal(MIResultClass.Running, MIDebugger.Request("-exec-next").Class);

            return(WasStep(lbp));
        }
예제 #25
0
파일: Program.cs 프로젝트: wilvk/dotnet-sos
        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);
        }
예제 #26
0
        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);
            }
        }
예제 #27
0
        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);
        }
예제 #28
0
        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);
        }
예제 #29
0
        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);
        }
예제 #30
0
        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);
        }