[hg] main-silver: #235860: Remember if VirtualMachine.suspend() ...

  • From:
  • To:
  • Subject: [hg] main-silver: #235860: Remember if VirtualMachine.suspend() ...
  • Date: Thu, 19 Sep 2013 05:30:36 -0700

changeset 03410a8ffdea in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/03410a8ffdea
description:
        #235860: Remember if VirtualMachine.suspend() was called and keep 
Continue action enabled until VirtualMachine.resume() is performed.

diffstat:

 debugger.jpda/manifest.mf                                                    
            |   2 +-
 debugger.jpda/src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java   
            |  17 ++++++++-
 
debugger.jpda/src/org/netbeans/modules/debugger/jpda/actions/ContinueActionProvider.java
 |   1 +
 3 files changed, 16 insertions(+), 4 deletions(-)

diffs (110 lines):

diff --git a/debugger.jpda/manifest.mf b/debugger.jpda/manifest.mf
--- a/debugger.jpda/manifest.mf
+++ b/debugger.jpda/manifest.mf
@@ -2,6 +2,6 @@
 OpenIDE-Module: org.netbeans.modules.debugger.jpda/2
 OpenIDE-Module-Localizing-Bundle: 
org/netbeans/modules/debugger/jpda/Bundle.properties
 OpenIDE-Module-Layer: 
org/netbeans/modules/debugger/jpda/resources/mf-layer.xml
-OpenIDE-Module-Specification-Version: 1.57
+OpenIDE-Module-Specification-Version: 1.58
 OpenIDE-Module-Provides: 
org.netbeans.api.debugger.jpda.JPDADebuggerEngineImpl
 OpenIDE-Module-Requires: org.netbeans.spi.debugger.jpda.EditorContext, 
org.netbeans.spi.debugger.jpda.SourcePathProvider
diff --git 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java
--- 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java
+++ 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java
@@ -211,6 +211,7 @@
     private InputOutput                 io;
     
     private PeriodicThreadsDump         ptd;
+    private boolean                     vmSuspended = false; // true after 
VM.suspend() was called.
 
     // init 
....................................................................
 
@@ -1469,6 +1470,10 @@
         }
     }
 
+    public boolean isVMSuspended() {
+        return vmSuspended;
+    }
+
     /**
      * Suspends the target virtual machine (if any).
      * Used by PauseActionProvider.
@@ -1486,6 +1491,7 @@
                 logger.fine("VM suspend");
                 try {
                     VirtualMachineWrapper.suspend (vm);
+                    vmSuspended = true;
                     // Check the suspended count
                     List<ThreadReference> threads = 
VirtualMachineWrapper.allThreads(vm);
                     for (ThreadReference t : threads) {
@@ -1622,6 +1628,8 @@
             // suspended threads.
             // But this looks like a reasonable trade-off considering the 
available functionality.
             
+            List<JPDAThreadImpl> threadsToResume = null;
+            try {
             // Deal only with threads that are living
             {
                 boolean modifiableAllThreads = false;
@@ -1642,13 +1650,13 @@
                 }
             }
 
-            List<JPDAThreadImpl> threadsToResume = new 
ArrayList<JPDAThreadImpl>();
+                threadsToResume = new ArrayList<JPDAThreadImpl>();
             for (JPDAThread t : allThreads) {
                 if (t.isSuspended()) {
                     threadsToResume.add((JPDAThreadImpl) t);
                 }
             }
-            try {
+
                 for (int i = 0; i < threadsToResume.size(); i++) {
                     JPDAThreadImpl t = threadsToResume.get(i);
                     boolean can = t.cleanBeforeResume();
@@ -1657,7 +1665,7 @@
                         i--;
                     }
                 }
-                if (allThreads.size() == threadsToResume.size()) {
+                if (vmSuspended || allThreads.size() == 
threadsToResume.size()) {
                     // Resuming all
                     for (JPDAThreadImpl t : threadsToResume) {
                         t.setAsResumed(false);
@@ -1670,6 +1678,7 @@
                     //logger.severe("Before VM.resume():");
                     //Operator.dumpThreadsStatus(vm, Level.SEVERE);
                     VirtualMachineWrapper.resume(vm);
+                    vmSuspended = false;
                     logger.finer("All threads resumed.");
                     //logger.severe("After VM.resume():");
                     //Operator.dumpThreadsStatus(vm, Level.SEVERE);
@@ -1687,6 +1696,7 @@
                 if (stateChangeEvent != null) {
                     firePropertyChange(stateChangeEvent);
                 }
+                if (threadsToResume != null) {
                 for (JPDAThreadImpl t : threadsToResume) {
                     try {
                         t.fireAfterResume();
@@ -1699,6 +1709,7 @@
             }
         }
     }
+    }
     
     private void reduceThreadSuspendCountOfAllBut(VirtualMachine vm, 
List<JPDAThreadImpl> threadsToIgnore) {
         List<ThreadReference> allThreads = 
VirtualMachineWrapper.allThreads0(vm);
diff --git 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/actions/ContinueActionProvider.java
 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/actions/ContinueActionProvider.java
--- 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/actions/ContinueActionProvider.java
+++ 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/actions/ContinueActionProvider.java
@@ -101,6 +101,7 @@
     protected void checkEnabled (int debuggerState) {
         setEnabled (
             ActionsManager.ACTION_CONTINUE,
+            getDebuggerImpl().isVMSuspended() ||
             threadsCollector.isSomeThreadSuspended()
         );
     }

[hg] main-silver: #235860: Remember if VirtualMachine.suspend() ...

mentlicher 09/19/2013

Project Features

About this Project

Debugger was started in November 2009, is owned by tpavek, and has 29 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close