Exemple #1
0
        /// <summary>
        /// Update process info and thread stack traces
        /// </summary>
        /// <param name="withStack">Updates stack traces or just general info</param>
        /// <param name="allThreads">If updating stack trace should we update all of them</param>
        /// <param name="threadIds">If not updating all which ones do we update</param>
        /// <param name="depth">How many frames deep to display, 0 means show all</param>
        private void UpdateProcessInfo(bool withStack, bool allThreads, IList <int> threadIds, int depth)
        {
            processThreads.Clear();
            processCorThreads.Clear();
            generalThreadInfos.Clear();

            try
            {
                AttachAndStop();

                //build the general thread information hash
                foreach (ProcessThread gThread in generalProcessInfo.Threads)
                {
                    generalThreadInfos[gThread.Id] = gThread;
                }

                if (isAttached)
                {
                    //add the threads to an arraylist
                    foreach (CorThread cThread in debuggeeProcess.Threads)
                    {
                        try
                        {
                            ThreadInfo thread = new ThreadInfo(cThread, this);
                            if (withStack)         //update stacks also
                            {
                                if (allThreads || threadIds.Contains(cThread.Id))
                                {
                                    thread.UpdateStackTrace(depth);
                                }
                            }
                            processCorThreads.Add(cThread);
                            processThreads[cThread.Id] = thread;
                        }
                        catch (KeyNotFoundException)
                        {
                            // This can happen if the thread died before we could get to it
                        }
                    }
                }
            }
            catch (COMException)
            {
            }
            catch (Exception e)
            {
                // We need to explicitly catch the exception here (finally handler may not be invoked, when the exception terminates the whole process)
                Console.WriteLine("Caught exception: " + e);
                DetachAndResume();
                throw;
            }
            finally
            {
                DetachAndResume();
            }
        }
Exemple #2
0
        /// <summary>
        /// Update process info and thread stack traces
        /// </summary>
        /// <param name="withStack">Updates stack traces or just general info</param>
        /// <param name="allThreads">If updating stack trace should we update all of them</param>
        /// <param name="threadIds">If not updating all which ones do we update</param>
        /// <param name="depth">How many frames deep to display, 0 means show all</param>
        private void UpdateProcessInfo(bool withStack, bool allThreads, IList <int> threadIds, int depth)
        {
            processThreads.Clear();
            processCorThreads.Clear();
            generalThreadInfos.Clear();

            try
            {
                AttachAndStop();

                //build the general thread information hash
                foreach (ProcessThread gThread in generalProcessInfo.Threads)
                {
                    generalThreadInfos[gThread.Id] = gThread;
                }

                if (isAttached)
                {
                    //add the threads to an arraylist
                    foreach (CorThread cThread in debuggeeProcess.Threads)
                    {
                        try
                        {
                            ThreadInfo thread = new ThreadInfo(cThread, this);
                            if (withStack)                            //update stacks also
                            {
                                if (allThreads || threadIds.Contains(cThread.Id))
                                {
                                    thread.UpdateStackTrace(depth);
                                }
                            }
                            processCorThreads.Add(cThread);
                            processThreads[cThread.Id] = thread;
                        }
                        catch (KeyNotFoundException ex)
                        {
                            // This can happen if the thread died before we could get to it
                            Debug.WriteLine(ex.ToString());
                        }
                    }
                }
            }
            catch (COMException ex)
            {
                Debug.WriteLine(ex.ToString());
            }
            finally
            {
                DetachAndResume();
            }
        }
Exemple #3
0
        /// <summary>
        /// Update process info and thread stack traces
        /// </summary>
        /// <param name="withStack">Updates stack traces or just general info</param>
        /// <param name="allThreads">If updating stack trace should we update all of them</param>
        /// <param name="threadIds">If not updating all which ones do we update</param>
        /// <param name="depth">How many frames deep to display, 0 means show all</param>
        private void UpdateProcessInfo(bool withStack, bool allThreads, IList<int> threadIds, int depth)
        {
            processThreads.Clear();
            processCorThreads.Clear();
            generalThreadInfos.Clear();

            try
            {
                AttachAndStop();

                //build the general thread information hash
                foreach (ProcessThread gThread in generalProcessInfo.Threads)
                {
                    generalThreadInfos[gThread.Id] = gThread;
                }

                if (isAttached)
                {
                    //add the threads to an arraylist
                    foreach (CorThread cThread in debuggeeProcess.Threads)
                    {
                        try
                        {
                            ThreadInfo thread = new ThreadInfo(cThread, this);
                            if (withStack)//update stacks also
                            {
                                if (allThreads || threadIds.Contains(cThread.Id))
                                {
                                    thread.UpdateStackTrace(depth);
                                }
                            }
                            processCorThreads.Add(cThread);
                            processThreads[cThread.Id] = thread;
                        }
                        catch (KeyNotFoundException ex)
                        {
                            // This can happen if the thread died before we could get to it
                            Debug.WriteLine(ex.ToString());
                        }
                    }
                }
            }
            catch (COMException ex)
            {
                Debug.WriteLine(ex.ToString());
            }
            finally
            {
                DetachAndResume();
            }
        }