Exemplo n.º 1
0
 /// <summary>
 /// Detach the MoonSharp script from the debugger.
 /// </summary>
 protected virtual void OnDestroy()
 {
     if (DebugServer != null)
     {
         DebugServer.Detach(interpreter);
     }
 }
Exemplo n.º 2
0
 public SimulatorDebugger(IServiceProvider serviceProvider, Output output)
 {
     _output  = output;
     _running = false;
     _dte     = serviceProvider.GetService(typeof(SDTE)) as DTE;
     _server  = new DebugServer();
     _events  = new DebuggerEventsProxy(_server, _output);
 }
Exemplo n.º 3
0
        private static void RunDebugServer()
        {
            DebugServer server      = new DebugServer(context.VirtualMachine);
            Thread      debugThread = new Thread(() => {
                server.Start(new IPEndPoint(IPAddress.Loopback, 6569));
            });

            debugThread.Start();
            Console.WriteLine("Debug server listening on 127.0.0.1:6569");
        }
Exemplo n.º 4
0
 public DebuggerWrapper(Interfaces.IServiceProvider serviceProvider)
 {
     _serviceProvider = serviceProvider;
     _entryOffset     = 0x800000;
     _debugServer     = new DebugServer();
     _transport       = new SerialTransport();
     _eventService    = serviceProvider.GetService <IEventService>();
     CpuState         = new CpuState
     {
         Registers = new byte[32]
     };
 }
Exemplo n.º 5
0
        public static void Main(string[] args)
        {
            string input   = null;
            uint   ramsize = 0x20000000;
            bool   debug   = false;

            for (int i = 0; i < args.Length; i++)
            {
                if (!args[i].StartsWith("-") && input == null)
                {
                    input = args[i];
                }
                else if (args[i] == "-S")
                {
                    debug = true;
                }
                else if (args[i] == "-m")
                {
                    string amount = args[++i];
                    uint   rs;
                    if (uint.TryParse(amount, out rs))
                    {
                        ramsize = rs * 0x100000;
                    }
                    else
                    {
                        Fail("Size {0} is not valid!", amount);
                    }
                }
            }

            if (input == null)
            {
                Fail("No input specified!");
            }


            Emulator emu = new Emulator(new QuasarRam(ramsize));

            byte[] data = File.ReadAllBytes(input);
            for (uint i = 0; i < data.Length; i++)
            {
                emu.Memory[i] = data[i];
            }
            if (debug)
            {
                DebugServer serv = new DebugServer(emu);
                serv.Start();
                serv.WaitForConnection();
            }

            emu.Emulate();
        }
 void Start()
 {
     ui = new DirectViewerSampleUi(
         debugUi,
         debugServerPort,
         OnClickPlay,
         OnClickStop,
         OnClickNext);
     debugServer = new DebugServer(debugServerPort, "/upload/", OnDebugFileServiceChanged);
     debugServer.RegisterRequestCallback("/", OnAccessRoot);
     debugServer.RegisterRequestCallback("/ping", OnAccessPing);
     debugServer.RegisterRequestCallback("/toggle-debug-ui", OnAccessToggleDebugUi);
     shaderReplacer = new IncompatibleShaderReplacer();
 }
Exemplo n.º 7
0
    void Start()
    {
        Application.logMessageReceived += OnLogReceived;
        debugServerIndexHtml            = debugServerIndexHtmlAsset.text;

        debugServer = new DebugServer(debugServerPort, "/assets/", OnFileChanged);

        // 上書き検出
        debugServer.RegisterRequestCallback("/", OnWebRequestRoot);
        debugServer.RegisterRequestCallback("/api/file/upload", OnWebRequestUploadFile);
        debugServer.RegisterRequestCallback("/api/file/delete", OnWebRequestDeleteFile);
        debugServer.RegisterRequestCallback("/api/file/delete-all", OnWebRequestDeleteAllFile);
        loadRequested = true;
    }
Exemplo n.º 8
0
        private async Task <int> AnalyzeAsync()
        {
            var debugServer = new DebugServer(LoggingContext, m_port, (d) => new DebugSession(m_state, m_pathTranslator, d));

            Debugger = await debugServer.StartAsync();

            Session = (DebugSession)Debugger.Session;
            Session.WaitSessionInitialized();

            m_state.SetThreadState(XlgState);
            Debugger.SendEvent(new StoppedEvent(XlgState.ThreadId, "Break on start", ""));

            await Session.Completion;

            return(0);
        }
Exemplo n.º 9
0
 public MavlinkServerBase(IMavlinkV2Connection connection, MavlinkServerIdentity identity, IPacketSequenceCalculator sequenceCalculator = null)
 {
     _seq      = sequenceCalculator ?? new PacketSequenceCalculator();
     Heartbeat = new MavlinkHeartbeatServer(connection, _seq, identity, new MavlinkHeartbeatServerConfig
     {
         HeartbeatRateMs = 1000
     });
     StatusText = new StatusTextServer(connection, _seq, identity, new StatusTextLoggerConfig
     {
         MaxQueueSize  = 100,
         MaxSendRateHz = 10
     });
     CommandLong = new CommandLongServer(connection, _seq, identity);
     Debug       = new DebugServer(connection, _seq, identity);
     Logging     = new LoggingServer(connection, _seq, identity);
     V2Extension = new V2ExtensionServer(connection, _seq, identity);
 }
Exemplo n.º 10
0
    IEnumerator Start()
    {
        var ipAddress = DebugServer.GetLanIpAddress();

        debugServerIndexHtml = debugServerIndexHtmlAsset.text;
        debugServerIndexHtml = debugServerIndexHtml.Replace(
            "__TO_BE_REPLACED_WITH_ACTUAL_IP_ADDRESS_IN_RUNTIME__",
            ipAddress);

        debugServer = new DebugServer(debugServerPort);

        // 上書き検出
        debugServer.RegisterRequestCallback("/", OnWebRequestRoot);
        debugServer.RegisterRequestCallback("/upload-file", OnWebRequestUploadFile);
        debugServer.RegisterRequestCallback("/delete-file", OnWebRequestDeleteFile);
        debugServer.RegisterRequestCallback("/delete-all-file", OnWebRequestDeleteAllFile);
        yield return(CoLoad());
    }
Exemplo n.º 11
0
        // LIMITS
        //  WRITING TO UART REGISTERS WILL STOP THE COMMUNICATION
        static void Main(string[] args)
        {
            SetupCommandProcessor();

            var transport = new SerialTransport();

            transport.SetPort("COM4");
            transport.SetSpeed(500000);

            _srv = new DebugServer();
            _srv.SetTransport(transport);
            _srv.DebuggerAttached += _srv_DebuggerAttached;
            _srv.DebuggerDetached += _srv_DebuggerDetached;
            _srv.UnknownData      += SrvOnUnknownData;
            _th = new Thread(CommandLoop);

            SysConsole.WriteLine("Available register names");
            SysConsole.WriteLine("**************************************");
            SysConsole.WriteLine(Registers.RegisterMappings.Aggregate("", (s, pair) => s + ", " + pair.Key).Trim(','));
            SysConsole.WriteLine("**************************************");
            SysConsole.WriteLine("Available commands");
            SysConsole.WriteLine("c - Continue execution");
            SysConsole.WriteLine("t - Toggle all of PORTB (usually a led is on PB5)");
            SysConsole.WriteLine("w - write to memory, w (location, or IO reg) data");
            SysConsole.WriteLine("    the data is in the following format (number)[,(number)]");
            SysConsole.WriteLine("    Exp. ");
            SysConsole.WriteLine("    w pinb 0xFF");
            SysConsole.WriteLine("    w 0x0123 0xFF,0xF0,0xF1,100,255");
            SysConsole.WriteLine("r - read from memory, r (location, or IO reg) size");
            SysConsole.WriteLine("    Exp. ");
            SysConsole.WriteLine("    r pinb 1");
            SysConsole.WriteLine("    r 0x0123 0xFF");
            SysConsole.WriteLine("**************************************");

            SysConsole.WriteLine("Press any key to continue");
            SysConsole.ReadLine();

            _srv.Start();
            _th.Start();
            SysConsole.WriteLine("Powercycle the target");

            // Block everything
            _th.Join();
        }
Exemplo n.º 12
0
    void OnGUI()
    {
        GUILayout.Label("debuger");

        GUILayout.Label("server state:" + server == null ? "close" : "open");
        if (server == null)
        {
            if (GUILayout.Button("StartServer"))
            {
                server = new DebugServer();
            }
        }
        else
        {
            if (GUILayout.Button("EndServer"))
            {
                server.Close();
                server = null;
            }
        }
    }
Exemplo n.º 13
0
    void OnGUI()
    {
        GUILayout.Label("debuger");

        GUILayout.Label("server state:" + server == null ? "close" : "open");
        if (server == null)
        {
            if (GUILayout.Button("StartServer"))
            {
                server = new DebugServer();
            }
        }
        else
        {
            if(GUILayout.Button("EndServer"))
            {
                server.Close();
                server = null;
            }
        }
    }
        private IFrontEndController CreateControllerWithDebugger(PathTable pathTable, SymbolTable symbolTable)
        {
            var confPort        = Configuration.FrontEnd.DebuggerPort();
            var debugServerPort = confPort != 0 ? confPort : DebugServer.DefaultDebugPort;
            var pathTranslator  = GetPathTranslator(Configuration.Logging, pathTable);
            var debugState      = new DebuggerState(pathTable, LoggingContext, DScriptDebugerRenderer.Render, new DScriptExprEvaluator(LoggingContext));
            var debugServer     = new DebugServer(LoggingContext, debugServerPort,
                                                  (debugger) => new DebugSession(debugState, pathTranslator, debugger));
            Task <IDebugger> debuggerTask = debugServer.StartAsync();
            var evaluationDecorator       = new LazyDecorator(debuggerTask, Configuration.FrontEnd.DebuggerBreakOnExit());
            var frontEndFactory           = new FrontEndFactory();

            frontEndFactory.AddPhaseStartHook(EnginePhases.Evaluate, () =>
            {
                if (!debuggerTask.IsCompleted)
                {
                    Logger.Log.WaitingForClientDebuggerToConnect(LoggingContext, debugServer.Port);
                }

                debuggerTask.Result?.Session.WaitSessionInitialized();
            });

            frontEndFactory.AddPhaseEndHook(EnginePhases.Evaluate, () =>
            {
                // make sure the debugger is shut down at the end (unnecessary in most cases, as the debugger will shut itself down after completion)
                debugServer.ShutDown();
                debuggerTask.Result?.ShutDown();
            });

            return(TryCreateFrontEndController(
                       frontEndFactory,
                       evaluationDecorator,
                       Configuration,
                       symbolTable,
                       LoggingContext,
                       Collector,
                       collectMemoryAsSoonAsPossible: CollectMemoryAsSoonAsPossible,
                       statistics: m_statistics));
        }
Exemplo n.º 15
0
 void Start()
 {
     debugServer = new DebugServer(8080, "/upload/", OnDebugFileServiceChanged);
     debugServer.RegisterRequestCallback("/", OnAccessRoot);
     ipAddress = DebugServerUtil.GetLanIpAddress();
 }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            DotaDebuggerLib.DebugServer.StartServer();
            DotaDebuggerLib.DebugServer.OnDataRecieved += RecieveDataFromDebugger;

            int ScrollbackIndex = 0;

            RequiresUpdate = true;
            while (true)
            {
                if (RequiresUpdate)
                {
                    Console.Clear();

                    Console.SetCursorPosition(0, 0);
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Write("Server: ");
                    Console.ForegroundColor = DebugServer.Started ? ConsoleColor.Green : ConsoleColor.Red;
                    Console.Write(DebugServer.Started ? "Online" : "Offline");

                    Console.ForegroundColor = ConsoleColor.White;
                    Console.Write("  Dota Debugger: ");
                    Console.ForegroundColor = DebugServer.Connected ? ConsoleColor.Green : ConsoleColor.Red;
                    Console.Write(DebugServer.Connected ? "Connected" : "Disconnected");

                    Console.ForegroundColor = ConsoleColor.Gray;

                    Console.SetCursorPosition(0, 1);
                    //Write the text
                    foreach (String s in OutputList)
                    {
                        Console.WriteLine(s);
                    }



                    Console.SetCursorPosition(0, Console.WindowHeight - 1);
                    Console.Write("> " + Input);

                    RequiresUpdate = false;
                }


                if (Console.KeyAvailable)
                {
                    var KeyInfo = Console.ReadKey(true);
                    if (KeyInfo.Key == ConsoleKey.Enter)
                    {
                        if (Input.StartsWith("server."))
                        {
                            if (Input == "server.Start")
                            {
                                DebugServer.StartServer();
                            }
                            if (Input == "server.Disconnect")
                            {
                                DebugServer.Disconnect();
                            }
                            if (Input == "server.Clear")
                            {
                                OutputList.Clear();
                            }
                        }
                        else
                        {
                            //Send the command to the server
                            DebugServer.SendData(Input);
                        }

                        Scrollback.Push(Input);
                        Input = "";
                    }
                    else if (KeyInfo.Key == ConsoleKey.Backspace)
                    {
                        if (Input.Length > 0)
                        {
                            Input = Input.Substring(0, Input.Length - 1);
                        }
                    }
                    else if (KeyInfo.Key == ConsoleKey.UpArrow && Scrollback.Count > 0)
                    {
                        Input = Scrollback.ElementAt(0);
                        ScrollbackIndex++;
                        if (ScrollbackIndex >= Scrollback.Count)
                        {
                            ScrollbackIndex = 0;
                        }
                    }
                    else if (char.IsLetterOrDigit(KeyInfo.KeyChar) || char.IsWhiteSpace(KeyInfo.KeyChar) || char.IsPunctuation(KeyInfo.KeyChar))
                    {
                        Input += KeyInfo.KeyChar;
                    }

                    RequiresUpdate = true;
                }
            }
        }
Exemplo n.º 17
0
    public static void RunSource(string sourcePath, string sourceContent, bool printDisassembled)
    {
        var filename = Path.GetFileNameWithoutExtension(sourcePath);
        var source   = new Source(new Uri(filename), sourceContent);

        /*
         * var debugger = new EmbeddedDebugger((s, v) =>
         * {
         *      EmbeddedDebugger.Break();
         * });
         * /*/
        var debugger = new DebugServer(DebugServer.DefaultPort);

        debugger.StartPaused();
        //*/

        var cflat = new CFlat();

        //cflat.SetDebugger(debugger);

        cflat.AddFunction <Class <Stopwatch> >(nameof(StartStopwatch), StartStopwatch);
        cflat.AddFunction <Class <Stopwatch>, Float>(nameof(StopStopwatch), StopStopwatch);

        var compileErrors = cflat.CompileSource(source, Mode.Debug, Option.None);

        if (compileErrors.count > 0)
        {
            var errorMessage = cflat.GetFormattedCompileErrors();
            ConsoleHelper.Error("COMPILER ERROR\n");
            ConsoleHelper.Error(errorMessage);
            ConsoleHelper.LineBreak();

            System.Environment.ExitCode = 65;
            return;
        }

        if (printDisassembled)
        {
            ConsoleHelper.Write(cflat.Disassemble());
            ConsoleHelper.LineBreak();
        }

        var main = cflat.GetFunction <Empty, Unit>("main");

        if (main.isSome)
        {
            System.Console.WriteLine("RESULT: {0}", main.value.Call(cflat, new Empty()));
        }
        else
        {
            System.Console.WriteLine("NOT FOUNDED");
        }

        var runtimeError = cflat.GetRuntimeError();

        if (runtimeError.isSome)
        {
            var errorMessage = cflat.GetFormattedRuntimeError();
            ConsoleHelper.Error("RUNTIME ERROR\n");
            ConsoleHelper.Error(errorMessage);
            ConsoleHelper.LineBreak();
            ConsoleHelper.Error(cflat.TraceCallStack());

            System.Environment.ExitCode = 70;
        }
        else
        {
            System.Environment.ExitCode = 0;
        }

        ConsoleHelper.LineBreak();
    }
Exemplo n.º 18
0
    public DebugService(
        World world,
        int serverPort,
        Camera camera,
        Shader textShader,
        Shader texturedShader,
        Font font,
        Sprite tapMark,
        string debugServerIndexHtml)
    {
        var decodedToken = DebugSlack.DecryptXor(slackKey, slackEncodedToken);

        if (decodedToken != null)
        {
            slack = new DebugSlack(decodedToken, "テキトーなチャンネル名");
        }
        // ログできるだけ速く欲しいので、こいつのコンストラクトだけ先にやる
        Log         = new DebugUiLogWindow(12f, 380f, 700f, borderEnabled: true, captureUnityLog: true);
        Log.enabled = false;

        this.world = world;
        this.debugServerIndexHtml = debugServerIndexHtml;
        server = new DebugServer(serverPort, "/assets/", OnFileChanged);

        uiManager = DebugUiManager.Create(
            camera,
            textShader,
            texturedShader,
            font,
            432,
            768,
            1f,
            8192);
        uiManager.safeAreaVisualizationEnabled = true;
        var frameTimeGauge = new FrameTimeGauge(100f, 15f, null);

        uiManager.Add(frameTimeGauge, 0f, 0f, DebugUi.AlignX.Right, DebugUi.AlignY.Bottom);
        menu = new DebugUiMenu(100f, 40f, DebugUi.Direction.Down, "DebugMenu");
        uiManager.Add(menu);
        menu.AddItem("LogWindow", () =>
        {
            Log.enabled = !Log.enabled;
        });
        uiManager.Add(Log, 0, 40f, DebugUi.AlignX.Center, DebugUi.AlignY.Top);

        var dataSubMenu = new DebugUiSubMenu("Data", 100f, 40f, DebugUi.Direction.Down);

        menu.AddSubMenu(dataSubMenu, DebugUi.Direction.Right);
        dataSubMenu.AddItem("SendJsons", () =>
        {
            world.StartCoroutine(CoSendJsons());
        });
        dataSubMenu.AddItem("Reload\nGlobalParams", () =>
        {
            world.ReloadGlobalParams();
        });

        var debugSubMenu = new DebugUiSubMenu("Debug", 100f, 40f, DebugUi.Direction.Down);

        menu.AddSubMenu(debugSubMenu, DebugUi.Direction.Right);

        debugSubMenu.AddItem("HideDebug", () =>
        {
            ToggleUiEnabled();
        });

        debugSubMenu.AddItem("AutoTap", () =>
        {
            tapper.enabled = !tapper.enabled;
        });

        var resoSubMenu = new DebugUiSubMenu("Resolution", 100f, 40f, DebugUi.Direction.Down);

        menu.AddSubMenu(resoSubMenu, DebugUi.Direction.Right);
        var text = string.Format("{0}x{1}", Screen.width, Screen.height);

        resoButton = resoSubMenu.AddItem(text, () =>
        {
            var w = Screen.width * 70 / 100;
            var h = Screen.height * 70 / 100;
            if (w < (16 * 9))
            {
                w = 720;
                h = 1280;
            }
            Screen.SetResolution(w, h, false, 60);
            resoButton.text = w.ToString() + "x" + h.ToString();
        });
        resoSubMenu.AddItem("Aspect\n4:3", () =>
        {
            ScreenSettings.Save(1536, 2048, 0, 0, 0, 0);
        });
        resoSubMenu.AddItem("Aspect\n16:9", () =>
        {
            ScreenSettings.Save(1080, 1920, 0, 0, 0, 0);
        });
        resoSubMenu.AddItem("Aspect\niPhoneX", () =>
        {
            ScreenSettings.Save(1242, 2688, 0, 0, 132, 102);
        });
        resoSubMenu.AddItem("Aspect\nDefault", () =>
        {
            ScreenSettings.SaveDefault();
        });

        menu.AddItem(DebugServerUtil.GetLanIpAddress(), () =>
        {
            var url = string.Format("http://{0}:{1}/", DebugServerUtil.GetLanIpAddress(), serverPort);
            Application.OpenURL(url);
        });
//		uiManager.enabled = false; // 初期状態は無効

        server.RegisterRequestCallback("/", OnWebRequestRoot);
        server.RegisterRequestCallback("/api/upload-file", OnWebRequestUploadFile);
        server.RegisterRequestCallback("/api/delete-file", OnWebRequestDeleteFile);
        server.RegisterRequestCallback("/api/delete-all-file", OnWebRequestDeleteAllFile);
        server.RegisterRequestCallback("/api/toggle-debug", OnWebRequestToggleDebug);

        var go = new GameObject("DebugTapper");

        tapper = go.AddComponent <DefaultDebugTapper>();
        tapper.ManualStart(8, tapMark);
        tapper.enabled = false;
    }
Exemplo n.º 19
0
 private void EndAccept(IAsyncResult ar)
 {
     new Thread(() => DebugServer.Wait(_listener.EndAcceptSocket(ar))).Start();
     _listener.BeginAcceptSocket(EndAccept, null);
 }