1 package jde.debugger.command;
5 import com.sun.jdi.ObjectReference;
6 import com.sun.jdi.ThreadReference;
7 import com.sun.jdi.request.EventRequestManager;
8 import com.sun.jdi.request.ThreadDeathRequest;
9 import com.sun.jdi.request.ThreadStartRequest;
10 import jde.debugger.Etc;
11 import jde.debugger.JDEException;
12 import jde.debugger.ObjectStore;
16 * 'trace_threads' command.
21 * trace_threads <u>type</u> [threadID]
22 * [{@link Etc#getSuspendPolicyFromArgs(List) suspend-policy}]
27 * <li> <u>type</u> can be either "start" or "death"
28 * <li> If no threadID is specified, all the corresponding thread
33 * @see jde.debugger.EventHandler#threadStartEvent(ThreadStartEvent)
34 * @see jde.debugger.EventHandler#threadDeathEvent(ThreadDeathEvent)
36 * @author Paul Kinnucan
37 * @version $Revision: 1.2 $
39 * Copyright (c) 2000, 2001, 2003 Paul Kinnucan
42 public class TraceThreads extends DebugProcessCommand {
46 * @exception jde.debugger.JDEException <description>
48 public void doCommand() throws JDEException {
49 if (m_args.size() < 2)
50 throw new JDEException("Insufficient arguments");
52 String type = m_args.remove(0).toString().toLowerCase();
54 if (!(type.equals("start") || type.equals("death")))
55 throw new JDEException("Invalid type");
57 List classFilters = Etc.getClassFiltersFromArgs(m_args);
58 List classExFilters = Etc.getClassExFiltersFromArgs(m_args);
60 EventRequestManager em = m_debugger.getVM().eventRequestManager();
62 Long requestID = null;
63 ObjectStore store = m_debugger.getStore();
65 if (type.equals("start")) {
66 ThreadStartRequest ter = em.createThreadStartRequest();
68 ter.setSuspendPolicy(Etc.getSuspendPolicyFromArgs(m_args));
70 if (m_args.size() > 0) {
71 Long threadID = Etc.safeGetLong(m_args.remove(0), "thread ID");
72 ObjectReference tRef = store.get(threadID);
74 throw new JDEException("No such thread exists");
75 } else if (!(tRef instanceof ThreadReference)) {
76 throw new JDEException("No such thread exists (anymore?)");
78 ter.addThreadFilter((ThreadReference)tRef);
81 requestID = m_debugger.addIdentifiableRequest(ter);
83 } else if (type.equals("death")) {
85 ThreadDeathRequest ter = em.createThreadDeathRequest();
87 ter.setSuspendPolicy(Etc.getSuspendPolicyFromArgs(m_args));
89 if (m_args.size() > 0) {
90 Long threadID = Etc.safeGetLong(m_args.remove(0), "thread ID");
91 ObjectReference tRef = store.get(threadID);
93 throw new JDEException("No such thread exists");
94 } else if (!(tRef instanceof ThreadReference)) {
95 throw new JDEException("No such thread exists (anymore?)");
97 ter.addThreadFilter((ThreadReference)tRef);
100 requestID = m_debugger.addIdentifiableRequest(ter);
104 m_debugger.signalCommandResult(m_cmdID, requestID.toString(), CMD_OK);
109 public Object clone() {return new TraceThreads();}
114 * $Log: TraceThreads.java,v $
115 * Revision 1.2 2003/01/15 05:56:26 paulk
116 * Add Petter Mahlen's changes.
118 * Revision 1.1 2001/03/24 13:35:26 paulk
124 // End of TraceThreads.java