コード例 #1
0
 protected virtual void OnGUI(int elementIndex)
 {
     using (Profiling.GetMarker(Profiling.MarkerId.MemoryProfiler).Auto())
     {
         try
         {
             using (new Service <IDebugContextService> .ScopeService(new DebugContextService()))
             {
                 var rect = m_VisualElements[elementIndex].contentRect;
                 if (float.IsNaN(rect.width) || float.IsNaN(rect.height))
                 {
                     rect = new Rect(0, 0, 1, 1);
                 }
                 m_VisualElementsOnGUICalls[elementIndex](rect);
             }
         }
         catch (ExitGUIException)
         {
             throw;
         }
         catch (Exception e)
         {
             throw new Exception(DebugUtility.GetExceptionHelpMessage(e));
         }
     }
 }
コード例 #2
0
        void ShowDiffOfOpenSnapshots()
        {
            if (m_UIState.diffMode != null)
            {
                SwitchSnapshotMode(UIState.ViewMode.ShowDiff);
            }
            else if (First != null && Second != null)
            {
                try
                {
                    using (new Service <IDebugContextService> .ScopeService(new DebugContextService()))
                    {
                        MemoryProfilerAnalytics.StartEvent <MemoryProfilerAnalytics.DiffedSnapshotEvent>();

                        m_UIState.DiffLastAndCurrentSnapshot(First.GuiData.UtcDateTime.CompareTo(Second.GuiData.UtcDateTime) < 0);

                        MemoryProfilerAnalytics.EndEvent(new MemoryProfilerAnalytics.DiffedSnapshotEvent());
                    }
                }
                catch (ExitGUIException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    throw new Exception(DebugUtility.GetExceptionHelpMessage(e));
                }
            }
            else
            {
                Debug.LogError("No second snapshot opened to diff to!");
            }
        }
コード例 #3
0
        public void ShowAllObjects(Treemap.IMetricValue itemCopyToSelect, bool focus)
        {
            // TODO: Fix history zooming UX
            focus = false;

            Treemap.IMetricValue itemToSelect = null;
            m_TreeMap.ClearMetric();
            if (m_CurrentCodeType == CodeType.Unknown || m_CurrentCodeType == CodeType.Managed)
            {
                foreach (var managedObject in m_UIState.snapshotMode.snapshot.CrawledData.ManagedObjects)
                {
                    if (managedObject.Size > 0)
                    {
                        var o = new Treemap.ManagedObjectMetric(m_UIState.snapshotMode.snapshot, managedObject);
                        if (o.IsSame(itemCopyToSelect))
                        {
                            itemToSelect = o;
                        }
                        m_TreeMap.AddMetric(o);
                    }
                }
            }
            if (m_CurrentCodeType == CodeType.Unknown || m_CurrentCodeType == CodeType.Native)
            {
                for (int i = 0; i != m_UIState.snapshotMode.snapshot.nativeObjects.Count; ++i)
                {
                    if (m_UIState.snapshotMode.snapshot.nativeObjects.size[i] > 0)
                    {
                        var o = new Treemap.NativeObjectMetric(m_UIState.snapshotMode.snapshot, i);
                        if (o.IsSame(itemCopyToSelect))
                        {
                            itemToSelect = o;
                        }
                        m_TreeMap.AddMetric(o);
                    }
                }
            }
            m_TreeMap.UpdateMetric();

            if (itemToSelect != null)
            {
                OpenMetricData(itemToSelect, focus);
            }
            else
            {
                try
                {
                    using (new Service <IDebugContextService> .ScopeService(new DebugContextService()))
                    {
                        var lr = new Database.LinkRequestTable();
                        lr.LinkToOpen           = new Database.TableLink();
                        lr.LinkToOpen.TableName = ObjectAllTable.TableName;
                        lr.SourceTable          = null;
                        lr.SourceColumn         = null;
                        lr.SourceRow            = -1;
                        OpenLinkRequest(lr, false, null, false);
                    }
                }
                catch (ExitGUIException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    throw new Exception(DebugUtility.GetExceptionHelpMessage(e));
                }
            }
        }
コード例 #4
0
        public void CloseCapture(SnapshotFileData snapshot)
        {
            if (snapshot == null)
            {
                return;
            }
            try
            {
                using (new Service <IDebugContextService> .ScopeService(new DebugContextService()))
                {
                    if (Second != null)
                    {
                        if (snapshot == Second)
                        {
                            m_UIState.ClearSecondMode();
                            Second.GuiData.CurrentState = SnapshotFileGUIData.State.Closed;
                        }
                        else if (snapshot == First)
                        {
                            m_UIState.ClearFirstMode();
                            if (First != null)
                            {
                                First.GuiData.CurrentState = SnapshotFileGUIData.State.Closed;
                            }
                            First = Second;
                            m_UIState.SwapLastAndCurrentSnapshot();
                        }
                        else
                        {
                            // The snapshot wasn't open, there is nothing left todo here.
                            return;
                        }
                        UIElementsHelper.SwitchVisibility(snapshot.GuiData.dynamicVisualElements.openButton, snapshot.GuiData.dynamicVisualElements.closeButton);
                        Second = null;
                        m_UIState.CurrentViewMode = UIState.ViewMode.ShowFirst;

                        if (First != null)
                        {
                            m_OpenSnapshotsPane.SetSnapshotUIData(true, First.GuiData, true);
                        }
                        else
                        {
                            m_OpenSnapshotsPane.SetSnapshotUIData(true, null, true);
                        }
                        m_OpenSnapshotsPane.SetSnapshotUIData(false, null, false);
                        // With two snapshots open, there could also be a diff to be closed/cleared.
                        m_UIState.ClearDiffMode();
                    }
                    else
                    {
                        if (snapshot == First)
                        {
                            First.GuiData.CurrentState = SnapshotFileGUIData.State.Closed;
                            First = null;
                            m_UIState.ClearAllOpenModes();
                        }
                        else if (snapshot == Second)
                        {
                            Second.GuiData.CurrentState = SnapshotFileGUIData.State.Closed;
                            Second = null;
                            m_UIState.ClearAllOpenModes();
                        }
                        else
                        {
                            // The snapshot wasn't open, there is nothing left todo here.
                            return;
                        }
                        m_OpenSnapshotsPane.SetSnapshotUIData(true, null, false);
                        m_OpenSnapshotsPane.SetSnapshotUIData(false, null, false);
                    }
                    UIElementsHelper.SwitchVisibility(snapshot.GuiData.dynamicVisualElements.openButton, snapshot.GuiData.dynamicVisualElements.closeButton);
                }
            }
            catch (ExitGUIException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new Exception(DebugUtility.GetExceptionHelpMessage(e));
            }
        }