IDEA-79921 Suspend one thread while debugging
authorEgor.Ushakov <egor.ushakov@jetbrains.com>
Mon, 29 Jun 2015 10:49:12 +0000 (13:49 +0300)
committerEgor.Ushakov <egor.ushakov@jetbrains.com>
Mon, 29 Jun 2015 10:50:19 +0000 (13:50 +0300)
java/debugger/impl/src/com/intellij/debugger/actions/FreezeThreadAction.java
java/debugger/impl/src/com/intellij/debugger/actions/ResumeThreadAction.java
java/debugger/impl/src/com/intellij/debugger/engine/DebugProcessImpl.java
java/debugger/impl/src/com/intellij/debugger/engine/SuspendManagerImpl.java
java/debugger/impl/src/com/intellij/debugger/ui/impl/watch/DebuggerTree.java
platform/platform-resources-en/src/messages/ActionsBundle.properties
resources/src/idea/JavaActions.xml

index eb6dea34891c0bf257466d4d2730ba188b9adf58..808c7c7d4bba2e02b2965d743aac6b6a8420ef53 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
 package com.intellij.debugger.actions;
 
 import com.intellij.debugger.engine.DebugProcessImpl;
-import com.intellij.debugger.engine.events.SuspendContextCommandImpl;
+import com.intellij.debugger.engine.events.DebuggerCommandImpl;
 import com.intellij.debugger.impl.DebuggerContextImpl;
 import com.intellij.debugger.jdi.ThreadReferenceProxyImpl;
 import com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl;
@@ -41,8 +41,9 @@ public class FreezeThreadAction extends DebuggerAction {
       final ThreadReferenceProxyImpl thread = threadDescriptor.getThreadReference();
 
       if (!threadDescriptor.isFrozen()) {
-        debugProcess.getManagerThread().schedule(new SuspendContextCommandImpl(debuggerContext.getSuspendContext()) {
-          public void contextAction() throws Exception {
+        debugProcess.getManagerThread().schedule(new DebuggerCommandImpl(){
+          @Override
+          protected void action() throws Exception {
             debugProcess.createFreezeThreadCommand(thread).run();
             debuggerTreeNode.calcValue();
           }
index fe3ef56441caed61a84564d73dd95a885ba40d55..a2e3129e634a18a01184b07df888de027aac30f5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -78,11 +78,11 @@ public class ResumeThreadAction extends DebuggerAction{
             enabled = false;
             break;
           }
-          else {
-            if (threadDescriptor.isFrozen()) {
-              text = DebuggerBundle.message("action.resume.thread.text.unfreeze");
-            }
-          }
+          //else {
+          //  if (threadDescriptor.isFrozen()) {
+          //    text = DebuggerBundle.message("action.resume.thread.text.unfreeze");
+          //  }
+          //}
         }
       }
     }
index 85514282eeebdf6c91282bfe1d07c8621d675d8c..43149c603d8f5e9b6b12a3a6cefea30adbfcd251 100644 (file)
@@ -1685,7 +1685,8 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
 
     @Override
     public void contextAction() {
-      if (getSuspendManager().isFrozen(myThread)) {
+      // handle unfreeze through the regular context resume
+      if (false && getSuspendManager().isFrozen(myThread)) {
         getSuspendManager().unfreezeThread(myThread);
         return;
       }
@@ -1714,6 +1715,9 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
       SuspendManager suspendManager = getSuspendManager();
       if (!suspendManager.isFrozen(myThread)) {
         suspendManager.freezeThread(myThread);
+        SuspendContextImpl suspendContext = mySuspendManager.pushSuspendContext(EventRequest.SUSPEND_EVENT_THREAD, 0);
+        suspendContext.setThread(myThread.getThreadReference());
+        mySuspendManager.notifyPaused(suspendContext);
       }
     }
   }
index c1f1f87db1a9cc58310816e97dbf1622ce7b517d..0717168a41c8504b9f448e8d05afb87cdc882bf3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -92,6 +92,7 @@ public class SuspendManagerImpl implements SuspendManager {
             }
             break;
           case EventRequest.SUSPEND_EVENT_THREAD:
+            myFrozenThreads.remove(getThread());
             getThread().resume();
             if(LOG.isDebugEnabled()) {
               LOG.debug("Thread resumed : " + getThread().toString());
index b652cd1e272ae75234ee5a03624b827878ba89ed..e58dd58ee2aa6762d67d429b7622b5f3954b8371 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,9 +22,7 @@ package com.intellij.debugger.ui.impl.watch;
 
 import com.intellij.debugger.DebuggerBundle;
 import com.intellij.debugger.DebuggerInvocationUtil;
-import com.intellij.debugger.engine.DebugProcessImpl;
-import com.intellij.debugger.engine.DebuggerUtils;
-import com.intellij.debugger.engine.SuspendContextImpl;
+import com.intellij.debugger.engine.*;
 import com.intellij.debugger.engine.evaluation.EvaluateException;
 import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
 import com.intellij.debugger.engine.events.DebuggerCommandImpl;
index c02b4f8b5c5f160f1ecf43666e658c4cc6c2c2ec..2e497a3f75ef15a325ad304d949c962c81b763af 100644 (file)
@@ -1015,7 +1015,7 @@ action.Debugger.ViewAsGroup.text=View as
 action.Debugger.SetValue.text=Set Value...
 action.Debugger.ShowFrame.text=Show Frame
 action.Debugger.ResumeThread.text=Resume
-action.Debugger.FreezeThread.text=Freeze
+action.Debugger.FreezeThread.text=Suspend
 action.Debugger.InterruptThread.text=Interrupt
 action.Debugger.MuteBreakpoints.text=Mute Breakpoints
 action.Debugger.MuteBreakpoints.description=Mute/unmute all breakpoints in a debug session.
index 208f77a1d8b5e2a6baa99ebe52e37148825b94a3..36b7960d73cec32feb801e2e1848afa67b30ea99 100644 (file)
     </group>
 
     <group id="Debugger.ThreadsPanelPopup">
-      <!--<reference ref="Debugger.ResumeThread"/>-->
-      <!--<reference ref="Debugger.FreezeThread"/>-->
+      <reference ref="Debugger.ResumeThread"/>
+      <reference ref="Debugger.FreezeThread"/>
       <reference ref="Debugger.InterruptThread"/>
       <!--<reference ref="Debugger.ShowFrame"/>-->
       <reference ref="Debugger.PopFrame"/>