public ThreadsCache getThreadsCache() { synchronized (threadsCollectorLock) { if (threadsCache == null) { threadsCache = new ThreadsCache(this); threadsCache.addPropertyChangeListener(new PropertyChangeListener() { // Re-fire the changes @Override public void propertyChange(PropertyChangeEvent evt) { String propertyName = evt.getPropertyName(); if (ThreadsCache.PROP_THREAD_STARTED.equals(propertyName)) { firePropertyChange(PROP_THREAD_STARTED, null, getThread((ThreadReference) evt.getNewValue())); } if (ThreadsCache.PROP_THREAD_DIED.equals(propertyName)) { firePropertyChange(PROP_THREAD_DIED, getThread((ThreadReference) evt.getOldValue()), null); } if (ThreadsCache.PROP_GROUP_ADDED.equals(propertyName)) { firePropertyChange(PROP_THREAD_GROUP_ADDED, null, getThreadGroup((ThreadGroupReference) evt.getNewValue())); } } }); } return threadsCache; } }
/** * Creates a new translated node for given original one. * * @param o a node to be translated * @return a new translated node */ private Object createTranslation (Object o) { switch (translationID) { case THREAD_ID: if (o instanceof ThreadReference) { return new JPDAThreadImpl ((ThreadReference) o, debugger); } else if (o instanceof ThreadGroupReference) { return new JPDAThreadGroupImpl ((ThreadGroupReference) o, debugger); } else { return null; } case LOCALS_ID: if (o instanceof ArrayType) { return new JPDAArrayTypeImpl(debugger, (ArrayType) o); } if (o instanceof ReferenceType) { return new JPDAClassTypeImpl(debugger, (ReferenceType) o); } default: throw new IllegalStateException(""+o); } }
private void initGroups(ThreadGroupReference group) { try { List<ThreadGroupReference> groups = new ArrayList(ThreadGroupReferenceWrapper.threadGroups0(group)); List<ThreadReference> threads = new ArrayList(ThreadGroupReferenceWrapper.threads0(group)); filterThreads(threads); groupMap.put(group, groups); threadMap.put(group, threads); for (ThreadGroupReference g : groups) { initGroups(g); } } catch (ObjectCollectedException e) { } }
List<ThreadGroupReference> topLevelThreadGroups() { List<ThreadGroupReference> groups = null; try { Cache local = getCache(); if (local != null) { groups = local.groups; } if (groups == null) { groups = Arrays.asList( (ThreadGroupReference[])JDWP.VirtualMachine.TopLevelThreadGroups. process(vm).groups); if (local != null) { local.groups = groups; if ((vm.traceFlags & VirtualMachine.TRACE_OBJREFS) != 0) { vm.printTrace( "Caching top level thread groups (count = " + groups.size() + ") while VM suspended"); } } } } catch (JDWPException exc) { throw exc.toJDIException(); } return groups; }
public static F3ObjectReference wrap(F3VirtualMachine f3vm, ObjectReference ref) { if (ref == null) { return null; } else if (ref instanceof ArrayReference) { return f3vm.arrayReference((ArrayReference)ref); } else if (ref instanceof StringReference) { return f3vm.stringReference((StringReference)ref); } else if (ref instanceof ThreadReference) { return f3vm.threadReference((ThreadReference)ref); } else if (ref instanceof ThreadGroupReference) { return f3vm.threadGroupReference((ThreadGroupReference)ref); } else if (ref instanceof ClassLoaderReference) { return f3vm.classLoaderReference((ClassLoaderReference)ref); } else if (ref instanceof ClassObjectReference) { return f3vm.classObjectReference((ClassObjectReference)ref); } else { return f3vm.objectReference(ref); } }
public JPDAThreadGroup[] getTopLevelThreadGroups() { ThreadsCache tc = getThreadsCache(); if (tc == null) { return new JPDAThreadGroup[0]; } List<ThreadGroupReference> groupList = tc.getTopLevelThreadGroups(); JPDAThreadGroup[] groups = new JPDAThreadGroup[groupList.size()]; for (int i = 0; i < groups.length; i++) { groups[i] = getThreadGroup((ThreadGroupReference) groupList.get(i)); } return groups; }
public JPDAThreadGroupImpl[] getThreadGroups () { ThreadsCache tc = debugger.getThreadsCache(); if (tc == null) { return new JPDAThreadGroupImpl[0]; } List<ThreadGroupReference> l = tc.getGroups(tgr); int i, k = l.size (); JPDAThreadGroupImpl[] ts = new JPDAThreadGroupImpl[k]; for (i = 0; i < k; i++) { ts [i] = (JPDAThreadGroupImpl) debugger.getThreadGroup(l.get (i)); } return ts; }
void notifyToBeResumed(ThreadsCache tc) { List<ThreadReference> threads = tc.getThreads(tgr); for (ThreadReference threadRef : threads) { JPDAThreadImpl thread = debugger.getThread(threadRef); thread.notifyToBeResumed(); } List<ThreadGroupReference> groups = tc.getGroups(tgr); for (ThreadGroupReference groupRef : groups) { JPDAThreadGroupImpl group = (JPDAThreadGroupImpl) debugger.getThreadGroup(groupRef); group.notifyToBeResumed(tc); } }
void notifySuspended(ThreadsCache tc) { List<ThreadReference> threads = tc.getThreads(tgr); for (ThreadReference threadRef : threads) { JPDAThreadImpl thread = debugger.getThread(threadRef); thread.notifySuspended(); } List<ThreadGroupReference> groups = tc.getGroups(tgr); for (ThreadGroupReference groupRef : groups) { JPDAThreadGroupImpl group = (JPDAThreadGroupImpl) debugger.getThreadGroup(groupRef); group.notifySuspended(tc); } }
/** * The invariant in this class is that the top iterator * on the stack has more elements. If the stack is * empty, there is no top. This method assures * this invariant. */ private void push(List<ThreadGroupReference> tgl) { stack.push(tgl.iterator()); while (!stack.isEmpty() && !top().hasNext()) { stack.pop(); } }
static ThreadGroupReference find(String name) { ThreadGroupIterator tgi = new ThreadGroupIterator(); while (tgi.hasNext()) { ThreadGroupReference tg = tgi.nextThreadGroup(); if (tg.name().equals(name)) { return tg; } } return null; }
static ThreadGroupReference group() { if (group == null) { // Current thread group defaults to the first top level // thread group. setThreadGroup(Env.vm().topLevelThreadGroups().get(0)); } return group; }
public ThreadGroupReference threadGroup() { /* * Thread group can't change, so it's cached once and for all. */ if (threadGroup == null) { try { threadGroup = JDWP.ThreadReference.ThreadGroup. process(vm, this).group; } catch (JDWPException exc) { throw exc.toJDIException(); } } return threadGroup; }
public String name() { if (name == null) { // Does not need synchronization, since worst-case // static info is fetched twice (Thread group name // cannot change) try { name = JDWP.ThreadGroupReference.Name. process(vm, this).groupName; } catch (JDWPException exc) { throw exc.toJDIException(); } } return name; }
public ThreadGroupReference parent() { if (!triedParent) { // Does not need synchronization, since worst-case // static info is fetched twice (Thread group parent cannot // change) try { parent = JDWP.ThreadGroupReference.Parent. process(vm, this).parentGroup; triedParent = true; } catch (JDWPException exc) { throw exc.toJDIException(); } } return parent; }
public void suspend() { for (ThreadReference thread : threads()) { thread.suspend(); } for (ThreadGroupReference threadGroup : threadGroups()) { threadGroup.suspend(); } }
public void resume() { for (ThreadReference thread : threads()) { thread.resume(); } for (ThreadGroupReference threadGroup : threadGroups()) { threadGroup.resume(); } }
public List<ThreadGroupReferenceProxyImpl> threadGroups() { List<ThreadGroupReference> list = getThreadGroupReference().threadGroups(); List<ThreadGroupReferenceProxyImpl> proxies = new ArrayList<ThreadGroupReferenceProxyImpl>(list.size()); for (Iterator<ThreadGroupReference> iterator = list.iterator(); iterator.hasNext();) { ThreadGroupReference threadGroupReference = iterator.next(); proxies.add(getVirtualMachineProxy().getThreadGroupReferenceProxy(threadGroupReference)); } return proxies; }
public static List<ThreadGroupReference> wrapThreadGroups(F3VirtualMachine f3vm, List<ThreadGroupReference> threadGroups) { if (threadGroups == null) { return null; } List<ThreadGroupReference> result = new ArrayList<ThreadGroupReference>(threadGroups.size()); for (ThreadGroupReference tref : threadGroups) { result.add(wrap(f3vm, tref)); } return result; }
static ThreadGroupReference find(VirtualMachine vm, String name) { ThreadGroupIterator tgi = new ThreadGroupIterator(vm.topLevelThreadGroups()); while (tgi.hasNext()) { ThreadGroupReference tg = tgi.nextThreadGroup(); if (tg.name().equals(name)) { return tg; } } return null; }