Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreutarass2008-06-04 20:57:08 +0000
committereutarass2008-06-04 20:57:08 +0000
commit72cddcac552c4ae7d945157e34bd5d737d6e801d (patch)
tree11a73bbf915d49c38629b161f468e31565976411 /plugins/org.eclipse.tm.tcf.debug
parentc8ed77ecfd7c897791825f30846b5f5c09d534af (diff)
downloadorg.eclipse.tcf-72cddcac552c4ae7d945157e34bd5d737d6e801d.tar.gz
org.eclipse.tcf-72cddcac552c4ae7d945157e34bd5d737d6e801d.tar.xz
org.eclipse.tcf-72cddcac552c4ae7d945157e34bd5d737d6e801d.zip
1. Source line breakpoints are implemented.
2. TCF agent bug fixed: hash functions could return negative number causing memory corruption. 3. TCF agent: switched to latest version of dbghelp.dll - Windows XP comes with broken version of the DLL. 4. TCF agent: fixed a bug in DWARF line number information reader.
Diffstat (limited to 'plugins/org.eclipse.tm.tcf.debug')
-rw-r--r--plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFSourceLookupParticipant.java36
-rw-r--r--plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFBreakpointsModel.java86
2 files changed, 90 insertions, 32 deletions
diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFSourceLookupParticipant.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFSourceLookupParticipant.java
index 717af08e3..5ef55e5ee 100644
--- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFSourceLookupParticipant.java
+++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/launch/TCFSourceLookupParticipant.java
@@ -10,7 +10,13 @@
*******************************************************************************/
package org.eclipse.tm.internal.tcf.debug.launch;
+import java.io.File;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant;
import org.eclipse.tm.tcf.services.ILineNumbers;
@@ -21,10 +27,40 @@ import org.eclipse.tm.tcf.services.ILineNumbers;
public class TCFSourceLookupParticipant extends AbstractSourceLookupParticipant {
public String getSourceName(Object object) throws CoreException {
+ if (object instanceof String) {
+ return (String)object;
+ }
if (object instanceof ILineNumbers.CodeArea) {
ILineNumbers.CodeArea area = (ILineNumbers.CodeArea)object;
+ // TODO: map file path from remote file system to local
+ if (area.directory != null && area.file != null) {
+ return new File(area.directory, area.file).getAbsolutePath();
+ }
return area.file;
}
return null;
}
+
+ @Override
+ public Object[] findSourceElements(Object object) throws CoreException {
+ String name = getSourceName(object);
+ if (name != null) {
+ IPath path = new Path(name);
+ if (path.isAbsolute()) {
+ IFile[] arr = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(path);
+ if (arr != null && arr.length > 0) return arr;
+ }
+ }
+ Object[] res = super.findSourceElements(name);
+ if (name != null && (res == null || res.length == 0)) {
+ // Remove file path and search by file base name
+ String base = name;
+ int i = name.lastIndexOf('/');
+ int j = name.lastIndexOf('\\');
+ if (i > j) base = name.substring(i + 1);
+ if (j > i) base = name.substring(j + 1);
+ res = super.findSourceElements(base);
+ }
+ return res;
+ }
}
diff --git a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFBreakpointsModel.java b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFBreakpointsModel.java
index 00ae04f60..a38779f98 100644
--- a/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFBreakpointsModel.java
+++ b/plugins/org.eclipse.tm.tcf.debug/src/org/eclipse/tm/internal/tcf/debug/model/TCFBreakpointsModel.java
@@ -44,7 +44,6 @@ import org.eclipse.tm.tcf.services.IBreakpoints;
*/
public class TCFBreakpointsModel implements IBreakpointListener, IBreakpointManagerListener {
- private static final String PROP_ID = "ID";
private final IBreakpointManager bp_manager = DebugPlugin.getDefault().getBreakpointManager();
public TCFBreakpointsModel() {
@@ -66,20 +65,31 @@ public class TCFBreakpointsModel implements IBreakpointListener, IBreakpointMana
return true;
}
+ private String getBreakpointID(IBreakpoint bp) throws CoreException {
+ IMarker marker = bp.getMarker();
+ String id = (String)marker.getAttributes().get(ITCFConstants.ID_TCF_DEBUG_MODEL + '.' + IBreakpoints.PROP_ID);
+ if (id != null) return id;
+ id = marker.getResource().getLocationURI().toString();
+ if (id == null) return null;
+ return id + ':' + marker.getId();
+ }
+
@SuppressWarnings("unchecked")
public void downloadBreakpoints(final IChannel channel, final Runnable done)
throws IOException, CoreException {
assert Protocol.isDispatchThread();
IBreakpoints service = channel.getRemoteService(IBreakpoints.class);
if (service != null) {
- IBreakpoint[] arr = bp_manager.getBreakpoints(ITCFConstants.ID_TCF_DEBUG_MODEL);
+ IBreakpoint[] arr = bp_manager.getBreakpoints();
if (arr != null && arr.length > 0) {
Map<String,Object>[] bps = new Map[arr.length];
for (int i = 0; i < arr.length; i++) {
if (!isSupported(channel, arr[i])) continue;
+ String id = getBreakpointID(arr[i]);
+ if (id == null) continue;
IMarker marker = arr[i].getMarker();
String file = getFilePath(marker.getResource());
- bps[i] = toBreakpointAttributes(file, marker.getAttributes());
+ bps[i] = toBreakpointAttributes(id, file, marker.getAttributes());
}
service.set(bps, new IBreakpoints.DoneCommand() {
public void doneCommand(IToken token, Exception error) {
@@ -95,15 +105,15 @@ public class TCFBreakpointsModel implements IBreakpointListener, IBreakpointMana
public void breakpointManagerEnablementChanged(final boolean enabled) {
try {
- IBreakpoint[] arr = bp_manager.getBreakpoints(ITCFConstants.ID_TCF_DEBUG_MODEL);
+ IBreakpoint[] arr = bp_manager.getBreakpoints();
if (arr == null || arr.length == 0) return;
final Map<String,IBreakpoint> map = new HashMap<String,IBreakpoint>();
for (int i = 0; i < arr.length; i++) {
IMarker marker = arr[i].getMarker();
Boolean b = marker.getAttribute(IBreakpoint.ENABLED, Boolean.FALSE);
if (!b.booleanValue()) continue;
- String id = marker.getAttribute(ITCFConstants.ID_TCF_DEBUG_MODEL +
- '.' + IBreakpoints.PROP_ID, (String)null);
+ String id = getBreakpointID(arr[i]);
+ if (id == null) continue;
map.put(id, arr[i]);
}
if (map.isEmpty()) return;
@@ -162,6 +172,7 @@ public class TCFBreakpointsModel implements IBreakpointListener, IBreakpointMana
private final ILaunch[] launches;
private final Map<String,Object> marker_attrs;
private final String marker_file;
+ private final String marker_id;
IBreakpoints service;
IBreakpoints.DoneCommand done;
@@ -172,6 +183,7 @@ public class TCFBreakpointsModel implements IBreakpointListener, IBreakpointMana
this.breakpoint = breakpoint;
marker_attrs = new HashMap<String,Object>(breakpoint.getMarker().getAttributes());
marker_file = getFilePath(breakpoint.getMarker().getResource());
+ marker_id = getBreakpointID(breakpoint);
launches = DebugPlugin.getDefault().getLaunchManager().getLaunches();
}
@@ -182,22 +194,24 @@ public class TCFBreakpointsModel implements IBreakpointListener, IBreakpointMana
}
public void run() {
- tcf_attrs = toBreakpointAttributes(marker_file, marker_attrs);
- for (int i = 0; i < launches.length; i++) {
- if (launches[i] instanceof TCFLaunch) {
- final TCFLaunch launch = (TCFLaunch)launches[i];
- final IChannel channel = launch.getChannel();
- if (channel == null) continue;
- if (channel.getState() != IChannel.STATE_OPEN) continue;
- service = channel.getRemoteService(IBreakpoints.class);
- if (service == null) continue;
- if (!isSupported(channel, breakpoint)) continue;
- done = new IBreakpoints.DoneCommand() {
- public void doneCommand(IToken token, Exception error) {
- if (error != null) channel.terminate(error);
- }
- };
- update();
+ if (marker_id != null) {
+ tcf_attrs = toBreakpointAttributes(marker_id, marker_file, marker_attrs);
+ for (int i = 0; i < launches.length; i++) {
+ if (launches[i] instanceof TCFLaunch) {
+ final TCFLaunch launch = (TCFLaunch)launches[i];
+ final IChannel channel = launch.getChannel();
+ if (channel == null) continue;
+ if (channel.getState() != IChannel.STATE_OPEN) continue;
+ service = channel.getRemoteService(IBreakpoints.class);
+ if (service == null) continue;
+ if (!isSupported(channel, breakpoint)) continue;
+ done = new IBreakpoints.DoneCommand() {
+ public void doneCommand(IToken token, Exception error) {
+ if (error != null) channel.terminate(error);
+ }
+ };
+ update();
+ }
}
}
Protocol.sync(new Runnable() {
@@ -221,7 +235,6 @@ public class TCFBreakpointsModel implements IBreakpointListener, IBreakpointMana
public void breakpointAdded(IBreakpoint breakpoint) {
try {
- if (!breakpoint.getModelIdentifier().equals(ITCFConstants.ID_TCF_DEBUG_MODEL)) return;
new BreakpointUpdate(breakpoint) {
@Override
void update() {
@@ -259,7 +272,6 @@ public class TCFBreakpointsModel implements IBreakpointListener, IBreakpointMana
public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
try {
- if (!breakpoint.getModelIdentifier().equals(ITCFConstants.ID_TCF_DEBUG_MODEL)) return;
final Set<String> s = calcMarkerDeltaKeys(breakpoint.getMarker(), delta);
if (s.isEmpty()) return;
new BreakpointUpdate(breakpoint) {
@@ -268,10 +280,10 @@ public class TCFBreakpointsModel implements IBreakpointListener, IBreakpointMana
if (s.size() == 1 && s.contains(IBreakpoint.ENABLED)) {
Boolean enabled = (Boolean)tcf_attrs.get(IBreakpoints.PROP_ENABLED);
if (enabled == null || !enabled.booleanValue()) {
- service.disable(new String[]{ (String)tcf_attrs.get(PROP_ID) }, done);
+ service.disable(new String[]{ (String)tcf_attrs.get(IBreakpoints.PROP_ID) }, done);
}
else {
- service.enable(new String[]{ (String)tcf_attrs.get(PROP_ID) }, done);
+ service.enable(new String[]{ (String)tcf_attrs.get(IBreakpoints.PROP_ID) }, done);
}
}
else {
@@ -287,11 +299,10 @@ public class TCFBreakpointsModel implements IBreakpointListener, IBreakpointMana
public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
try {
- if (!breakpoint.getModelIdentifier().equals(ITCFConstants.ID_TCF_DEBUG_MODEL)) return;
new BreakpointUpdate(breakpoint) {
@Override
void update() {
- service.remove(new String[]{ (String)tcf_attrs.get(PROP_ID) }, done);
+ service.remove(new String[]{ (String)tcf_attrs.get(IBreakpoints.PROP_ID) }, done);
}
}.exec();
}
@@ -324,7 +335,7 @@ public class TCFBreakpointsModel implements IBreakpointListener, IBreakpointMana
m.put(IMarker.MESSAGE, "Breakpoint: " + msg);
Number line = (Number)p.get(IBreakpoints.PROP_LINE);
if (line != null) {
- m.put(IMarker.LINE_NUMBER, new Integer(line.intValue() + 1));
+ m.put(IMarker.LINE_NUMBER, new Integer(line.intValue()));
Number column = (Number)p.get(IBreakpoints.PROP_COLUMN);
if (column != null) {
m.put(IMarker.CHAR_START, new Integer(column.intValue()));
@@ -334,9 +345,10 @@ public class TCFBreakpointsModel implements IBreakpointListener, IBreakpointMana
return m;
}
- public Map<String,Object> toBreakpointAttributes(String file, Map<String,Object> p) {
+ public Map<String,Object> toBreakpointAttributes(String id, String file, Map<String,Object> p) {
assert Protocol.isDispatchThread();
Map<String,Object> m = new HashMap<String,Object>();
+ m.put(IBreakpoints.PROP_ID, id);
for (Iterator<Map.Entry<String,Object>> i = p.entrySet().iterator(); i.hasNext();) {
Map.Entry<String,Object> e = i.next();
String key = e.getKey();
@@ -349,14 +361,24 @@ public class TCFBreakpointsModel implements IBreakpointListener, IBreakpointMana
m.put(IBreakpoints.PROP_ENABLED, enabled);
}
if (file != null) {
- m.put(IBreakpoints.PROP_FILE, file);
+ // Map file path to remote file system
+ int i = file.lastIndexOf('/');
+ int j = file.lastIndexOf('\\');
+ String name = file;
+ if (i > j) name = file.substring(i + 1);
+ else if (i < j) name = file.substring(j + 1);
+ m.put(IBreakpoints.PROP_FILE, name);
Integer line = (Integer)p.get(IMarker.LINE_NUMBER);
if (line != null) {
- m.put(IBreakpoints.PROP_LINE, new Integer(line.intValue() - 1));
+ m.put(IBreakpoints.PROP_LINE, new Integer(line.intValue()));
Integer column = (Integer)p.get(IMarker.CHAR_START);
if (column != null) m.put(IBreakpoints.PROP_COLUMN, column);
}
}
+ String condition = (String)p.get("org.eclipse.cdt.debug.core.condition");
+ if (condition != null && condition.length() > 0) m.put(IBreakpoints.PROP_CONDITION, condition);
+ Integer skip_count = (Integer)p.get("org.eclipse.cdt.debug.core.ignoreCount");
+ if (skip_count != null && skip_count.intValue() > 0) m.put(IBreakpoints.PROP_SKIP_COUNT, skip_count);
return m;
}
}

Back to the top