internal static void CompareCores(Core c1, Core c2)
        {
            Assert.AreEqual(c1.DSExecutable.runtimeSymbols.Length, c2.DSExecutable.runtimeSymbols.Length);


            for (int symTableIndex = 0; symTableIndex < c1.DSExecutable.runtimeSymbols.Length; symTableIndex++)
            {
                foreach (SymbolNode symNode in c1.DSExecutable.runtimeSymbols[symTableIndex].symbolList.Values)
                {
                    ExecutionMirror runExecMirror = new ExecutionMirror(c1.CurrentExecutive.CurrentDSASMExec,
                                                                        c1);
                    ExecutionMirror debugExecMirror =
                        new ExecutionMirror(c2.CurrentExecutive.CurrentDSASMExec, c2);

                    bool       lookupOk = false;
                    StackValue runValue = new StackValue();

                    if (symNode.name.StartsWith("%") || symNode.functionIndex != Constants.kInvalidIndex)
                    {
                        continue; //Don't care about internal variables
                    }
                    try
                    {
                        runValue = runExecMirror.GetGlobalValue(symNode.name);
                        Console.WriteLine(symNode.name + ": " + runValue);
                        lookupOk = true;
                    }
                    catch (NotImplementedException)
                    {
                    }
                    catch (Exception ex)
                    {
                        if ((ex is ArgumentOutOfRangeException || ex is IndexOutOfRangeException) &&
                            (c1.RunningBlock != symNode.runtimeTableIndex))
                        {
                            // Quite possible that variables defined in the inner
                            // language block have been garbage collected and
                            // stack frame pointer has been adjusted when return
                            // to the outer block.
                        }
                        else
                        {
                            throw ex;
                        }
                    }

                    if (lookupOk)
                    {
                        StackValue debugValue = debugExecMirror.GetGlobalValue(symNode.name);
                        if (!StackUtils.CompareStackValues(debugValue, runValue, c2, c1))
                        {
                            Assert.Fail(string.Format("\tThe value of variable \"{0}\" doesn't match in run mode and in debug mode.\n", symNode.name));
                        }
                    }
                }
            }
        }
示例#2
0
            /// <summary>
            ///
            /// </summary>
            /// <param name="obj"></param>
            /// <returns></returns>
            public override bool Equals(object obj)
            {
                if (object.ReferenceEquals(obj, this))
                {
                    return(true);
                }

                MirrorData data = obj as MirrorData;

                if (null == data)
                {
                    return(false);
                }

                return(StackUtils.CompareStackValues(this.svData, data.svData, this.runtimeCore, data.runtimeCore));
            }
示例#3
0
        internal static void CompareCores(RuntimeCore rtcore1, RuntimeCore rtcore2, string defectID = "")
        {
            Assert.AreEqual(rtcore1.DSExecutable.runtimeSymbols.Length, rtcore1.DSExecutable.runtimeSymbols.Length, defectID);


            for (int symTableIndex = 0; symTableIndex < rtcore1.DSExecutable.runtimeSymbols.Length; symTableIndex++)
            {
                var rtc1Symbols = rtcore1.DSExecutable.runtimeSymbols[symTableIndex];
                if (rtc1Symbols == null)
                {
                    continue;
                }
                foreach (SymbolNode symNode in rtc1Symbols.symbolList.Values)
                {
                    ExecutionMirror runExecMirror   = new ExecutionMirror(rtcore1.CurrentExecutive.CurrentDSASMExec, rtcore1);
                    ExecutionMirror debugExecMirror = new ExecutionMirror(rtcore2.CurrentExecutive.CurrentDSASMExec, rtcore2);

                    bool       lookupOk = false;
                    StackValue runValue = StackValue.Null;

                    if (symNode.name.StartsWith("%") || symNode.functionIndex != Constants.kInvalidIndex)
                    {
                        continue; //Don't care about internal variables
                    }
                    try
                    {
                        runValue = runExecMirror.GetValue(symNode.name);
                        lookupOk = true;
                    }
                    catch (NotImplementedException)
                    {
                    }
                    catch (SymbolNotFoundException)
                    {
                    }
                    catch (Exception ex)
                    {
                        if ((ex is ArgumentOutOfRangeException || ex is IndexOutOfRangeException) &&
                            (rtcore1.RunningBlock != symNode.runtimeTableIndex))
                        {
                            // Quite possible that variables defined in the inner
                            // language block have been garbage collected and
                            // stack frame pointer has been adjusted when return
                            // to the outer block.
                        }
                        else
                        {
                            throw ex;
                        }
                    }

                    if (lookupOk)
                    {
                        StackValue debugValue = debugExecMirror.GetValue(symNode.name);
                        if (!StackUtils.CompareStackValues(debugValue, runValue, rtcore2, rtcore1))
                        {
                            Assert.Fail(string.Format("\tThe value of variable \"{0}\" doesn't match in run mode and in debug mode.\nTracked by {1}", symNode.name, defectID));
                        }
                    }
                }
            }
        }