39 |
|
|
40 |
package gnu.classpath.jdwp.processor; |
package gnu.classpath.jdwp.processor; |
41 |
|
|
|
import gnu.classpath.jdwp.Jdwp; |
|
42 |
import gnu.classpath.jdwp.JdwpConstants; |
import gnu.classpath.jdwp.JdwpConstants; |
43 |
import gnu.classpath.jdwp.exception.JdwpException; |
import gnu.classpath.jdwp.exception.JdwpException; |
44 |
import gnu.classpath.jdwp.exception.JdwpInternalErrorException; |
import gnu.classpath.jdwp.exception.JdwpInternalErrorException; |
45 |
import gnu.classpath.jdwp.exception.NotImplementedException; |
import gnu.classpath.jdwp.exception.NotImplementedException; |
|
import gnu.classpath.jdwp.id.IdManager; |
|
46 |
import gnu.classpath.jdwp.id.ObjectId; |
import gnu.classpath.jdwp.id.ObjectId; |
47 |
import gnu.classpath.jdwp.util.JdwpString; |
import gnu.classpath.jdwp.util.JdwpString; |
48 |
|
|
55 |
* |
* |
56 |
* @author Aaron Luchko <aluchko@redhat.com> |
* @author Aaron Luchko <aluchko@redhat.com> |
57 |
*/ |
*/ |
58 |
public class ThreadGroupReferenceCommandSet implements CommandSet |
public class ThreadGroupReferenceCommandSet |
59 |
|
extends CommandSet |
60 |
{ |
{ |
|
// Manages all the different ids that are assigned by jdwp |
|
|
private final IdManager idMan = Jdwp.getIdManager(); |
|
|
|
|
61 |
public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command) |
public boolean runCommand(ByteBuffer bb, DataOutputStream os, byte command) |
62 |
throws JdwpException |
throws JdwpException |
63 |
{ |
{ |
91 |
private void executeName(ByteBuffer bb, DataOutputStream os) |
private void executeName(ByteBuffer bb, DataOutputStream os) |
92 |
throws JdwpException, IOException |
throws JdwpException, IOException |
93 |
{ |
{ |
94 |
ObjectId oid = idMan.readId(bb); |
ObjectId oid = idMan.readObjectId(bb); |
95 |
ThreadGroup group = (ThreadGroup) oid.getObject(); |
ThreadGroup group = (ThreadGroup) oid.getObject(); |
96 |
JdwpString.writeString(os, group.getName()); |
JdwpString.writeString(os, group.getName()); |
97 |
} |
} |
99 |
private void executeParent(ByteBuffer bb, DataOutputStream os) |
private void executeParent(ByteBuffer bb, DataOutputStream os) |
100 |
throws JdwpException, IOException |
throws JdwpException, IOException |
101 |
{ |
{ |
102 |
ObjectId oid = idMan.readId(bb); |
ObjectId oid = idMan.readObjectId(bb); |
103 |
ThreadGroup group = (ThreadGroup) oid.getObject(); |
ThreadGroup group = (ThreadGroup) oid.getObject(); |
104 |
ThreadGroup parent = group.getParent(); |
ThreadGroup parent = group.getParent(); |
105 |
ObjectId parentId = idMan.getId(parent); |
ObjectId parentId = idMan.getObjectId(parent); |
106 |
parentId.write(os); |
parentId.write(os); |
107 |
} |
} |
108 |
|
|
109 |
private void executeChildren(ByteBuffer bb, DataOutputStream os) |
private void executeChildren(ByteBuffer bb, DataOutputStream os) |
110 |
throws JdwpException, IOException |
throws JdwpException, IOException |
111 |
{ |
{ |
112 |
ObjectId oid = idMan.readId(bb); |
ObjectId oid = idMan.readObjectId(bb); |
113 |
ThreadGroup group = (ThreadGroup) oid.getObject(); |
ThreadGroup group = (ThreadGroup) oid.getObject(); |
114 |
|
|
115 |
ThreadGroup jdwpGroup = Thread.currentThread().getThreadGroup(); |
ThreadGroup jdwpGroup = Thread.currentThread().getThreadGroup(); |
139 |
if (thread == null) |
if (thread == null) |
140 |
break; // No threads after this point |
break; // No threads after this point |
141 |
if (!thread.getThreadGroup().equals(jdwpGroup)) |
if (!thread.getThreadGroup().equals(jdwpGroup)) |
142 |
idMan.getId(thread).write(os); |
idMan.getObjectId(thread).write(os); |
143 |
} |
} |
144 |
|
|
145 |
int numGroups = group.activeCount(); |
int numGroups = group.activeCount(); |
168 |
if (tgroup == null) |
if (tgroup == null) |
169 |
break; // No ThreadGroups after this point |
break; // No ThreadGroups after this point |
170 |
if (!tgroup.equals(jdwpGroup)) |
if (!tgroup.equals(jdwpGroup)) |
171 |
idMan.getId(tgroup).write(os); |
idMan.getObjectId(tgroup).write(os); |
172 |
} |
} |
173 |
} |
} |
174 |
} |
} |