Exemple #1
0
        static int Main(string[] args)
        {
            String        command                   = null;
            List <String> scriptFilename            = new List <String>();
            bool          showUsage                 = false;
            bool          nonDebugNonGuiExitOnError = false;
            bool          showIncludes              = false;
            int           errorCode                 = 0; // 0==success, the return value

            PrintVersion();

            ParseArguments(args,
                           out command, out scriptFilename, out showUsage,
                           out nonDebugNonGuiExitOnError, out showIncludes, out errorCode);

            if (showUsage)
            {
                PrintUsage();
                return(errorCode);
            }

            TextReader reader;
            bool       showPrompt;
            bool       readFromConsole;

            errorCode = DetermineAndOpenInputSource(command, scriptFilename,
                                                    out reader, out showPrompt, out readFromConsole);
            if (errorCode != 0)
            {
                return(errorCode);
            }

            GrShell               shell     = new GrShell(reader);
            GrShellImpl           shellImpl = new GrShellImpl();
            IGrShellImplForDriver impl      = shellImpl;
            GrShellDriver         driver    = new GrShellDriver(shell, impl);

            shell.SetImpl(shellImpl);
            shell.SetDriver(driver);
            driver.tokenSources.Push(shell.token_source);
            driver.showIncludes            = showIncludes;
            impl.nonDebugNonGuiExitOnError = nonDebugNonGuiExitOnError;

            try
            {
                driver.conditionalEvaluationResults.Push(true);

                while (!driver.Quitting && !driver.Eof)
                {
                    driver.ShowPromptAsNeeded(showPrompt);

                    bool success = shell.ParseShellCommand();

                    errorCode = HandleEofOrErrorIfNonConsoleShell(scriptFilename, success, nonDebugNonGuiExitOnError,
                                                                  shell, driver,
                                                                  ref reader, ref showPrompt, ref readFromConsole);
                    if (errorCode != 0)
                    {
                        return(errorCode);
                    }
                }

                driver.conditionalEvaluationResults.Pop();
            }
            catch (Exception e)
            {
                Console.WriteLine("exit due to " + e.Message);
                errorCode = -2;
            }
            finally
            {
                impl.Cleanup();
            }

            return(errorCode);
        }
Exemple #2
0
 public Debugger(GrShellImpl grShellImpl, String debugLayout)
     : this(grShellImpl, debugLayout, null)
 {
 }
Exemple #3
0
        /// <summary>
        /// Initializes a new Debugger instance using the given layout and options.
        /// Any invalid options will be removed from layoutOptions.
        /// </summary>
        /// <param name="grShellImpl">An GrShellImpl instance.</param>
        /// <param name="debugLayout">The name of the layout to be used.</param>
        /// <param name="layoutOptions">An dictionary mapping layout option names to their values.
        /// It may be null, if no options are to be applied.</param>
        public Debugger(GrShellImpl grShellImpl, String debugLayout, Dictionary<String, String> layoutOptions)
        {
            this.grShellImpl = grShellImpl;
            this.shellProcEnv = grShellImpl.CurrentShellProcEnv;
            this.realizers = grShellImpl.realizers;

            this.context = new PrintSequenceContext(grShellImpl.Workaround);

            int ycompPort = GetFreeTCPPort();
            if(ycompPort < 0)
            {
                throw new Exception("Didn't find a free TCP port in the range 4242-4251!");
            }
            try
            {
                viewerProcess = Process.Start(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
                    + Path.DirectorySeparatorChar + "ycomp", "--nomaximize -p " + ycompPort);
            }
            catch(Exception e)
            {
                throw new Exception("Unable to start yComp: " + e.ToString());
            }

            try
            {
                ycompClient = new YCompClient(shellProcEnv.ProcEnv.NamedGraph, debugLayout, 20000, ycompPort, 
                    shellProcEnv.DumpInfo, realizers);
            }
            catch(Exception ex)
            {
                throw new Exception("Unable to connect to yComp at port " + ycompPort + ": " + ex.Message);
            }

            shellProcEnv.ProcEnv.NamedGraph.ReuseOptimization = false;
            NotifyOnConnectionLost = true;

            try
            {
                if(layoutOptions != null)
                {
                    List<String> illegalOptions = null;
                    foreach(KeyValuePair<String, String> option in layoutOptions)
                    {
                        if(!SetLayoutOption(option.Key, option.Value))
                        {
                            if(illegalOptions == null) illegalOptions = new List<String>();
                            illegalOptions.Add(option.Key);
                        }
                    }
                    if(illegalOptions != null)
                    {
                        foreach(String illegalOption in illegalOptions)
                            layoutOptions.Remove(illegalOption);
                    }
                }

                if(!ycompClient.dumpInfo.IsExcludedGraph())
                    UploadGraph(shellProcEnv.ProcEnv.NamedGraph);
            }
            catch(OperationCanceledException)
            {
                throw new Exception("Connection to yComp lost");
            }

            NotifyOnConnectionLost = false;
            RegisterLibGrEvents(shellProcEnv.ProcEnv.NamedGraph);
        }
Exemple #4
0
 public Debugger(GrShellImpl grShellImpl)
     : this(grShellImpl, "Orthogonal", null)
 {
 }