mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 459114 - [visualizer] Make it possible to override the construction of the data model
Change-Id: Ib2af550136fa3ca638fd970e3c2e40ddf597ba80
This commit is contained in:
parent
275feb6874
commit
384e9759c4
4 changed files with 302 additions and 311 deletions
|
@ -22,6 +22,7 @@
|
|||
* Marc Dumais (Ericsson) - Bug 451392
|
||||
* Marc Dumais (Ericsson) - Bug 453206
|
||||
* Marc Dumais (Ericsson) - Bug 458076
|
||||
* Alvaro Sanchez-Leon (Ericsson) - Bug 459114 - override construction of the data model
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;
|
||||
|
@ -33,7 +34,10 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor;
|
||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
|
||||
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
|
||||
import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
||||
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData;
|
||||
|
@ -54,14 +58,15 @@ import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerL
|
|||
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerModel;
|
||||
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerThread;
|
||||
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.DSFDebugModel;
|
||||
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.DSFDebugModelListener;
|
||||
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.DSFSessionState;
|
||||
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.DebugViewUtils;
|
||||
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.IDSFTargetDataProxy;
|
||||
import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.ICPUDMContext;
|
||||
import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.ICoreDMContext;
|
||||
import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS2.ILoadInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
|
||||
import org.eclipse.cdt.dsf.mi.service.IMIProcessDMContext;
|
||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
||||
import org.eclipse.cdt.visualizer.ui.canvas.GraphicCanvas;
|
||||
import org.eclipse.cdt.visualizer.ui.canvas.GraphicCanvasVisualizer;
|
||||
|
@ -102,9 +107,7 @@ import org.eclipse.swt.widgets.Composite;
|
|||
* This visualizer uses the CDT Visualizer framework.
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class MulticoreVisualizer extends GraphicCanvasVisualizer
|
||||
implements DSFDebugModelListener, IPinnable
|
||||
{
|
||||
public class MulticoreVisualizer extends GraphicCanvasVisualizer implements IPinnable {
|
||||
// --- constants ---
|
||||
|
||||
/** Eclipse ID for this view */
|
||||
|
@ -117,6 +120,11 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
|
|||
* The data model drawn by this visualizer.
|
||||
*/
|
||||
protected VisualizerModel fDataModel;
|
||||
|
||||
/**
|
||||
* Proxy to the target data needed to build the model
|
||||
*/
|
||||
protected IDSFTargetDataProxy fTargetData;
|
||||
|
||||
/** Downcast reference to canvas. */
|
||||
protected MulticoreVisualizerCanvas m_canvas;
|
||||
|
@ -226,6 +234,7 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
|
|||
/** Constructor. */
|
||||
public MulticoreVisualizer()
|
||||
{
|
||||
fTargetData = new DSFDebugModel();
|
||||
}
|
||||
|
||||
/** Dispose method. */
|
||||
|
@ -259,7 +268,7 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
|
|||
*/
|
||||
protected void initializeLoadMeterTimer() {
|
||||
if (!m_loadMetersEnabled) return;
|
||||
m_updateLoadMeterTimer = DSFDebugModel.getLoadTimer(m_sessionState, m_loadMeterTimerPeriod, this);
|
||||
m_updateLoadMeterTimer = getLoadTimer(m_sessionState, m_loadMeterTimerPeriod);
|
||||
// one-shot timer (re-scheduled upon successful triggering)
|
||||
m_updateLoadMeterTimer.setRepeating(false);
|
||||
}
|
||||
|
@ -984,7 +993,7 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
|
|||
// is the visualizer pinned? Then inhibit context change
|
||||
if (isPinned())
|
||||
return false;
|
||||
|
||||
|
||||
String sessionId = null;
|
||||
IAdaptable debugContext = DebugUITools.getDebugContext();
|
||||
if (debugContext instanceof IDMVMContext) {
|
||||
|
@ -1119,8 +1128,19 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
|
|||
*/
|
||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||
public void getVisualizerModel() {
|
||||
fDataModel = new VisualizerModel(m_sessionState.getSessionID());
|
||||
DSFDebugModel.getCPUs(m_sessionState, this, fDataModel);
|
||||
String sessionId = m_sessionState.getSessionID();
|
||||
DsfSession session = DsfSession.getSession(sessionId);
|
||||
|
||||
if (session != null) {
|
||||
fDataModel = new VisualizerModel(sessionId);
|
||||
fTargetData.getCPUs(m_sessionState, new DataRequestMonitor<ICPUDMContext[]>(session.getExecutor(), null) {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
ICPUDMContext[] cpuContexts = isSuccess() ? getData() : null;
|
||||
getCPUsDone(cpuContexts, fDataModel);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** Invoked when getModel() request completes. */
|
||||
|
@ -1136,9 +1156,8 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
|
|||
// --- DSFDebugModelListener implementation ---
|
||||
|
||||
/** Invoked when DSFDebugModel.getCPUs() completes. */
|
||||
@Override
|
||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||
public void getCPUsDone(ICPUDMContext[] cpuContexts, Object arg)
|
||||
public void getCPUsDone(ICPUDMContext[] cpuContexts, final Object arg)
|
||||
{
|
||||
VisualizerModel model = (VisualizerModel) arg;
|
||||
|
||||
|
@ -1152,7 +1171,24 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
|
|||
model.getTodo().add(1);
|
||||
|
||||
// Collect core data.
|
||||
DSFDebugModel.getCores(m_sessionState, this, model);
|
||||
fTargetData.getCores(m_sessionState, new ImmediateDataRequestMonitor<ICoreDMContext[]>() {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
// Get Cores
|
||||
ICoreDMContext[] coreContexts = isSuccess() ? getData() : null;
|
||||
|
||||
ICPUDMContext cpu = null;
|
||||
if (coreContexts != null && coreContexts.length > 0) {
|
||||
// TODO: This keeps the functionality to the same level before change: 459114,
|
||||
// although it's noted that this does not cover the possibility to have multiple CPU's
|
||||
// within the list of resolved cores
|
||||
cpu = DMContexts.getAncestorOfType(coreContexts[0], ICPUDMContext.class);
|
||||
}
|
||||
|
||||
// Continue
|
||||
getCoresDone(cpu, coreContexts, arg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// save CPU contexts
|
||||
m_cpuCoreContextsCache.addAll(Arrays.asList(cpuContexts));
|
||||
|
@ -1161,24 +1197,25 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
|
|||
int count = cpuContexts.length;
|
||||
model.getTodo().add(count);
|
||||
|
||||
for (ICPUDMContext cpuContext : cpuContexts) {
|
||||
for (final ICPUDMContext cpuContext : cpuContexts) {
|
||||
int cpuID = Integer.parseInt(cpuContext.getId());
|
||||
model.addCPU(new VisualizerCPU(cpuID));
|
||||
|
||||
// Collect core data.
|
||||
DSFDebugModel.getCores(m_sessionState, cpuContext, this, model);
|
||||
fTargetData.getCores(m_sessionState, cpuContext, new ImmediateDataRequestMonitor<ICoreDMContext[]>() {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
ICoreDMContext[] coreContexts = isSuccess() ? getData() : null;
|
||||
getCoresDone(cpuContext, coreContexts, arg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Invoked when getCores() request completes. */
|
||||
@Override
|
||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||
public void getCoresDone(ICPUDMContext cpuContext,
|
||||
ICoreDMContext[] coreContexts,
|
||||
Object arg)
|
||||
public void getCoresDone(final ICPUDMContext cpuContext, ICoreDMContext[] coreContexts, final Object arg)
|
||||
{
|
||||
VisualizerModel model = (VisualizerModel) arg;
|
||||
|
||||
|
@ -1196,12 +1233,19 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
|
|||
int count = coreContexts.length;
|
||||
model.getTodo().add(count);
|
||||
|
||||
for (ICoreDMContext coreContext : coreContexts) {
|
||||
for (final ICoreDMContext coreContext : coreContexts) {
|
||||
int coreID = Integer.parseInt(coreContext.getId());
|
||||
cpu.addCore(new VisualizerCore(cpu, coreID));
|
||||
|
||||
// Collect thread data
|
||||
DSFDebugModel.getThreads(m_sessionState, cpuContext, coreContext, this, model);
|
||||
fTargetData.getThreads(m_sessionState, cpuContext, coreContext, new ImmediateDataRequestMonitor<IDMContext[]>() {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
IDMContext[] threadContexts = isSuccess() ? getData() : null;
|
||||
|
||||
getThreadsDone(cpuContext, coreContext, threadContexts, arg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1212,12 +1256,11 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
|
|||
|
||||
|
||||
/** Invoked when getThreads() request completes. */
|
||||
@Override
|
||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||
public void getThreadsDone(ICPUDMContext cpuContext,
|
||||
ICoreDMContext coreContext,
|
||||
public void getThreadsDone(final ICPUDMContext cpuContext,
|
||||
final ICoreDMContext coreContext,
|
||||
IDMContext[] threadContexts,
|
||||
Object arg)
|
||||
final Object arg)
|
||||
{
|
||||
VisualizerModel model = (VisualizerModel) arg;
|
||||
|
||||
|
@ -1230,11 +1273,17 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
|
|||
model.getTodo().add(count);
|
||||
|
||||
for (IDMContext threadContext : threadContexts) {
|
||||
IMIExecutionDMContext execContext =
|
||||
final IMIExecutionDMContext execContext =
|
||||
DMContexts.getAncestorOfType(threadContext, IMIExecutionDMContext.class);
|
||||
// Don't add the thread to the model just yet, let's wait until we have its data and execution state.
|
||||
// Collect thread data
|
||||
DSFDebugModel.getThreadData(m_sessionState, cpuContext, coreContext, execContext, this, model);
|
||||
fTargetData.getThreadData(m_sessionState, cpuContext, coreContext, execContext, new ImmediateDataRequestMonitor<IThreadDMData>() {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
IThreadDMData threadData = isSuccess() ? getData() : null;
|
||||
getThreadDataDone(cpuContext, coreContext, execContext, threadData, arg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1244,22 +1293,40 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
|
|||
}
|
||||
|
||||
/** Invoked when getThreads() request completes. */
|
||||
@Override
|
||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||
public void getThreadDataDone(ICPUDMContext cpuContext,
|
||||
ICoreDMContext coreContext,
|
||||
IMIExecutionDMContext execContext,
|
||||
IThreadDMData threadData,
|
||||
Object arg)
|
||||
public void getThreadDataDone(final ICPUDMContext cpuContext,
|
||||
final ICoreDMContext coreContext,
|
||||
final IMIExecutionDMContext execContext,
|
||||
final IThreadDMData threadData,
|
||||
final Object arg)
|
||||
{
|
||||
|
||||
// Don't add the thread to the model just yet, let's wait until we have its execution state.
|
||||
DSFDebugModel.getThreadExecutionState(m_sessionState, cpuContext, coreContext, execContext, threadData, this, arg);
|
||||
// Get the execution state
|
||||
fTargetData.getThreadExecutionState(m_sessionState, cpuContext, coreContext, execContext,
|
||||
threadData, new ImmediateDataRequestMonitor<VisualizerExecutionState>() {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
final VisualizerExecutionState state = isSuccess() ? getData() : null;
|
||||
if (state != null && !(state.equals(VisualizerExecutionState.RUNNING)) ) {
|
||||
// Get the frame data
|
||||
fTargetData.getTopFrameData(m_sessionState, execContext, new ImmediateDataRequestMonitor<IFrameDMData>() {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
IFrameDMData frameData = isSuccess() ? getData() : null;
|
||||
getThreadExecutionStateDone(cpuContext, coreContext, execContext, threadData,
|
||||
frameData, state, arg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// frame data is not valid
|
||||
getThreadExecutionStateDone(cpuContext, coreContext, execContext, threadData,
|
||||
null, state, arg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/** Invoked when getThreadExecutionState() request completes. */
|
||||
@Override
|
||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||
public void getThreadExecutionStateDone(ICPUDMContext cpuContext,
|
||||
ICoreDMContext coreContext,
|
||||
|
@ -1311,7 +1378,6 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
|
|||
|
||||
/** Updates the loads for all cpus and cores */
|
||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||
@Override
|
||||
public void updateLoads() {
|
||||
if (m_cpuCoreContextsCache.isEmpty()) {
|
||||
// not ready to get load info yet
|
||||
|
@ -1322,20 +1388,25 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
|
|||
return;
|
||||
}
|
||||
|
||||
VisualizerModel model = fDataModel;
|
||||
final VisualizerModel model = fDataModel;
|
||||
|
||||
model.getLoadTodo().dispose();
|
||||
// keep track of how many loads we expect
|
||||
model.getLoadTodo().add(m_cpuCoreContextsCache.size());
|
||||
|
||||
// ask load for each CPU and core
|
||||
for (IDMContext context : m_cpuCoreContextsCache) {
|
||||
DSFDebugModel.getLoad(m_sessionState, context, this, model);
|
||||
for (final IDMContext context : m_cpuCoreContextsCache) {
|
||||
fTargetData.getLoad(m_sessionState, context, new ImmediateDataRequestMonitor<ILoadInfo>() {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
ILoadInfo loadInfo = isSuccess() ? getData() : null;
|
||||
getLoadDone(context, loadInfo, model);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** Invoked when a getLoad() request completes. */
|
||||
@Override
|
||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||
public void getLoadDone(IDMContext context, ILoadInfo load, Object arg)
|
||||
{
|
||||
|
@ -1386,5 +1457,30 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Timer getLoadTimer(final DSFSessionState sessionState, final int timeout) {
|
||||
Timer t = new Timer(timeout) {
|
||||
@Override
|
||||
public void run() {
|
||||
if (sessionState != null) {
|
||||
DsfSession session = DsfSession.getSession(sessionState.getSessionID());
|
||||
if (session != null) {
|
||||
DsfExecutor executor = session.getExecutor();
|
||||
if (executor != null) {
|
||||
executor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateLoads();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012, 2014 Tilera Corporation and others.
|
||||
* Copyright (c) 2012, 2015 Tilera Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -9,6 +9,7 @@
|
|||
* William R. Swanson (Tilera Corporation) - initial API and implementation
|
||||
* Marc Dumais (Ericsson) - Add CPU/core load information to the multicore visualizer (Bug 396268)
|
||||
* Xavier Raynaud (Kalray) - Bug 431935
|
||||
* Alvaro Sanchez-Leon (Ericsson) - Bug 459114 - override construction of the data model
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils;
|
||||
|
@ -16,7 +17,7 @@ package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils;
|
|||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor;
|
||||
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
|
||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.ImmediateCountingRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor;
|
||||
|
@ -44,98 +45,73 @@ import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS2;
|
|||
import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS2.ILoadInfo;
|
||||
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData;
|
||||
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
|
||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||
import org.eclipse.cdt.visualizer.ui.util.Timer;
|
||||
|
||||
|
||||
/** Debugger state information accessors.
|
||||
/** Debugger state information accessors.</br>
|
||||
*
|
||||
* NOTE: The methods on this class perform asynchronous operations,
|
||||
* and call back to a method on a provided DSFDebugModelListener instance
|
||||
* when the operation is completed.
|
||||
*
|
||||
* The "arg" argument to each method can be used by the caller to
|
||||
* pass through information (partial state, etc.) that will be needed
|
||||
* by the callback method. This argument is ignored by the methods
|
||||
* on this class, and is allowed to be null.
|
||||
* NOTE: The methods on this class perform asynchronous operations
|
||||
* and the result is reported back via the received request monitor
|
||||
*/
|
||||
public class DSFDebugModel {
|
||||
public class DSFDebugModel implements IDSFTargetDataProxy {
|
||||
|
||||
// --- static methods ---
|
||||
|
||||
/** Requests list of CPUs.
|
||||
* Calls back to getCPUsDone() on listener. */
|
||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||
public static void getCPUs(DSFSessionState sessionState,
|
||||
final DSFDebugModelListener listener,
|
||||
final Object arg)
|
||||
{
|
||||
@Override
|
||||
@ConfinedToDsfExecutor("sessionState.getDsfSession().getExecutor()")
|
||||
public void getCPUs(DSFSessionState sessionState, final DataRequestMonitor<ICPUDMContext[]> rm) {
|
||||
ICommandControlService controlService = sessionState.getService(ICommandControlService.class);
|
||||
IGDBHardwareAndOS hwService = sessionState.getService(IGDBHardwareAndOS.class);
|
||||
if (controlService == null || hwService == null) {
|
||||
listener.getCPUsDone(null, arg);
|
||||
rm.done(new ICPUDMContext[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
IHardwareTargetDMContext contextToUse = DMContexts.getAncestorOfType(controlService.getContext(),
|
||||
IHardwareTargetDMContext.class);
|
||||
hwService.getCPUs(contextToUse,
|
||||
new ImmediateDataRequestMonitor<ICPUDMContext[]>() {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
ICPUDMContext[] cpuContexts = getData();
|
||||
if (! isSuccess()) cpuContexts = null;
|
||||
listener.getCPUsDone(cpuContexts, arg);
|
||||
|
||||
IHardwareTargetDMContext contextToUse = DMContexts.getAncestorOfType(controlService.getContext(), IHardwareTargetDMContext.class);
|
||||
hwService.getCPUs(contextToUse, new ImmediateDataRequestMonitor<ICPUDMContext[]>(rm) {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
ICPUDMContext[] cpuContexts;
|
||||
if (isSuccess()) {
|
||||
cpuContexts = getData();
|
||||
} else {
|
||||
cpuContexts = new ICPUDMContext[0];
|
||||
}
|
||||
|
||||
rm.done(cpuContexts);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/** Request load information for a single CPU or core */
|
||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||
public static void getLoad(DSFSessionState sessionState,
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ConfinedToDsfExecutor("sessionState.getDsfSession().getExecutor()")
|
||||
public void getLoad(DSFSessionState sessionState,
|
||||
final IDMContext context,
|
||||
final DSFDebugModelListener listener,
|
||||
final Object arg)
|
||||
final DataRequestMonitor<ILoadInfo> rm)
|
||||
{
|
||||
IGDBHardwareAndOS2 hwService = sessionState.getService(IGDBHardwareAndOS2.class);
|
||||
if (hwService == null) {
|
||||
listener.getLoadDone(context, null, arg);
|
||||
rm.setData(null);
|
||||
rm.done();
|
||||
return;
|
||||
}
|
||||
|
||||
hwService.getLoadInfo(context,
|
||||
new ImmediateDataRequestMonitor<ILoadInfo>() {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
listener.getLoadDone(context, getData(), arg);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/** Requests list of Cores.
|
||||
* Calls back to getCoresDone() on listener. */
|
||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||
public static void getCores(DSFSessionState sessionState,
|
||||
DSFDebugModelListener listener,
|
||||
Object arg)
|
||||
{
|
||||
getCores(sessionState, null, listener, arg);
|
||||
hwService.getLoadInfo(context, rm);
|
||||
}
|
||||
|
||||
/** Requests list of Cores.
|
||||
* Calls back to getCoresDone() on listener. */
|
||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||
public static void getCores(DSFSessionState sessionState,
|
||||
@Override
|
||||
@ConfinedToDsfExecutor("sessionState.getDsfSession().getExecutor()")
|
||||
public void getCores(DSFSessionState sessionState, final DataRequestMonitor<ICoreDMContext[]> rm) {
|
||||
getCores(sessionState, null, rm);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ConfinedToDsfExecutor("sessionState.getDsfSession().getExecutor()")
|
||||
public void getCores(DSFSessionState sessionState,
|
||||
final ICPUDMContext cpuContext,
|
||||
final DSFDebugModelListener listener,
|
||||
final Object arg)
|
||||
final DataRequestMonitor<ICoreDMContext[]> rm)
|
||||
{
|
||||
IGDBHardwareAndOS hwService = sessionState.getService(IGDBHardwareAndOS.class);
|
||||
if (hwService == null) {
|
||||
listener.getCoresDone(cpuContext, null, arg);
|
||||
rm.done(new ICoreDMContext[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -156,29 +132,21 @@ public class DSFDebugModel {
|
|||
|
||||
if (!isSuccess() || coreContexts == null || coreContexts.length < 1) {
|
||||
// Unable to get any core data
|
||||
listener.getCoresDone(cpuContext, null, arg);
|
||||
return;
|
||||
rm.done(new ICoreDMContext[0]);
|
||||
} else {
|
||||
rm.done(coreContexts);
|
||||
}
|
||||
|
||||
ICPUDMContext cpuContextToUse = cpuContext;
|
||||
if (cpuContextToUse == null) {
|
||||
// If we didn't have a CPU context, lets use the ancestor of the first core context
|
||||
cpuContextToUse = DMContexts.getAncestorOfType(coreContexts[0], ICPUDMContext.class);
|
||||
}
|
||||
listener.getCoresDone(cpuContextToUse, coreContexts, arg);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/** Requests list of Threads.
|
||||
* Calls back to getThreadsDone() on listener. */
|
||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||
public static void getThreads(DSFSessionState sessionState,
|
||||
|
||||
@Override
|
||||
@ConfinedToDsfExecutor("sessionState.getDsfSession().getExecutor()")
|
||||
public void getThreads(DSFSessionState sessionState,
|
||||
final ICPUDMContext cpuContext,
|
||||
final ICoreDMContext coreContext,
|
||||
final DSFDebugModelListener listener,
|
||||
final Object arg)
|
||||
final DataRequestMonitor<IDMContext[]> rm)
|
||||
{
|
||||
// Get control DM context associated with the core
|
||||
// Process/Thread Info service (GDBProcesses_X_Y_Z)
|
||||
|
@ -187,7 +155,7 @@ public class DSFDebugModel {
|
|||
ICommandControlDMContext controlContext =
|
||||
DMContexts.getAncestorOfType(coreContext, ICommandControlDMContext.class);
|
||||
if (procService == null || controlContext == null) {
|
||||
listener.getThreadsDone(cpuContext, coreContext, null, arg);
|
||||
rm.done(new IDMContext[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -202,18 +170,18 @@ public class DSFDebugModel {
|
|||
if (!isSuccess() || processContexts == null || processContexts.length < 1) {
|
||||
// Unable to get any process data for this core
|
||||
// Is this an issue? A core may have no processes/threads, right?
|
||||
listener.getThreadsDone(cpuContext, coreContext, null, arg);
|
||||
rm.done(new IDMContext[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
final ArrayList<IDMContext> threadContextsList = new ArrayList<IDMContext>();
|
||||
final ArrayList<IDMContext> threadContextsList = new ArrayList<>();
|
||||
|
||||
final ImmediateCountingRequestMonitor crm1 = new ImmediateCountingRequestMonitor(
|
||||
new ImmediateRequestMonitor() {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
IDMContext[] threadContexts = threadContextsList.toArray(new IDMContext[threadContextsList.size()]);
|
||||
listener.getThreadsDone(cpuContext, coreContext, threadContexts, arg);
|
||||
rm.done(threadContexts);
|
||||
}
|
||||
});
|
||||
crm1.setDoneCount(processContexts.length);
|
||||
|
@ -271,105 +239,83 @@ public class DSFDebugModel {
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
/** Requests data of a thread.
|
||||
* Calls back to getThreadDataDone() on listener. */
|
||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||
public static void getThreadData(DSFSessionState sessionState,
|
||||
|
||||
@Override
|
||||
@ConfinedToDsfExecutor("sessionState.getDsfSession().getExecutor()")
|
||||
public void getThreadData(DSFSessionState sessionState,
|
||||
final ICPUDMContext cpuContext,
|
||||
final ICoreDMContext coreContext,
|
||||
final IMIExecutionDMContext execContext,
|
||||
final DSFDebugModelListener listener,
|
||||
final Object arg)
|
||||
final IMIExecutionDMContext execContext, final DataRequestMonitor<IThreadDMData> rm)
|
||||
{
|
||||
IProcesses procService = sessionState.getService(IProcesses.class);
|
||||
|
||||
if (procService == null) {
|
||||
listener.getThreadDataDone(cpuContext, coreContext, execContext, null, arg);
|
||||
rm.setData(null);
|
||||
rm.done();
|
||||
return;
|
||||
}
|
||||
|
||||
final IThreadDMContext threadContext = DMContexts.getAncestorOfType(execContext, IThreadDMContext.class);
|
||||
procService.getExecutionData(threadContext,
|
||||
new ImmediateDataRequestMonitor<IThreadDMData>() {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
IThreadDMData threadData = isSuccess() ? getData() : null;
|
||||
listener.getThreadDataDone(cpuContext, coreContext, execContext, threadData, arg);
|
||||
}
|
||||
});
|
||||
|
||||
procService.getExecutionData(threadContext, rm);
|
||||
}
|
||||
|
||||
/** Requests execution state of a thread.
|
||||
* Calls back to getThreadExecutionStateDone() on listener. */
|
||||
@ConfinedToDsfExecutor("getSession().getExecutor()")
|
||||
public static void getThreadExecutionState(final DSFSessionState sessionState,
|
||||
final ICPUDMContext cpuContext,
|
||||
final ICoreDMContext coreContext,
|
||||
final IMIExecutionDMContext execContext,
|
||||
final IThreadDMData threadData,
|
||||
final DSFDebugModelListener listener,
|
||||
final Object arg)
|
||||
{
|
||||
@Override
|
||||
@ConfinedToDsfExecutor("sessionState.getDsfSession().getExecutor()")
|
||||
public void getTopFrameData(final DSFSessionState sessionState, final IMIExecutionDMContext execContext, final DataRequestMonitor<IFrameDMData> rm) {
|
||||
final IFrameDMData nullFrameData = null;
|
||||
// For a suspended thread, retrieve the current stack
|
||||
final IStack stackService = sessionState.getService(IStack.class);
|
||||
if (stackService != null) {
|
||||
stackService.getTopFrame(execContext, new ImmediateDataRequestMonitor<IFrameDMContext>(null) {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
IFrameDMContext targetFrameContext = isSuccess() ? getData() : null;
|
||||
if (targetFrameContext != null) {
|
||||
stackService.getFrameData(targetFrameContext, new ImmediateDataRequestMonitor<IFrameDMData>(null) {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
IFrameDMData frameData = isSuccess() ? getData() : null;
|
||||
rm.done(frameData);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
rm.done(nullFrameData);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
rm.done(nullFrameData);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ConfinedToDsfExecutor("sessionState.getDsfSession().getExecutor()")
|
||||
public void getThreadExecutionState(final DSFSessionState sessionState, final ICPUDMContext cpuContext, final ICoreDMContext coreContext,
|
||||
final IMIExecutionDMContext execContext, final IThreadDMData threadData, final DataRequestMonitor<VisualizerExecutionState> rm) {
|
||||
IRunControl runControl = sessionState.getService(IRunControl.class);
|
||||
|
||||
if (runControl == null) {
|
||||
listener.getThreadExecutionStateDone(cpuContext, coreContext, execContext, threadData, null, null, arg);
|
||||
rm.setData(null);
|
||||
rm.done();
|
||||
return;
|
||||
}
|
||||
|
||||
if (runControl.isSuspended(execContext) == false) {
|
||||
// The thread is running
|
||||
listener.getThreadExecutionStateDone(cpuContext, coreContext, execContext, threadData, null,
|
||||
VisualizerExecutionState.RUNNING, arg);
|
||||
rm.done(VisualizerExecutionState.RUNNING);
|
||||
} else {
|
||||
// For a suspended thread, retrieve the current stack
|
||||
final IStack stackService = sessionState.getService(IStack.class);
|
||||
if (stackService != null) {
|
||||
stackService.getTopFrame(execContext, new ImmediateDataRequestMonitor<IFrameDMContext>(null) {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
IFrameDMContext targetFrameContext = null;
|
||||
if (isSuccess()) {
|
||||
targetFrameContext = getData();
|
||||
}
|
||||
if (targetFrameContext!= null) {
|
||||
stackService.getFrameData(targetFrameContext, new ImmediateDataRequestMonitor<IFrameDMData>(null) {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
IFrameDMData frameData = null;
|
||||
if (isSuccess()) {
|
||||
frameData = getData();
|
||||
}
|
||||
getThreadSuspendReason(sessionState, cpuContext, coreContext, execContext, threadData, frameData, listener, arg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
getThreadSuspendReason(sessionState, cpuContext, coreContext, execContext, threadData, null, listener, arg);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
getThreadSuspendReason(sessionState, cpuContext, coreContext, execContext, threadData, null, listener, arg);
|
||||
}
|
||||
getThreadSuspendReason(sessionState, execContext, rm);
|
||||
}
|
||||
}
|
||||
|
||||
/** For a suspended thread, let's see why it is suspended,
|
||||
* to find out if the thread is crashed */
|
||||
private static void getThreadSuspendReason(DSFSessionState sessionState,
|
||||
final ICPUDMContext cpuContext,
|
||||
final ICoreDMContext coreContext,
|
||||
final IMIExecutionDMContext execContext,
|
||||
final IThreadDMData threadData,
|
||||
final IFrameDMData frameData,
|
||||
final DSFDebugModelListener listener,
|
||||
final Object arg) {
|
||||
@ConfinedToDsfExecutor("sessionState.getDsfSession().getExecutor()")
|
||||
private static void getThreadSuspendReason(DSFSessionState sessionState, IMIExecutionDMContext execContext,
|
||||
final DataRequestMonitor<VisualizerExecutionState> rm) {
|
||||
IRunControl runControl = sessionState.getService(IRunControl.class);
|
||||
if (runControl != null) {
|
||||
runControl.getExecutionData(execContext,
|
||||
new ImmediateDataRequestMonitor<IExecutionDMData>() {
|
||||
runControl.getExecutionData(execContext, new ImmediateDataRequestMonitor<IExecutionDMData>() {
|
||||
@Override
|
||||
protected void handleCompleted() {
|
||||
IExecutionDMData executionData = getData();
|
||||
|
@ -378,7 +324,7 @@ public class DSFDebugModel {
|
|||
if (isSuccess() && executionData != null) {
|
||||
if (executionData.getStateChangeReason() == StateChangeReason.SIGNAL) {
|
||||
if (executionData instanceof IExecutionDMData2) {
|
||||
String details = ((IExecutionDMData2)executionData).getDetails();
|
||||
String details = ((IExecutionDMData2) executionData).getDetails();
|
||||
if (details != null) {
|
||||
if (isCrashSignal(details)) {
|
||||
state = VisualizerExecutionState.CRASHED;
|
||||
|
@ -387,11 +333,13 @@ public class DSFDebugModel {
|
|||
}
|
||||
}
|
||||
}
|
||||
listener.getThreadExecutionStateDone(cpuContext, coreContext, execContext, threadData, frameData, state, arg);
|
||||
|
||||
rm.done(state);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
listener.getThreadExecutionStateDone(cpuContext, coreContext, execContext, threadData, frameData, null, arg);
|
||||
rm.setData(null);
|
||||
rm.done();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -412,32 +360,4 @@ public class DSFDebugModel {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Creates and returns a timer that refreshes the load meters */
|
||||
public static Timer getLoadTimer(final DSFSessionState sessionState,
|
||||
final int timeout,
|
||||
final DSFDebugModelListener listener)
|
||||
{
|
||||
Timer t = new Timer(timeout) {
|
||||
@Override
|
||||
public void run() {
|
||||
if (sessionState != null) {
|
||||
DsfSession session = DsfSession.getSession(sessionState.getSessionID());
|
||||
if (session != null) {
|
||||
DsfExecutor executor = session.getExecutor();
|
||||
if (executor != null) {
|
||||
executor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
listener.updateLoads();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012, 2014 Tilera Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* William R. Swanson (Tilera Corporation) - initial API and implementation
|
||||
* Marc Dumais (Ericsson) - Add CPU/core load information to the multicore visualizer (Bug 396268)
|
||||
* Xavier Raynaud (Kalray) - Bug 431935
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils;
|
||||
|
||||
|
||||
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
||||
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData;
|
||||
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMData;
|
||||
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerExecutionState;
|
||||
import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.ICPUDMContext;
|
||||
import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.ICoreDMContext;
|
||||
import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS2.ILoadInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
|
||||
|
||||
/** Interface for classes that interact with DSFDebugModel.
|
||||
*
|
||||
* An instance of this interface is passed as
|
||||
* an argument to a method of DSFDebugModel, and
|
||||
* the corresponding callback on this interface is
|
||||
* invoked when the method completes.
|
||||
*
|
||||
* The "arg" argument is the value (if any) passed
|
||||
* through the corresponding "arg" argument of the
|
||||
* DSFDebugModel method.
|
||||
*
|
||||
* TODO: we intend to refactor this API and make this
|
||||
* a base class rather than an instance.
|
||||
*/
|
||||
public interface DSFDebugModelListener {
|
||||
|
||||
/** Invoked when getCPUs() request completes. */
|
||||
public void getCPUsDone(ICPUDMContext[] cpuContexts,
|
||||
Object arg);
|
||||
|
||||
/** Invoked when getCores() request completes. */
|
||||
public void getCoresDone(ICPUDMContext cpuContext,
|
||||
ICoreDMContext[] coreContexts,
|
||||
Object arg);
|
||||
|
||||
/** Invoked when getThreads() request completes. */
|
||||
public void getThreadsDone(ICPUDMContext cpuContext,
|
||||
ICoreDMContext coreContext,
|
||||
IDMContext[] threadContexts,
|
||||
Object arg);
|
||||
|
||||
/** Invoked when getThreadDataState() request completes. */
|
||||
public void getThreadDataDone(ICPUDMContext cpuContext,
|
||||
ICoreDMContext coreContext,
|
||||
IMIExecutionDMContext threadContext,
|
||||
IThreadDMData data,
|
||||
Object arg);
|
||||
|
||||
/** Invoked when getThreadExecutionState() request completes. */
|
||||
public void getThreadExecutionStateDone(ICPUDMContext cpuContext,
|
||||
ICoreDMContext coreContext,
|
||||
IMIExecutionDMContext threadContext,
|
||||
IThreadDMData threadData,
|
||||
IFrameDMData frame,
|
||||
VisualizerExecutionState state,
|
||||
Object arg);
|
||||
|
||||
/** Invoked when getLoad() request completes. */
|
||||
public void getLoadDone(IDMContext context, ILoadInfo loads, Object arg);
|
||||
|
||||
/** Invoked when the load timer triggers. */
|
||||
public void updateLoads();
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 Ericsson AB and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Alvaro Sanchez-Leon (Ericsson) - Bug 459114 - override construction of the data model
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils;
|
||||
|
||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
||||
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData;
|
||||
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMData;
|
||||
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerExecutionState;
|
||||
import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.ICPUDMContext;
|
||||
import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.ICoreDMContext;
|
||||
import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS2.ILoadInfo;
|
||||
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
|
||||
|
||||
/**
|
||||
* Describes the methods to query data from a target system under debug
|
||||
*/
|
||||
public interface IDSFTargetDataProxy {
|
||||
|
||||
/** Requests list of CPUs. */
|
||||
public void getCPUs(DSFSessionState sessionState, DataRequestMonitor<ICPUDMContext[]> rm);
|
||||
|
||||
/** Requests list of Cores. */
|
||||
public void getCores(DSFSessionState sessionState, DataRequestMonitor<ICoreDMContext[]> rm);
|
||||
|
||||
/** Requests list of Cores */
|
||||
public void getCores(DSFSessionState sessionState, ICPUDMContext cpuContext, DataRequestMonitor<ICoreDMContext[]> rm);
|
||||
|
||||
/** Requests list of Threads Related to the specified CPU and Core */
|
||||
public void getThreads(DSFSessionState sessionState, ICPUDMContext cpuContext, ICoreDMContext coreContext, DataRequestMonitor<IDMContext[]> rm);
|
||||
|
||||
/** Requests data for the thread associated to the give execution context */
|
||||
public void getThreadData(DSFSessionState sessionState, ICPUDMContext cpuContext, ICoreDMContext coreContext, IMIExecutionDMContext execContext,
|
||||
DataRequestMonitor<IThreadDMData> rm);
|
||||
|
||||
/** Requests frame data for a given thread */
|
||||
public void getTopFrameData(DSFSessionState sessionState, IMIExecutionDMContext execContext, DataRequestMonitor<IFrameDMData> rm);
|
||||
|
||||
/** Requests execution state of a thread. */
|
||||
public void getThreadExecutionState(DSFSessionState sessionState, ICPUDMContext cpuContext, ICoreDMContext coreContext,
|
||||
IMIExecutionDMContext execContext, IThreadDMData threadData, DataRequestMonitor<VisualizerExecutionState> rm);
|
||||
|
||||
/** Request load information for a single CPU or core */
|
||||
public void getLoad(DSFSessionState sessionState, IDMContext context, DataRequestMonitor<ILoadInfo> rm);
|
||||
}
|
Loading…
Add table
Reference in a new issue