Inheritance: MonoBehaviour
Beispiel #1
0
 internal MondProgram(byte[] bytecode, List<double> numbers, List<string> strings, DebugInfo debugInfo = null)
 {
     Bytecode = bytecode;
     Numbers = numbers;
     Strings = strings;
     DebugInfo = debugInfo;
 }
Beispiel #2
0
		public static DebugInfo GetNewDebugInfo(DebugLogTypeEnum type, string systemname, string log){
			DebugInfo newDebugInfo = new DebugInfo ();
			newDebugInfo.Type = type;
			newDebugInfo.SystemType = systemname;
			newDebugInfo.Log = log;
			return newDebugInfo;
		}
Beispiel #3
0
 public override bool Execute()
 {
   var xSW = new Stopwatch();
   xSW.Start();
   try
   {
     var xSourceInfos = ParseMapFile(InputBaseDir);
     if (xSourceInfos.Count == 0)
     {
       Log.LogError("No SourceInfos found!");
       return false;
     }
     using (var xDebugInfo = new DebugInfo(DebugInfoFile))
     {
       xDebugInfo.AddLabels(xSourceInfos);
       xDebugInfo.CreateIndexes();
     }
     return true;
   }
   catch (Exception ex)
   {
     Log.LogErrorFromException(ex, true, true, null);
     return false;
   }
   finally
   {
     xSW.Stop();
     Log.LogMessage(MessageImportance.High, "ReadNAsmMapToDebugInfo took {0}", xSW.Elapsed);
   }
 }
Beispiel #4
0
    private static void DoScan()
    {

        var xSW = new Stopwatch();
        xSW.Start();
        string MDFFile = AppDomain.CurrentDomain.BaseDirectory + "TestKernel.mdf";
        if (File.Exists(MDFFile))
            File.Delete(MDFFile);

        var outFile = AppDomain.CurrentDomain.BaseDirectory + "TestKernel.out";
        if (File.Exists(outFile))
            File.Delete(outFile);

        var logFile = AppDomain.CurrentDomain.BaseDirectory + "TestKernel.log";
        if (File.Exists(logFile))
            File.Delete(logFile);

        var xAsmblr = new AppAssembler(1, "Cosmos.Assembler.Log");
        using (var xScanner = new ILScanner(xAsmblr))
        {
            xScanner.LogException = (Exception e) =>
            {
                Console.WriteLine("ILScanner exception : " + e.Message);
            };
            using (var xDebugInfo = new DebugInfo(MDFFile, true, true))
            {
                xAsmblr.DebugInfo = xDebugInfo;
                xAsmblr.DebugEnabled = true;
                xAsmblr.DebugMode = DebugMode.Source;
                xAsmblr.TraceAssemblies = TraceAssemblies.All;
                xAsmblr.IgnoreDebugStubAttribute = false;

                xAsmblr.Assembler.Initialize();
                //TODO: Add plugs into the scanning equation to profile scanning them too
                //System.Reflection.MethodInfo[] name = typeof(SSchockeTest.Kernel).GetMethods();
                Type xFoundType = typeof(FakeKernel);
                var xCtor = xFoundType.GetConstructor(Type.EmptyTypes);
                typeof(Cosmos.System.Plugs.System.ConsoleImpl).IsSubclassOf(typeof(object));
                var xEntryPoint = typeof(Kernel).GetMethod("Start", BindingFlags.Public | BindingFlags.Instance);
                //var xEntryPoint = typeof(Program).GetMethod("ScannerEntryPoint", BindingFlags.NonPublic | BindingFlags.Static);
                //EnableLogging(pathToLogFile)
                xScanner.EnableLogging(logFile);
                //xScanner.TempDebug += new Action<string>(xScanner_TempDebug);
                //xScanner.
                xScanner.QueueMethod(xEntryPoint);
                xScanner.Execute(xCtor);
                using (var xOut = new StreamWriter(outFile, false))
                {
                    //if (EmitDebugSymbols) {
                    xAsmblr.Assembler.FlushText(xOut);
                    xAsmblr.FinalizeDebugInfo();
                }
                xSW.Stop();
                Console.WriteLine("Total time : {0}", xSW.Elapsed);
                Console.WriteLine("Method count: {0}", xScanner.MethodCount);
                //Console.WriteLine("Instruction count: {0}", xScanner.InstructionCount);
            }
        }
    }
Beispiel #5
0
        internal Interpreter(string name, LocalVariables locals, InstructionArray instructions, DebugInfo[] debugInfos)
        {
            Name = name;
            LocalCount = locals.LocalCount;
            ClosureVariables = locals.ClosureVariables;

            _instructions = instructions;
            _objects = instructions.Objects;
            _labels = instructions.Labels;
            _debugInfos = debugInfos;
        }
Beispiel #6
0
 internal Interpreter(string name, LocalVariables locals, HybridReferenceDictionary<LabelTarget, BranchLabel> labelMapping, InstructionArray instructions, DebugInfo[] debugInfos, int compilationThreshold)
 {
     this._name = name;
     this._localCount = locals.LocalCount;
     this._closureVariables = locals.ClosureVariables;
     this._instructions = instructions;
     this._objects = instructions.Objects;
     this._labels = instructions.Labels;
     this._labelMapping = labelMapping;
     this._debugInfos = debugInfos;
     this._compilationThreshold = compilationThreshold;
 }
        internal Interpreter(string name, LocalVariables locals, HybridReferenceDictionary<LabelTarget, BranchLabel> labelMapping,
            InstructionArray instructions, DebugInfo[] debugInfos)
        {
            Name = name;
            LocalCount = locals.LocalCount;
            LabelMapping = labelMapping;
            ClosureVariables = locals.ClosureVariables;

            _instructions = instructions;
            _objects = instructions.Objects;
            _labels = instructions.Labels;
            _debugInfos = debugInfos;
        }
        public static void NotifyDebug2(string previousActionId, string actionId, object[] variables)
        {
#if UNITY_EDITOR
            if (_debugInfo != null)
            {
                var debugInfo = new DebugInfo()
                {
                    PreviousId = previousActionId,
                    ActionId = actionId,
                    Variables = variables
                };
                _debugInfo.OnNext(debugInfo);

            }
#endif
        }
Beispiel #9
0
        static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch s = new System.Diagnostics.Stopwatch();
            StreamWriter strw = new StreamWriter("log.txt");
            s.Start();
            System.Reflection.Assembly.Load("Cosmos.Build.Common");
            System.Reflection.Assembly.Load("Cosmos.Compiler.Assembler");
            System.Reflection.Assembly.Load("Cosmos.Compiler.Assembler.X86");
            System.Reflection.Assembly.Load("Cosmos.Core.Plugs");
            System.Reflection.Assembly.Load("Cosmos.Debug.Common");
            System.Reflection.Assembly.Load("Cosmos.Debug.DebugStub");
            System.Reflection.Assembly.Load("Cosmos.Debug.Kernel");
            System.Reflection.Assembly.Load("Cosmos.Debug.Kernel.Plugs");
            System.Reflection.Assembly.Load("Cosmos.IL2CPU");
            System.Reflection.Assembly.Load("Cosmos.IL2CPU.Plugs");
            System.Reflection.Assembly.Load("Cosmos.IL2CPU.X86");
            System.Reflection.Assembly.Load("Cosmos.System");
            System.Reflection.Assembly.Load("Cosmos.System.Plugs");
            var xInitMethod = typeof(StructTest.Kernel).GetConstructor(Type.EmptyTypes);
            var xOutputFilename = System.Windows.Forms.Application.StartupPath + "\\" + "StructTest";
            var xAsm = new AppAssemblerNasm(0);
            using (var xDebugInfo = new DebugInfo())
            {
                xDebugInfo.CreateCPDB(xOutputFilename + ".cpdb");
                xAsm.DebugInfo = xDebugInfo;
                xAsm.DebugMode = DebugMode.None;
                xAsm.TraceAssemblies = TraceAssemblies.All;
                xAsm.ShouldOptimize = true;

                var xNasmAsm = (AssemblerNasm)xAsm.Assembler;
                xAsm.Assembler.Initialize();
                using (var xScanner = new ILScanner(xAsm))
                {
                    // TODO: shouldn't be here?
                    xScanner.QueueMethod(xInitMethod.DeclaringType.BaseType.GetMethod("Start"));
                    xScanner.Execute(xInitMethod);

                    using (var xOut = new StreamWriter(xOutputFilename + ".asm", false))
                    {
                        xAsm.Assembler.FlushText(xOut);
                    }
                }
            }
            s.Stop();
            strw.Write("Total Time to Run: " + s.ElapsedMilliseconds.ToString() + "ms");
            strw.Close();
        }
 public static int NotifyDebug(string previousActionId, string actionId, object[] variables)
 {
     #if UNITY_EDITOR
     if (_debugInfo != null)
     {
         var debugInfo = new DebugInfo()
         {
             PreviousId = previousActionId,
             ActionId = actionId,
             Variables = variables
         };
         _debugInfo.OnNext(debugInfo);
         return debugInfo.Result;
     }
     #endif
     return 0;
 }
Beispiel #11
0
 public unsafe void TestFieldOrderingOfDataLookupEntry()
 {
     ILOp.mPlugManager = new PlugManager(delegate(Exception exception)
                                         {
                                             throw new Exception("Error: " + exception.Message, exception);
                                         });
     using (var xDbg = new DebugInfo(":memory:", true))
     {
         try
         {
             var xInfo = ILOp.GetFieldsInfo(typeof(DataLookupEntry), false).OrderBy(i => i.Offset).ToArray();
             Assert.IsNotNull(xInfo);
             Assert.AreEqual(3, xInfo.Length);
             Assert.AreEqual(nameof(DataLookupEntry.DataBlock), xInfo[0].Field.Name);
         }
         finally
         {
             ILOp.mPlugManager = null;
         }
     }
 }
        private void SignalInfo(DebugInfo _)
        {
            if (DebugSystem == null) return;
            DebugSystem.OnActionExecuting(_);
            if (_.Result == 1)
            {
                if (EditorApplication.isPlaying)
                {
                    EditorApplication.isPaused = true;
                }
            }
            else
            {
                if (!EditorApplication.isPlaying)
                {
                    EditorApplication.isPaused = false;
                    EditorApplication.isPlaying = true;
                }

            }

        }
Beispiel #13
0
        private static void Write(DebugInfo debugFlags)
        {
            var templateLines = GetSystemInfoTemplate(debugFlags);
            var outputLines = templateLines.SelectMany(s => GenerateLines(s, debugFlags)).ToList();

            if (m_initialSystemInfo == null)
            {
                m_initialSystemInfo = outputLines.Distinct().ToDictionary(s => s, s => !LineIsHeader(s));
            }
            else
            {
                outputLines = outputLines.Where(s => !m_initialSystemInfo.ContainsKey(s) || !m_initialSystemInfo[s]).ToList();

                // remove section headers that have no content
                int lastHeaderIndex = -2;
                for (int i = 0; i < outputLines.Count; i++)
                {
                    string line = outputLines[i];
                    if (LineIsHeader(line))
                    {
                        if ((i - lastHeaderIndex) == 1)
                        {
                            outputLines.RemoveAt(lastHeaderIndex);
                            --i;
                            lastHeaderIndex = -2;
                        }

                        if (i == (outputLines.Count - 1))
                            outputLines.RemoveAt(i);

                        lastHeaderIndex = i;
                    }
                }
            }

            foreach (string line in outputLines)
            {
                ContextManager.WriteLine(line);
            }
        }
        internal AD7Process(Dictionary <string, string> aDebugInfo, EngineCallback aCallback, AD7Engine aEngine, IDebugPort2 aPort)
        {
            mCallback  = aCallback;
            mDebugInfo = aDebugInfo;

            mLaunch = (LaunchType)Enum.Parse(typeof(LaunchType), aDebugInfo[BuildPropertyNames.LaunchString]);

            if (mDebugDownPipe == null)
            {
                mDebugDownPipe = new PipeClient(Pipes.DownName);

                mDebugUpPipe = new PipeServer(Pipes.UpName);
                mDebugUpPipe.DataPacketReceived += mDebugUpPipe_DataPacketReceived;
                mDebugUpPipe.Start();
            }
            else
            {
                mDebugUpPipe.CleanHandlers();
                mDebugUpPipe.DataPacketReceived += mDebugUpPipe_DataPacketReceived;
            }

            // Must be after mDebugDownPipe is initialized
            OutputClear();
            OutputText("Debugger process initialized.");

            mISO = mDebugInfo["ISOFile"];
            OutputText("Using ISO file " + mISO + ".");
            mProjectFile = mDebugInfo["ProjectFile"];
            //
            bool xUseGDB = string.Equals(mDebugInfo[BuildPropertyNames.EnableGDBString], "true", StringComparison.InvariantCultureIgnoreCase);

            OutputText("GDB " + (xUseGDB ? "Enabled" : "Disabled") + ".");
            //
            var xGDBClient = false;

            Boolean.TryParse(mDebugInfo[BuildPropertyNames.StartCosmosGDBString], out xGDBClient);

            switch (mLaunch)
            {
            case LaunchType.VMware:
                #region CheckIfHyperVServiceIsRunning

                using (System.ServiceProcess.ServiceController sc = new System.ServiceProcess.ServiceController("vmms"))
                {
                    try
                    {
                        if (sc.Status == System.ServiceProcess.ServiceControllerStatus.Running)
                        {
                            AD7Util.MessageBox(
                                "The Hyper-V Virtual Machine Management Service will be stopped. This is needed to allow to run VMware. If you press \"No\" the debug will stop.",
                                "Question");
                            sc.Stop();
                        }
                    }
                    catch (InvalidOperationException)
                    {
                        // service not present
                    }
                }

                #endregion CheckIfHyperVServiceIsRunning

                mHost = new VMware(mDebugInfo, xUseGDB);
                break;

#if SERIAL_PORT
            case LaunchType.Slave:
                mHost = new Slave(mDebugInfo, xUseGDB);
                break;
#endif
            case LaunchType.Bochs:
                // The project has been created on another machine or Bochs has been uninstalled since the project has
                // been created.
                if (!BochsSupport.BochsEnabled)
                {
                    throw new Exception(Resources.BochsIsNotInstalled);
                }

                string bochsConfigurationFileName;
                mDebugInfo.TryGetValue(BuildProperties.BochsEmulatorConfigurationFileString, out bochsConfigurationFileName);

                if (string.IsNullOrEmpty(bochsConfigurationFileName))
                {
                    bochsConfigurationFileName = BuildProperties.BochsDefaultConfigurationFileName;
                }

                if (!Path.IsPathRooted(bochsConfigurationFileName))
                {
                    // Assume the configuration file name is relative to project output path.
                    bochsConfigurationFileName = Path.Combine(new FileInfo(mDebugInfo["ProjectFile"]).Directory.FullName,
                                                              mDebugInfo["OutputPath"], bochsConfigurationFileName);
                }
                FileInfo bochsConfigurationFile = new FileInfo(bochsConfigurationFileName);
                // TODO : What if the configuration file doesn't exist ? This will throw a FileNotFoundException in
                // the Bochs class constructor. Is this appropriate behavior ?
                mHost = new Bochs(mDebugInfo, xUseGDB, bochsConfigurationFile);

                //((Host.Bochs)mHost).FixBochsConfiguration(new KeyValuePair<string, string>[] { new KeyValuePair<string, string>("IsoFileName", mISO) });
                break;

            case LaunchType.IntelEdison:
                mHost = new IntelEdison(mDebugInfo, false);
                break;

            case LaunchType.HyperV:
                mHost = new HyperV(mDebugInfo, false);
                break;

            default:
                throw new Exception("Invalid Launch value: '" + mLaunch + "'.");
            }
            mHost.OnShutDown += HostShutdown;

            string xDbPath = Path.ChangeExtension(mISO, "cdb");
            if (!File.Exists(xDbPath))
            {
                throw new Exception("Debug data file " + xDbPath + " not found. Could be a omitted build process of Cosmos project so that not created.");
            }

            mDebugInfoDb = new DebugInfo(xDbPath);
            mDebugInfoDb.LoadLookups();

            CreateDebugConnector();
            aEngine.BPMgr.SetDebugConnector(mDbgConnector);

            mEngine = aEngine;
            mThread = new AD7Thread(aEngine, this);
            mCallback.OnThreadStart(mThread);
            mPort = aPort;

            if (xUseGDB && xGDBClient)
            {
                LaunchGdbClient();
            }
        }
 public DebugInfo GetDebugInfo(int instructionIndex)
 {
     return(DebugInfo.GetMatchingDebugInfo(Interpreter.DebugInfos, instructionIndex));
 }
Beispiel #16
0
 public virtual void Collect(DebugInfo debugInfo)
 {
     Collect(debugInfo.DebugInstructions);
     Collect(debugInfo.Parameters);
 }
 public Token MakeToken(string term, DebugInfo info) => new Token(TokenType.PRINT, info);
Beispiel #18
0
        /// <summary>
        /// Extract symbols from the specified map file and populate debug database from that file.
        /// </summary>
        /// <param name="debugFile">Debug file to popuplate with symbols.</param>
        /// <param name="mapFile">Map file from where sybols should be extracted.</param>
        public static void ExtractMapSymbolsForElfFile(string debugFile, string mapFile)
        {
            DebugInfo.SetRange(DebugInfo.ElfFileMapExtractionRange);
            using (var xDebugInfo = new DebugInfo(debugFile))
            {
                // In future instead of loading all labels, save indexes to major labels but not IL.ASM labels.
                // Then code can find major lables, and use position markers into the map file to parse in between 
                // as needed.
                var xLabels = new List<Label>();
                var xFileLines = File.ReadLines(mapFile);
                foreach (var xLabel in ExtractMapSymbolsForElfFile(xFileLines))
                {
                    xLabels.Add(xLabel);
                    xDebugInfo.AddLabels(xLabels);
                }

                xDebugInfo.AddLabels(xLabels, true);
                xDebugInfo.CreateIndexes();
            }
        }
Beispiel #19
0
            public LineProperties GetLineStyle(int cpuAddress, int lineNumber)
            {
                DebugInfo      info  = ConfigManager.Config.DebugInfo;
                LineProperties props = null;

                if (_code._currentActiveAddress.HasValue && cpuAddress == _code._currentActiveAddress)
                {
                    props = new LineProperties()
                    {
                        TextBgColor = info.CodeActiveStatementColor, Symbol = LineSymbol.Arrow
                    };
                }
                else if (_code._unexecutedAddresses.Contains(lineNumber))
                {
                    props = new LineProperties()
                    {
                        LineBgColor = info.CodeUnexecutedCodeColor
                    };
                }
                else if (_code._speculativeCodeAddreses.Contains(lineNumber))
                {
                    props = new LineProperties()
                    {
                        LineBgColor = info.CodeUnidentifiedDataColor
                    };
                }
                else if (_code._verifiedDataAddresses.Contains(lineNumber))
                {
                    props = new LineProperties()
                    {
                        LineBgColor = info.CodeVerifiedDataColor
                    };
                }

                foreach (Breakpoint breakpoint in BreakpointManager.Breakpoints)
                {
                    if (breakpoint.Matches(cpuAddress))
                    {
                        Color?     fgColor      = Color.White;
                        Color?     bgColor      = null;
                        Color      bpColor      = breakpoint.BreakOnExec ? info.CodeExecBreakpointColor : (breakpoint.BreakOnWrite ? info.CodeWriteBreakpointColor : info.CodeReadBreakpointColor);
                        Color?     outlineColor = bpColor;
                        LineSymbol symbol;
                        if (breakpoint.Enabled)
                        {
                            bgColor = bpColor;
                            symbol  = LineSymbol.Circle;
                        }
                        else
                        {
                            fgColor = Color.Black;
                            symbol  = LineSymbol.CircleOutline;
                        }

                        if (_code._currentActiveAddress.HasValue && breakpoint.Matches((int)_code._currentActiveAddress.Value))
                        {
                            fgColor = Color.Black;
                            bgColor = Color.Yellow;
                            symbol |= LineSymbol.Arrow;
                        }

                        if (props == null)
                        {
                            props = new LineProperties();
                        }
                        props.FgColor      = fgColor;
                        props.TextBgColor  = bgColor;
                        props.OutlineColor = outlineColor;
                        props.Symbol       = symbol;
                        break;
                    }
                }

                return(props);
            }
Beispiel #20
0
        private static void ReadSymbols(BinaryReader reader, Unit unit)
        {
            var di = new DebugInfo();

            unit.Symbols = di;
            di.File      = reader.ReadString();

            var scopes = reader.ReadInt32();

            for (var i = 0; i < scopes; i++)
            {
                var s = new ScopeSym();
                s.Index       = reader.ReadInt32();
                s.ParentIndex = reader.ReadInt32();
                s.StartOffset = reader.ReadInt32();
                s.EndOffset   = reader.ReadInt32();
                s.StartLine   = reader.ReadInt32();
                s.StartColumn = reader.ReadInt32();
                s.EndLine     = reader.ReadInt32();
                s.EndColumn   = reader.ReadInt32();
                di.Scopes.Add(s);
            }

            var lines = reader.ReadInt32();

            for (var i = 0; i < lines; i++)
            {
                var l = new LineSym();
                l.Offset = reader.ReadInt32();
                l.Line   = reader.ReadInt32();
                l.Column = reader.ReadInt32();
                di.Lines.Add(l);
            }

            var vars = reader.ReadInt32();

            for (var i = 0; i < vars; i++)
            {
                var v = new VarSym();
                v.Name    = reader.ReadString();
                v.Address = reader.ReadInt32();
                v.Offset  = reader.ReadInt32();
                v.Scope   = reader.ReadInt32();
                v.Flags   = reader.ReadInt32();
                v.Data    = reader.ReadInt32();
                di.Vars.Add(v);
            }

            var funs = reader.ReadInt32();

            for (var i = 0; i < funs; i++)
            {
                var f = new FunSym();
                f.Name        = reader.ReadString();
                f.Handle      = reader.ReadInt32();
                f.StartOffset = reader.ReadInt32();
                f.EndOffset   = reader.ReadInt32();

                var pars = reader.ReadInt32();
                f.Parameters = new Par[pars];
                for (var j = 0; j < pars; j++)
                {
                    var name  = reader.ReadString();
                    var va    = reader.ReadBoolean();
                    var value = ObjectFile.DeserializeObject(reader);
                    var p     = new Par(name, value, va);
                    f.Parameters[j] = p;
                }

                di.Functions.Add(f.Handle, f);
            }
        }
Beispiel #21
0
 public Viewport()
 {
     DebugInfo = new DebugInfo();
 }
Beispiel #22
0
 public Column(DebugInfo debugInfo, object value)
 {
     DebugInfo = debugInfo ?? throw new ArgumentNullException(nameof(debugInfo));
     Value     = value ?? throw new ArgumentNullException(nameof(value));
 }
Beispiel #23
0
        internal static void DebugRunnerStepIn(string includePath, string code, /*string logFile*/ Dictionary <int, List <string> > map,
                                               bool watchNestedMode = false, string defectID = "")
        {
            //Internal setup
            ProtoCore.Core core;
            DebugRunner    fsr;

            ProtoScript.Config.RunConfiguration runnerConfig;

            // Specify some of the requirements of IDE.
            var options = new ProtoCore.Options();

            options.ExecutionMode       = ProtoCore.ExecutionMode.Serial;
            options.SuppressBuildOutput = false;
            options.GCTempVarsOnDebug   = false;

            // Cyclic dependency threshold is lowered from the default (2000)
            // as this causes the test framework to be painfully slow
            options.kDynamicCycleThreshold = 5;

            // Pass the absolute path so that imported filepaths can be resolved
            // in "FileUtils.GetDSFullPathName()"
            if (!String.IsNullOrEmpty(includePath))
            {
                includePath = Path.GetDirectoryName(includePath);
                options.IncludeDirectories.Add(includePath);
            }


            core = new ProtoCore.Core(options);

            // Use the InjectionExecutive to overload POP and POPM
            // as we still need the symbol names and line nos. in debug mode for comparisons
            core.ExecutiveProvider = new InjectionExecutiveProvider();

            core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
            core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));

            runnerConfig             = new ProtoScript.Config.RunConfiguration();
            runnerConfig.IsParrallel = false;
            fsr = new DebugRunner(core);

            DLLFFIHandler.Register(FFILanguage.CSharp, new CSModuleHelper());

            //Run
            fsr.PreStart(code, runnerConfig);

            //StreamReader log = new StreamReader(logFile);

            //bool isPrevBreakAtPop = false;
            int    lineAtPrevBreak = -1;
            string symbolName      = null;

            DebugRunner.VMState vms = null;

            while (!fsr.isEnded)
            {
                vms = fsr.LastState;

                OpCode    opCode = OpCode.NONE;
                DebugInfo debug  = null;
                if (vms != null)
                {
                    // check if previous break is a POP
                    // if so, get the line no. and LHS
                    opCode = fsr.CurrentInstruction.opCode;
                    debug  = fsr.CurrentInstruction.debug;

                    if (opCode == ProtoCore.DSASM.OpCode.POP)
                    {
                        //isPrevBreakAtPop = true;
                        lineAtPrevBreak = vms.ExecutionCursor.StartInclusive.LineNo;
                    }
                }

                DebugRunner.VMState currentVms = fsr.Step();

                //if (isPrevBreakAtPop)

                if (debug != null)
                {
                    // Do not do the verification for imported DS files, for which the FilePath is non null
                    if (debug.Location.StartInclusive.SourceLocation.FilePath == null)
                    {
                        if (opCode == ProtoCore.DSASM.OpCode.POP)
                        {
                            VerifyWatch_Run(lineAtPrevBreak, core.DebugProps.CurrentSymbolName, core, map, watchNestedMode, defectID: defectID);
                        }
                        // if previous breakpoint was at a CALLR
                        else if (opCode == ProtoCore.DSASM.OpCode.CALLR)
                        {
                            if (core.DebugProps.IsPopmCall)
                            {
                                int ci = (int)currentVms.mirror.MirrorTarget.rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexClass).opdata;
                                VerifyWatch_Run(InjectionExecutive.callrLineNo, core.DebugProps.CurrentSymbolName, core, map, watchNestedMode, ci, defectID);
                            }
                        }
                    }
                }
                //isPrevBreakAtPop = false;
            }
            core.Cleanup();
        }
        private void WriteDebugInfo(IHtmlWriter html, DebugInfo debugInfo, int depth)
        {
            if (depth == 0)
            {
                return;
            }

            html.WriteElementLine("h2", debugInfo.Type + " '" + debugInfo.Name + "'");
            if (debugInfo.Instance != null)
            {
                html.WriteOpenTag("p");
                html.WriteElementLine("i", debugInfo.Instance.GetType().DisplayName());
                html.WriteCloseTag("p");
            }

            if (debugInfo.DataConsumer != null)
            {
                var consumerDescription = debugInfo.DataConsumer.ToString();
                var lines = consumerDescription.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                if (lines.Length > 0)
                {
                    html.WriteElementLine("p", "Is a data consumer");
                    html.WriteOpenTag("ul");
                    foreach (var line in lines)
                    {
                        html.WriteElementLine("li", line.InitialCaps());
                    }
                    html.WriteCloseTag("ul");
                }
            }

            if (debugInfo.DependentComponents != null && debugInfo.DependentComponents.Count > 0)
            {
                html.WriteElementLine("p", "Dependent components");
                html.WriteOpenTag("ul");
                foreach (var component in debugInfo.DependentComponents)
                {
                    html.WriteElementLine("li", component.GetDebugInfo(0, 0).ToString().InitialCaps());
                }
                html.WriteCloseTag("ul");
            }

            if (debugInfo is DebugComponent)
            {
                WriteHtml(html, (DebugComponent)debugInfo, depth);
            }
            if (debugInfo is DebugDataContext)
            {
                WriteHtml(html, (DebugDataContext)debugInfo, depth);
            }
            if (debugInfo is DebugDataProvider)
            {
                WriteHtml(html, (DebugDataProvider)debugInfo, depth);
            }
            if (debugInfo is DebugDataScopeRules)
            {
                WriteHtml(html, (DebugDataScopeRules)debugInfo, depth);
            }
            if (debugInfo is DebugLayout)
            {
                WriteHtml(html, (DebugLayout)debugInfo, depth);
            }
            if (debugInfo is DebugModule)
            {
                WriteHtml(html, (DebugModule)debugInfo, depth);
            }
            if (debugInfo is DebugPackage)
            {
                WriteHtml(html, (DebugPackage)debugInfo, depth);
            }
            if (debugInfo is DebugPage)
            {
                WriteHtml(html, (DebugPage)debugInfo, depth);
            }
            if (debugInfo is DebugRegion)
            {
                WriteHtml(html, (DebugRegion)debugInfo, depth);
            }
            if (debugInfo is DebugRenderContext)
            {
                WriteHtml(html, (DebugRenderContext)debugInfo, depth);
            }
            if (debugInfo is DebugRoute)
            {
                WriteHtml(html, (DebugRoute)debugInfo, depth);
            }
            if (debugInfo is DebugService)
            {
                WriteHtml(html, (DebugService)debugInfo, depth);
            }
        }
 public InvalidFunctionCallException(DebugInfo info, FunctionDeclaration function)
     : base(info, $"Function call '{Function(function)}' has too few or too many required parameters")
 {
 }
Beispiel #26
0
 public Row(DebugInfo debugInfo, List <Column> columns)
 {
     DebugInfo = debugInfo ?? throw new ArgumentNullException(nameof(debugInfo));
     Columns   = columns ?? throw new ArgumentNullException(nameof(columns));
 }
Beispiel #27
0
 /// <summary>
 /// Token Constructor
 /// </summary>
 /// <param name="value">Value of Token</param>
 /// <param name="type">Type of Token</param>
 /// <param name="debugInfo">Original source code information</param>
 /// <remarks>Default value of <c>Token</c> is a Unknown-typed NULL token.
 /// Its position in the source code is -1.</remarks>
 public Token(string value = "", TokenType type = TokenType.Unknown, DebugInfo debugInfo = null)
 {
     Value = value;
     Type = type;
     OriginalCode = debugInfo;
 }
Beispiel #28
0
        public frmScript(bool forceBlank = false)
        {
            InitializeComponent();
            ThemeHelper.ExcludeFromTheme(txtScriptContent);
            txtScriptContent.ForeColor = Color.Black;

            DebugInfo.ApplyConfig();

            List <string> builtInScripts = new List <string> {
                "DmcCapture.lua", "DrawMode.lua", "Example.lua", "GameBoyMode.lua", "Grid.lua", "LogParallax.lua", "ModifyScreen.lua", "NtscSafeArea.lua", "ReverseMode.lua", "SpriteBox.lua"
            };

            foreach (string script in builtInScripts)
            {
                ToolStripItem item = mnuBuiltInScripts.DropDownItems.Add(script);
                item.Click += (s, e) => {
                    LoadBuiltInScript(item.Text);
                };
            }

            tsToolbar.AddItemsToToolbar(
                mnuOpen, mnuSave, null,
                mnuRun, mnuStop, null,
                mnuBuiltInScripts
                );

            DebugInfo config = ConfigManager.Config.DebugInfo;

            _popupMenu           = new AutocompleteMenu(txtScriptContent, this);
            _popupMenu.ImageList = new ImageList();
            _popupMenu.ImageList.Images.Add(Resources.Enum);
            _popupMenu.ImageList.Images.Add(Resources.Function);
            _popupMenu.SelectedColor = Color.LightBlue;
            _popupMenu.SearchPattern = @"[\w\.]";

            List <AutocompleteItem> items = new List <AutocompleteItem>();

            _availableFunctions.Sort((a, b) => {
                int type = a[0].CompareTo(b[0]);
                if (type == 0)
                {
                    return(a[1].CompareTo(b[1]));
                }
                else
                {
                    return(-type);
                }
            });

            foreach (List <string> item in _availableFunctions)
            {
                MethodAutocompleteItem autocompleteItem = new MethodAutocompleteItem(item[1]);
                autocompleteItem.ImageIndex   = item[0] == "func" ? 1 : 0;
                autocompleteItem.ToolTipTitle = item[2];
                if (!string.IsNullOrWhiteSpace(item[3]))
                {
                    autocompleteItem.ToolTipText = "Parameters" + Environment.NewLine + item[3] + Environment.NewLine + Environment.NewLine;
                }
                if (!string.IsNullOrWhiteSpace(item[4]))
                {
                    autocompleteItem.ToolTipText += "Return Value" + Environment.NewLine + item[4] + Environment.NewLine + Environment.NewLine;
                }
                if (!string.IsNullOrWhiteSpace(item[5]))
                {
                    autocompleteItem.ToolTipText += "Description" + Environment.NewLine + item[5] + Environment.NewLine + Environment.NewLine;
                }
                items.Add(autocompleteItem);
            }

            _popupMenu.Items.SetAutocompleteItems(items);

            UpdateRecentScripts();

            mnuTutorialScript.Checked     = config.ScriptStartupBehavior == ScriptStartupBehavior.ShowTutorial;
            mnuBlankWindow.Checked        = config.ScriptStartupBehavior == ScriptStartupBehavior.ShowBlankWindow;
            mnuAutoLoadLastScript.Checked = config.ScriptStartupBehavior == ScriptStartupBehavior.LoadLastScript;

            if (!forceBlank)
            {
                if (mnuAutoLoadLastScript.Checked && mnuRecentScripts.DropDownItems.Count > 0)
                {
                    string scriptToLoad = config.RecentScripts.Where((s) => File.Exists(s)).FirstOrDefault();
                    if (scriptToLoad != null)
                    {
                        LoadScriptFile(scriptToLoad, false);
                    }
                }
                else if (mnuTutorialScript.Checked)
                {
                    LoadBuiltInScript("Example.lua");
                }
            }

            RestoreLocation(config.ScriptWindowLocation, config.ScriptWindowSize);
            mnuSaveBeforeRun.Checked = config.SaveScriptBeforeRun;
            mnuAutoRestart.Checked   = config.AutoRestartScript;

            if (config.ScriptCodeWindowHeight >= ctrlSplit.Panel1MinSize)
            {
                if (config.ScriptCodeWindowHeight == Int32.MaxValue)
                {
                    ctrlSplit.CollapsePanel();
                }
                else
                {
                    ctrlSplit.SplitterDistance = config.ScriptCodeWindowHeight;
                }
            }

            txtScriptContent.Font = new Font(config.ScriptFontFamily, config.ScriptFontSize, config.ScriptFontStyle);
            txtScriptContent.Zoom = config.ScriptZoom;
        }
        private void OutputDebugInfo(DebugInfo info, params object[] values)
        {
            if (!_isDebugModeActive
                || _debugCanvas == null)
            {
                return;
            }

            var text = _debugCanvas.FindName(DebugTextPrefix + info) as TextBlock;
            if (text == null
                || text.Tag == null)
            {
                return;
            }

            text.Text = string.Format(text.Tag.ToString(), values);
        }
 public DebugSymbolConstraint(string configurationName, DebugInfo requestedDebugInfo)
 {
     _configurationName  = configurationName;
     _requestedDebugInfo = requestedDebugInfo;
 }
 public Token MakeToken(string term, DebugInfo info) => new Token(TokenType.RETURN, info);
Beispiel #32
0
 public FormattingException(string message, DebugInfo debugInfo) : base(message)
 {
     DebugInfo = debugInfo;
 }
 public Token MakeToken(string term, DebugInfo info) => new Token(TokenType.FUNC_DECLARE, info);
Beispiel #34
0
 public Breakpoint(DebugInfo di, string sourceLocation = null)
 {
     Location = di.Location;
 }
Beispiel #35
0
        private void ReadDebugInfo(BinaryReader reader, MethodDefinition mdef, uint debugOffset)
        {
            reader.PreserveCurrentPosition(debugOffset, () =>
            {
                var debugInfo       = new DebugInfo(mdef.Body);
                mdef.Body.DebugInfo = debugInfo;

                var lineStart       = reader.ReadULEB128();
                debugInfo.LineStart = lineStart;

                var parametersSize = reader.ReadULEB128();
                for (var i = 0; i < parametersSize; i++)
                {
                    var index   = reader.ReadULEB128P1();
                    string name = null;
                    if (index != DexConsts.NoIndex && index >= 0)
                    {
                        name = Dex.Strings[(int)index];
                    }
                    debugInfo.Parameters.Add(name);
                }

                while (true)
                {
                    var ins = new DebugInstruction {
                        OpCode = (DebugOpCodes)reader.ReadByte()
                    };
                    debugInfo.DebugInstructions.Add(ins);

                    uint registerIndex;
                    long nameIndex;
                    string name;

                    switch (ins.OpCode)
                    {
                    case DebugOpCodes.AdvancePc:
                        // uleb128 addr_diff
                        var addrDiff = reader.ReadULEB128();
                        ins.Operands.Add(addrDiff);
                        break;

                    case DebugOpCodes.AdvanceLine:
                        // sleb128 line_diff
                        var lineDiff = reader.ReadSLEB128();
                        ins.Operands.Add(lineDiff);
                        break;

                    case DebugOpCodes.EndLocal:
                    case DebugOpCodes.RestartLocal:
                        // uleb128 register_num
                        registerIndex = reader.ReadULEB128();
                        ins.Operands.Add(mdef.Body.Registers[(int)registerIndex]);
                        break;

                    case DebugOpCodes.SetFile:
                        // uleb128p1 name_idx
                        nameIndex = reader.ReadULEB128P1();
                        name      = null;
                        if (nameIndex != DexConsts.NoIndex && nameIndex >= 0)
                        {
                            name = Dex.Strings[(int)nameIndex];
                        }
                        ins.Operands.Add(name);
                        break;

                    case DebugOpCodes.StartLocalExtended:
                    case DebugOpCodes.StartLocal:
                        // StartLocalExtended : uleb128 register_num, uleb128p1 name_idx, uleb128p1 type_idx, uleb128p1 sig_idx
                        // StartLocal : uleb128 register_num, uleb128p1 name_idx, uleb128p1 type_idx
                        var isExtended = ins.OpCode == DebugOpCodes.StartLocalExtended;

                        registerIndex = reader.ReadULEB128();
                        ins.Operands.Add(mdef.Body.Registers[(int)registerIndex]);

                        nameIndex = reader.ReadULEB128P1();
                        name      = null;
                        if (nameIndex != DexConsts.NoIndex && nameIndex >= 0)
                        {
                            name = Dex.Strings[(int)nameIndex];
                        }
                        ins.Operands.Add(name);

                        var typeIndex      = reader.ReadULEB128P1();
                        TypeReference type = null;
                        if (typeIndex != DexConsts.NoIndex && typeIndex >= 0)
                        {
                            type = Dex.TypeReferences[(int)typeIndex];
                        }
                        ins.Operands.Add(type);

                        if (isExtended)
                        {
                            var signatureIndex = reader.ReadULEB128P1();
                            string signature   = null;
                            if (signatureIndex != DexConsts.NoIndex && signatureIndex >= 0)
                            {
                                signature = Dex.Strings[(int)signatureIndex];
                            }
                            ins.Operands.Add(signature);
                        }

                        break;

                    case DebugOpCodes.EndSequence:
                        return;
                        //case DebugOpCodes.Special:
                        // between 0x0a and 0xff (inclusive)
                        //case DebugOpCodes.SetPrologueEnd:
                        //case DebugOpCodes.SetEpilogueBegin:
                        //default:
                        //    break;
                    }
                }
            });
        }
Beispiel #36
0
 public Token MakeToken(string term, DebugInfo info) => new Token(TokenType.NUMBER, info, term);
Beispiel #37
0
        private static void DoScan()
        {
            var xSW = new Stopwatch();

            xSW.Start();
            string MDFFile = AppDomain.CurrentDomain.BaseDirectory + "TestKernel.mdf";

            if (File.Exists(MDFFile))
            {
                File.Delete(MDFFile);
            }

            var outFile = AppDomain.CurrentDomain.BaseDirectory + "TestKernel.out";

            if (File.Exists(outFile))
            {
                File.Delete(outFile);
            }

            var logFile = AppDomain.CurrentDomain.BaseDirectory + "TestKernel.log";

            if (File.Exists(logFile))
            {
                File.Delete(logFile);
            }

            var xAsmblr = new AppAssembler(1, "Cosmos.Assembler.Log");

            using (var xScanner = new ILScanner(xAsmblr))
            {
                xScanner.LogException = (Exception e) =>
                {
                    Console.WriteLine("ILScanner exception : " + e.Message);
                };
                using (var xDebugInfo = new DebugInfo(MDFFile, true, true))
                {
                    xAsmblr.DebugInfo                = xDebugInfo;
                    xAsmblr.DebugEnabled             = true;
                    xAsmblr.DebugMode                = DebugMode.Source;
                    xAsmblr.TraceAssemblies          = TraceAssemblies.All;
                    xAsmblr.IgnoreDebugStubAttribute = false;

                    xAsmblr.Assembler.Initialize();
                    //TODO: Add plugs into the scanning equation to profile scanning them too
                    //System.Reflection.MethodInfo[] name = typeof(SSchockeTest.Kernel).GetMethods();
                    Type xFoundType = typeof(FakeKernel);
                    var  xCtor      = xFoundType.GetConstructor(Type.EmptyTypes);
                    typeof(Cosmos.System.Plugs.System.ConsoleImpl).IsSubclassOf(typeof(object));
                    var xEntryPoint = typeof(Kernel).GetMethod("Start", BindingFlags.Public | BindingFlags.Instance);
                    //var xEntryPoint = typeof(Program).GetMethod("ScannerEntryPoint", BindingFlags.NonPublic | BindingFlags.Static);
                    //EnableLogging(pathToLogFile)
                    xScanner.EnableLogging(logFile);
                    //xScanner.TempDebug += new Action<string>(xScanner_TempDebug);
                    //xScanner.
                    xScanner.QueueMethod(xEntryPoint);
                    xScanner.Execute(xCtor);
                    using (var xOut = new StreamWriter(outFile, false))
                    {
                        //if (EmitDebugSymbols) {
                        xAsmblr.Assembler.FlushText(xOut);
                        xAsmblr.FinalizeDebugInfo();
                    }
                    xSW.Stop();
                    Console.WriteLine("Total time : {0}", xSW.Elapsed);
                    Console.WriteLine("Method count: {0}", xScanner.MethodCount);
                    //Console.WriteLine("Instruction count: {0}", xScanner.InstructionCount);
                }
            }
        }
Beispiel #38
0
        internal AD7Process(NameValueCollection aDebugInfo, EngineCallback aCallback, AD7Engine aEngine, IDebugPort2 aPort)
        {
            mCallback = aCallback;
            mDebugInfo = aDebugInfo;

            mLaunch = (LaunchType)Enum.Parse(typeof(LaunchType), aDebugInfo[BuildPropertyNames.LaunchString]);

            if (mDebugDownPipe == null)
            {
                mDebugDownPipe = new Cosmos.Debug.Common.PipeClient(Pipes.DownName);

                mDebugUpPipe = new Cosmos.Debug.Common.PipeServer(Pipes.UpName);
                mDebugUpPipe.DataPacketReceived += mDebugUpPipe_DataPacketReceived;
                mDebugUpPipe.Start();
            }
            else
            {
                mDebugUpPipe.CleanHandlers();
                mDebugUpPipe.DataPacketReceived += mDebugUpPipe_DataPacketReceived;
            }

            // Must be after mDebugDownPipe is initialized
            OutputClear();
            OutputText("Debugger process initialized.");

            mISO = mDebugInfo["ISOFile"];
            OutputText("Using ISO file " + mISO + ".");
            mProjectFile = mDebugInfo["ProjectFile"];
            //
            bool xUseGDB = string.Equals(mDebugInfo[BuildPropertyNames.EnableGDBString], "true", StringComparison.InvariantCultureIgnoreCase);
            OutputText("GDB " + (xUseGDB ? "Enabled" : "Disabled") + ".");
            //
            var xGDBClient = false;
            Boolean.TryParse(mDebugInfo[BuildPropertyNames.StartCosmosGDBString], out xGDBClient);

            switch (mLaunch)
            {
                case LaunchType.VMware:
                    mHost = new Host.VMware(mDebugInfo, xUseGDB);
                    break;
                case LaunchType.Slave:
                    mHost = new Host.Slave(mDebugInfo, xUseGDB);
                    break;
                case LaunchType.Bochs:
                    // The project has been created on another machine or Bochs has been uninstalled since the project has
                    // been created.
                    if (!BochsSupport.BochsEnabled) { throw new Exception(ResourceStrings.BochsIsNotInstalled); }
                    string bochsConfigurationFileName = mDebugInfo[BuildProperties.BochsEmulatorConfigurationFileString];
                    if (string.IsNullOrEmpty(bochsConfigurationFileName))
                    {
                        bochsConfigurationFileName = BuildProperties.BochsDefaultConfigurationFileName;
                    }
                    if (!Path.IsPathRooted(bochsConfigurationFileName))
                    {
                        // Assume the configuration file name is relative to project output path.
                        bochsConfigurationFileName = Path.Combine(new FileInfo(mDebugInfo["ProjectFile"]).Directory.FullName,
                          mDebugInfo["OutputPath"], bochsConfigurationFileName);
                    }
                    FileInfo bochsConfigurationFile = new FileInfo(bochsConfigurationFileName);
                    // TODO : What if the configuration file doesn't exist ? This will throw a FileNotFoundException in
                    // the Bochs class constructor. Is this appropriate behavior ?
                    mHost = new Host.Bochs(mDebugInfo, xUseGDB, bochsConfigurationFile);

                    //((Host.Bochs)mHost).FixBochsConfiguration(new KeyValuePair<string, string>[] { new KeyValuePair<string, string>("IsoFileName", mISO) });
                    break;
                case LaunchType.IntelEdison:
                    mHost = new Host.IntelEdison(mDebugInfo, false);
                    break;
                default:
                    throw new Exception("Invalid Launch value: '" + mLaunch + "'.");
            }
            mHost.OnShutDown += HostShutdown;

            string xDbPath = Path.ChangeExtension(mISO, "cdb");
            if (!File.Exists(xDbPath))
            {
                throw new Exception("Debug data file " + xDbPath + " not found. Could be a omitted build process of Cosmos project so that not created.");
            }

            mDebugInfoDb = new DebugInfo(xDbPath);
            mDebugInfoDb.LoadLookups();

            CreateDebugConnector();
            aEngine.BPMgr.SetDebugConnector(mDbgConnector);

            mEngine = aEngine;
            mThread = new AD7Thread(aEngine, this);
            mCallback.OnThreadStart(mThread);
            mPort = aPort;

            if (xUseGDB && xGDBClient)
            {
                LaunchGdbClient();
            }
        }
Beispiel #39
0
        private static List<string> GetSystemInfoTemplate(DebugInfo infoFlags)
        {
            var templateLines = new List<string>();

            if ((infoFlags & DebugInfo.Environment) > 0)
            {
                templateLines.Add(@"[Environment]");
                templateLines.Add(@"  User       : $Domain\$User");
                templateLines.Add(@"  Machine    : $Machine");
                templateLines.Add(@"  Debugging  : $DebuggerAttached");
                templateLines.Add(@"  Interactive: $Interactive");
                templateLines.Add(@"  OS Version : $OS");
                templateLines.Add(@"  CLR Version: $CLR");
                templateLines.Add(@"  Processors : $Processors");
                templateLines.Add(@"  Memory     : $Memory");
                templateLines.Add(@"  Graphics   : $Graphics");
                templateLines.Add(@"  Drive $DriveLetter    : $DriveDetails");
            }
            if ((infoFlags & DebugInfo.Context) > 0)
            {
                templateLines.Add(@"[Context]");
                templateLines.Add(@"  Types      : $Types");
                templateLines.Add(@"  Options    : $Options");
                templateLines.Add(@"  Base Path  : $BasePath");
                templateLines.Add(@"  Temp       : $Temp");
                templateLines.Add(@"  Temp Used  : $TempUsed");
            }
            if ((infoFlags & DebugInfo.Process) > 0)
            {
                templateLines.Add(@"[Process]");
                templateLines.Add(@"  Name       : $ProcName");
                templateLines.Add(@"  ID         : $ProcId");
                templateLines.Add(@"  Start Time : $ProcStart");
                templateLines.Add(@"  Handles    : $ProcHandles");
                templateLines.Add(@"  Total CPU  : $ProcTotalCpu");
                templateLines.Add(@"  User CPU   : $ProcUserCpu");
            }
            if ((infoFlags & DebugInfo.Memory) > 0)
            {
                templateLines.Add(@"[Memory]");
                templateLines.Add(@"  Working Set: $ProcWorkingSet ($PeakProcWorkingSet)");
                templateLines.Add(@"  Paged      : $ProcPagedMemory ($PeakProcPagedMemory)");
                templateLines.Add(@"  Virtual    : $ProcVirtualMemory ($PeakProcVirtualMemory)");
            }
            if ((infoFlags & DebugInfo.Options) > 0)
            {
                templateLines.Add(@"[Options]");
                templateLines.Add(@"  $Option");
            }

            return templateLines;
        }
Beispiel #40
0
        public frmTraceLogger()
        {
            InitializeComponent();

            DebugInfo debugInfo = ConfigManager.Config.DebugInfo;

            RestoreLocation(debugInfo.TraceLoggerLocation, debugInfo.TraceLoggerSize);

            _tooltipManager = new CodeTooltipManager(this, txtTraceLog);

            txtTraceLog.BaseFont = new Font(debugInfo.TraceFontFamily, debugInfo.TraceFontSize, debugInfo.TraceFontStyle);
            txtTraceLog.TextZoom = debugInfo.TraceTextZoom;

            mnuAutoRefresh.Checked = debugInfo.TraceAutoRefresh;
            _lineCount             = debugInfo.TraceLineCount;

            _entityBinder.Entity = debugInfo.TraceLoggerOptions;
            _entityBinder.AddBinding("ShowByteCode", chkShowByteCode);
            _entityBinder.AddBinding("ShowCpuCycles", chkShowCpuCycles);
            _entityBinder.AddBinding("ShowEffectiveAddresses", chkShowEffectiveAddresses);
            _entityBinder.AddBinding("ShowMemoryValues", chkShowMemoryValues);
            _entityBinder.AddBinding("ShowExtraInfo", chkShowExtraInfo);
            _entityBinder.AddBinding("ShowPpuFrames", chkShowFrameCount);
            _entityBinder.AddBinding("ShowPpuCycles", chkShowPpuCycles);
            _entityBinder.AddBinding("ShowPpuScanline", chkShowPpuScanline);
            _entityBinder.AddBinding("ShowRegisters", chkShowRegisters);
            _entityBinder.AddBinding("IndentCode", chkIndentCode);
            _entityBinder.AddBinding("UseLabels", chkUseLabels);
            _entityBinder.AddBinding("ExtendZeroPage", chkExtendZeroPage);
            _entityBinder.AddBinding("UseWindowsEol", chkUseWindowsEol);
            _entityBinder.AddBinding("StatusFormat", cboStatusFlagFormat);
            _entityBinder.AddBinding("OverrideFormat", chkOverrideFormat);
            _entityBinder.UpdateUI();

            this.toolTip.SetToolTip(this.picExpressionWarning, "Condition contains invalid syntax or symbols.");
            this.toolTip.SetToolTip(this.picHelp, "When a condition is given, instructions will only be logged by the trace logger if the condition returns a value not equal to 0 or false." + Environment.NewLine + Environment.NewLine + frmBreakpoint.GetConditionTooltip(false));
            this.toolTip.SetToolTip(this.picFormatHelp,
                                    "You can customize the trace logger's output by enabling the 'Override' option and altering the format." + Environment.NewLine + Environment.NewLine +
                                    "The following tags are available: " + Environment.NewLine +
                                    "[ByteCode]: The byte code for the instruction (1 to 3 bytes)." + Environment.NewLine +
                                    "[Disassembly]: The disassembly for the current instruction." + Environment.NewLine +
                                    "[EffectiveAddress]: The effective address used for indirect addressing modes." + Environment.NewLine +
                                    "[MemoryValue]: The value stored at the memory location referred to by the instruction." + Environment.NewLine +
                                    "[PC]: Program Counter" + Environment.NewLine +
                                    "[A]: A register" + Environment.NewLine +
                                    "[X]: X register" + Environment.NewLine +
                                    "[Y]: Y register" + Environment.NewLine +
                                    "[SP]: Stack Pointer" + Environment.NewLine +
                                    "[P]: Processor Flags" + Environment.NewLine +
                                    "[Cycle]: The current PPU cycle." + Environment.NewLine +
                                    "[Scanline]: The current PPU scanline." + Environment.NewLine +
                                    "[FrameCount]: The current PPU frame." + Environment.NewLine +
                                    "[CycleCount]: The current CPU cycle (32-bit signed value, resets to 0 at power on)" + Environment.NewLine + Environment.NewLine +
                                    "You can also specify some options by using a comma. e.g:" + Environment.NewLine +
                                    "[Cycle,3] will display the cycle and pad out the output to always be 3 characters wide." + Environment.NewLine +
                                    "[Scanline,h] will display the scanline in hexadecimal." + Environment.NewLine +
                                    "[Align,50]: Align is a special tag that is useful when trying to align some content. [Align,50] will make the next tag start on column 50."
                                    );

            this._initialized = true;
        }
Beispiel #41
0
        private static List<string> GenerateLines(string sourceLine, DebugInfo flags)
        {
            var variables = GetVariableUsages(sourceLine);
            var newLines = new List<string>();

            if (variables.Count == 0)
            {
                newLines.Add(sourceLine);
            }
            else
            {
                // check if one of them has a multi-line handler
                if (variables[0] == "DriveLetter")
                {
                    string queryString = "SELECT Name FROM Win32_LogicalDisk";
                    if ((flags & DebugInfo.AllDrives) == 0)
                        queryString += " WHERE DriveType = 3";
                    else
                        queryString += " WHERE NOT DriveType = 5";
                    var query = new SelectQuery(queryString);
                    var searcher = new ManagementObjectSearcher(query);
                    var drives = searcher.Get().Cast<ManagementObject>().Select(o => new DriveInfo((string)o["Name"]));
                    foreach (DriveInfo d in drives)
                    {
                        string newLine = sourceLine;
                        newLine = ReplaceVariable(newLine, "DriveLetter", GetDriveName(d));
                        newLine = ReplaceVariable(newLine, "DriveDetails", GetDriveDetails(d));
                        newLines.Add(newLine);
                    }
                }
                else if (variables[0] == "Option")
                {
            #warning no property access at this point
                    //newLines.AddRange(Context.RegisteredProperties.Select(p => ReplaceVariable(sourceLine, "Option", p.ToString())));
                }
                else
                {
                    string newLine = sourceLine;
                    foreach (string variable in variables)
                    {
                        string value = GetVariableValue(variable);
                        if (value != null)
                            newLine = ReplaceVariable(newLine, variable, value);
                    }
                    newLines.Add(newLine);
                }
            }
            return newLines;
        }
Beispiel #42
0
        internal DebugInfo Method_GetDebugInfo(long id)
        {
            var res = SendReceive(CommandSet.METHOD, (int)CmdMethod.GET_DEBUG_INFO, new PacketWriter().WriteId(id));

            DebugInfo info = new DebugInfo();
            info.max_il_offset = res.ReadInt();
            info.filename = res.ReadString();

            int n_il_offsets = res.ReadInt();
            info.il_offsets = new int[n_il_offsets];
            info.line_numbers = new int[n_il_offsets];
            for (int i = 0; i < n_il_offsets; ++i)
            {
                info.il_offsets[i] = res.ReadInt();
                info.line_numbers[i] = res.ReadInt();
            }

            return info;
        }
Beispiel #43
0
            /// <summary>
            /// Set the debug information
            /// </summary>
            /// <param name="offset">Index of token in the entire source code</param>
            /// <param name="expression">Original source code</param>
            public void SetThisCodeLine(int offset, string expression)
            {
                int lines = expression.Substring(0, offset).Count(x => x == '\n') + 1;

                int curLinePos = expression.LastIndexOf('\n', offset);
                curLinePos = (curLinePos == -1) ? 0 : curLinePos + 1;

                int nextLinePos = expression.IndexOf('\n', offset);
                nextLinePos = (nextLinePos == -1) ? expression.Length - 1 : nextLinePos - 1;

                int position = offset - curLinePos;

                string curLine = expression.Substring(curLinePos, nextLinePos - curLinePos + 1).Replace('\t', ' ');

                OriginalCode = new DebugInfo(lines, position, curLine);
            }
Beispiel #44
0
 private void CompileDebugInfoExpression(Expression expr)
 {
     DebugInfoExpression expression = (DebugInfoExpression) expr;
     int count = this._instructions.Count;
     DebugInfo item = new DebugInfo {
         Index = count,
         FileName = expression.Document.FileName,
         StartLine = expression.StartLine,
         EndLine = expression.EndLine,
         IsClear = expression.IsClear
     };
     this._debugInfos.Add(item);
 }
Beispiel #45
0
        internal AD7Process(NameValueCollection aDebugInfo, EngineCallback aCallback, AD7Engine aEngine, IDebugPort2 aPort)
        {
            mCallback  = aCallback;
            mDebugInfo = aDebugInfo;

            mLaunch = (LaunchType)Enum.Parse(typeof(LaunchType), aDebugInfo[BuildProperties.LaunchString]);

            if (mDebugDownPipe == null)
            {
                mDebugDownPipe = new Cosmos.Debug.Common.PipeClient(Pipes.DownName);

                mDebugUpPipe = new Cosmos.Debug.Common.PipeServer(Pipes.UpName);
                mDebugUpPipe.DataPacketReceived += mDebugUpPipe_DataPacketReceived;
                mDebugUpPipe.Start();
            }
            else
            {
                mDebugUpPipe.CleanHandlers();
                mDebugUpPipe.DataPacketReceived += mDebugUpPipe_DataPacketReceived;
            }

            // Must be after mDebugDownPipe is initialized
            OutputClear();
            OutputText("Debugger process initialized.");

            mISO = mDebugInfo["ISOFile"];
            OutputText("Using ISO file " + mISO + ".");
            mProjectFile = mDebugInfo["ProjectFile"];
            //
            bool xUseGDB = string.Equals(mDebugInfo[BuildProperties.EnableGDBString], "true", StringComparison.InvariantCultureIgnoreCase);

            OutputText("GDB " + (xUseGDB ? "Enabled" : "Disabled") + ".");
            //
            var xGDBClient = false;

            Boolean.TryParse(mDebugInfo[BuildProperties.StartCosmosGDBString], out xGDBClient);

            switch (mLaunch)
            {
            case LaunchType.VMware:
                mHost = new Host.VMware(mDebugInfo, xUseGDB);
                break;

            case LaunchType.Slave:
                mHost = new Host.Slave(mDebugInfo, xUseGDB);
                break;

            case LaunchType.Bochs:
                // The project has been created on another machine or Bochs has been uninstalled since the project has
                // been created.
                if (!BochsSupport.BochsEnabled)
                {
                    throw new Exception(ResourceStrings.BochsIsNotInstalled);
                }
                string bochsConfigurationFileName = mDebugInfo[BuildProperties.BochsEmulatorConfigurationFileString];
                if (string.IsNullOrEmpty(bochsConfigurationFileName))
                {
                    bochsConfigurationFileName = BuildProperties.BochsDefaultConfigurationFileName;
                }
                if (!Path.IsPathRooted(bochsConfigurationFileName))
                {
                    // Assume the configuration file name is relative to project output path.
                    bochsConfigurationFileName = Path.Combine(new FileInfo(mDebugInfo["ProjectFile"]).Directory.FullName,
                                                              mDebugInfo["OutputPath"], bochsConfigurationFileName);
                }
                FileInfo bochsConfigurationFile = new FileInfo(bochsConfigurationFileName);
                // TODO : What if the configuration file doesn't exist ? This will throw a FileNotFoundException in
                // the Bochs class constructor. Is this appropriate behavior ?
                mHost = new Host.Bochs(mDebugInfo, xUseGDB, bochsConfigurationFile);

                //((Host.Bochs)mHost).FixBochsConfiguration(new KeyValuePair<string, string>[] { new KeyValuePair<string, string>("IsoFileName", mISO) });
                break;

            case LaunchType.IntelEdison:
                mHost = new Host.IntelEdison(mDebugInfo, false);
                break;

            default:
                throw new Exception("Invalid Launch value: '" + mLaunch + "'.");
            }
            mHost.OnShutDown += HostShutdown;

            string xDbPath = Path.ChangeExtension(mISO, "cdb");

            if (!File.Exists(xDbPath))
            {
                throw new Exception("Debug data file " + xDbPath + " not found. Could be a omitted build process of Cosmos project so that not created.");
            }

            mDebugInfoDb = new DebugInfo(xDbPath);
            mDebugInfoDb.LoadLookups();

            CreateDebugConnector();
            aEngine.BPMgr.SetDebugConnector(mDbgConnector);

            mEngine = aEngine;
            mThread = new AD7Thread(aEngine, this);
            mCallback.OnThreadStart(mThread);
            mPort = aPort;

            if (xUseGDB && xGDBClient)
            {
                LaunchGdbClient();
            }
        }
Beispiel #46
0
    private static void WriteSymbols(BinaryWriter writer, DebugInfo di)
    {
        writer.Write(di.File ?? "");

        writer.Write(di.Scopes.Count);
        foreach (var s in di.Scopes)
        {
            writer.Write(s.Index);
            writer.Write(s.ParentIndex);
            writer.Write(s.StartOffset);
            writer.Write(s.EndOffset);
            writer.Write(s.StartLine);
            writer.Write(s.StartColumn);
            writer.Write(s.EndLine);
            writer.Write(s.EndColumn);
        }

        writer.Write(di.Lines.Count);
        foreach (var l in di.Lines)
        {
            writer.Write(l.Offset);
            writer.Write(l.Line);
            writer.Write(l.Column);
        }

        writer.Write(di.Vars.Count);
        foreach (var v in di.Vars)
        {
            writer.Write(v.Name);
            writer.Write(v.Address);
            writer.Write(v.Offset);
            writer.Write(v.Scope);
            writer.Write(v.Flags);
            writer.Write(v.Data);
        }

        writer.Write(di.Functions.Count);
        foreach (var f in di.Functions.Values)
        {
            writer.Write(f.Name);
            writer.Write(f.Handle);
            writer.Write(f.StartOffset);
            writer.Write(f.EndOffset);
            writer.Write(f.TypeName is not null);
            writer.Write(f.TypeName ?? "");
            writer.Write(f.Parameters is null ? 0 : f.Parameters.Length);
            if (f.Parameters is not null)
            {
                foreach (var p in f.Parameters)
                {
                    writer.Write(p.Name);
                    writer.Write(p.IsVarArg);
                    if (p.Value == null)
                    {
                        writer.Write(-1);
                    }
                    else
                    {
                        p.Value.Serialize(writer);
                    }
                }
            }
        }
    }
Beispiel #47
0
        public bool Execute()
        {
            try
            {
                LogMessage("Executing IL2CPU on assembly");
                if (!Initialize())
                {
                    return false;
                }
                LogTime("Engine execute started");

                // Find the kernel's entry point. We are looking for a public class Kernel, with public static void Boot()
                var xInitMethod = LoadAssemblies();
                if (xInitMethod == null)
                {
                    return false;
                }

                var xOutputFilename = Path.Combine(Path.GetDirectoryName(OutputFilename), Path.GetFileNameWithoutExtension(OutputFilename));
                if (!DebugEnabled)
                {
                    // Default of 1 is in Cosmos.Targets. Need to change to use proj props.
                    DebugCom = 0;
                }

                using (var xAsm = GetAppAssembler())
                {
                    using (var xDebugInfo = new DebugInfo(xOutputFilename + ".cdb", true, false))
                    {
                        xAsm.DebugInfo = xDebugInfo;
                        xAsm.DebugEnabled = DebugEnabled;
                        xAsm.StackCorruptionDetection = StackCorruptionDetectionEnabled;
                        xAsm.StackCorruptionDetectionLevel = mStackCorruptionDetectionLevel;
                        xAsm.DebugMode = mDebugMode;
                        xAsm.TraceAssemblies = mTraceAssemblies;
                        xAsm.IgnoreDebugStubAttribute = IgnoreDebugStubAttribute;
                        if (DebugEnabled == false)
                        {
                            xAsm.ShouldOptimize = true;
                        }

                        xAsm.Assembler.Initialize();
                        using (var xScanner = new ILScanner(xAsm))
                        {
                            xScanner.LogException = LogException;
                            xScanner.LogWarning = LogWarning;
                            CompilerHelpers.DebugEvent += LogMessage;
                            if (EnableLogging)
                            {
                                var xLogFile = xOutputFilename + ".log.html";
                                if (false == xScanner.EnableLogging(xLogFile))
                                {
                                    // file creation not possible
                                    EnableLogging = false;
                                    LogWarning("Could not create the file \"" + xLogFile + "\"! No log will be created!");
                                }
                            }
                            xScanner.QueueMethod(xInitMethod.DeclaringType.BaseType.GetMethod("Start"));
                            xScanner.Execute(xInitMethod);

                            AppAssemblerRingsCheck.Execute(xScanner, xInitMethod.DeclaringType.Assembly);

                            using (var xOut = new StreamWriter(OutputFilename, false, Encoding.ASCII, 128 * 1024))
                            {
                                //if (EmitDebugSymbols) {
                                xAsm.Assembler.FlushText(xOut);
                                xAsm.FinalizeDebugInfo();
                                //// for now: write debug info to console
                                //Console.WriteLine("Wrote {0} instructions and {1} datamembers", xAsm.Assembler.Instructions.Count, xAsm.Assembler.DataMembers.Count);
                                //var dict = new Dictionary<string, long>(StringComparer.OrdinalIgnoreCase);
                                //foreach (var instr in xAsm.Assembler.Instructions)
                                //{
                                //    var mn = instr.Mnemonic ?? "";
                                //    if (dict.ContainsKey(mn))
                                //    {
                                //        dict[mn] = dict[mn] + 1;
                                //    }
                                //    else
                                //    {
                                //        dict[mn] = 1;
                                //    }
                                //}
                                //foreach (var entry in dict)
                                //{
                                //    Console.WriteLine("{0}|{1}", entry.Key, entry.Value);
                                //}
                            }
                        }
                        // If you want to uncomment this line make sure to enable PERSISTANCE_PROFILING symbol in
                        // DebugInfo.cs file.
                        //LogMessage(string.Format("DebugInfo flatening {0} seconds, persistance : {1} seconds",
                        //    (int)xDebugInfo.FlateningDuration.TotalSeconds,
                        //    (int)xDebugInfo.PersistanceDuration.TotalSeconds));
                    }
                }
                LogTime("Engine execute finished");
                return true;
            }
            catch (Exception ex)
            {
                LogException(ex);
                LogMessage("Loaded assemblies: ");
                foreach (var xAsm in AppDomain.CurrentDomain.GetAssemblies())
                {
                    // HACK: find another way to skip dynamic assemblies (which belong to dynamic methods)
                    if (xAsm.IsDynamic)
                    {
                        continue;
                    }

                    try
                    {
                        LogMessage(xAsm.Location);
                    }
                    catch
                    {
                    }
                }
                return false;
            }
        }
 public void InitializeDebugInfo() => DebugInfo.Init();
Beispiel #49
0
        void HostShutdown(object sender, EventArgs e)
        {
            //AD7ThreadDestroyEvent.Send(mEngine, mThread, (uint)mProcess.ExitCode);
            //mCallback.OnProgramDestroy((uint)mProcess.ExitCode);

            // We dont use process info any more, but have to call this to tell
            // VS to stop debugging.
            if (Interlocked.CompareExchange(ref mProcessExitEventSent, 1, 0) == 0)
            {
                try
                {
                    mCallback.OnProcessExit(0);
                }
                catch
                {
                    // swallow exceptions here?
                }
            }

            if (mDbgConnector != null)
            {
                mDbgConnector.Dispose();
                mDbgConnector = null;
            }
            if (mDebugInfoDb != null)
            {
                // Commented for debugging, so we can look at the DB after
                //mDebugInfoDb.DeleteDB();
                mDebugInfoDb.Dispose();
                mDebugInfoDb = null;
            }
        }
 public StepFormattingException(string message, DebugInfo debugInfo) : base(message, debugInfo)
 {
 }
Beispiel #51
0
	public static void AddLog(DebugInfo logInfo){
		if (logInfo == null)
			return;
		if (DebugInfoText != null) {
			logInfo.ID = LogInfoList.Count;
			LogInfoList.Add (logInfo);
			UpdateLogText ();
		}
	}
        protected override T PopulateDebugInfo <T>(DebugInfo debugInfo, int parentDepth, int childDepth)
        {
            if (typeof(T).IsAssignableFrom(typeof(DebugRegion)))
            {
                var debugRegion = debugInfo as DebugRegion ?? new DebugRegion();

                if (childDepth != 0)
                {
                    var content = Content as IDebuggable;
                    if (content != null)
                    {
                        debugRegion.Children = new List <DebugInfo> {
                            content.GetDebugInfo(0, childDepth - 1)
                        }
                    }
                    ;
                }

                debugRegion.RepeatScope = RepeatScope;
                debugRegion.RepeatType  = _repeatType;
                debugRegion.ListType    = _listType;
                debugRegion.ListScope   = ListScope;

                if (_dataScopeRules != null)
                {
                    debugRegion.Scope = _dataScopeRules.GetDebugInfo <DebugDataScopeRules>();
                }

                return(base.PopulateDebugInfo <T>(debugRegion, parentDepth, childDepth));
            }

            if (typeof(T).IsAssignableFrom(typeof(DebugDataScopeRules)))
            {
                var debugDataScopeRules = _dataScopeRules.GetDebugInfo <DebugDataScopeRules>(parentDepth, childDepth);

                if (RepeatType != null)
                {
                    if (debugDataScopeRules.DataSupplies == null)
                    {
                        debugDataScopeRules.DataSupplies = new List <DebugSuppliedDependency>();
                    }

                    var repeatDataSupply = new DebugSuppliedDependency
                    {
                        DataTypeSupplied = new DebugDataScope
                        {
                            DataType  = RepeatType,
                            ScopeName = RepeatScope
                        },
                        DataConsumer = new DebugDataConsumer
                        {
                            DependentData = new List <DebugDataScope>
                            {
                                new DebugDataScope
                                {
                                    DataType  = ListType,
                                    ScopeName = ListScope
                                }
                            }
                        }
                    };

                    debugDataScopeRules.DataSupplies.Add(repeatDataSupply);
                }

                return(base.PopulateDebugInfo <T>(debugDataScopeRules, parentDepth, childDepth));
            }

            if (typeof(T).IsAssignableFrom(typeof(DebugDataSupplier)))
            {
                var debugDataSupplier = debugInfo as DebugDataSupplier ?? new DebugDataSupplier();

                if (RepeatType != null)
                {
                    debugDataSupplier.SuppliedTypes = new List <Type> {
                        RepeatType
                    };
                    debugDataSupplier.DefaultSupply = new DebugDataScope
                    {
                        DataType  = RepeatType,
                        ScopeName = RepeatScope
                    };
                }

                return(base.PopulateDebugInfo <T>(debugDataSupplier, parentDepth, childDepth));
            }

            return(base.PopulateDebugInfo <T>(debugInfo, parentDepth, childDepth));
        }
    private void _onMessage(DebugInfo info) {
      
      DispatcherHelper.CheckBeginInvokeOnUI(() =>
      {
        if (info != null && !string.IsNullOrWhiteSpace(info.Info))
        {
          if (_debugInfoWin == null)
          {
            _debugInfoWin = new DebugInfoWin();
          }
          else
          {
            if (ShowDebugWin)
              _debugInfoWin.Show();
          }

          Messenger.Default.Send(info);
        }
      });
    }
 /// <summary>
 /// Initialize a new instance of <see cref="AlgorithmInterpreterStateEventArgs"/>
 /// </summary>
 /// <param name="state">The <see cref="AlgorithmInterpreterState"/></param>
 /// <param name="debugInfo">The debug information</param>
 public AlgorithmInterpreterStateEventArgs(AlgorithmInterpreterState state, DebugInfo debugInfo)
     : this(state)
 {
     DebugInfo = debugInfo;
 }
Beispiel #55
0
        /// <summary>
        /// Helper method to return source name, line numbers and IL offsets for given method token.
        /// </summary>
        /// <param name="assemblyFileName">file name of the assembly</param>
        /// <param name="methToken">method token</param>
        /// <param name="pints">List of debug information for each sequence point return</param>
        /// <returns> true if information is available</returns>
        private static bool GetDebugInfoForMethod(string assemblyFileName, int methodToken, out List<DebugInfo> points)
        {
            MetadataReader peReader, pdbReader;
            
            points = null;
            try
            {
                if (!GetReaders(assemblyFileName, out peReader, out pdbReader))
                    return false;
                Handle handle = MetadataTokens.Handle(methodToken);
                if (handle.Kind != HandleKind.MethodDefinition)
                    return false;

                points = new List<DebugInfo>();
                MethodDebugInformationHandle methodDebugHandle =
                    ((MethodDefinitionHandle)handle).ToDebugInformationHandle();
                MethodDebugInformation methodDebugInfo = pdbReader.GetMethodDebugInformation(methodDebugHandle);
                SequencePointCollection sequencePoints = methodDebugInfo.GetSequencePoints();

                foreach (SequencePoint point in sequencePoints)
                {
                    if (point.StartLine == 0 || point.StartLine == SequencePoint.HiddenLine)
                        continue;
                    DebugInfo debugInfo = new DebugInfo();

                    debugInfo.lineNumber = point.StartLine;
                    debugInfo.fileName = pdbReader.GetString(pdbReader.GetDocument(point.Document).Name);
                    debugInfo.ilOffset = point.Offset;
                    points.Add(debugInfo);
                }
                return true;
            }
            finally
            {
                peReader = null;
                pdbReader = null;
            }
        }
 /// <summary>
 /// Initialize a new instance of <see cref="AlgorithmInterpreterStateEventArgs"/>
 /// </summary>
 /// <param name="error">An <see cref="Error"/></param>
 /// <param name="debugInfo">The debug information</param>
 public AlgorithmInterpreterStateEventArgs(Error error, DebugInfo debugInfo)
 {
     State     = AlgorithmInterpreterState.StoppedWithError;
     Error     = error;
     DebugInfo = debugInfo;
 }
Beispiel #57
0
        /// <summary>
        /// Helper method to return source name, line numbers and IL offsets for given method token.
        /// </summary>
        /// <param name="assemblyPath">file path of the assembly</param>
        /// <param name="methodToken">method token</param>
        /// <param name="points">list of debug information for each sequence point return</param>
        /// <returns>true if information is available</returns>
        /// <remarks>used by the gdb JIT support (not SOS). Does not support in-memory PEs or PDBs</remarks>
        private static bool GetDebugInfoForMethod(string assemblyPath, int methodToken, out List<DebugInfo> points)
        {
            points = null;

            OpenedReader openedReader = GetReader(assemblyPath, isFileLayout: true, peStream: null, pdbStream: null);
            if (openedReader == null)
                return false;

            using (openedReader)
            {
                try
                {
                    Handle handle = MetadataTokens.Handle(methodToken);
                    if (handle.Kind != HandleKind.MethodDefinition)
                        return false;

                    points = new List<DebugInfo>();
                    MethodDebugInformationHandle methodDebugHandle = ((MethodDefinitionHandle)handle).ToDebugInformationHandle();
                    MethodDebugInformation methodDebugInfo = openedReader.Reader.GetMethodDebugInformation(methodDebugHandle);
                    SequencePointCollection sequencePoints = methodDebugInfo.GetSequencePoints();

                    foreach (SequencePoint point in sequencePoints)
                    {
                        if (point.StartLine == 0 || point.StartLine == SequencePoint.HiddenLine)
                            continue;

                        DebugInfo debugInfo = new DebugInfo();
                        debugInfo.lineNumber = point.StartLine;
                        debugInfo.fileName = openedReader.Reader.GetString(openedReader.Reader.GetDocument(point.Document).Name);
                        debugInfo.ilOffset = point.Offset;
                        points.Add(debugInfo);
                    }
                }
                catch
                {
                    return false;
                }
            }
            return true;
        }
Beispiel #58
0
 public static void UpdateDebugInfo(DebugInfo info)
 {
     _context.DebugInfo = info;
 }
        private void OutputInitialDebugInfo(DebugInfo index, TextBlock value)
        {
            if (!_isDebugModeActive)
            {
                return;
            }

            ManipulationStarted += (s, e) => OutputDebugInfo(DebugInfo.IsManipulationActive, true);
            ManipulationCompleted += (s, e) => OutputDebugInfo(DebugInfo.IsManipulationActive, false);

            switch (index)
            {
                case DebugInfo.Scale:
                    value.Text = string.Format(value.Tag.ToString(), 1);
                    break;
                case DebugInfo.Rotate:
                    value.Text = string.Format(value.Tag.ToString(), 0);
                    break;
                case DebugInfo.Translate:
                    value.Text = string.Format(value.Tag.ToString(), 0, 0);
                    break;
                case DebugInfo.ScaleRotateTranslateEnabled:
                    value.Text = string.Format(
                        value.Tag.ToString(),
                        IsScaleEnabled,
                        IsRotateEnabled,
                        IsTranslateXEnabled,
                        IsTranslateYEnabled);
                    break;
                case DebugInfo.MaximumScale:
                    value.Text = string.Format(value.Tag.ToString(), MaximumScale);
                    break;
                case DebugInfo.MinimumScale:
                    value.Text = string.Format(value.Tag.ToString(), MinimumScale);
                    break;
                case DebugInfo.IsManipulationActive:
                    value.Text = string.Format(value.Tag.ToString(), false);
                    break;
            }
        }
Beispiel #60
0
 public override string GetDebugInfo()
 {
     return(DebugInfo.ToString(debugInfo));
 }