Beispiel #1
0
        private void Query()
        {
            lbMethodID.Text = string.Empty;
            lbOffset.Text   = string.Empty;

            dataGridView1.Enabled = false;
            dataGridView2.Enabled = false;

            if (!IsConnected || !IsPaused)
            {
                return;
            }

            if (Platform == null)
            {
                return;
            }

            if (Platform.Registers == null)
            {
                return;
            }

            var address = Platform.InstructionPointer.Value;

            var method = DebugSource.GetMethod(address);

            if (method == null)
            {
                return;
            }

            lbOffset.Text   = (address - method.Address).ToString();
            lbMethodID.Text = method.ID.ToString();

            var sourceLabels = DebugSource.GetSourceLabels(method.ID);

            dataGridView1.Enabled    = true;
            dataGridView1.DataSource = sourceLabels;
            dataGridView1.Columns["MethodID"].Visible = false;
            dataGridView1.AutoResizeColumns();

            var sourceInfos = DebugSource.GetSources(method.ID);

            if (sourceInfos == null)
            {
                dataGridView2.Enabled = false;
            }
            else
            {
                dataGridView2.Enabled    = true;
                dataGridView2.DataSource = sourceInfos;
                dataGridView2.Columns["MethodID"].Visible = false;
                dataGridView2.Columns["Offset"].Visible   = false;
                dataGridView2.AutoResizeColumns();
            }
        }
Beispiel #2
0
        public override void OnPause()
        {
            this.method = null;
            stackentries.Clear();

            if (Platform == null)
            {
                return;
            }

            if (Platform.Registers == null)
            {
                return;
            }

            if (StackFrame == 0 || StackPointer == 0)
            {
                return;
            }

            method = DebugSource.GetMethod(InstructionPointer);

            if (method == null)
            {
                return;
            }

            if (method.ParameterStackSize == 0)
            {
                return;
            }

            var symbol = DebugSource.GetFirstSymbolsStartingAt(InstructionPointer);

            ulong paramStart = StackFrame + (NativeIntegerSize * 2);

            if (symbol != null)
            {
                // new stack frame has not been setup
                paramStart = StackPointer + NativeIntegerSize;
            }
            else
            {
                symbol = DebugSource.GetFirstSymbolsStartingAt(InstructionPointer - Platform.FirstPrologueInstructionSize);

                if (symbol != null)
                {
                    // new stack frame has not been setup
                    paramStart = StackPointer + (NativeIntegerSize * 2);
                }
            }

            MemoryCache.ReadMemory(paramStart, method.ParameterStackSize, OnMemoryRead);
        }
        protected override void UpdateDisplay()
        {
            method = null;
            ClearDisplay();

            if (StackFrame == 0 || StackPointer == 0)
            {
                return;
            }

            method = DebugSource.GetMethod(InstructionPointer);

            if (method == null)
            {
                return;
            }

            if (method.ParameterStackSize == 0)
            {
                return;
            }

            var symbol = DebugSource.GetFirstSymbolsStartingAt(InstructionPointer);

            ulong paramStart = StackFrame + (NativeIntegerSize * 2);

            if (symbol != null)
            {
                // new stack frame has not been setup
                paramStart = StackPointer + NativeIntegerSize;
            }
            else
            {
                symbol = DebugSource.GetFirstSymbolsStartingAt(InstructionPointer - Platform.FirstPrologueInstructionSize);

                if (symbol != null)
                {
                    // new stack frame has not been setup
                    paramStart = StackPointer + (NativeIntegerSize * 2);
                }
            }

            MemoryCache.ReadMemory(paramStart, method.ParameterStackSize, OnMemoryRead);
        }
Beispiel #4
0
        public static SourceLocation Find(DebugSource debugSource, ulong address)
        {
            var method = debugSource.GetMethod(address);

            if (method == null)
            {
                return(null);
            }

            var sourceLabel = debugSource.GetSourceLabel(method.ID, (int)(address - method.Address));

            if (sourceLabel == null)
            {
                return(null);
            }

            var sourceInfo = debugSource.GetSourcePreviousClosest(method.ID, sourceLabel.Label);

            if (sourceInfo == null)
            {
                return(null);
            }

            var sourceFileInfo = debugSource.GetSourceFile(sourceInfo.SourceFileID);

            var sourceLocation = new SourceLocation()
            {
                Address        = method.Address + (ulong)sourceLabel.StartOffset,
                Length         = sourceLabel.Length,
                Label          = sourceLabel.Label,
                SourceLabel    = sourceInfo.Label,
                MethodFullName = method.FullName,
                StartLine      = sourceInfo.StartLine,
                StartColumn    = sourceInfo.StartColumn,
                EndLine        = sourceInfo.EndLine,
                EndColumn      = sourceInfo.EndColumn,
                SourceFilename = sourceFileInfo.Filename,
                MethodID       = method.ID,
                SourceFileID   = sourceInfo.SourceFileID,
            };

            return(sourceLocation);
        }
Beispiel #5
0
        protected override void UpdateDisplay()
        {
            ClearDisplay();

            var method = DebugSource.GetMethod(InstructionPointer);

            if (method == null)
            {
                return;
            }

            lbOffset.Text   = (InstructionPointer - method.Address).ToString();
            lbMethodID.Text = method.ID.ToString();

            var sourceLabels = DebugSource.GetSourceLabels(method.ID);

            dataGridView1.Enabled    = true;
            dataGridView1.DataSource = sourceLabels;
            dataGridView1.Columns["MethodID"].Visible = false;
            dataGridView1.AutoResizeColumns();

            var sourceInfos = DebugSource.GetSources(method.ID);

            if (sourceInfos == null)
            {
                dataGridView2.Enabled = false;
            }
            else
            {
                dataGridView2.Enabled    = true;
                dataGridView2.DataSource = sourceInfos;
                dataGridView2.Columns["MethodID"].Visible = false;
                dataGridView2.Columns["Offset"].Visible   = false;
                dataGridView2.AutoResizeColumns();
            }
        }