Beispiel #1
0
        public static void Main(string[] args)
        {
            Parser.Default.ParseArguments <CommandLineOption>(args)
            .WithParsed(option =>
            {
                var emulator = new Emulator(option.XLEN);

                emulator.Pc = option.Pc;
                emulator.LoadToMemory(option.Load);
                emulator.Process(option.Cycle, Emulator.StopCondition.HostIo);

                var exitCode = emulator.GetHostIoValue() == 1 ? 0 : 1;

                if (option.GdbPort == 0)
                {
                    // GDB server is disabled.
                    Environment.Exit(exitCode);
                }

                using (var gdbServer = new GdbServer(emulator, option.GdbPort))
                {
                    Console.WriteLine("GDB server is running.");
                    Console.WriteLine("Please input some characters to finish.");
                    Console.Read();
                }

                Environment.Exit(exitCode);
            });
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public int OnAttachClient(CLangDebugger debugger)
        {
            LoggingUtils.PrintFunction();

            try
            {
                GdbServer gdbServer = debugger.GdbServer;

                debugger.GdbClient.Attach(gdbServer);

                return(Constants.S_OK);
            }
            catch (Exception e)
            {
                LoggingUtils.HandleException(e);

                throw;
            }
        }