1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 14:12:10 +02:00

Bug 444736 - Importing a subset of exported breakpoints often logs exceptions

This fixes also 
Bug 413787 - Occasional "Breakpoint does not have an associated marker" in the log
This commit is contained in:
Anton Leherbauer 2014-09-24 08:35:22 +02:00
parent db67b263b9
commit f3860cc65b
3 changed files with 32 additions and 17 deletions

View file

@ -321,22 +321,32 @@ public class CDebugUtils {
}
public static String getBreakpointText(IBreakpoint breakpoint, boolean qualified) throws CoreException {
if (breakpoint instanceof ICAddressBreakpoint) {
return getAddressBreakpointText((ICAddressBreakpoint)breakpoint, qualified);
try {
if (breakpoint instanceof ICAddressBreakpoint) {
return getAddressBreakpointText((ICAddressBreakpoint)breakpoint, qualified);
}
if (breakpoint instanceof ICFunctionBreakpoint) {
return getFunctionBreakpointText((ICFunctionBreakpoint)breakpoint, qualified);
}
if (breakpoint instanceof ICLineBreakpoint) {
return getLineBreakpointText((ICLineBreakpoint)breakpoint, qualified);
}
if (breakpoint instanceof ICWatchpoint) {
return getWatchpointText((ICWatchpoint)breakpoint, qualified);
}
// This allows to create a new breakpoint without implementing one of the interfaces above and still see a label
Object message = breakpoint.getMarker().getAttribute(IMarker.MESSAGE);
if (message != null)
return message.toString();
} catch (CoreException e) {
// don't log if breakpoint has been deleted
IMarker marker = breakpoint.getMarker();
if (marker == null || !marker.exists()) {
return DebugCoreMessages.getString("CDebugUtils.breakpoint_deleted"); //$NON-NLS-1$
}
CDebugCorePlugin.log(e);
return DebugCoreMessages.getString("CDebugUtils.exception_occurred"); //$NON-NLS-1$
}
if (breakpoint instanceof ICFunctionBreakpoint) {
return getFunctionBreakpointText((ICFunctionBreakpoint)breakpoint, qualified);
}
if (breakpoint instanceof ICLineBreakpoint) {
return getLineBreakpointText((ICLineBreakpoint)breakpoint, qualified);
}
if (breakpoint instanceof ICWatchpoint) {
return getWatchpointText((ICWatchpoint)breakpoint, qualified);
}
// This allows to create a new breakpoint without implementing one of the interfaces above and still see a label
Object message = breakpoint.getMarker().getAttribute(IMarker.MESSAGE);
if (message != null)
return message.toString();
return ""; //$NON-NLS-1$
}

View file

@ -32,5 +32,7 @@ CDebugUtils.Program_file_does_not_exist=The program file specified in the launch
CDebugUtils.Program_file_not_specified=A program file was not specified in the launch configuration.
CDebugUtils.Project_NAME_does_not_exist=Project {0} does not exist. Please check that your launch configuration specifies a valid project in your workspace.
CDebugUtils.Project_NAME_is_closed=Project {0} is closed
CDebugUtils.exception_occurred=An exception occurred. See log for details.
CDebugUtils.breakpoint_deleted=<deleted breakpoint>
CDIDebugModel.0=Unable to parser binary information from file

View file

@ -164,15 +164,18 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
}
if ( element instanceof ICBreakpoint ) {
ICBreakpoint b = (ICBreakpoint)element;
IMarker marker = b.getMarker();
if (marker == null || !marker.exists())
return null;
// If the BP's marker is on an IFile, job done
IFile file = (IFile)b.getMarker().getResource().getAdapter(IFile.class);
IFile file = (IFile)marker.getResource().getAdapter(IFile.class);
if (file == null) {
try {
// Not backed by an IFile, try its source handle (may be workspace / project based)
String handle = b.getSourceHandle();
if (handle != null && Path.ROOT.isValidPath(handle)) {
Path path = new Path(handle);
IProject project = b.getMarker().getResource().getProject();
IProject project = marker.getResource().getProject();
// Select the most 'relevant' IFile for an external location
file = ResourceLookup.selectFileForLocation(path, project);
if (file == null || !file.isAccessible()) {