Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorMikhail Khodjaiants2007-06-12 16:01:28 +0000
committerMikhail Khodjaiants2007-06-12 16:01:28 +0000
commit9a6485265787f3b1fe899db6422f20aecec4f18b (patch)
tree6f8ef6458ed09f7f8a35355d5a98a2bad7b67baf /debug
parent81aa5dcb4d43c5fe00b8f1dc5daf7975a33a6ce3 (diff)
downloadorg.eclipse.cdt-9a6485265787f3b1fe899db6422f20aecec4f18b.tar.gz
org.eclipse.cdt-9a6485265787f3b1fe899db6422f20aecec4f18b.tar.xz
org.eclipse.cdt-9a6485265787f3b1fe899db6422f20aecec4f18b.zip
Bug 186929: Run to Line and Resume At Line should be passing absolute path to CDI client.
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java148
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineAdapter.java49
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineAdapter.java3
3 files changed, 122 insertions, 78 deletions
diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java
index 61fdfb3a395..74d1ec16d3a 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java
@@ -11,6 +11,7 @@
*******************************************************************************/
package org.eclipse.cdt.debug.mi.core.cdi.model;
+import java.io.File;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
@@ -19,6 +20,7 @@ import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIAddressLocation;
import org.eclipse.cdt.debug.core.cdi.ICDICondition;
+import org.eclipse.cdt.debug.core.cdi.ICDIFileLocation;
import org.eclipse.cdt.debug.core.cdi.ICDIFunctionLocation;
import org.eclipse.cdt.debug.core.cdi.ICDILineLocation;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
@@ -577,20 +579,24 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
public void stepUntil(ICDILocation location) throws CDIException {
CommandFactory factory = miSession.getCommandFactory();
String loc = null;
+ File file = null;
+ if (location instanceof ICDIFileLocation) {
+ String filePath = ((ICDIFileLocation)location).getFile();
+ if (filePath != null && filePath.length() > 0)
+ file = new File(filePath);
+ }
if (location instanceof ICDILineLocation) {
ICDILineLocation lineLocation = (ICDILineLocation)location;
- if (lineLocation.getFile() != null && lineLocation.getFile().length() > 0) {
- loc = lineLocation.getFile() + ":" + lineLocation.getLineNumber(); //$NON-NLS-1$
+ if (file != null) {
+ loc = file.getName() + ":" + lineLocation.getLineNumber(); //$NON-NLS-1$
}
} else if (location instanceof ICDIFunctionLocation) {
ICDIFunctionLocation funcLocation = (ICDIFunctionLocation)location;
if (funcLocation.getFunction() != null && funcLocation.getFunction().length() > 0) {
loc = funcLocation.getFunction();
}
- if (funcLocation.getFile() != null && funcLocation.getFile().length() > 0) {
- if (loc != null) {
- loc = funcLocation.getFile() + ":" + loc; //$NON-NLS-1$
- }
+ if (file != null && loc != null) {
+ loc = funcLocation.getFile() + ":" + loc; //$NON-NLS-1$
}
} else if (location instanceof ICDIAddressLocation) {
ICDIAddressLocation addrLocation = (ICDIAddressLocation)location;
@@ -675,14 +681,65 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteResume#resume(org.eclipse.cdt.debug.core.cdi.ICDILocation)
*/
public void resume(ICDILocation location) throws CDIException {
- jump(location);
+ CommandFactory factory = miSession.getCommandFactory();
+ String loc = null;
+ File file = null;
+ if (location instanceof ICDIFileLocation) {
+ String filePath = ((ICDIFileLocation)location).getFile();
+ if (filePath != null && filePath.length() > 0)
+ file = new File(filePath);
+ }
+ if (location instanceof ICDILineLocation) {
+ ICDILineLocation lineLocation = (ICDILineLocation)location;
+ if (file != null) {
+ loc = file.getName() + ":" + lineLocation.getLineNumber(); //$NON-NLS-1$
+ }
+ } else if (location instanceof ICDIFunctionLocation) {
+ ICDIFunctionLocation funcLocation = (ICDIFunctionLocation)location;
+ if (funcLocation.getFunction() != null && funcLocation.getFunction().length() > 0) {
+ loc = funcLocation.getFunction();
+ }
+ if (file != null && loc != null) {
+ loc = funcLocation.getFile() + ":" + loc; //$NON-NLS-1$
+ }
+ } else if (location instanceof ICDIAddressLocation) {
+ ICDIAddressLocation addrLocation = (ICDIAddressLocation)location;
+ if (!addrLocation.getAddress().equals(BigInteger.ZERO)) {
+ loc = "*0x" + addrLocation.getAddress().toString(16); //$NON-NLS-1$
+ }
+ }
+ // Throw an exception we do know where to go
+ if (loc == null) {
+ throw new CDIException(CdiResources.getString("cdi.mode.Target.Bad_location")); //$NON-NLS-1$
+ }
+
+ CLIJump jump = factory.createCLIJump(loc);
+ try {
+ miSession.postCommand(jump);
+ MIInfo info = jump.getMIInfo();
+ if (info == null) {
+ throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$
+ }
+ } catch (MIException e) {
+ throw new MI2CDIException(e);
+ }
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIExecuteResume#resume(org.eclipse.cdt.debug.core.cdi.model.ICDISignal)
*/
public void resume(ICDISignal signal) throws CDIException {
- signal(signal);
+ CommandFactory factory = miSession.getCommandFactory();
+ CLISignal sig = factory.createCLISignal(signal.getName());
+ try {
+ miSession.postCommand(sig);
+ MIInfo info = sig.getMIInfo();
+ if (info == null) {
+ throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$
+ }
+ } catch (MIException e) {
+ throw new MI2CDIException(e);
+ }
}
/* (non-Javadoc)
@@ -693,7 +750,17 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
throw new CDIException(CdiResources.getString("cdi.model.Target.Inferior_already_running")); //$NON-NLS-1$
} else if (miSession.getMIInferior().isSuspended()) {
if (passSignal) {
- signal();
+ CommandFactory factory = miSession.getCommandFactory();
+ CLISignal signal = factory.createCLISignal("0"); //$NON-NLS-1$
+ try {
+ miSession.postCommand(signal);
+ MIInfo info = signal.getMIInfo();
+ if (info == null) {
+ throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$
+ }
+ } catch (MIException e) {
+ throw new MI2CDIException(e);
+ }
} else {
continuation();
}
@@ -722,78 +789,21 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
* @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#jump(ICDILocation)
*/
public void jump(ICDILocation location) throws CDIException {
- CommandFactory factory = miSession.getCommandFactory();
- String loc = null;
- if (location instanceof ICDILineLocation) {
- ICDILineLocation lineLocation = (ICDILineLocation)location;
- if (lineLocation.getFile() != null && lineLocation.getFile().length() > 0) {
- loc = lineLocation.getFile() + ":" + lineLocation.getLineNumber(); //$NON-NLS-1$
- }
- } else if (location instanceof ICDIFunctionLocation) {
- ICDIFunctionLocation funcLocation = (ICDIFunctionLocation)location;
- if (funcLocation.getFunction() != null && funcLocation.getFunction().length() > 0) {
- loc = funcLocation.getFunction();
- }
- if (funcLocation.getFile() != null && funcLocation.getFile().length() > 0) {
- if (loc != null) {
- loc = funcLocation.getFile() + ":" + loc; //$NON-NLS-1$
- }
- }
- } else if (location instanceof ICDIAddressLocation) {
- ICDIAddressLocation addrLocation = (ICDIAddressLocation)location;
- if (!addrLocation.getAddress().equals(BigInteger.ZERO)) {
- loc = "*0x" + addrLocation.getAddress().toString(16); //$NON-NLS-1$
- }
- }
- // Throw an exception we do know where to go
- if (loc == null) {
- throw new CDIException(CdiResources.getString("cdi.mode.Target.Bad_location")); //$NON-NLS-1$
- }
-
- CLIJump jump = factory.createCLIJump(loc);
- try {
- miSession.postCommand(jump);
- MIInfo info = jump.getMIInfo();
- if (info == null) {
- throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$
- }
- } catch (MIException e) {
- throw new MI2CDIException(e);
- }
+ resume(location);
}
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#signal()
*/
public void signal() throws CDIException {
- CommandFactory factory = miSession.getCommandFactory();
- CLISignal signal = factory.createCLISignal("0"); //$NON-NLS-1$
- try {
- miSession.postCommand(signal);
- MIInfo info = signal.getMIInfo();
- if (info == null) {
- throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$
- }
- } catch (MIException e) {
- throw new MI2CDIException(e);
- }
+ resume(true);
}
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#signal(ICDISignal)
*/
public void signal(ICDISignal signal) throws CDIException {
- CommandFactory factory = miSession.getCommandFactory();
- CLISignal sig = factory.createCLISignal(signal.getName());
- try {
- miSession.postCommand(sig);
- MIInfo info = sig.getMIInfo();
- if (info == null) {
- throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$
- }
- } catch (MIException e) {
- throw new MI2CDIException(e);
- }
+ resume(signal);
}
public String evaluateExpressionToString(ICDIStackFrame frame, String expressionText) throws CDIException {
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineAdapter.java
index a030ee7fe28..112198b2638 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineAdapter.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ResumeAtLineAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 QNX Software Systems and others.
+ * Copyright (c) 2004, 2007 QNX Software Systems 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
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
+ * Freescale - https://bugs.eclipse.org/bugs/show_bug.cgi?id=186929
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
@@ -16,17 +17,23 @@ import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.model.IJumpToAddress;
import org.eclipse.cdt.debug.core.model.IJumpToLine;
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
+import org.eclipse.cdt.debug.internal.core.model.CDebugElement;
+import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceLookupDirector;
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
import org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyEditorInput;
import org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyView;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.ISourceLocator;
import org.eclipse.debug.core.model.ISuspendResume;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
@@ -60,17 +67,22 @@ public class ResumeAtLineAdapter implements IResumeAtLineTarget {
errorMessage = ActionMessages.getString( "ResumeAtLineAdapter.1" ); //$NON-NLS-1$
}
else {
- final String fileName = getFileName( input );
+ final String fileName = getFileName( input ); // actually, absolute path, not just file name
+ IDebugTarget debugTarget = null;
+ if ( target instanceof CDebugElement ) { // should always be, but just in case
+ debugTarget = ((CDebugElement)target).getDebugTarget();
+ }
+ final IPath path = convertPath( fileName, debugTarget );
ITextSelection textSelection = (ITextSelection)selection;
final int lineNumber = textSelection.getStartLine() + 1;
if ( target instanceof IAdaptable ) {
final IJumpToLine jumpToLine = (IJumpToLine)((IAdaptable)target).getAdapter( IJumpToLine.class );
- if ( jumpToLine != null && jumpToLine.canJumpToLine( fileName, lineNumber ) ) {
+ if ( jumpToLine != null && jumpToLine.canJumpToLine( path.toPortableString(), lineNumber ) ) {
Runnable r = new Runnable() {
public void run() {
try {
- jumpToLine.jumpToLine( fileName, lineNumber );
+ jumpToLine.jumpToLine( path.toPortableString(), lineNumber );
}
catch( DebugException e ) {
failed( e );
@@ -141,16 +153,21 @@ public class ResumeAtLineAdapter implements IResumeAtLineTarget {
if ( document == null ) {
return false;
}
- String fileName;
+ String fileName; // actually, absolute path, not just file name
try {
fileName = getFileName( input );
}
catch( CoreException e ) {
return false;
}
+ IDebugTarget debugTarget = null;
+ if ( target instanceof CDebugElement ) { // should always be, but just in case
+ debugTarget = ((CDebugElement)target).getDebugTarget();
+ }
+ final IPath path = convertPath( fileName, debugTarget );
ITextSelection textSelection = (ITextSelection)selection;
int lineNumber = textSelection.getStartLine() + 1;
- return jumpToLine.canJumpToLine( fileName, lineNumber );
+ return jumpToLine.canJumpToLine( path.toPortableString(), lineNumber );
}
if ( part instanceof DisassemblyView ) {
IJumpToAddress jumpToAddress = (IJumpToAddress)((IAdaptable)target).getAdapter( IJumpToAddress.class );
@@ -171,10 +188,10 @@ public class ResumeAtLineAdapter implements IResumeAtLineTarget {
private String getFileName( IEditorInput input ) throws CoreException {
if ( input instanceof IFileEditorInput ) {
- return ((IFileEditorInput)input).getFile().getName();
+ return ((IFileEditorInput)input).getFile().getLocation().toOSString();
}
if ( input instanceof IStorageEditorInput ) {
- return ((IStorageEditorInput)input).getStorage().getName();
+ return ((IStorageEditorInput)input).getStorage().getFullPath().toOSString();
}
return null;
}
@@ -188,4 +205,20 @@ public class ResumeAtLineAdapter implements IResumeAtLineTarget {
ms.add( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), ICDebugInternalConstants.STATUS_CODE_ERROR, e.getMessage(), e ) );
CDebugUtils.error( ms, this );
}
+
+ private IPath convertPath( String sourceHandle, IDebugTarget debugTarget ) {
+ IPath path = null;
+ if ( Path.EMPTY.isValidPath( sourceHandle ) ) {
+ if ( debugTarget != null ) {
+ ISourceLocator sl = debugTarget.getLaunch().getSourceLocator();
+ if ( sl instanceof CSourceLookupDirector ) {
+ path = ((CSourceLookupDirector)sl).getCompilationPath( sourceHandle );
+ }
+ }
+ if ( path == null ) {
+ path = new Path( sourceHandle );
+ }
+ }
+ return path;
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineAdapter.java
index d9e5c670f8b..848a31414eb 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineAdapter.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RunToLineAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 QNX Software Systems and others.
+ * Copyright (c) 2004, 2007 QNX Software Systems 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
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
+ * Freescale - https://bugs.eclipse.org/bugs/show_bug.cgi?id=186929
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;

Back to the top