Пример #1
0
        public void FillWithSource()
        {
            lines.Clear();

            StackFrame sf = DebuggingService.CurrentFrame;

            if (currentFile != sf.SourceLocation.Filename)
            {
                AssemblyLine[] asmLines = DebuggingService.DebuggerSession.DisassembleFile(sf.SourceLocation.Filename);
                if (asmLines == null)
                {
                    // Mixed disassemble not supported
                    Fill();
                    return;
                }
                currentFile = sf.SourceLocation.Filename;
                addressLines.Clear();
                editor.Document.Text = string.Empty;
                StreamReader  sr = new StreamReader(sf.SourceLocation.Filename);
                string        line;
                int           sourceLine  = 1;
                int           na          = 0;
                int           editorLine  = 0;
                StringBuilder sb          = new StringBuilder();
                List <int>    asmLineNums = new List <int> ();
                while ((line = sr.ReadLine()) != null)
                {
                    InsertSourceLine(sb, editorLine++, line);
                    while (na < asmLines.Length && asmLines [na].SourceLine == sourceLine)
                    {
                        asmLineNums.Add(editorLine);
                        InsertAssemblerLine(sb, editorLine++, asmLines [na++]);
                    }
                    sourceLine++;
                }
                editor.Document.Text = sb.ToString();
                foreach (int li in asmLineNums)
                {
                    editor.Document.AddMarker(li, asmMarker);
                }
            }
            int aline;

            if (!addressLines.TryGetValue(sf.Address, out aline))
            {
                return;
            }
            lastDebugLine     = aline;
            editor.Caret.Line = aline;
            editor.Document.AddMarker(lastDebugLine, currentDebugLineMarker);
            editor.QueueDraw();
        }
Пример #2
0
        void UpdateCurrentLineMarker(bool moveCaret)
        {
            editor.Document.RemoveMarker(currentDebugLineMarker);
            StackFrame sf = DebuggingService.CurrentFrame;
            int        line;

            if (addressLines.TryGetValue(GetAddrId(sf.Address, sf.AddressSpace), out line))
            {
                editor.Document.AddMarker(line, currentDebugLineMarker);
                if (moveCaret)
                {
                    editor.Caret.Line = line;
                    GLib.Timeout.Add(100, delegate {
                        editor.CenterToCaret();
                        return(false);
                    });
                }
                editor.QueueDraw();
            }
        }