public void Populate(Project project, ProjectFile pf, CPUImage cpu)
        {
            if (typeface == null)
            {
                typeface = new Typeface(viewer.FontFamily, viewer.FontStyle, viewer.FontWeight, viewer.FontStretch);
            }

            SourceFileSegment segment;

            project.GetLineSegment(out segment, cpu.PC);

            int hiStart, hiEnd;
            var sb = new StringBuilder(4096);

            AppendDissassembly(sb, out hiStart, out hiEnd, pf.Module, segment);

            text = new FormattedText(sb.ToString(), culture, FlowDirection.LeftToRight, typeface, viewer.FontSize, Brushes.Black, 1.0);
            text.SetForegroundBrush(Brushes.White, hiStart, hiEnd);

            viewer.Width  = text.Width;
            viewer.Height = text.Height;

            viewer.Text    = text;
            viewer.HiStart = hiStart;
            viewer.HiEnd   = hiEnd;

            if (text != null && hiEnd > hiStart)
            {
                BringScrollerIntoView(hiStart, hiEnd);
            }

            viewer.InvalidateVisual();
        }
Exemple #2
0
        public static void StackWalkToView(Project project, ListView view, CPUImage cpu)
        {
            view.Items.Clear();
            int callDepth = 0;

            for (IntPtr sf = cpu.SF, pc = cpu.PC; sf != IntPtr.Zero; pc = project.GetReturnAddress(sf), sf = project.GetCallerSF(sf))
            {
                AppendStackFrame(project, view, callDepth++, pc);
            }
        }
        internal void Populate(Project project, CPUImage cpu)
        {
            if (typeface == null)
            {
                typeface = new Typeface(viewer.FontFamily, viewer.FontStyle, viewer.FontWeight, viewer.FontStretch);
            }

            SourceFileSegment segment;

            project.GetLineSegment(out segment, cpu.PC);

            AssemblySection section = GetSection(segment.Source, segment.Function.Name);

            if (section == null || segment.Function.Handle == IntPtr.Zero)
            {
                string s = "No assembly code at this location: " + cpu.PC;
                text = new FormattedText(s, culture, FlowDirection.LeftToRight, typeface, viewer.FontSize, Brushes.Black, 1.0);

                viewer.HiStart = 0;
                viewer.HiEnd   = 0;
                viewer.Text    = text;

                lastFunction = IntPtr.Zero;
            }
            else if (segment.Function.Handle != lastFunction)
            {
                int hiStart, hiEnd;
                var sb        = new StringBuilder(4096);
                int lineCount = 0;
                AppendDissassembly(sb, out hiStart, out hiEnd, section, segment, ref lineCount);

                text          = new FormattedText(sb.ToString(), culture, FlowDirection.LeftToRight, typeface, viewer.FontSize, Brushes.Black, 1.0);
                viewer.Width  = text.Width;
                viewer.Height = text.Height;

                viewer.Text    = text;
                viewer.HiStart = hiStart;
                viewer.HiEnd   = hiEnd;

                if (hiEnd > hiStart)
                {
                    BringScrollerIntoView(hiStart, hiEnd);
                }

                lastFunction = segment.Function.Handle;
            }
            else
            {
                int hiStart, hiEnd;
                var sb        = new StringBuilder(4096);
                int lineCount = 0;
                AppendDissassembly(sb, out hiStart, out hiEnd, section, segment, ref lineCount);

                text = new FormattedText(sb.ToString(), culture, FlowDirection.LeftToRight, typeface, viewer.FontSize, Brushes.Black, 1.0);
                if (text != null && hiEnd > hiStart)
                {
                    BringScrollerIntoView(hiStart, hiEnd);
                }

                viewer.Text    = text;
                viewer.HiStart = hiStart;
                viewer.HiEnd   = hiEnd;
            }

            viewer.InvalidateVisual();
        }
 public static void Populate(ListView callStackView, TreeView itemView, Project project, CPUImage cpu)
 {
     Populate(callStackView, itemView, project, 0);
 }