Package: TraceData

TraceData

nameinstructionbranchcomplexitylinemethod
TraceData(NextGenRTLogger)
M: 60 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 13 C: 0
0%
M: 1 C: 0
0%
getBUS(Long)
M: 96 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 12 C: 0
0%
M: 1 C: 0
0%
getBuses()
M: 33 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
getCPU(Long)
M: 64 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
getCPUs()
M: 26 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
getConnectedBuses(Long)
M: 52 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
getCpuFromThreadId(Long)
M: 30 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getEventManager()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getInitThreadObject()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getLastMarkerTime()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getMainThreadObject()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getObject(Long)
M: 56 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
getOperation(String)
M: 57 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 10 C: 0
0%
M: 1 C: 0
0%
getOrderedCpus()
M: 33 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
getStaticObject(String)
M: 22 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getThread(Long)
M: 32 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
reset()
M: 35 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 11 C: 0
0%
M: 1 C: 0
0%
setLastMarkerTime(Long)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * RT Trace Viewer Plugin
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.ide.plugins.rttraceviewer.data;
23:
24: import java.util.Collections;
25: import java.util.HashMap;
26: import java.util.Map;
27: import java.util.Vector;
28:
29: import javax.management.RuntimeErrorException;
30: import org.overture.interpreter.messages.rtlog.nextgen.*;
31:
32:
33: public class TraceData
34: {
35:         private NextGenRTLogger rtLogger;
36:         private HashMap<Long, TraceCPU> cpus;
37:         private HashMap<Long, TraceObject> objects;
38:         private HashMap<String, TraceObject> staticObjects; //Static Objects dont have ids, use name instead
39:         private HashMap<Long, TraceBus> buses;
40:         private HashMap<Long, TraceThread> threads;
41:         private HashMap<String, TraceOperation> operations; //Key = Class+Operation
42:         private TraceEventManager eventManager;
43:         
44:         private TraceObject mainThreadObject;
45:         private TraceObject initThreadObject;
46:
47:         private Long lastMarkerTime;
48:         
49: public TraceData(NextGenRTLogger logger)
50: {
51:         //Pass by reference is needed to avoid problems when switching between two RT models (different NextGenRTLogger instances)
52:         rtLogger = logger;
53:         
54:         eventManager = new TraceEventManager(logger);
55:                  
56:         cpus = new HashMap<Long, TraceCPU>();
57:         objects = new HashMap<Long, TraceObject>();
58:         staticObjects = new HashMap<String, TraceObject>();
59:         buses = new HashMap<Long, TraceBus>();
60:         threads = new HashMap<Long, TraceThread>();
61:         operations = new HashMap<String, TraceOperation>();
62:         
63:         mainThreadObject = new TraceObject(0L,"MAIN");
64:         initThreadObject = new TraceObject(0L, "INIT");
65:
66:         reset();
67: }
68:
69:         public void reset()
70: {
71:                 cpus.clear();
72: objects.clear();
73: buses.clear();
74: threads.clear();
75: operations.clear();
76: staticObjects.clear();
77:
78: mainThreadObject.setVisible(false);
79: initThreadObject.setVisible(false);
80: eventManager.reset();
81: lastMarkerTime = null;
82: }
83:
84: public TraceEventManager getEventManager() {
85:         return eventManager;
86: }
87:
88: public TraceCPU getCPU(Long pid) throws RuntimeErrorException
89: {
90:•         if(!rtLogger.getCpuMap().containsKey((int)(long)pid))
91:                 throw new RuntimeErrorException(null, "Run-Time Error:Precondition failure in getCPU");
92:
93:•         if(!cpus.containsKey(pid))
94:         {
95:                 NextGenCpu cpu = rtLogger.getCpuMap().get(pid.intValue());
96:                 
97:                 Long cpuId = new Long(cpu.id);
98:                 String cpuName = cpu.name;
99:•                 boolean isVirtual = !cpu.expl;
100:                 
101:                 cpus.put(cpuId, new TraceCPU(cpuId, cpuName, isVirtual));
102:         }
103:         
104: return cpus.get(pid);
105: }
106:
107: public Vector<TraceCPU> getCPUs()
108: {
109:         Vector<TraceCPU> cpus = new Vector<TraceCPU>();
110:•         for(Long cpuId : getOrderedCpus())
111:         {
112:                 TraceCPU cpu = getCPU(cpuId);
113:                 cpus.add(cpu);
114:         }
115:         
116:         return cpus;
117: }
118:
119: public Vector<Long> getOrderedCpus()
120: {
121: Map<Integer, NextGenCpu> cpus = rtLogger.getCpuMap();
122: Vector<Long> tdCpuIds = new Vector<Long>();
123:
124:• for(Integer key : cpus.keySet())
125: {
126:         tdCpuIds.add(new Long(key));
127: }
128:
129: Collections.sort(tdCpuIds);
130: return tdCpuIds;
131: }
132:
133: public TraceBus getBUS(Long pid) throws RuntimeErrorException
134: {
135:• if(!rtLogger.getBusMap().containsKey(pid.intValue()))
136:          throw new RuntimeErrorException(null, "Run-Time Error:Precondition failure in getBUS");
137:
138:• if(!buses.containsKey(pid))
139: {
140:         NextGenBus bus = rtLogger.getBusMap().get(pid.intValue());
141:         
142:         Long id = new Long(bus.id);
143:         String name = bus.name;
144:•         Boolean isVirtual = (id.intValue() == rtLogger.getvBus().id);
145:         Vector<Long> connectedCPUIds = new Vector<Long>();
146:         
147:•         for(NextGenCpu connectedCPU : bus.cpus)
148:         {
149:                 connectedCPUIds.add(new Long(connectedCPU.id));
150:         }
151:         
152:         buses.put(pid, new TraceBus(id, name, isVirtual, connectedCPUIds));
153: }
154:
155: return buses.get(pid);
156: }
157:
158: public Vector<TraceBus> getBuses()
159: {
160:         Vector<TraceBus> buses = new Vector<TraceBus>();
161:•         for(Integer busId : rtLogger.getBusMap().keySet())
162:         {
163:                 TraceBus bus = getBUS(new Long(busId));
164:                 buses.add(bus);
165:         }
166:         
167:         return buses;
168: }
169:
170: public TraceThread getThread(Long pthrid) throws RuntimeErrorException
171: {
172:• if(!rtLogger.getThreadMap().containsKey(pthrid))
173: throw new RuntimeErrorException(null, "Run-Time Error:Precondition failure in getThread");
174:
175:• if(!threads.containsKey(pthrid))
176: {
177:         threads.put(pthrid, new TraceThread(pthrid));
178: }
179:
180: return threads.get(pthrid);
181: }
182:
183: public TraceOperation getOperation(String classNameOperationName)
184: {
185:• if(!rtLogger.getOperationMap().containsKey(classNameOperationName))
186: throw new RuntimeErrorException(null, "Run-Time Error:Precondition failure in getOpreation");
187:
188:• if(!operations.containsKey(classNameOperationName))
189: {
190:         NextGenOperation message = rtLogger.getOperationMap().get(classNameOperationName);
191:         
192:         String opName = message.name;
193:         Boolean isStatic = message.isStatic;
194:         Boolean isAsync = message.isAsync;
195:         String clName = message.classDef.name;
196:         
197:         operations.put(classNameOperationName, new TraceOperation(opName, isAsync, isStatic, clName));
198: }
199:
200: return operations.get(classNameOperationName);
201: }
202:
203: public TraceObject getObject(Long pobjid) throws RuntimeErrorException
204: {
205:• if(!rtLogger.getObjectMap().containsKey(pobjid.intValue()))
206: throw new RuntimeErrorException(null, "Run-Time Error:Precondition failure in getThread");
207:
208:• if(!objects.containsKey(pobjid))
209: {
210:         NextGenObject object = rtLogger.getObjectMap().get(pobjid.intValue());
211:         
212:         Long id = new Long(object.id);
213:         String name = object.classDef.name;
214:         
215:         objects.put(pobjid, new TraceObject(id, name));
216: }
217:
218: return objects.get(pobjid);
219: }
220:
221: public TraceObject getStaticObject(String name)
222: {
223:•         if(!staticObjects.containsKey(name))
224:         {
225:                 staticObjects.put(name, new TraceObject(0L, name));
226:         }
227:         return staticObjects.get(name);
228: }
229:
230: public TraceObject getMainThreadObject()
231: {
232:         return mainThreadObject;
233: }
234:
235: public TraceObject getInitThreadObject() {
236:         return initThreadObject;
237: }
238:
239:         
240:         public Vector<TraceBus> getConnectedBuses(Long cpuId)
241:         {
242:         Vector<TraceBus> res = new Vector<TraceBus>();
243:         
244:         Map<Integer, NextGenBus> buses = rtLogger.getBusMap();         
245:•         for(NextGenBus bus : buses.values())
246:         {        
247:•                 for (NextGenCpu cpu : bus.cpus)
248:                 {
249:•                         if(cpuId.intValue() == cpu.id)
250:                         {
251:                                 res.add(getBUS(new Long(bus.id)));
252:                         }
253:                         }                 
254:         }
255: return res;
256:         }
257:
258:         public TraceCPU getCpuFromThreadId(Long threadID)
259:         {
260:•                if(!rtLogger.getThreadMap().containsKey(threadID))
261:                         throw new RuntimeErrorException(null, "Run-Time Error:Precondition failure in getCpuFromThreadId");
262:                 
263:                 int CpuId = rtLogger.getThreadMap().get(threadID).cpu.id;
264:                 
265:                 return getCPU(new Long(CpuId));
266:         }
267:         
268:
269:         public Long getLastMarkerTime()
270:         {
271:                 return lastMarkerTime;
272:         }
273:         
274:         public void setLastMarkerTime(Long time)
275:         {
276:                 lastMarkerTime = time;
277:         }
278: }