/* * Sets up the TwoThreadInfo subtree with a node and up to two leaves */ private void setupTwoThreadInfoTree( TreeItem threadTree, TwoThreadInfo twoThreadInfo, String lowLevelLabel, IProject project) { final TreeItem twoThreadTree = new TreeItem(threadTree, SWT.NONE); twoThreadTree.setText(lowLevelLabel); // set data for double click retrieval twoThreadTree.setData(twoThreadInfo); setupThreadInfoLeaf(twoThreadTree, twoThreadInfo.getThreadInfo0(), project); setupThreadInfoLeaf(twoThreadTree, twoThreadInfo.getThreadInfo1(), project); }
/* * puts the twoThreadInfo object into its appropriate spot based on which thread is specified (O or 1) */ private void organize(TwoThreadInfo twoThreadInfo, int i) { ThreadInfo threadInfo; if (i == 0) { threadInfo = twoThreadInfo.getThreadInfo0(); } else { threadInfo = twoThreadInfo.getThreadInfo1(); } try { // we find out where in the data structure to put it, and initialize that element if needed, // then put it in there. final int block = threadInfo.getBlock(); final int thread = threadInfo.getThread(); final int warp = thread / threadsPerWarp; if (blocks.containsKey(block)) { final Map<Integer, Map<Integer, List<TwoThreadInfo>>> warps = blocks.get(block); if (warps.containsKey(warp)) { final Map<Integer, List<TwoThreadInfo>> threads = warps.get(warp); if (threads.containsKey(thread)) { final List<TwoThreadInfo> threadInfos = threads.get(thread); threadInfos.add(twoThreadInfo); } else { final List<TwoThreadInfo> threadInfos = new ArrayList<TwoThreadInfo>(); threadInfos.add(twoThreadInfo); threads.put(thread, threadInfos); } } else { final Map<Integer, List<TwoThreadInfo>> threads = new HashMap<Integer, List<TwoThreadInfo>>(); final List<TwoThreadInfo> threadInfos = new ArrayList<TwoThreadInfo>(); threadInfos.add(twoThreadInfo); threads.put(thread, threadInfos); warps.put(warp, threads); } } else { final Map<Integer, Map<Integer, List<TwoThreadInfo>>> warps = new HashMap<Integer, Map<Integer, List<TwoThreadInfo>>>(); final Map<Integer, List<TwoThreadInfo>> threads = new HashMap<Integer, List<TwoThreadInfo>>(); final List<TwoThreadInfo> threadInfos = new ArrayList<TwoThreadInfo>(); threadInfos.add(twoThreadInfo); threads.put(thread, threadInfos); warps.put(warp, threads); blocks.put(block, warps); } } catch (final NumberFormatException nfe) { /* * Just ignore this improperly formatted ThreadInfo object (not all of them are "properly" formatted after all--example: * deadlock doesn't specify two threads) */ } }