From 5b11c386f9cfa5dccf566cfc2229a29da07ba4b9 Mon Sep 17 00:00:00 2001
From: eutarass
Date: Thu, 30 Jun 2011 20:54:27 +0000
Subject: TCF Debugger: implemented editor markers that show breakpoints status
for current selection in the Debug view.
---
.../org.eclipse.tm.tcf.debug.ui/plugin.properties | 1 +
plugins/org.eclipse.tm.tcf.debug.ui/plugin.xml | 19 +
.../tm/internal/tcf/debug/ui/Activator.java | 3 -
.../tm/internal/tcf/debug/ui/ImageCache.java | 3 +-
.../tcf/debug/ui/model/TCFAnnotationManager.java | 452 +++++++++++++++------
.../tm/internal/tcf/debug/ui/model/TCFModel.java | 52 +--
.../tcf/debug/ui/model/TCFNodeStackFrame.java | 5 +
.../debug/launch/TCFSourceLookupParticipant.java | 2 +-
.../tcf/debug/model/TCFBreakpointsStatus.java | 27 +-
9 files changed, 380 insertions(+), 184 deletions(-)
(limited to 'plugins')
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/plugin.properties b/plugins/org.eclipse.tm.tcf.debug.ui/plugin.properties
index 5e5f22e79..a246bf272 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/plugin.properties
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/plugin.properties
@@ -15,6 +15,7 @@ preferencePage.name = Target Communication
debugCurrentInstructionPointer = Debug Current Instruction Pointer
debugCallStack = Debug Call Stack
+debugBreakpointInstance = Breakpoint
DebuggerActionSet.label = TCF Debugger
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/plugin.xml b/plugins/org.eclipse.tm.tcf.debug.ui/plugin.xml
index 08c01f973..571483967 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/plugin.xml
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/plugin.xml
@@ -146,6 +146,9 @@
+
+
@@ -181,6 +184,22 @@
verticalRulerPreferenceKey="secondaryIPVerticalRuler"
verticalRulerPreferenceValue="true">
+
+
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/Activator.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/Activator.java
index 9f3becfcf..ae58135e7 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/Activator.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/Activator.java
@@ -40,9 +40,6 @@ public class Activator extends AbstractUIPlugin {
if (model_manager == null) {
model_manager = new TCFModelManager();
}
- if (annotation_manager == null) {
- annotation_manager = new TCFAnnotationManager();
- }
}
});
}
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/ImageCache.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/ImageCache.java
index 9ea786aee..42ac06899 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/ImageCache.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/ImageCache.java
@@ -63,7 +63,8 @@ public class ImageCache {
IMG_BREAKPOINT_DISABLED = "icons/full/obj16/brkpd_obj.gif",
IMG_BREAKPOINT_INSTALLED = "icons/ovr16/installed_ovr.gif",
IMG_BREAKPOINT_CONDITIONAL = "icons/ovr16/conditional_ovr.gif",
- IMG_BREAKPOINT_WARNING = "icons/ovr16/warning_ovr.gif";
+ IMG_BREAKPOINT_WARNING = "icons/ovr16/warning_ovr.gif",
+ IMG_BREAKPOINT_ERROR = "icons/ovr16/error_ovr.gif";
private static final Map desc_cache = new HashMap();
private static final Map image_cache = new HashMap();
diff --git a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFAnnotationManager.java b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFAnnotationManager.java
index 1bd5d35d6..3e81bb7dd 100644
--- a/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFAnnotationManager.java
+++ b/plugins/org.eclipse.tm.tcf.debug.ui/src/org/eclipse/tm/internal/tcf/debug/ui/model/TCFAnnotationManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2008, 2011 Wind River Systems, Inc. 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
@@ -10,36 +10,56 @@
*******************************************************************************/
package org.eclipse.tm.internal.tcf.debug.ui.model;
+import java.math.BigInteger;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
-import java.util.Set;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.model.ISourceLocator;
+import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants;
-import org.eclipse.debug.ui.IDebugView;
+import org.eclipse.debug.ui.ISourcePresentation;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.tm.internal.tcf.debug.launch.TCFSourceLookupDirector;
+import org.eclipse.tm.internal.tcf.debug.launch.TCFSourceLookupParticipant;
import org.eclipse.tm.internal.tcf.debug.model.ITCFBreakpointListener;
import org.eclipse.tm.internal.tcf.debug.model.TCFBreakpoint;
import org.eclipse.tm.internal.tcf.debug.model.TCFBreakpointsStatus;
import org.eclipse.tm.internal.tcf.debug.model.TCFLaunch;
+import org.eclipse.tm.internal.tcf.debug.model.TCFSourceRef;
+import org.eclipse.tm.internal.tcf.debug.ui.Activator;
+import org.eclipse.tm.internal.tcf.debug.ui.ImageCache;
import org.eclipse.tm.tcf.protocol.IChannel;
import org.eclipse.tm.tcf.protocol.Protocol;
import org.eclipse.tm.tcf.services.IBreakpoints;
+import org.eclipse.tm.tcf.services.ILineNumbers;
+import org.eclipse.tm.tcf.services.IRunControl;
+import org.eclipse.tm.tcf.util.TCFDataCache;
+import org.eclipse.tm.tcf.util.TCFTask;
import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWindowListener;
-import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
@@ -50,18 +70,19 @@ public class TCFAnnotationManager {
class TCFAnnotation extends Annotation {
- final TCFModel model;
- final String exe_id;
- final ITextEditor editor;
+ final ILineNumbers.CodeArea area;
final Image image;
- final Position position;
+ final String text;
+ final int hash_code;
- TCFAnnotation(TCFModel model, String exe_id, ITextEditor editor, Image image, Position position) {
- this.model = model;
- this.exe_id = exe_id;
- this.editor = editor;
+ IAnnotationModel model;
+
+ TCFAnnotation(ILineNumbers.CodeArea area, Image image, String text) {
+ this.area = area;
this.image = image;
- this.position = position;
+ this.text = text;
+ hash_code = area.hashCode() + image.hashCode() + text.hashCode();
+ setText(text);
}
protected Image getImage() {
@@ -70,17 +91,30 @@ public class TCFAnnotationManager {
void dispose() {
assert Thread.currentThread() == display.getThread();
- IDocumentProvider doc_provider = editor.getDocumentProvider();
- IEditorInput editor_input = editor.getEditorInput();
- if (doc_provider != null) {
- IAnnotationModel ann_model = doc_provider.getAnnotationModel(editor_input);
- if (ann_model != null) ann_model.removeAnnotation(this);
+ if (model != null) {
+ model.removeAnnotation(this);
+ model = null;
}
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof TCFAnnotation)) return false;
+ TCFAnnotation a = (TCFAnnotation)o;
+ if (!area.equals(a.area)) return false;
+ if (!image.equals(a.image)) return false;
+ if (!text.equals(a.text)) return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return hash_code;
+ }
}
private class WorkbenchWindowInfo {
- final ArrayList annotations = new ArrayList();
+ final LinkedList annotations = new LinkedList();
void dispose() {
for (TCFAnnotation a : annotations) a.dispose();
@@ -92,6 +126,9 @@ public class TCFAnnotationManager {
private final HashMap windows =
new HashMap();
+ private final HashSet dirty_windows = new HashSet();
+ private final HashSet dirty_launches = new HashSet();
+
private final TCFLaunch.LaunchListener launch_listener = new TCFLaunch.LaunchListener() {
public void onCreated(TCFLaunch launch) {
@@ -99,26 +136,17 @@ public class TCFAnnotationManager {
public void onConnected(final TCFLaunch launch) {
updateActiveLaunch();
+ updateAnnotations(null, launch);
TCFBreakpointsStatus bps = launch.getBreakpointsStatus();
if (bps == null) return;
bps.addListener(new ITCFBreakpointListener() {
public void breakpointStatusChanged(String id) {
- displayExec(new Runnable() {
- public void run() {
- if (active_launch != launch) return;
- refreshBreakpointView();
- }
- });
+ updateAnnotations(null, launch);
}
public void breakpointRemoved(String id) {
- displayExec(new Runnable() {
- public void run() {
- if (active_launch != launch) return;
- refreshBreakpointView();
- }
- });
+ updateAnnotations(null, launch);
}
public void breakpointChanged(String id) {
@@ -128,22 +156,8 @@ public class TCFAnnotationManager {
public void onDisconnected(final TCFLaunch launch) {
assert Protocol.isDispatchThread();
- synchronized (Device.class) {
- displayExec(new Runnable() {
- public void run() {
- for (WorkbenchWindowInfo info : windows.values()) {
- for (Iterator i = info.annotations.iterator(); i.hasNext();) {
- TCFAnnotation a = i.next();
- if (a.model.getLaunch() == launch) {
- i.remove();
- a.dispose();
- }
- }
- }
- }
- });
- }
updateActiveLaunch();
+ updateAnnotations(null, launch);
}
public void onProcessOutput(TCFLaunch launch, String process_id, int stream_id, byte[] data) {
@@ -158,6 +172,7 @@ public class TCFAnnotationManager {
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
updateActiveLaunch();
+ updateAnnotations(part.getSite().getWorkbenchWindow(), (TCFLaunch)null);
}
};
@@ -185,12 +200,13 @@ public class TCFAnnotationManager {
IDebugUIConstants.ID_DEBUG_VIEW, selection_listener);
windows.put(window, new WorkbenchWindowInfo());
updateActiveLaunch();
+ updateAnnotations(window, (TCFLaunch)null);
}
};
private final Display display = Display.getDefault();
- private int refresh_breakpoint_view_cnt = 0;
private int update_active_launch_cnt = 0;
+ private int update_unnotations_cnt = 0;
private boolean started;
private boolean disposed;
@@ -253,35 +269,12 @@ public class TCFAnnotationManager {
if (adaptable != null) {
ILaunch x = (ILaunch)adaptable.getAdapter(ILaunch.class);
if (x instanceof TCFLaunch) {
- final TCFLaunch l = (TCFLaunch)x;
- final boolean[] b = new boolean[1];
- Protocol.invokeAndWait(new Runnable() {
- public void run() {
- IChannel channel = l.getChannel();
- b[0] = channel != null && channel.getState() == IChannel.STATE_OPEN;
- }
- });
- if (b[0]) launch = l;
+ TCFLaunch l = (TCFLaunch)x;
+ IChannel channel = l.getChannel();
+ if (channel != null && channel.getState() == IChannel.STATE_OPEN) launch = l;
}
}
- if (active_launch != launch) {
- active_launch = launch;
- refreshBreakpointView();
- }
- }
- });
- }
-
- private void refreshBreakpointView() {
- assert !disposed;
- final int cnt = ++refresh_breakpoint_view_cnt;
- displayExec(new Runnable() {
- public void run() {
- if (cnt != refresh_breakpoint_view_cnt) return;
- for (IWorkbenchWindow window : windows.keySet()) {
- IDebugView view = (IDebugView)window.getActivePage().findView(IDebugUIConstants.ID_BREAKPOINT_VIEW);
- if (view != null) view.getViewer().refresh();
- }
+ active_launch = launch;
}
});
}
@@ -290,7 +283,7 @@ public class TCFAnnotationManager {
assert Protocol.isDispatchThread();
if (disposed) return null;
final TCFLaunch launch = active_launch;
- if (launch != null && launch.getBreakpointsStatus() != null) {
+ if (launch != null) {
TCFBreakpointsStatus bs = launch.getBreakpointsStatus();
if (bs != null) {
Map map = bs.getStatus(breakpoint);
@@ -307,74 +300,273 @@ public class TCFAnnotationManager {
return null;
}
- void addStackFrameAnnotation(TCFModel model, String exe_id, boolean top_frame,
- IWorkbenchPage page, ITextEditor editor, IRegion region) {
- if (disposed) return;
- assert Thread.currentThread() == display.getThread();
- TCFAnnotation annotation = null;
- IAnnotationModel ann_model = null;
+ @SuppressWarnings("unchecked")
+ private Object[] toObjectArray(Object o) {
+ if (o == null) return null;
+ Collection