Initial Commit
[packages] / xemacs-packages / jde / java / src / jde / debugger / command / Resume.java
1 /*
2  * Copyright (c) 2000, 2001, 2003    Paul Kinnucan
3  *
4  * $Revision: 1.2 $
5  */
6
7 package jde.debugger.command;
8 import java.util.Iterator;
9
10 import com.sun.jdi.ObjectReference;
11 import com.sun.jdi.ThreadGroupReference;
12 import com.sun.jdi.ThreadReference;
13 import jde.debugger.Etc;
14 import jde.debugger.JDEException;
15
16
17 /**
18  * 'resume' command.
19  * <p>
20  *
21  * <b>Syntax:</b>
22  * <pre>
23  * resume [threadID]*
24  * </pre>
25  *
26  * <b>Comments:</b>
27  * <ul>
28  * <li> threadIDs can be retrieved using the get_threads command
29  * <li> if the list is omitted, the entire VM is resumed
30  * <li> threadIDs can refer to either threads or thereadgroups.
31  * </ul>
32  *
33  * @author Paul Kinnucan
34  * @version $Revision: 1.2 $
35  * @copyright Copyright (c) 2000, 2001, 2003    Paul Kinnucan
36  *
37  */
38 public class Resume extends DebugProcessCommand {
39     
40   /**
41    *
42    * @exception jde.debugger.JDEException <description>
43    */
44   public void doCommand() throws JDEException {
45     // see if there are arguments (should be the thread id). if so, we
46     // resume the thread ids passed. else, resume the whole vm.
47     if (m_args.size() > 0) {
48       Iterator it = m_args.iterator();
49       while (it.hasNext()) {
50         Long uniqueID = Etc.safeGetLong(it.next(), "thread(group)");
51                 
52         ObjectReference oRef = (ObjectReference) m_debugger.getStore().get(uniqueID);
53         if (oRef == null) {
54           throw new JDEException("Invalid ThreadID, or the thread/threadgroup is dead");
55         } else if (oRef instanceof ThreadReference) {
56           ((ThreadReference)oRef).resume();
57         } else if (oRef instanceof ThreadGroupReference) {
58           ((ThreadGroupReference)oRef).resume();
59         } else {
60           throw new JDEException("The object is not a thread or a threadgroup");
61         }
62       }
63       m_debugger.signalCommandResult(m_cmdID, null, CMD_OK);
64     } else {
65       try {
66         m_debugger.getVM().resume();
67         m_debugger.signalCommandResult(m_cmdID, null, CMD_OK);
68       } catch (Exception ex) {
69         throw new JDEException("Unable to resume the application");
70       }
71     }
72   }
73     
74   public Object clone() {return new Resume();}
75     
76 } // Resume
77
78 /*
79  * $Log: Resume.java,v $
80  * Revision 1.2  2003/01/15 05:56:26  paulk
81  * Add Petter Mahlen's changes.
82  *
83  * Revision 1.1  2001/03/24 13:35:25  paulk
84  * Initial revision.
85  *
86  *
87  */
88
89 // End of Resume.java