1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-19 15:05:36 +02:00

Bug 431935 - Add tooltips in Thread object of multicore visualizer

Change-Id: I18c4f4de4740c8c0286b78e5b079fc55b159f78d
Signed-off-by: Xavier Raynaud <xavier.raynaud@kalray.eu>
Reviewed-on: https://git.eclipse.org/r/24522
Reviewed-by: Marc Dumais <marc.dumais@ericsson.com>
Tested-by: Marc Dumais <marc.dumais@ericsson.com>
This commit is contained in:
Xavier Raynaud 2014-04-11 13:35:05 +02:00 committed by Marc Dumais
parent 882369b295
commit 62e660108a
9 changed files with 240 additions and 31 deletions

View file

@ -14,7 +14,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.cdt.ui, org.eclipse.cdt.ui,
org.eclipse.cdt.visualizer.core, org.eclipse.cdt.visualizer.core,
org.eclipse.cdt.visualizer.ui, org.eclipse.cdt.visualizer.ui,
org.eclipse.debug.ui org.eclipse.debug.ui,
org.eclipse.cdt.core
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: com.ibm.icu.text Import-Package: com.ibm.icu.text

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012, 2013 Tilera Corporation and others. * Copyright (c) 2012, 2014 Tilera Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
* William R. Swanson (Tilera Corporation) - initial API and implementation * William R. Swanson (Tilera Corporation) - initial API and implementation
* Marc Dumais (Ericsson) - Bug 405390 * Marc Dumais (Ericsson) - Bug 405390
* Marc Dumais (Ericsson) - Bug 407321 * Marc Dumais (Ericsson) - Bug 407321
* Xavier Raynaud (Kalray) - Add tooltip support (Bug 431935)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model; package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model;
@ -269,6 +270,7 @@ public class VisualizerModel
if (m_keepExitedThreads) { if (m_keepExitedThreads) {
VisualizerThread thread = getThread(threadId); VisualizerThread thread = getThread(threadId);
thread.setState(VisualizerExecutionState.EXITED); thread.setState(VisualizerExecutionState.EXITED);
thread.setLocationInfo((String) null);
} else { } else {
removeThread(threadId); removeThread(threadId);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012, 2013 Tilera Corporation and others. * Copyright (c) 2012, 2014 Tilera Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -11,10 +11,13 @@
* state and os/gdb thread ids * state and os/gdb thread ids
* Marc Dumais (Ericsson) - Bug 405390 * Marc Dumais (Ericsson) - Bug 405390
* Marc Dumais (Ericsson) - Bug 409965 * Marc Dumais (Ericsson) - Bug 409965
* Xavier Raynaud (Kalray) - Add tooltip support (Bug 431935)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model; package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model;
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMData;
/** Represents single thread. */ /** Represents single thread. */
public class VisualizerThread public class VisualizerThread
@ -37,16 +40,25 @@ public class VisualizerThread
/** Thread execution state. */ /** Thread execution state. */
protected VisualizerExecutionState m_threadState; protected VisualizerExecutionState m_threadState;
/** Location of this Thread, if any, based on his MIFrame */
private String m_locInfo;
// --- constructors/destructors --- // --- constructors/destructors ---
/** Constructor. */ /** Constructor. */
public VisualizerThread(VisualizerCore core, int pid, int tid, int gdbtid, VisualizerExecutionState state) { public VisualizerThread(VisualizerCore core, int pid, int tid, int gdbtid, VisualizerExecutionState state) {
this(core, pid, tid, gdbtid, state, null);
}
/** Constructor. */
public VisualizerThread(VisualizerCore core, int pid, int tid, int gdbtid, VisualizerExecutionState state, IFrameDMData frame) {
m_core = core; m_core = core;
m_pid = pid; m_pid = pid;
m_tid = tid; m_tid = tid;
m_gdbtid = gdbtid; m_gdbtid = gdbtid;
m_threadState = state; m_threadState = state;
setLocationInfo(frame);
} }
/** Dispose method */ /** Dispose method */
@ -186,4 +198,80 @@ public class VisualizerThread
} }
return 1; return 1;
} }
/**
* Sets the location info of this thread
* @param s a string, displayinf location information of this thread.
*/
public void setLocationInfo(String s) {
this.m_locInfo = s;
}
/**
* Sets the location info of this thread, based on given
* {@link IFrameDMData}
*
* @param dmData
* a {@link IFrameDMData} (can be <code>null</code>)
*/
public void setLocationInfo(IFrameDMData dmData) {
if (dmData == null) {
this.m_locInfo = null;
} else {
StringBuilder label = new StringBuilder();
// Add the function name
if (dmData.getFunction() != null
&& dmData.getFunction().length() != 0) {
label.append(" "); //$NON-NLS-1$
label.append(dmData.getFunction());
label.append("()"); //$NON-NLS-1$
}
boolean hasFileName = dmData.getFile() != null
&& dmData.getFile().length() != 0;
// Add full file name
if (hasFileName) {
label.append(" at "); //$NON-NLS-1$
label.append(dmData.getFile());
// Add line number
if (dmData.getLine() >= 0) {
label.append(":"); //$NON-NLS-1$
label.append(dmData.getLine());
label.append(" "); //$NON-NLS-1$
}
}
// Add module
if (!hasFileName
&& (dmData.getModule() != null && dmData.getModule()
.length() != 0)) {
label.append(" "); //$NON-NLS-1$
label.append(dmData.getModule());
label.append(" "); //$NON-NLS-1$
}
// Add the address
if (dmData.getAddress() != null) {
label.append("- 0x" + dmData.getAddress().toString(16)); //$NON-NLS-1$
}
this.m_locInfo = label.toString();
}
}
/**
* Gets the location of this thread or <code>null</code> if none.
*
* @return a String, or <code>null</code>
* @since 3.0
*/
public String getLocationInfo() {
if (m_threadState == VisualizerExecutionState.RUNNING
|| m_threadState == VisualizerExecutionState.EXITED) {
return null;
}
return m_locInfo;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012, 2013 Tilera Corporation and others. * Copyright (c) 2012, 2014 Tilera Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -16,6 +16,7 @@
* Marc Dumais (Ericsson) - Bug 407321 * Marc Dumais (Ericsson) - Bug 407321
* Marc-Andre Laperle (Ericsson) - Bug 411634 * Marc-Andre Laperle (Ericsson) - Bug 411634
* Marc Dumais (Ericsson) - Bug 409965 * Marc Dumais (Ericsson) - Bug 409965
* Xavier Raynaud (kalray) - Bug 431935
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view; package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;
@ -30,6 +31,7 @@ import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
import org.eclipse.cdt.dsf.datamodel.DMContexts; import org.eclipse.cdt.dsf.datamodel.DMContexts;
import org.eclipse.cdt.dsf.datamodel.IDMContext; import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData; import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData;
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMData;
import org.eclipse.cdt.dsf.gdb.launching.GDBProcess; import org.eclipse.cdt.dsf.gdb.launching.GDBProcess;
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch; import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.MulticoreVisualizerUIPlugin; import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.MulticoreVisualizerUIPlugin;
@ -1118,7 +1120,6 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
for (IDMContext threadContext : threadContexts) { for (IDMContext threadContext : threadContexts) {
IMIExecutionDMContext execContext = IMIExecutionDMContext execContext =
DMContexts.getAncestorOfType(threadContext, IMIExecutionDMContext.class); 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. // Don't add the thread to the model just yet, let's wait until we have its data and execution state.
// Collect thread data // Collect thread data
DSFDebugModel.getThreadData(m_sessionState, cpuContext, coreContext, execContext, this, model); DSFDebugModel.getThreadData(m_sessionState, cpuContext, coreContext, execContext, this, model);
@ -1153,6 +1154,7 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
ICoreDMContext coreContext, ICoreDMContext coreContext,
IMIExecutionDMContext execContext, IMIExecutionDMContext execContext,
IThreadDMData threadData, IThreadDMData threadData,
IFrameDMData frame,
VisualizerExecutionState state, VisualizerExecutionState state,
Object arg) Object arg)
{ {
@ -1181,15 +1183,15 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
// through the listener. Checking at both places to prevent this. // through the listener. Checking at both places to prevent this.
VisualizerThread t = model.getThread(tid); VisualizerThread t = model.getThread(tid);
if (t == null) { if (t == null) {
model.addThread(new VisualizerThread(core, pid, osTid, tid, state)); model.addThread(new VisualizerThread(core, pid, osTid, tid, state, frame));
} }
// if the thread is already in the model, update it's parameters. // if the thread is already in the model, update it's parameters.
else { else {
t.setCore(core); t.setCore(core);
t.setTID(osTid); t.setTID(osTid);
t.setState(state); t.setState(state);
t.setLocationInfo(frame);
} }
// keep track of threads visited // keep track of threads visited
done(1, model); done(1, model);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012, 2013 Tilera Corporation and others. * Copyright (c) 2012, 2014 Tilera Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -17,6 +17,7 @@
* Marc Dumais (Ericsson) - Bug 404894 * Marc Dumais (Ericsson) - Bug 404894
* Marc Dumais (Ericsson) - Bug 405390 * Marc Dumais (Ericsson) - Bug 405390
* Marc Dumais (Ericsson) - Bug 407321 * Marc Dumais (Ericsson) - Bug 407321
* Xavier Raynaud (Kalray) - Bug 431935
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view; package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;
@ -33,6 +34,7 @@ import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerC
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerModel; 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.ui.model.VisualizerThread;
import org.eclipse.cdt.visualizer.ui.canvas.GraphicCanvas; import org.eclipse.cdt.visualizer.ui.canvas.GraphicCanvas;
import org.eclipse.cdt.visualizer.ui.canvas.IGraphicObject;
import org.eclipse.cdt.visualizer.ui.plugin.CDTVisualizerUIPlugin; import org.eclipse.cdt.visualizer.ui.plugin.CDTVisualizerUIPlugin;
import org.eclipse.cdt.visualizer.ui.util.GUIUtils; import org.eclipse.cdt.visualizer.ui.util.GUIUtils;
import org.eclipse.cdt.visualizer.ui.util.MouseMonitor; import org.eclipse.cdt.visualizer.ui.util.MouseMonitor;
@ -1120,4 +1122,22 @@ public class MulticoreVisualizerCanvas extends GraphicCanvas
public boolean isFilterActive() { public boolean isFilterActive() {
return m_canvasFilterManager.isCurrentFilterActive(); return m_canvasFilterManager.isCurrentFilterActive();
} }
@Override
public IGraphicObject getGraphicObject(Class<?> type, int x, int y) {
// Why m_cpus are not added in super.m_objects ?
IGraphicObject result = null;
for (IGraphicObject gobj : getSelectableObjects()) {
if (gobj.contains(x, y)) {
if (type != null) {
Class<?> objType = gobj.getClass();
if (! type.isAssignableFrom(objType)) continue;
}
result = gobj;
break;
}
}
return result;
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012, 2013 Ericsson and others. * Copyright (c) 2012, 2014 Ericsson and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -14,6 +14,7 @@
* Marc Dumais (Ericsson) - Bug 409512 * Marc Dumais (Ericsson) - Bug 409512
* Marc Dumais (Ericsson) - Bug 409965 * Marc Dumais (Ericsson) - Bug 409965
* Marc Dumais (Ericsson) - Bug 416524 * Marc Dumais (Ericsson) - Bug 416524
* Xavier Raynaud (Kalray) - Bug 431935
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view; package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;
@ -33,6 +34,9 @@ import org.eclipse.cdt.dsf.debug.service.IRunControl.IResumedDMEvent;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IStartedDMEvent; import org.eclipse.cdt.dsf.debug.service.IRunControl.IStartedDMEvent;
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent; import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
import org.eclipse.cdt.dsf.debug.service.IRunControl.StateChangeReason; import org.eclipse.cdt.dsf.debug.service.IRunControl.StateChangeReason;
import org.eclipse.cdt.dsf.debug.service.IStack;
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMData;
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.MulticoreVisualizerUIPlugin; import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.MulticoreVisualizerUIPlugin;
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerCore; import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerCore;
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerExecutionState; import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerExecutionState;
@ -87,6 +91,7 @@ public class MulticoreVisualizerEventListener {
IDMContext context = event.getDMContext(); IDMContext context = event.getDMContext();
// all-stop mode? If so, we take the opportunity, now that GDB has suspended // all-stop mode? If so, we take the opportunity, now that GDB has suspended
// execution, to re-create the model so that we synchronize with the debug session // execution, to re-create the model so that we synchronize with the debug session
if (context != null && isSessionAllStop(context.getSessionId()) ) { if (context != null && isSessionAllStop(context.getSessionId()) ) {
@ -104,10 +109,11 @@ public class MulticoreVisualizerEventListener {
IThreadDMContext threadContext = IThreadDMContext threadContext =
DMContexts.getAncestorOfType(execDmc, IThreadDMContext.class); DMContexts.getAncestorOfType(execDmc, IThreadDMContext.class);
DsfServicesTracker tracker = final DsfServicesTracker tracker =
new DsfServicesTracker(MulticoreVisualizerUIPlugin.getBundleContext(), new DsfServicesTracker(MulticoreVisualizerUIPlugin.getBundleContext(),
execDmc.getSessionId()); execDmc.getSessionId());
IProcesses procService = tracker.getService(IProcesses.class); IProcesses procService = tracker.getService(IProcesses.class);
final IStack stackService = tracker.getService(IStack.class);
tracker.dispose(); tracker.dispose();
procService.getExecutionData(threadContext, procService.getExecutionData(threadContext,
@ -122,16 +128,16 @@ public class MulticoreVisualizerEventListener {
if (cores != null) { if (cores != null) {
assert cores.length == 1; // A thread belongs to a single core assert cores.length == 1; // A thread belongs to a single core
int coreId = Integer.parseInt(cores[0]); int coreId = Integer.parseInt(cores[0]);
VisualizerCore vCore = model.getCore(coreId); final VisualizerCore vCore = model.getCore(coreId);
int tid = execDmc.getThreadId(); int tid = execDmc.getThreadId();
VisualizerThread thread = model.getThread(tid); final VisualizerThread thread = model.getThread(tid);
if (thread != null) { if (thread != null) {
assert thread.getState() == VisualizerExecutionState.RUNNING; assert thread.getState() == VisualizerExecutionState.RUNNING;
VisualizerExecutionState newState = VisualizerExecutionState.SUSPENDED; VisualizerExecutionState _newState = VisualizerExecutionState.SUSPENDED;
if (event.getReason() == StateChangeReason.SIGNAL) { if (event.getReason() == StateChangeReason.SIGNAL) {
if (event instanceof IMIDMEvent) { if (event instanceof IMIDMEvent) {
@ -139,15 +145,42 @@ public class MulticoreVisualizerEventListener {
if (miEvent instanceof MISignalEvent) { if (miEvent instanceof MISignalEvent) {
String signalName = ((MISignalEvent)miEvent).getName(); String signalName = ((MISignalEvent)miEvent).getName();
if (DSFDebugModel.isCrashSignal(signalName)) { if (DSFDebugModel.isCrashSignal(signalName)) {
newState = VisualizerExecutionState.CRASHED; _newState = VisualizerExecutionState.CRASHED;
} }
} }
} }
} }
final VisualizerExecutionState newState = _newState;
thread.setState(newState); if (stackService != null) {
thread.setCore(vCore); stackService.getTopFrame(execDmc,
fVisualizer.refresh(); 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();
}
updateThread(thread, newState, vCore, frameData);
}
});
} else {
updateThread(thread, newState, vCore, null);
}
}
});
} else {
updateThread(thread, newState, vCore, null);
}
} }
} }
} }
@ -156,6 +189,13 @@ public class MulticoreVisualizerEventListener {
); );
} }
} }
private void updateThread(VisualizerThread thread, VisualizerExecutionState newState, VisualizerCore vCore, IFrameDMData frameData) {
thread.setState(newState);
thread.setCore(vCore);
thread.setLocationInfo(frameData);
fVisualizer.refresh();
}
/** Invoked when a thread or process is resumed. */ /** Invoked when a thread or process is resumed. */
@DsfServiceEventHandler @DsfServiceEventHandler
@ -173,6 +213,7 @@ public class MulticoreVisualizerEventListener {
List<VisualizerThread> tList = model.getThreads(); List<VisualizerThread> tList = model.getThreads();
for(VisualizerThread t : tList) { for(VisualizerThread t : tList) {
t.setState(VisualizerExecutionState.RUNNING); t.setState(VisualizerExecutionState.RUNNING);
t.setLocationInfo((String) null);
} }
fVisualizer.getMulticoreVisualizerCanvas().requestUpdate(); fVisualizer.getMulticoreVisualizerCanvas().requestUpdate();
return; return;
@ -192,6 +233,7 @@ public class MulticoreVisualizerEventListener {
thread.getState() == VisualizerExecutionState.CRASHED; thread.getState() == VisualizerExecutionState.CRASHED;
thread.setState(VisualizerExecutionState.RUNNING); thread.setState(VisualizerExecutionState.RUNNING);
thread.setLocationInfo((String) null);
fVisualizer.getMulticoreVisualizerCanvas().requestUpdate(); fVisualizer.getMulticoreVisualizerCanvas().requestUpdate();
} }
} }

View file

@ -7,7 +7,7 @@
* *
* Contributors: * Contributors:
* William R. Swanson (Tilera Corporation) - initial API and implementation * William R. Swanson (Tilera Corporation) - initial API and implementation
* Xavier Raynaud (Kalray) - Bug 431690, 432151 * Xavier Raynaud (Kalray) - Bug 431690, 432151, 431935
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view; package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;
@ -188,4 +188,10 @@ public class MulticoreVisualizerThread extends MulticoreVisualizerGraphicObject
} }
} }
} }
@Override
public String getTooltip(int x, int y) {
return m_thread.getLocationInfo();
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Tilera Corporation and others. * Copyright (c) 2012, 2014 Tilera Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* William R. Swanson (Tilera Corporation) - initial API and implementation * William R. Swanson (Tilera Corporation) - initial API and implementation
* Marc Dumais (Ericsson) - Add CPU/core load information to the multicore visualizer (Bug 396268) * 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; package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils;
@ -29,6 +30,9 @@ import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMData; import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMData;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMData2; import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMData2;
import org.eclipse.cdt.dsf.debug.service.IRunControl.StateChangeReason; import org.eclipse.cdt.dsf.debug.service.IRunControl.StateChangeReason;
import org.eclipse.cdt.dsf.debug.service.IStack;
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMData;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext;
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerExecutionState; import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerExecutionState;
@ -301,7 +305,7 @@ public class DSFDebugModel {
/** Requests execution state of a thread. /** Requests execution state of a thread.
* Calls back to getThreadExecutionStateDone() on listener. */ * Calls back to getThreadExecutionStateDone() on listener. */
@ConfinedToDsfExecutor("getSession().getExecutor()") @ConfinedToDsfExecutor("getSession().getExecutor()")
public static void getThreadExecutionState(DSFSessionState sessionState, public static void getThreadExecutionState(final DSFSessionState sessionState,
final ICPUDMContext cpuContext, final ICPUDMContext cpuContext,
final ICoreDMContext coreContext, final ICoreDMContext coreContext,
final IMIExecutionDMContext execContext, final IMIExecutionDMContext execContext,
@ -312,25 +316,66 @@ public class DSFDebugModel {
IRunControl runControl = sessionState.getService(IRunControl.class); IRunControl runControl = sessionState.getService(IRunControl.class);
if (runControl == null) { if (runControl == null) {
listener.getThreadExecutionStateDone(cpuContext, coreContext, execContext, threadData, null, arg); listener.getThreadExecutionStateDone(cpuContext, coreContext, execContext, threadData, null, null, arg);
return; return;
} }
if (runControl.isSuspended(execContext) == false) { if (runControl.isSuspended(execContext) == false) {
// The thread is running // The thread is running
listener.getThreadExecutionStateDone(cpuContext, coreContext, execContext, threadData, listener.getThreadExecutionStateDone(cpuContext, coreContext, execContext, threadData, null,
VisualizerExecutionState.RUNNING, arg); VisualizerExecutionState.RUNNING, arg);
} else { } else {
// For a suspended thread, let's see why it is suspended, // For a suspended thread, retrieve the current stack
// to find out if the thread is crashed 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);
}
}
}
// 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) {
IRunControl runControl = sessionState.getService(IRunControl.class);
if (runControl != null) {
runControl.getExecutionData(execContext, runControl.getExecutionData(execContext,
new ImmediateDataRequestMonitor<IExecutionDMData>() { new ImmediateDataRequestMonitor<IExecutionDMData>() {
@Override @Override
protected void handleCompleted() { protected void handleCompleted() {
IExecutionDMData executionData = getData(); IExecutionDMData executionData = getData();
VisualizerExecutionState state = VisualizerExecutionState.SUSPENDED; VisualizerExecutionState state = VisualizerExecutionState.SUSPENDED;
if (isSuccess() && executionData != null) { if (isSuccess() && executionData != null) {
if (executionData.getStateChangeReason() == StateChangeReason.SIGNAL) { if (executionData.getStateChangeReason() == StateChangeReason.SIGNAL) {
if (executionData instanceof IExecutionDMData2) { if (executionData instanceof IExecutionDMData2) {
@ -343,12 +388,12 @@ public class DSFDebugModel {
} }
} }
} }
listener.getThreadExecutionStateDone(cpuContext, coreContext, execContext, threadData, frameData, state, arg);
listener.getThreadExecutionStateDone(cpuContext, coreContext, execContext, threadData, state, arg);
} }
}); });
} else {
listener.getThreadExecutionStateDone(cpuContext, coreContext, execContext, threadData, frameData, null, arg);
} }
} }
/** /**

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012 Tilera Corporation and others. * Copyright (c) 2012, 2014 Tilera Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* William R. Swanson (Tilera Corporation) - initial API and implementation * William R. Swanson (Tilera Corporation) - initial API and implementation
* Marc Dumais (Ericsson) - Add CPU/core load information to the multicore visualizer (Bug 396268) * 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; package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils;
@ -15,6 +16,7 @@ package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils;
import org.eclipse.cdt.dsf.datamodel.IDMContext; import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData; 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.multicorevisualizer.internal.ui.model.VisualizerExecutionState;
import org.eclipse.cdt.dsf.gdb.service.IGDBHardwareAndOS.ICPUDMContext; 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.IGDBHardwareAndOS.ICoreDMContext;
@ -64,6 +66,7 @@ public interface DSFDebugModelListener {
ICoreDMContext coreContext, ICoreDMContext coreContext,
IMIExecutionDMContext threadContext, IMIExecutionDMContext threadContext,
IThreadDMData threadData, IThreadDMData threadData,
IFrameDMData frame,
VisualizerExecutionState state, VisualizerExecutionState state,
Object arg); Object arg);