1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Applied patch to 204028. Setting an address breakpoint in a session with no symbolics (executable) would NPE.

This commit is contained in:
John Cortell 2008-01-04 21:16:32 +00:00
parent e1478e3c72
commit 048b012111
2 changed files with 52 additions and 31 deletions

View file

@ -26,6 +26,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory; import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
import org.eclipse.cdt.debug.core.CDIDebugModel; import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.CDIException;
@ -847,9 +848,7 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
} }
private ICFunctionBreakpoint createFunctionBreakpoint( ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException { private ICFunctionBreakpoint createFunctionBreakpoint( ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException {
IPath execFile = getExecFilePath(); ICFunctionBreakpoint breakpoint = CDIDebugModel.createFunctionBreakpoint( getExecFileHandle(),
String sourceHandle = execFile.toOSString();
ICFunctionBreakpoint breakpoint = CDIDebugModel.createFunctionBreakpoint( sourceHandle,
getProject(), getProject(),
cdiBreakpoint.getLocator().getFunction(), cdiBreakpoint.getLocator().getFunction(),
-1, -1,
@ -863,8 +862,7 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
} }
private ICAddressBreakpoint createAddressBreakpoint( ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException { private ICAddressBreakpoint createAddressBreakpoint( ICDILocationBreakpoint cdiBreakpoint ) throws CDIException, CoreException {
IPath execFile = getExecFilePath(); String sourceHandle = getExecFileHandle();
String sourceHandle = execFile.toOSString();
IAddress address = getDebugTarget().getAddressFactory().createAddress( cdiBreakpoint.getLocator().getAddress() ); IAddress address = getDebugTarget().getAddressFactory().createAddress( cdiBreakpoint.getLocator().getAddress() );
ICAddressBreakpoint breakpoint = CDIDebugModel.createAddressBreakpoint( sourceHandle, ICAddressBreakpoint breakpoint = CDIDebugModel.createAddressBreakpoint( sourceHandle,
sourceHandle, sourceHandle,
@ -878,8 +876,7 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
} }
private ICWatchpoint createWatchpoint( ICDIWatchpoint cdiWatchpoint ) throws CDIException, CoreException { private ICWatchpoint createWatchpoint( ICDIWatchpoint cdiWatchpoint ) throws CDIException, CoreException {
IPath execFile = getExecFilePath(); String sourceHandle = getExecFileHandle();
String sourceHandle = execFile.toOSString();
ICWatchpoint watchpoint = null; ICWatchpoint watchpoint = null;
if ( cdiWatchpoint instanceof ICDIWatchpoint2 ){ if ( cdiWatchpoint instanceof ICDIWatchpoint2 ){
watchpoint = CDIDebugModel.createWatchpoint( sourceHandle, watchpoint = CDIDebugModel.createWatchpoint( sourceHandle,
@ -1058,28 +1055,42 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
return s; return s;
} }
/**
* Checks for a match between the symbolics referenced by the breakpoint
* and the symbolics of the contained CDebugTarget.
* @param breakpoint
* @return true if the symbolics match or if the breakpoint has no symbolics
*/
public boolean supportsAddressBreakpoint( ICAddressBreakpoint breakpoint ) { public boolean supportsAddressBreakpoint( ICAddressBreakpoint breakpoint ) {
String module = null; boolean sessionHasSymbols = getExecFileHandle() != null && getExecFileHandle().length() > 0;
boolean bpHasSymbols = false;
try { try {
module = breakpoint.getModule(); String module = breakpoint.getModule();
if ( module != null && module.length() > 0 ) {
bpHasSymbols = true;
if ( sessionHasSymbols ) {
return getExecFileHandle().equals( module );
}
}
} }
catch( CoreException e ) { catch( CoreException e ) {
} }
if ( module != null && getExecFilePath() != null )
return getExecFilePath().toOSString().equals( module );
// supporting old breakpoints (> 3.0) // supporting old breakpoints (> 3.0)
String sourceHandle = null;
try { try {
sourceHandle = breakpoint.getSourceHandle(); String sourceHandle = breakpoint.getSourceHandle();
if ( sourceHandle != null && sourceHandle.length() > 0 ) {
bpHasSymbols = true;
if ( sessionHasSymbols ) {
return getExecFileHandle().equals( sourceHandle );
}
}
} }
catch( CoreException e ) { catch( CoreException e ) {
} }
if ( sourceHandle != null && getExecFilePath() != null )
return getExecFilePath().toOSString().equals( sourceHandle );
return module != null && module.length() == 0 && // an address breakpoint can also be set in the absence of any symbols
sourceHandle != null && sourceHandle.length() == 0; return !bpHasSymbols;
} }
public void skipBreakpoints( boolean enabled ) { public void skipBreakpoints( boolean enabled ) {
@ -1131,10 +1142,18 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
return getDebugTarget().getProject(); return getDebugTarget().getProject();
} }
private IPath getExecFilePath() { private String getExecFileHandle() {
if (getDebugTarget() == null || getDebugTarget().getExecFile() == null) CDebugTarget target = getDebugTarget();
if ( target != null ) {
IBinaryObject binary = target.getExecFile();
if ( binary != null ) {
IPath path = binary.getPath();
if ( path != null ) {
return path.toOSString();
}
}
}
return null; return null;
return getDebugTarget().getExecFile().getPath();
} }
private ISourceLocator getSourceLocator() { private ISourceLocator getSourceLocator() {

View file

@ -147,6 +147,7 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
IFile file = null; IFile file = null;
try { try {
String handle = b.getSourceHandle(); String handle = b.getSourceHandle();
if ( handle != null ) {
IPath path = new Path( handle ); IPath path = new Path( handle );
if ( path.isValidPath( handle ) ) { if ( path.isValidPath( handle ) ) {
IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation( path ); IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation( path );
@ -161,6 +162,7 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
} }
} }
} }
}
catch( CoreException e ) { catch( CoreException e ) {
} }
if ( file == null ) if ( file == null )