40 |
package gnu.classpath.jdwp.processor; |
package gnu.classpath.jdwp.processor; |
41 |
|
|
42 |
import gnu.classpath.jdwp.VMFrame; |
import gnu.classpath.jdwp.VMFrame; |
|
import gnu.classpath.jdwp.IVirtualMachine; |
|
|
import gnu.classpath.jdwp.Jdwp; |
|
43 |
import gnu.classpath.jdwp.JdwpConstants; |
import gnu.classpath.jdwp.JdwpConstants; |
44 |
import gnu.classpath.jdwp.exception.InvalidObjectException; |
import gnu.classpath.jdwp.exception.InvalidObjectException; |
45 |
import gnu.classpath.jdwp.exception.JdwpException; |
import gnu.classpath.jdwp.exception.JdwpException; |
46 |
import gnu.classpath.jdwp.exception.JdwpInternalErrorException; |
import gnu.classpath.jdwp.exception.JdwpInternalErrorException; |
47 |
import gnu.classpath.jdwp.exception.NotImplementedException; |
import gnu.classpath.jdwp.exception.NotImplementedException; |
|
import gnu.classpath.jdwp.id.IdManager; |
|
48 |
import gnu.classpath.jdwp.id.ObjectId; |
import gnu.classpath.jdwp.id.ObjectId; |
49 |
import gnu.classpath.jdwp.id.ThreadId; |
import gnu.classpath.jdwp.id.ThreadId; |
50 |
import gnu.classpath.jdwp.util.JdwpString; |
import gnu.classpath.jdwp.util.JdwpString; |
60 |
* |
* |
61 |
* @author Aaron Luchko <aluchko@redhat.com> |
* @author Aaron Luchko <aluchko@redhat.com> |
62 |
*/ |
*/ |
63 |
public class ThreadReferenceCommandSet implements CommandSet |
public class ThreadReferenceCommandSet |
64 |
|
extends CommandSet |
65 |
{ |
{ |
|
// Our hook into the jvm |
|
|
private final IVirtualMachine vm = Jdwp.getIVirtualMachine(); |
|
|
|
|
|
// Manages all the different ids that are assigned by jdwp |
|
|
private final IdManager idMan = Jdwp.getIdManager(); |
|
|
|
|
66 |
public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command) |
public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command) |
67 |
throws JdwpException |
throws JdwpException |
68 |
{ |
{ |
123 |
private void executeName(ByteBuffer bb, DataOutputStream os) |
private void executeName(ByteBuffer bb, DataOutputStream os) |
124 |
throws JdwpException, IOException |
throws JdwpException, IOException |
125 |
{ |
{ |
126 |
ThreadId tid = (ThreadId) idMan.readId(bb); |
ThreadId tid = (ThreadId) idMan.readObjectId(bb); |
127 |
Thread thread = (Thread) tid.getObject(); |
Thread thread = (Thread) tid.getObject(); |
128 |
JdwpString.writeString(os, thread.getName()); |
JdwpString.writeString(os, thread.getName()); |
129 |
} |
} |
131 |
private void executeSuspend(ByteBuffer bb, DataOutputStream os) |
private void executeSuspend(ByteBuffer bb, DataOutputStream os) |
132 |
throws JdwpException, IOException |
throws JdwpException, IOException |
133 |
{ |
{ |
134 |
ThreadId tid = (ThreadId) idMan.readId(bb); |
ThreadId tid = (ThreadId) idMan.readObjectId(bb); |
135 |
Thread thread = (Thread) tid.getObject(); |
Thread thread = (Thread) tid.getObject(); |
136 |
vm.suspendThread(thread); |
vm.suspendThread(thread); |
137 |
} |
} |
139 |
private void executeResume(ByteBuffer bb, DataOutputStream os) |
private void executeResume(ByteBuffer bb, DataOutputStream os) |
140 |
throws JdwpException, IOException |
throws JdwpException, IOException |
141 |
{ |
{ |
142 |
ThreadId tid = (ThreadId) idMan.readId(bb); |
ThreadId tid = (ThreadId) idMan.readObjectId(bb); |
143 |
Thread thread = (Thread) tid.getObject(); |
Thread thread = (Thread) tid.getObject(); |
144 |
vm.suspendThread(thread); |
vm.suspendThread(thread); |
145 |
} |
} |
147 |
private void executeStatus(ByteBuffer bb, DataOutputStream os) |
private void executeStatus(ByteBuffer bb, DataOutputStream os) |
148 |
throws InvalidObjectException, IOException |
throws InvalidObjectException, IOException |
149 |
{ |
{ |
150 |
ThreadId tid = (ThreadId) idMan.readId(bb); |
ThreadId tid = (ThreadId) idMan.readObjectId(bb); |
151 |
Thread thread = (Thread) tid.getObject(); |
Thread thread = (Thread) tid.getObject(); |
152 |
int threadStatus = vm.getThreadStatus(thread); |
int threadStatus = vm.getThreadStatus(thread); |
153 |
// There's only one possible SuspendStatus... |
// There's only one possible SuspendStatus... |
154 |
int suspendStatus = JdwpConstants.SuspendStatus.SUSPEND_STATUS_SUSPENDED; |
int suspendStatus = JdwpConstants.SuspendStatus.SUSPENDED; |
155 |
|
|
156 |
os.writeInt(threadStatus); |
os.writeInt(threadStatus); |
157 |
os.writeInt(suspendStatus); |
os.writeInt(suspendStatus); |
160 |
private void executeThreadGroup(ByteBuffer bb, DataOutputStream os) |
private void executeThreadGroup(ByteBuffer bb, DataOutputStream os) |
161 |
throws InvalidObjectException, IOException |
throws InvalidObjectException, IOException |
162 |
{ |
{ |
163 |
ThreadId tid = (ThreadId) idMan.readId(bb); |
ThreadId tid = (ThreadId) idMan.readObjectId(bb); |
164 |
Thread thread = (Thread) tid.getObject(); |
Thread thread = (Thread) tid.getObject(); |
165 |
ThreadGroup group = thread.getThreadGroup(); |
ThreadGroup group = thread.getThreadGroup(); |
166 |
ObjectId groupId = idMan.getId(group); |
ObjectId groupId = idMan.getObjectId(group); |
167 |
groupId.write(os); |
groupId.write(os); |
168 |
} |
} |
169 |
|
|
170 |
private void executeFrames(ByteBuffer bb, DataOutputStream os) |
private void executeFrames(ByteBuffer bb, DataOutputStream os) |
171 |
throws JdwpException, IOException |
throws JdwpException, IOException |
172 |
{ |
{ |
173 |
ThreadId tid = (ThreadId) idMan.readId(bb); |
ThreadId tid = (ThreadId) idMan.readObjectId(bb); |
174 |
Thread thread = (Thread) tid.getObject(); |
Thread thread = (Thread) tid.getObject(); |
175 |
int startFrame = bb.getInt(); |
int startFrame = bb.getInt(); |
176 |
int length = bb.getInt(); |
int length = bb.getInt(); |
189 |
private void executeFrameCount(ByteBuffer bb, DataOutputStream os) |
private void executeFrameCount(ByteBuffer bb, DataOutputStream os) |
190 |
throws JdwpException, IOException |
throws JdwpException, IOException |
191 |
{ |
{ |
192 |
ThreadId tid = (ThreadId) idMan.readId(bb); |
ThreadId tid = (ThreadId) idMan.readObjectId(bb); |
193 |
Thread thread = (Thread) tid.getObject(); |
Thread thread = (Thread) tid.getObject(); |
194 |
|
|
195 |
int frameCount = vm.getFrameCount(thread); |
int frameCount = vm.getFrameCount(thread); |
218 |
private void executeStop(ByteBuffer bb, DataOutputStream os) |
private void executeStop(ByteBuffer bb, DataOutputStream os) |
219 |
throws JdwpException, IOException |
throws JdwpException, IOException |
220 |
{ |
{ |
221 |
ThreadId tid = (ThreadId) idMan.readId(bb); |
ThreadId tid = (ThreadId) idMan.readObjectId(bb); |
222 |
Thread thread = (Thread) tid.getObject(); |
Thread thread = (Thread) tid.getObject(); |
223 |
ObjectId exception = idMan.readId(bb); |
ObjectId exception = idMan.readObjectId(bb); |
224 |
vm.stopThread(thread, (Exception) exception.getObject()); |
vm.stopThread(thread, (Exception) exception.getObject()); |
225 |
} |
} |
226 |
|
|
227 |
private void executeInterrupt(ByteBuffer bb, DataOutputStream os) |
private void executeInterrupt(ByteBuffer bb, DataOutputStream os) |
228 |
throws JdwpException, IOException |
throws JdwpException, IOException |
229 |
{ |
{ |
230 |
ThreadId tid = (ThreadId) idMan.readId(bb); |
ThreadId tid = (ThreadId) idMan.readObjectId(bb); |
231 |
Thread thread = (Thread) tid.getObject(); |
Thread thread = (Thread) tid.getObject(); |
232 |
thread.interrupt(); |
thread.interrupt(); |
233 |
} |
} |
235 |
private void executeSuspendCount(ByteBuffer bb, DataOutputStream os) |
private void executeSuspendCount(ByteBuffer bb, DataOutputStream os) |
236 |
throws JdwpException, IOException |
throws JdwpException, IOException |
237 |
{ |
{ |
238 |
ThreadId tid = (ThreadId) idMan.readId(bb); |
ThreadId tid = (ThreadId) idMan.readObjectId(bb); |
239 |
Thread thread = (Thread) tid.getObject(); |
Thread thread = (Thread) tid.getObject(); |
240 |
int suspendCount = vm.getSuspendCount(thread); |
int suspendCount = vm.getSuspendCount(thread); |
241 |
os.writeInt(suspendCount); |
os.writeInt(suspendCount); |