Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlvaro Sanchez-Leon2016-03-16 00:50:13 +0000
committerMarc Khouzam2016-03-20 01:03:51 +0000
commitba6eb9e0f0aedafe848ea43320138c25b6882718 (patch)
tree6c85b15e5a4a7f973558302630628dfc95629065 /dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui
parenta56abb4783d3029f54a523fad248d8dceec4497d (diff)
downloadorg.eclipse.cdt-ba6eb9e0f0aedafe848ea43320138c25b6882718.tar.gz
org.eclipse.cdt-ba6eb9e0f0aedafe848ea43320138c25b6882718.tar.xz
org.eclipse.cdt-ba6eb9e0f0aedafe848ea43320138c25b6882718.zip
Bug 489777 - [API] Replace thread id type from int to String
in preparation for the introduction of thread groups syntax in GDB, thread id needs to be handled as a String. Change-Id: I379a92de9755ba0532265519ee70d1e199de811b
Diffstat (limited to 'dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui')
-rwxr-xr-xdsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizer.java29
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerEventListener.java76
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerSelectionFinder.java12
3 files changed, 97 insertions, 20 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizer.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizer.java
index 05aaeebf6f0..1bfbcda2b9d 100755
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizer.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizer.java
@@ -86,6 +86,8 @@ import org.eclipse.cdt.visualizer.ui.util.GUIUtils;
import org.eclipse.cdt.visualizer.ui.util.SelectionUtils;
import org.eclipse.cdt.visualizer.ui.util.Timer;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.internal.ui.commands.actions.DropToFrameCommandAction;
import org.eclipse.debug.internal.ui.commands.actions.ResumeCommandAction;
@@ -120,7 +122,9 @@ import org.eclipse.swt.widgets.Composite;
public class MulticoreVisualizer extends GraphicCanvasVisualizer implements IPinnable {
// --- constants ---
- /** Eclipse ID for this view */
+ private static final String THE_THREAD_ID_DOES_NOT_CONVERT_TO_AN_INTEGER = "The thread id does not convert to an integer: "; //$NON-NLS-1$
+
+ /** Eclipse ID for this view */
public static final String ECLIPSE_ID = "org.eclipse.cdt.dsf.gdb.multicorevisualizer.visualizer"; //$NON-NLS-1$
// --- members ---
@@ -999,7 +1003,16 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer implements IPin
IMIExecutionDMContext execContext =
DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class);
- int tid = (execContext == null) ? 0 : execContext.getThreadId();
+
+ int tid = 0;
+ if (execContext != null) {
+ try {
+ tid = Integer.parseInt(execContext.getThreadId());
+ } catch (NumberFormatException e) {
+ // continue tid=0
+ assert false : THE_THREAD_ID_DOES_NOT_CONVERT_TO_AN_INTEGER + execContext.getThreadId();
+ }
+ }
if (tid == 0) { // process
List<VisualizerThread> threads = model.getThreadsForProcess(pid);
@@ -1406,7 +1419,17 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer implements IPin
IMIProcessDMContext processContext =
DMContexts.getAncestorOfType(execContext, IMIProcessDMContext.class);
int pid = Integer.parseInt(processContext.getProcId());
- int tid = execContext.getThreadId();
+ int tid;
+ try {
+ tid = Integer.parseInt(execContext.getThreadId());
+ } catch (NumberFormatException e) {
+ rm.setStatus(new Status(IStatus.ERROR, MulticoreVisualizerUIPlugin.PLUGIN_ID, IStatus.ERROR,
+ "Unxepected thread id format:" + execContext.getThreadId(), e)); //$NON-NLS-1$
+ rm.done();
+ assert false : THE_THREAD_ID_DOES_NOT_CONVERT_TO_AN_INTEGER + execContext.getThreadId();
+ return;
+ }
+
String osTIDValue = threadData.getId();
// If we can't get the real Linux OS tid, fallback to using the gdb thread id
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerEventListener.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerEventListener.java
index 9ab24c3044f..901c2d52b88 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerEventListener.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerEventListener.java
@@ -61,7 +61,8 @@ import org.eclipse.cdt.dsf.service.DsfServicesTracker;
*/
public class MulticoreVisualizerEventListener {
- // --- members ---
+ private static final String THE_THREAD_ID_DOES_NOT_CONVERT_TO_AN_INTEGER = "The thread id does not convert to an integer: "; //$NON-NLS-1$
+ // --- members ---
/** Visualizer we're managing events for. */
protected MulticoreVisualizer fVisualizer;
@@ -130,11 +131,19 @@ public class MulticoreVisualizerEventListener {
int coreId = Integer.parseInt(cores[0]);
final VisualizerCore vCore = model.getCore(coreId);
- int tid = execDmc.getThreadId();
-
- final VisualizerThread thread = model.getThread(tid);
+ int tid;
+ VisualizerThread threadTmp = null;
+ try {
+ tid = Integer.parseInt(execDmc.getThreadId());
+ threadTmp = model.getThread(tid);
+ } catch (NumberFormatException e) {
+ // unable to resolve thread
+ assert false : THE_THREAD_ID_DOES_NOT_CONVERT_TO_AN_INTEGER + execDmc.getThreadId();
+ return;
+ }
- if (thread != null) {
+ if (threadTmp != null) {
+ final VisualizerThread thread = threadTmp;
assert thread.getState() == VisualizerExecutionState.RUNNING;
VisualizerExecutionState _newState = VisualizerExecutionState.SUSPENDED;
@@ -224,11 +233,19 @@ public class MulticoreVisualizerEventListener {
// We don't deal with processes
} else if (context instanceof IMIExecutionDMContext) {
// Thread resumed
- int tid = ((IMIExecutionDMContext)context).getThreadId();
+ int tid;
+ VisualizerThread thread = null;
+ String strThreadId = ((IMIExecutionDMContext) context).getThreadId();
+ try {
+ tid = Integer.parseInt(strThreadId);
+ thread = model.getThread(tid);
+ } catch (NumberFormatException e) {
+ // unable to resolve thread
+ assert false : THE_THREAD_ID_DOES_NOT_CONVERT_TO_AN_INTEGER + strThreadId;
+ return;
+ }
- VisualizerThread thread = model.getThread(tid);
-
- if (thread != null) {
+ if (thread != null) {
assert thread.getState() == VisualizerExecutionState.SUSPENDED ||
thread.getState() == VisualizerExecutionState.CRASHED;
@@ -267,7 +284,15 @@ public class MulticoreVisualizerEventListener {
if (vCore == null) return;
int pid = Integer.parseInt(processContext.getProcId());
- int tid = execDmc.getThreadId();
+
+ int tid;
+ try {
+ tid = Integer.parseInt(execDmc.getThreadId());
+ } catch (NumberFormatException e) {
+ // unable to resolve thread
+ assert false : THE_THREAD_ID_DOES_NOT_CONVERT_TO_AN_INTEGER + execDmc.getThreadId();
+ return;
+ }
int osTid = 0;
@@ -321,7 +346,14 @@ public class MulticoreVisualizerEventListener {
return;
int pid = Integer.parseInt(processContext.getProcId());
- int tid = execDmc.getThreadId();
+ int tid;
+ try {
+ tid = Integer.parseInt(execDmc.getThreadId());
+ } catch (NumberFormatException e) {
+ // Unable to resolve thread information
+ assert false : THE_THREAD_ID_DOES_NOT_CONVERT_TO_AN_INTEGER + execDmc.getThreadId();
+ return;
+ }
int osTid = 0;
try {
@@ -382,7 +414,16 @@ public class MulticoreVisualizerEventListener {
IDMContext[] contexts = getData();
for (IDMContext c : contexts) {
if (c instanceof IMIExecutionDMContext) {
- int tid = ((IMIExecutionDMContext)c).getThreadId();
+ int tid;
+ String strThreadId = ((IMIExecutionDMContext) c).getThreadId();
+ try {
+ tid = Integer.parseInt(strThreadId);
+ } catch (NumberFormatException e) {
+ // unable to resolve the thread id
+ assert false : THE_THREAD_ID_DOES_NOT_CONVERT_TO_AN_INTEGER + strThreadId;
+ continue;
+ }
+
model.markThreadExited(tid);
}
}
@@ -401,10 +442,15 @@ public class MulticoreVisualizerEventListener {
} else if (context instanceof IMIExecutionDMContext) {
// Thread exited
- int tid = ((IMIExecutionDMContext)context).getThreadId();
+ int tid;
+ String strThreadId = ((IMIExecutionDMContext) context).getThreadId();
+ try {
+ tid = Integer.parseInt(strThreadId);
+ model.markThreadExited(tid);
+ } catch (NumberFormatException e) {
+ assert false : THE_THREAD_ID_DOES_NOT_CONVERT_TO_AN_INTEGER + strThreadId;
+ }
- model.markThreadExited(tid);
-
if (canvas != null) {
canvas.requestUpdate();
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerSelectionFinder.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerSelectionFinder.java
index 18548113cf6..3ccdeccb108 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerSelectionFinder.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerSelectionFinder.java
@@ -140,8 +140,16 @@ public class MulticoreVisualizerSelectionFinder
{
IMIExecutionDMContext execContext =
DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class);
- int tid = (execContext == null) ? 0 :
- execContext.getThreadId();
+ int tid = 0;
+ if (execContext != null) {
+ try {
+ tid = Integer.parseInt(execContext.getThreadId());
+ } catch (NumberFormatException e) {
+ // Unable to resolve thread id
+ assert false : "The thread id does not convert to an integer: " + execContext.getThreadId(); //$NON-NLS-1$
+ }
+ }
+
return tid;
}

Back to the top