Exemple #1
0
        public void Break(bool silent = false)
        {
            if (!silent && !allowControlCBreak)
            {
                return;
            }

            // grab the full stack and tuck it away for future reference
            ValList stack = M1API.StackList(interpreter.vm);

            // also find the first non-null entry, to display right away
            SourceLoc loc = null;

            if (interpreter.vm != null)
            {
                foreach (var stackLoc in interpreter.vm.GetStack())
                {
                    loc = stackLoc;
                    if (loc != null)
                    {
                        break;
                    }
                }
            }
            interpreter.Stop();
            console.AbortInput();
            console.keyBuffer.Clear();
            if (!silent)
            {
                string msg = "BREAK";
                if (loc != null)
                {
                    msg += " at ";
                    if (loc.context != null)
                    {
                        msg += loc.context + " ";
                    }
                    msg += "line " + loc.lineNum;
                }
                textDisplay.Print(msg + "\n");
                //Debug.Log("printed: " + msg);
            }
            ValMap globals = interpreter.vm.globalContext.variables;

            interpreter.Reset();
            interpreter.REPL("");               // (forces creation of a VM)
            interpreter.vm.globalContext.variables = globals;
            globals.SetElem(M1API._stackAtBreak, stack);
            AddGlobals();
            //Debug.Log("Rebuilt VM and restored " + globals.Count + " globals");
        }
Exemple #2
0
        private SourceLoc GetSourceLoc()
        {
            DwarfMethodDIE first = null, ctor = null;

            foreach (var die in Children)
            {
                if (die is DwarfMethodDIE)
                {
                    var dmdie = die as DwarfMethodDIE;
                    if (first == null && dmdie.SourceFileId != 0)
                    {
                        first = dmdie;
                    }
                    if (ctor == null && dmdie.ms != null && dmdie.ms.Name == ".ctor" && dmdie.SourceFileId != 0)
                    {
                        ctor = dmdie;
                        break;
                    }
                }
            }
            if (first == null)
            {
                return(null);
            }
            var ret = new SourceLoc();

            if (ctor != null)
            {
                ret.file = ctor.SourceFileId;
                ret.line = ctor.StartLine;
                ret.col  = ctor.StartColumn;
            }
            else
            {
                ret.file = first.SourceFileId;
                ret.line = first.StartLine;
                ret.col  = first.StartColumn;
            }

            return(ret);
        }