From 75001014046d2d1c5678e3d4b347c56f213ee58d Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Fri, 7 Aug 2015 16:37:49 +0100 Subject: [PATCH] Bug 474179: Require file name to be absolute and exist When a file is not found, the debugger will be used to resolve it to an absolute file. One of the side effects at the moment is that no breakpoint marker is created in the editor for the file. To mitigate the situation and reduce user confusion, until installed breakpoints can be displayed in the UI don't allow users to create breakpoints on non-absolute file names. Change-Id: Ib69bfdfcde0c83fe6e20cacb0850d8ee907583a1 Signed-off-by: Jonah Graham (cherry picked from commit bd6fa94e63387dbaf42ce0f5f426cf1f1b1b4d00) --- .../breakpoints/BreakpointsMessages.properties | 2 +- .../ui/breakpoints/CBreakpointPropertyPage.java | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointsMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointsMessages.properties index dc6cf5c3f5c..8942d9a016e 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointsMessages.properties +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointsMessages.properties @@ -15,7 +15,7 @@ CBreakpointPropertyPage.0=Ignore count must be a nonnegative integer CBreakpointPropertyPage.file_system_button=File S&ystem... -CBreakpointPropertyPage.fileName_errorMessage=Enter a file name: +CBreakpointPropertyPage.fileName_errorMessage=Enter the absolute path to an existing file: CBreakpointPropertyPage.function_valueNotAvailable_label=Not available CBreakpointPropertyPage.function_label=Function name: CBreakpointPropertyPage.function_value_errorMessage=Enter a function expression: diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java index 80ef12f64a4..dcdf5d43ab0 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java @@ -14,6 +14,7 @@ *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui.breakpoints; +import java.io.File; import java.util.ArrayList; import java.util.List; @@ -293,6 +294,22 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement }); } + @Override + protected boolean doCheckState() { + // Check that the file name supplied is absolute and exists so that we can + // associate it to an IResource later for creating a breakpoint marker. + String stringValue = getStringValue(); + if (stringValue == null) { + return false; + } + File sourceFile = new File(stringValue); + if (!sourceFile.isAbsolute() || !sourceFile.exists() || !sourceFile.isFile()) { + return false; + } + + return super.doCheckState(); + } + } class WatchpointRangeFieldEditor extends IntegerFieldEditor {