コード例 #1
0
 /// <summary>
 /// Executes the command.
 /// </summary>
 /// <param name="arguments">Arguments to pass to the command.</param>
 public void Execute(string arguments)
 {
     try
     {
         m_mi.Invoke(null, new object[] { arguments });
     }
     catch (Exception ex)
     {
         OriginalMDbgMessages.WriteLine("Exception while executing " + arguments + "    :   " + ex.Message + "\n\n" +
                                        ex.StackTrace);
         if (ex.InnerException != null)
         {
             OriginalMDbgMessages.WriteLine("    ## Innerexeption: " + ex.InnerException.Message);
         }
     }
 }
コード例 #2
0
        // when process is first created wait till callbacks are enabled.

        internal void DispatchEvent(ManagedCallbackType callback, CorEventArgs e)
        {
            try
            {
                if (m_callbackAttachedEvent != null)
                {
                    m_callbackAttachedEvent.WaitOne(); // waits till callbacks are enabled
                }
                Debug.Assert((int)callback >= 0 && (int)callback < m_callbacksArray.Length);
                Delegate d = m_callbacksArray[(int)callback];
                if (d != null)
                {
                    d.DynamicInvoke(new Object[] { this, e });
                }
            }
            catch (Exception ex)
            {
                var e2 = new CorExceptionInCallbackEventArgs(e.Controller, ex);

                OriginalMDbgMessages.WriteLine("Exception in callback: " + ex);
                // DC Debug.Assert(false,"Exception in callback: "+ex.ToString());

                try
                {
                    // we need to dispatch the exceptin in callback error, but we cannot
                    // use DispatchEvent since throwing exception in ExceptionInCallback
                    // would lead to infinite recursion.
                    Debug.Assert(m_callbackAttachedEvent == null);
                    Delegate d = m_callbacksArray[(int)ManagedCallbackType.OnExceptionInCallback];
                    if (d != null)
                    {
                        d.DynamicInvoke(new Object[] { this, e2 });
                    }
                }
                catch (Exception ex2)
                {
                    OriginalMDbgMessages.WriteLine("Exception in Exception notification callback: " + ex2);
                    // DC Debug.Assert(false,"Exception in Exception notification callback: "+ex2.ToString());
                    // ignore it -- there is nothing we can do.
                }
                e.Continue = e2.Continue;
            }
        }
コード例 #3
0
 public void ParseCommand(string commandLineText, out IMDbgCommand command, out string commandArguments)
 {
     try
     {
         commandLineText = commandLineText.Trim();
         int n = commandLineText.Length;
         int i = 0;
         while (i < n && !Char.IsWhiteSpace(commandLineText, i))
         {
             i++;
         }
         string cmdName = commandLineText.Substring(0, i);
         commandArguments = commandLineText.Substring(i).Trim();
         command          = Lookup(cmdName);
     }
     catch (Exception ex)
     {
         OriginalMDbgMessages.WriteLine("In ParseCommand, Exception while executing " + commandLineText + "    :   " +
                                        ex.Message + "\n\n" + ex.StackTrace);
         command          = null;
         commandArguments = null;
     }
 }
コード例 #4
0
        /// <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);
        }