예제 #1
0
        private void loadDataFromMDbgSourcePosition(MDbgSourcePosition mDbgSourcePosition)
        {
            hasSourceCodeDetails = (mDbgSourcePosition != null);

            if (mDbgSourcePosition != null)
            {
                FileName = mDbgSourcePosition.Path;
                Line = mDbgSourcePosition.Line;
                IsSpecial = mDbgSourcePosition.IsSpecial;
                StartColumn = mDbgSourcePosition.StartColumn;
                EndColumn = mDbgSourcePosition.EndColumn;
                StartLine = mDbgSourcePosition.StartLine;
                EndLine = mDbgSourcePosition.EndLine;
            }
        }
예제 #2
0
        // Track if current source-position is in this doc.
        // Null if no current source, or if it's  in another doc.

        protected override void OnBreakWorker()
        {
            ClearHighlight();

            m_pos = MainForm.CurrentSource;
            if (m_pos == null)
            {
                return;
            }
            if (m_pos.Path != Text)
            {
                m_pos = null;
            }

            // Hilight in current source
            if (m_pos != null)
            {
                HighlightStatementAtPos(m_pos);
            }
        }
예제 #3
0
 // Highlight the statement for the given Source Position
 protected void HighlightStatementAtPos(MDbgSourcePosition pos)
 {
     HighlightRangeWorker(
         pos.StartLine, pos.StartColumn, pos.EndLine, pos.EndColumn,
         MainForm.IsCurrentSourceActive);
 }
예제 #4
0
 protected override void OnRunWorker()
 {
     m_pos = null;
 }
예제 #5
0
파일: Function.cs 프로젝트: pusp/o2platform
        /// <summary>
        /// Gets the source position from a given Instruction Pointer
        /// </summary>
        /// <param name="ip">The Instruction Pointer.</param>
        /// <returns>The Source Position.</returns>
        public MDbgSourcePosition GetSourcePositionFromIP(int ip)
        {
            EnsureIsUpToDate();
            if (!m_haveSymbols)
                return null;

            if ((m_SPcount > 0) && (m_SPoffsets[0] <= ip))
            {
                int i;
                for (i = 0; i < m_SPcount; ++i)
                    if (m_SPoffsets[i] >= ip)
                        break;

                if (i == m_SPcount || m_SPoffsets[i] != ip)
                    --i;

                MDbgSourcePosition sp = null;

                if (m_SPstartLines[i] == SpecialSequencePoint)
                {
                    int j = i;
                    // let's try to find a sequence point that is not special somewhere earlier in the code
                    // stream.
                    while (j > 0)
                    {
                        --j;
                        if (m_SPstartLines[j] != SpecialSequencePoint)
                        {
                            sp = new MDbgSourcePosition(true, m_SPdocuments[j].URL, m_SPstartLines[j],
                                                        m_SPendLines[j], m_SPstartColumns[j], m_SPendColumns[j]);
                            break;
                        }
                    }

                    if (sp == null)
                    {
                        // we didn't find any non-special seqeunce point before current one, let's try to search
                        // after.
                        j = i;
                        while (++j < m_SPcount)
                        {
                            if (m_SPstartLines[j] != SpecialSequencePoint)
                            {
                                sp = new MDbgSourcePosition(true, m_SPdocuments[j].URL, m_SPstartLines[j],
                                                            m_SPendLines[j], m_SPstartColumns[j], m_SPendColumns[j]);
                                break;
                            }
                        }
                    }
                    if (sp == null)
                        OriginalMDbgMessages.WriteLine(
                            "triiger: Debug.Assert(sp!=null, \"Only SpecialSequence point detected\");");
                    //      Debug.Assert(sp!=null, "Only SpecialSequence point detected");
                }
                else
                    // non special sequence point.
                    sp = new MDbgSourcePosition(false, m_SPdocuments[i].URL, m_SPstartLines[i], m_SPendLines[i],
                                                m_SPstartColumns[i], m_SPendColumns[i]);


                if (CorFunction.Version != 1) // function has been edited
                    sp.m_fixedFile = Module.GetEditsSourceFile(CorFunction.Version - 1);

                return sp;
            }
            return null;
        }
예제 #6
0
 public O2MDbgCurrentLocation(MDbgSourcePosition mdbgsourcePosition) : this()
 {
     loadDataFromMDbgSourcePosition(mdbgsourcePosition);            
 }
        /// <summary>
        /// Gets the source position from a given Instruction Pointer
        /// </summary>
        /// <param name="ip">The Instruction Pointer.</param>
        /// <returns>The Source Position.</returns>
        public MDbgSourcePosition GetSourcePositionFromIP(int ip)
        {
            EnsureIsUpToDate();
            if (!m_haveSymbols)
            {
                return(null);
            }

            if ((m_SPcount > 0) && (m_SPoffsets[0] <= ip))
            {
                int i;
                for (i = 0; i < m_SPcount; ++i)
                {
                    if (m_SPoffsets[i] >= ip)
                    {
                        break;
                    }
                }

                if (i == m_SPcount || m_SPoffsets[i] != ip)
                {
                    --i;
                }

                MDbgSourcePosition sp = null;

                if (m_SPstartLines[i] == SpecialSequencePoint)
                {
                    int j = i;
                    // let's try to find a sequence point that is not special somewhere earlier in the code
                    // stream.
                    while (j > 0)
                    {
                        --j;
                        if (m_SPstartLines[j] != SpecialSequencePoint)
                        {
                            sp = new MDbgSourcePosition(true, m_SPdocuments[j].URL, m_SPstartLines[j],
                                                        m_SPendLines[j], m_SPstartColumns[j], m_SPendColumns[j]);
                            break;
                        }
                    }

                    if (sp == null)
                    {
                        // we didn't find any non-special seqeunce point before current one, let's try to search
                        // after.
                        j = i;
                        while (++j < m_SPcount)
                        {
                            if (m_SPstartLines[j] != SpecialSequencePoint)
                            {
                                sp = new MDbgSourcePosition(true, m_SPdocuments[j].URL, m_SPstartLines[j],
                                                            m_SPendLines[j], m_SPstartColumns[j], m_SPendColumns[j]);
                                break;
                            }
                        }
                    }
                    if (sp == null)
                    {
                        OriginalMDbgMessages.WriteLine(
                            "triiger: Debug.Assert(sp!=null, \"Only SpecialSequence point detected\");");
                    }
                    //      Debug.Assert(sp!=null, "Only SpecialSequence point detected");
                }
                else
                {
                    // non special sequence point.
                    sp = new MDbgSourcePosition(false, m_SPdocuments[i].URL, m_SPstartLines[i], m_SPendLines[i],
                                                m_SPstartColumns[i], m_SPendColumns[i]);
                }


                if (CorFunction.Version != 1) // function has been edited
                {
                    sp.m_fixedFile = Module.GetEditsSourceFile(CorFunction.Version - 1);
                }

                return(sp);
            }
            return(null);
        }
        /// <summary>
        /// Returns a string that represents current frame
        /// Currently supported formats:
        /// null or empty string: returns short frame format (just frame name)
        /// "v"                 : returns long frame format (including module &amp; arguments)
        /// </summary>
        /// <param name="format">Which format to use.</param>
        /// <returns>The formatted string that represtents the current frame.</returns>
        public override string ToString(string format)
        {
            string fn;

            switch (m_frame.FrameType)
            {
            case CorFrameType.ILFrame:
                MDbgSourcePosition sl = SourcePosition;
                string             sp;

                if (sl != null)
                {
                    string filePath = sl.Path;
                    if (!Thread.m_threadMgr.m_process.m_engine.Options.ShowFullPaths)
                    {
                        filePath = Path.GetFileName(sl.Path);
                    }
                    sp = " (" + filePath + ":" + sl.Line.ToString(CultureInfo.CurrentUICulture) + ")";
                }
                else
                {
                    sp = " (source line information unavailable)";
                }

                var sbFuncName = new StringBuilder();

                MDbgModule  module = Function.Module;
                MDbgProcess proc   = Thread.m_threadMgr.m_process;


                // Get class name w/ generic args.
                CorType tClass = FunctionType;
                if (tClass != null)
                {
                    InternalUtil.PrintCorType(sbFuncName, proc, tClass);
                }

                sbFuncName.Append('.');


                // Get method name w/ generic args.
                MethodInfo mi = Function.MethodInfo;
                sbFuncName.Append(mi.Name);
                InternalUtil.AddGenericArgs(sbFuncName, proc, FunctionTypeParameters);


                string stFuncName = sbFuncName.ToString();

                if (format == "v")
                {
                    CorModule m = module.CorModule;
                    // verbose frame output
                    // in verbose output we'll print module name + arguments to the functions
                    var  sb     = new StringBuilder();
                    bool bFirst = true;
                    foreach (MDbgValue v in Function.GetArguments(this))
                    {
                        if (sb.Length != 0)
                        {
                            sb.Append(", ");
                        }
                        // skip this references
                        if (!(bFirst && v.Name == "this"))
                        {
                            sb.Append(v.Name).Append("=").Append(v.GetStringValue(0));
                        }
                        bFirst = false;
                    }

                    if (m.IsDynamic || m.IsInMemory)
                    {
                        fn = m.Name;
                    }
                    else
                    {
                        fn = Path.GetFileName(m.Name);
                    }

                    MDbgAppDomain ad = Thread.m_threadMgr.m_process.AppDomains.Lookup(m.Assembly.AppDomain);
                    fn += "#" + ad.Number
                          + "!" + stFuncName + "(" + sb + ") " + sp;
                }
                else
                {
                    fn = stFuncName + sp;
                }
                break;

            case CorFrameType.NativeFrame:
                fn = "[IL Method without Metadata]";
                break;

            case CorFrameType.InternalFrame:
                switch (m_frame.InternalFrameType)
                {
                case CorDebugInternalFrameType.STUBFRAME_NONE:
                    fn = "None";
                    break;

                case CorDebugInternalFrameType.STUBFRAME_M2U:
                    fn = "M-->U";
                    break;

                case CorDebugInternalFrameType.STUBFRAME_U2M:
                    fn = "U-->M";
                    break;

                case CorDebugInternalFrameType.STUBFRAME_APPDOMAIN_TRANSITION:
                    fn = "AD Switch";
                    break;

                case CorDebugInternalFrameType.STUBFRAME_LIGHTWEIGHT_FUNCTION:
                    fn = "LightWeight";
                    break;

                case CorDebugInternalFrameType.STUBFRAME_FUNC_EVAL:
                    fn = "FuncEval";
                    break;

                case CorDebugInternalFrameType.STUBFRAME_INTERNALCALL:
                    fn = "InternalCall";
                    break;

                default:
                    fn = "UNKNOWN";
                    break;
                }
                fn = "[Internal Frame, '" + fn + "']";
                break;

            default:
                fn = "UNKNOWN Frame Type";
                break;
            }
            return(fn);
        }