From ce2f595139c58965d065802fe35a1c00dfabbc29 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Thu, 22 Mar 2012 13:20:08 -0400 Subject: [PATCH 01/15] Bug 375091 - Invalid name of the generic test application --- .../org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java index 1ea3311afd8..797e4882983 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java @@ -58,7 +58,7 @@ public class BaseTestCase { @Rule public TestName testName = new TestName(); public static final String ATTR_DEBUG_SERVER_NAME = TestsPlugin.PLUGIN_ID + ".DEBUG_SERVER_NAME"; - private static final String DEFAULT_TEST_APP = "data/launch/bin/GDBMIGenericTestApp"; + private static final String DEFAULT_TEST_APP = "data/launch/bin/GDBMIGenericTestApp.exe"; private static GdbLaunch fLaunch; From 838d1e80e5c2721be9281199d1a905a1adfae7ed Mon Sep 17 00:00:00 2001 From: Anna Dushistova Date: Thu, 22 Mar 2012 13:44:51 -0400 Subject: [PATCH 02/15] Bug 375067: [remote] Automated remote launch does not support project-less debug --- .../eclipse/cdt/launch/remote/tabs/RemoteCDSFMainTab.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/tabs/RemoteCDSFMainTab.java b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/tabs/RemoteCDSFMainTab.java index f3d7b58cd56..aa911f3e5c9 100644 --- a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/tabs/RemoteCDSFMainTab.java +++ b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/tabs/RemoteCDSFMainTab.java @@ -19,6 +19,7 @@ * Anna Dushistova (Mentor Graphics) - adapted from RemoteCMainTab * Anna Dushistova (Mentor Graphics) - moved to org.eclipse.cdt.launch.remote.tabs * Anna Dushistova (Mentor Graphics) - [318052] [remote launch] Properties are not saved/used + * Anna Dushistova (MontaVista) - [375067] [remote] Automated remote launch does not support project-less debug *******************************************************************************/ package org.eclipse.cdt.launch.remote.tabs; @@ -31,6 +32,7 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.jface.dialogs.Dialog; @@ -540,8 +542,7 @@ public class RemoteCDSFMainTab extends CMainTab { remoteProgText.setText(remoteWsRoot); } else { // try to use remote path - IPath wsRoot = getCProject().getProject().getWorkspace() - .getRoot().getLocation(); + IPath wsRoot = Platform.getLocation(); IPath remotePath = makeRelativeToWSRootLocation(new Path( remoteName), remoteWsRoot, wsRoot); remoteProgText.setText(remotePath.toString()); From 32e726817d6f5ccf3bd99a6ea16fcfd81c97acf6 Mon Sep 17 00:00:00 2001 From: Vivian Kong Date: Thu, 22 Mar 2012 15:29:01 -0400 Subject: [PATCH 03/15] Add LR parser feature to p2 repo --- releng/org.eclipse.cdt.repo/category.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/releng/org.eclipse.cdt.repo/category.xml b/releng/org.eclipse.cdt.repo/category.xml index 41a589de88f..02a00902d20 100644 --- a/releng/org.eclipse.cdt.repo/category.xml +++ b/releng/org.eclipse.cdt.repo/category.xml @@ -8,6 +8,9 @@ + + + From 362cd87be01de89221ad5a3db9e47a23617a7a57 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Thu, 22 Mar 2012 17:53:03 -0400 Subject: [PATCH 04/15] bug 71511: Fixed scanner discovery for minGW Trim line by scanner discovery console parsers --- .../ScannerInfoConsoleParserFactory.java | 152 ++++++++++-------- .../gnu/AbstractGCCBOPConsoleParser.java | 4 + .../scannerconfig2/DefaultRunSIProvider.java | 11 +- .../AbstractXLCBuildOutputParser.java | 5 + .../scannerconfig/XlCSpecsConsoleParser.java | 5 + 5 files changed, 113 insertions(+), 64 deletions(-) diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java index f1f2b9ddd4e..db0634699da 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java @@ -40,60 +40,62 @@ import org.eclipse.core.runtime.Path; */ public class ScannerInfoConsoleParserFactory { - /** - * Creates a ConsoleOutputStreamSniffer, make builder scanner info console parser - * and a utility. - */ - public static ConsoleOutputSniffer getESIProviderOutputSniffer( - OutputStream outputStream, - OutputStream errorStream, - IProject currentProject, - String providerId, - IScannerConfigBuilderInfo2 scBuildInfo, - IScannerInfoCollector collector, - IMarkerGenerator markerGenerator) { - return getESIProviderOutputSniffer(outputStream, errorStream, currentProject, new InfoContext(currentProject), providerId, scBuildInfo, collector, markerGenerator); - } - /** - * Creates a ConsoleOutputStreamSniffer, make builder scanner info console parser - * and a utility. - */ - public static ConsoleOutputSniffer getESIProviderOutputSniffer( - OutputStream outputStream, - OutputStream errorStream, - IProject currentProject, - InfoContext context, - String providerId, - IScannerConfigBuilderInfo2 scBuildInfo, - IScannerInfoCollector collector, - IMarkerGenerator markerGenerator) { - if (scBuildInfo.isProviderOutputParserEnabled(providerId)) { - // get the ESIProvider console parser - SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance(). - getSCProfileInstance(currentProject, context, scBuildInfo.getSelectedProfileId()); - IScannerInfoConsoleParser clParser = profileInstance.createExternalScannerInfoParser(providerId); - IPath buildDirectory = MakeBuilderUtil.getBuildDirectory(currentProject, MakeBuilder.BUILDER_ID); - clParser.startup(currentProject, buildDirectory, collector, markerGenerator); - // create an output stream sniffer - return new ConsoleOutputSniffer(outputStream, errorStream, new - IScannerInfoConsoleParser[] {clParser}); - } - return null; - } - /** - * Creates a ConsoleOutputStreamSniffer, ESI provider scanner info console parser + * Creates a ConsoleOutputStreamSniffer, make builder scanner info console parser * and a utility. */ - public static ConsoleOutputSniffer getMakeBuilderOutputSniffer( - OutputStream outputStream, - OutputStream errorStream, - IProject currentProject, - IPath workingDirectory, - IScannerConfigBuilderInfo2 scBuildInfo, - IMarkerGenerator markerGenerator, - IScannerInfoCollector collector) { - return getMakeBuilderOutputSniffer(outputStream, errorStream, currentProject, new InfoContext(currentProject), workingDirectory, scBuildInfo, markerGenerator, collector); + public static ConsoleOutputSniffer getESIProviderOutputSniffer(OutputStream outputStream, + OutputStream errorStream, + IProject project, + String id, + IScannerConfigBuilderInfo2 info2, + IScannerInfoCollector collector, + IMarkerGenerator markerGenerator) { + + return getESIProviderOutputSniffer(outputStream, errorStream, project, new InfoContext(project), id, info2, collector, markerGenerator); + } + + /** + * Creates a ConsoleOutputStreamSniffer, make builder scanner info console parser + * and a utility. + */ + public static ConsoleOutputSniffer getESIProviderOutputSniffer(OutputStream outputStream, + OutputStream errorStream, + IProject project, + InfoContext infoContext, + String id, + IScannerConfigBuilderInfo2 info2, + IScannerInfoCollector collector, + IMarkerGenerator markerGenerator) { + + IScannerInfoConsoleParser parser = getESIConsoleParser(project, infoContext, id, info2, collector, markerGenerator); + if (parser != null) { + return new ConsoleOutputSniffer(outputStream, errorStream, new IScannerInfoConsoleParser[] { parser }); + } + return null; + } + + /** + /* Get the ESIProvider console parser. + */ + public static IScannerInfoConsoleParser getESIConsoleParser(IProject project, + InfoContext infoContext, + String id, + IScannerConfigBuilderInfo2 info2, + IScannerInfoCollector collector, + IMarkerGenerator markerGenerator) { + + if (info2.isProviderOutputParserEnabled(id)) { + SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance(). + getSCProfileInstance(project, infoContext, info2.getSelectedProfileId()); + + IScannerInfoConsoleParser parser = profileInstance.createExternalScannerInfoParser(id); + IPath buildDirectory = MakeBuilderUtil.getBuildDirectory(project, MakeBuilder.BUILDER_ID); + + parser.startup(project, buildDirectory, collector, markerGenerator); + return parser; + } + return null; } /** @@ -101,14 +103,30 @@ public class ScannerInfoConsoleParserFactory { * and a utility. */ public static ConsoleOutputSniffer getMakeBuilderOutputSniffer( - OutputStream outputStream, - OutputStream errorStream, - IProject project, - InfoContext infoContext, - IPath workingDirectory, - IScannerConfigBuilderInfo2 info2, - IMarkerGenerator markerGenerator, - IScannerInfoCollector collector) { + OutputStream outputStream, + OutputStream errorStream, + IProject project, + IPath workingDirectory, + IScannerConfigBuilderInfo2 info2, + IMarkerGenerator markerGenerator, + IScannerInfoCollector collector) { + + return getMakeBuilderOutputSniffer(outputStream, errorStream, project, new InfoContext(project), workingDirectory, info2, markerGenerator, collector); + } + + /** + * Creates a ConsoleOutputStreamSniffer, ESI provider scanner info console parser + * and a utility. + */ + public static ConsoleOutputSniffer getMakeBuilderOutputSniffer( + OutputStream outputStream, + OutputStream errorStream, + IProject project, + InfoContext infoContext, + IPath workingDirectory, + IScannerConfigBuilderInfo2 info2, + IMarkerGenerator markerGenerator, + IScannerInfoCollector collector) { IScannerInfoConsoleParser parser = getScannerInfoConsoleParserInternal(project, infoContext, workingDirectory, info2, markerGenerator, collector); if (parser != null) { @@ -119,8 +137,12 @@ public class ScannerInfoConsoleParserFactory { return null; } - private static IScannerInfoConsoleParser getScannerInfoConsoleParserInternal(IProject project, InfoContext infoContext, IPath workingDirectory, - IScannerConfigBuilderInfo2 info2, IMarkerGenerator markerGenerator, IScannerInfoCollector collector) { + private static IScannerInfoConsoleParser getScannerInfoConsoleParserInternal(IProject project, + InfoContext infoContext, + IPath workingDirectory, + IScannerConfigBuilderInfo2 info2, + IMarkerGenerator markerGenerator, + IScannerInfoCollector collector) { IScannerInfoConsoleParser parser = null; // try { @@ -166,8 +188,12 @@ public class ScannerInfoConsoleParserFactory { } // TODO - perhaps this be unified with the other one? - public static IScannerInfoConsoleParser getScannerInfoConsoleParser(IProject project, InfoContext infoContext, IPath workingDirectory, - IScannerConfigBuilderInfo2 info2, IMarkerGenerator markerGenerator, IScannerInfoCollector collector) { + public static IScannerInfoConsoleParser getScannerInfoConsoleParser(IProject project, + InfoContext infoContext, + IPath workingDirectory, + IScannerConfigBuilderInfo2 info2, + IMarkerGenerator markerGenerator, + IScannerInfoCollector collector) { IScannerInfoConsoleParser parser = null; if (info2 != null && info2.isAutoDiscoveryEnabled() && info2.isBuildOutputParserEnabled()) { diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParser.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParser.java index 26fcd27f749..32b9a9edc81 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParser.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParser.java @@ -94,6 +94,10 @@ public abstract class AbstractGCCBOPConsoleParser implements IScannerInfoConsole */ @Override public boolean processLine(String line) { + line= line.trim(); + if (line.length() == 0) { + return false; + } boolean rc = false; int lineBreakPos = line.length()-1; char[] lineChars = line.toCharArray(); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java index a88e64bb236..c6c96d541fc 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java @@ -15,12 +15,14 @@ import java.io.IOException; import java.net.URI; import java.util.ArrayList; import java.util.Enumeration; +import java.util.List; import java.util.Properties; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CommandLauncher; import org.eclipse.cdt.core.ErrorParserManager; import org.eclipse.cdt.core.ICommandLauncher; +import org.eclipse.cdt.core.IConsoleParser; import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.internal.core.BuildRunnerHelper; @@ -33,6 +35,7 @@ import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector; import org.eclipse.cdt.make.core.scannerconfig.InfoContext; import org.eclipse.cdt.make.internal.core.MakeMessages; import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil; +import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoConsoleParserFactory; import org.eclipse.cdt.utils.EFSExtensionManager; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -123,8 +126,14 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider { ErrorParserManager epm = new ErrorParserManager(project, markerGenerator, new String[] {GMAKE_ERROR_PARSER_ID}); + List parsers = new ArrayList(); + IConsoleParser parser = ScannerInfoConsoleParserFactory.getESIConsoleParser(project, context, providerId, buildInfo, collector, markerGenerator); + if (parser != null) { + parsers.add(parser); + } + buildRunnerHelper.setLaunchParameters(launcher, program, comandLineOptions, workingDirectoryURI, envp ); - buildRunnerHelper.prepareStreams(epm, null, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); + buildRunnerHelper.prepareStreams(epm, parsers, console, new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); buildRunnerHelper.greeting(MakeMessages.getFormattedString("ExternalScannerInfoProvider.Greeting", project.getName())); //$NON-NLS-1$ buildRunnerHelper.build(new SubProgressMonitor(monitor, 1 * MONITOR_SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); diff --git a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/AbstractXLCBuildOutputParser.java b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/AbstractXLCBuildOutputParser.java index 115a69ded71..64ed3c4c08e 100644 --- a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/AbstractXLCBuildOutputParser.java +++ b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/AbstractXLCBuildOutputParser.java @@ -110,6 +110,11 @@ public abstract class AbstractXLCBuildOutputParser implements IScannerInfoConsol */ @Override public boolean processLine(String line) { + line= line.trim(); + if (line.length() == 0) { + return false; + } + boolean rc = false; int lineBreakPos = line.length() - 1; char[] lineChars = line.toCharArray(); diff --git a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XlCSpecsConsoleParser.java b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XlCSpecsConsoleParser.java index 04cd1c42b9f..6df289d3a18 100644 --- a/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XlCSpecsConsoleParser.java +++ b/xlc/org.eclipse.cdt.make.xlc.core/src/org/eclipse/cdt/make/xlc/core/scannerconfig/XlCSpecsConsoleParser.java @@ -97,6 +97,11 @@ public class XlCSpecsConsoleParser implements IScannerInfoConsoleParser { TraceUtil.outputTrace( "XLCSpecsConsoleParser parsing line: [", line, "]"); //$NON-NLS-1$ //$NON-NLS-2$ + line= line.trim(); + if (line.length() == 0) { + return false; + } + // testing the output line against the pattern of interest Matcher lineMatcher = linePattern.matcher(line); if (lineMatcher.matches()) { From ccf74d51d0917607433997778b66dec882c14f79 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Thu, 22 Mar 2012 22:04:25 -0400 Subject: [PATCH 05/15] Bug 375131: [launch] Cancelling an attach or postmortem launch no longer cancels --- .../src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java index 11b0b02aa5c..dd4b956a7b5 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java @@ -311,6 +311,8 @@ public class GDBControl extends AbstractMIControl implements IGDBControl { if (!isCanceled()) { // Only set the status if the user has not cancelled the operation already. rm.setStatus(getStatus()); + } else { + rm.cancel(); } rm.done(); } From 4d2a4b2d7c3f712082bc580454bd6a0792452440 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Thu, 22 Mar 2012 19:49:31 -0700 Subject: [PATCH 06/15] Cosmetics. --- .../eclipse/cdt/core/dom/ast/cpp/ICPPASTWhileStatement.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTWhileStatement.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTWhileStatement.java index f068d05de17..4fba8bd3247 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTWhileStatement.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTWhileStatement.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM) - Initial API and implementation + * John Camelon (IBM) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -22,7 +22,6 @@ import org.eclipse.cdt.core.dom.ast.IScope; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTWhileStatement extends IASTWhileStatement { - /** * In C++ conditions can be declarations w/side effects. */ From 08c8ef800e1b076e08913ae57754c2fe1412d0c8 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Thu, 22 Mar 2012 19:51:08 -0700 Subject: [PATCH 07/15] Fixed a bug in Extract Function refactoring. --- .../ExtractFunctionRefactoringTest.java | 12 +++++------- .../corext/refactoring/code/flow/FlowAnalyzer.java | 5 +++++ .../refactoring/code/flow/InputFlowAnalyzer.java | 6 ++++-- .../corext/refactoring/code/flow/Selection.java | 4 ++-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java index 10910d20611..2c2a6f34faf 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java @@ -1775,9 +1775,8 @@ public class ExtractFunctionRefactoringTest extends RefactoringTestBase { //test.c //void test() { // int i = 0; - // while (i <= 10) { + // while (i <= 10) // /*$*/i++;/*$$*/ - // } //} //==================== //int extracted(int i) { @@ -1787,9 +1786,8 @@ public class ExtractFunctionRefactoringTest extends RefactoringTestBase { // //void test() { // int i = 0; - // while (i <= 10) { + // while (i <= 10) // i = extracted(i); - // } //} public void testOutputParametersDetectionInWhileLoop() throws Exception { assertRefactoringSuccess(); @@ -1887,7 +1885,7 @@ public class ExtractFunctionRefactoringTest extends RefactoringTestBase { //void method() { // loop(); //} - public void testDontReturnVariablesThatArentUsed() throws Exception { + public void testDoNotReturnVariablesThatAreNotUsed() throws Exception { extractedFunctionName = "loop"; assertRefactoringSuccess(); } @@ -1898,7 +1896,7 @@ public class ExtractFunctionRefactoringTest extends RefactoringTestBase { // return;/*$$*/ // //unreachable //} - public void testDontExtractCodeContainingReturn() throws Exception { + public void testDoNotExtractCodeContainingReturn() throws Exception { assertRefactoringFailure(); } @@ -1909,7 +1907,7 @@ public class ExtractFunctionRefactoringTest extends RefactoringTestBase { // continue;/*$$*/ // } //} - public void testDontExtractCodeContainingContinue() throws Exception { + public void testDoNotExtractCodeContainingContinue() throws Exception { assertRefactoringFailure(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java index b5a8f2304af..15bee0552bc 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java @@ -79,6 +79,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTRangeBasedForStatement; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTWhileStatement; import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVariableReadWriteFlags; @@ -668,6 +669,10 @@ abstract class FlowAnalyzer extends ASTGenericVisitor { WhileFlowInfo info= createWhile(); setFlowInfo(node, info); info.mergeCondition(getFlowInfo(node.getCondition()), fFlowContext); + if (node instanceof ICPPASTWhileStatement) { + info.mergeCondition(getFlowInfo(((ICPPASTWhileStatement) node).getConditionDeclaration()), + fFlowContext); + } info.mergeAction(getFlowInfo(node.getBody()), fFlowContext); info.removeLabel(null); return PROCESS_SKIP; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/InputFlowAnalyzer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/InputFlowAnalyzer.java index f2726269bf9..d851d153b1e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/InputFlowAnalyzer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/InputFlowAnalyzer.java @@ -299,15 +299,17 @@ public class InputFlowAnalyzer extends FlowAnalyzer { @Override protected boolean traverseNode(IASTNode node) { + if (fSelection.covers(node)) + return false; if (node instanceof IASTLabelStatement) return true; - return ASTNodes.endOffset(node) > fSelection.getEnd(); + return ASTNodes.endOffset(node) >= fSelection.getEnd(); } @Override protected boolean shouldCreateReturnFlowInfo(IASTReturnStatement node) { // Make sure that the whole return statement is located after the selection. - // There can be cases like return i + [x + 10] * 10; In this case we must not create + // There can be cases like return i + (x + 10) * 10; In this case we must not create // a return info node. return ASTNodes.offset(node) >= fSelection.getEnd(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/Selection.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/Selection.java index cc9d2b9bea1..e20dea162b0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/Selection.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/Selection.java @@ -108,7 +108,7 @@ public class Selection { return INTERSECTS; } - public int getEndVisitSelectionMode(IASTNode node) { + public int getLeaveSelectionMode(IASTNode node) { IASTFileLocation location = node.getFileLocation(); int nodeStart= location.getNodeOffset(); int nodeEnd= nodeStart + location.getNodeLength(); @@ -116,7 +116,7 @@ public class Selection { return BEFORE; } else if (covers(node)) { return SELECTED; - } else if (nodeEnd >= fEnd) { + } else if (fEnd <= nodeEnd) { return AFTER; } return INTERSECTS; From 7c29ca49ce6006e677c8fae86500ab82827bb2ff Mon Sep 17 00:00:00 2001 From: Pawel Piech Date: Fri, 23 Mar 2012 11:39:34 -0700 Subject: [PATCH 08/15] Bug 374988 - [breakpoints] Update "Add Watchpoint" action and "Add Event Breakpoint" actions to use new dialog --- .../cdt/debug/core/ICWatchpointTarget.java | 58 +++ .../internal/core/ICWatchpointTarget.java | 53 +-- .../debug/internal/core/model/CVariable.java | 2 +- debug/org.eclipse.cdt.debug.ui/plugin.xml | 8 +- .../ui/actions/AddWatchpointDialog.java | 419 ++++++++++++++++- ...AddWatchpointOnVariableActionDelegate.java | 22 + .../breakpoints/AddWatchpointDialog.java | 439 ------------------ .../AddWatchpointOnMemoryActionDelegate.java | 129 ----- ...AddWatchpointOnVariableActionDelegate.java | 179 ------- .../breakpoints/ToggleBreakpointAdapter.java | 4 +- .../breakpoints/ToggleTracepointAdapter.java | 2 +- .../BreakpointsMessages.properties | 2 + .../CBreakpointPreferenceStore.java | 3 +- .../breakpoints/CBreakpointPropertyPage.java | 292 ++++++++++++ .../ui/preferences/ComboFieldEditor.java | 6 +- .../AbstractToggleBreakpointAdapter.java | 179 ++++++- .../AddWatchpointActionDelegate.java | 79 +--- ...AddWatchpointOnVariableActionDelegate.java | 93 ++++ .../ui/viewmodel/GdbVariableVMNode.java | 2 +- 19 files changed, 1093 insertions(+), 878 deletions(-) create mode 100644 debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICWatchpointTarget.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointOnVariableActionDelegate.java delete mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddWatchpointDialog.java delete mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddWatchpointOnMemoryActionDelegate.java delete mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddWatchpointOnVariableActionDelegate.java rename debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/{internal/ui/actions => ui}/breakpoints/AddWatchpointActionDelegate.java (53%) create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AddWatchpointOnVariableActionDelegate.java diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICWatchpointTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICWatchpointTarget.java new file mode 100644 index 00000000000..3ade51c8a72 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICWatchpointTarget.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2010 Freescale Semiconductor 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Freescale Semiconductor - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.core; + +import org.eclipse.debug.core.IRequest; + +/** + * View model types for which the "Add Watchpoint (C/C++)" action is applicable + * should implement this interface. The action is a popupMenu/objectContribution + * that targets this type. + * + * @since 7.2 + */ +public interface ICWatchpointTarget { + + /** IRequest object used in the asynchronous method {@link ICWatchpointTarget#getSize()} */ + interface GetSizeRequest extends IRequest { + int getSize(); // returns -1 if size not available + void setSize(int size); + }; + + interface CanCreateWatchpointRequest extends IRequest { + boolean getCanCreate(); + void setCanCreate(boolean value); + }; + + /** + * Determine if a watchpoint can be set on the element. The result does not + * guarantee an attempt to set such a watchpoint will succeed. This is + * merely a way to find out whether it makes sense to even attempt it. For + * example, an expression that's not an l-value should return false. The + * implementation may choose to go even further and check that the target + * supports watchpoints (at all or at that particular location). + */ + void canSetWatchpoint(CanCreateWatchpointRequest request); + + /** + * Get the expression or the name of the variable + */ + String getExpression(); + + /** + * Asynchronous method to retrieve the size of the variable/expression, in + * bytes. + * + * @param request + * the async request object + */ + void getSize(GetSizeRequest request); +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ICWatchpointTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ICWatchpointTarget.java index 61d9a2a0ba8..d8a3888309d 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ICWatchpointTarget.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/ICWatchpointTarget.java @@ -1,60 +1,19 @@ /******************************************************************************* - * Copyright (c) 2010 Freescale Semiconductor and others. + * Copyright (c) 2012 Wind River 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 * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: - * Freescale Semiconductor - initial API and implementation + * Wind River Systems - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.debug.internal.core; -import org.eclipse.debug.core.IRequest; - /** - * View model types for which the "Add Watchpoint (C/C++)" action is applicable - * should implement this interface. The action is a popupMenu/objectContribution - * that targets this type. - * - *

- * Note that the action is particular to CBreakpoint, and not all CDT debugger - * solutions use CBreakpoint. + * @deprecated This interface has been moved to a public package. Use + * {@link org.eclipse.cdt.debug.core.ICWatchpointTarget} instead. */ -public interface ICWatchpointTarget { +public interface ICWatchpointTarget extends org.eclipse.cdt.debug.core.ICWatchpointTarget { - /** IRequest object used in the asynchronous method {@link ICWatchpointTarget#getSize()} */ - interface GetSizeRequest extends IRequest { - int getSize(); // returns -1 if size not available - void setSize(int size); - }; - - interface CanCreateWatchpointRequest extends IRequest { - boolean getCanCreate(); - void setCanCreate(boolean value); - }; - - /** - * Determine if a watchpoint can be set on the element. The result does not - * guarantee an attempt to set such a watchpoint will succeed. This is - * merely a way to find out whether it makes sense to even attempt it. For - * example, an expression that's not an l-value should return false. The - * implementation may choose to go even further and check that the target - * supports watchpoints (at all or at that particular location). - */ - void canSetWatchpoint(CanCreateWatchpointRequest request); - - /** - * Get the expression or the name of the variable - */ - String getExpression(); - - /** - * Asynchronous method to retrieve the size of the variable/expression, in - * bytes. - * - * @param request - * the async request object - */ - void getSize(GetSizeRequest request); } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java index 87537c2c313..76f17b4de21 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java @@ -15,6 +15,7 @@ import com.ibm.icu.text.MessageFormat; import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.debug.core.ICDebugConstants; +import org.eclipse.cdt.debug.core.ICWatchpointTarget; import org.eclipse.cdt.debug.core.cdi.event.ICDIChangedEvent; import org.eclipse.cdt.debug.core.cdi.event.ICDIDestroyedEvent; import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent; @@ -33,7 +34,6 @@ import org.eclipse.cdt.debug.core.model.ICDebugElementStatus; import org.eclipse.cdt.debug.core.model.ICType; import org.eclipse.cdt.debug.core.model.ICValue; import org.eclipse.cdt.debug.internal.core.CSettingsManager; -import org.eclipse.cdt.debug.internal.core.ICWatchpointTarget; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugException; diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index afdcbfac5a5..76eee9c0b5e 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -636,7 +636,7 @@ objectClass="org.eclipse.cdt.debug.internal.core.ICWatchpointTarget" id="org.eclipse.cdt.debug.ui.WatchpointActions"> sExpressionHistory = new ArrayList(); + + private boolean fHasMemorySpaceControls; + private Button fMemorySpaceEnableButton; + private Combo fMemorySpaceInput; + private String fMemorySpace; + + private boolean fRangeInitialEnable; + private Button fRangeEnableButton; + private Text fRangeField; + private String fRange = ""; //$NON-NLS-1$ + + private Button fChkBtnWrite; + private Button fChkBtnRead; + private boolean fRead; + private boolean fWrite; + + private ICDIMemorySpaceManagement fMemManagement; + + + /** + * Constructor for AddWatchpointDialog. + * + * @param parentShell + */ public AddWatchpointDialog( Shell parentShell, ICDIMemorySpaceManagement memMgmt ) { - super(parentShell, memMgmt); + super( parentShell ); + setShellStyle( getShellStyle() | SWT.RESIZE ); + fMemManagement = memMgmt; } + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ + @Override + protected Control createDialogArea( Composite parent ) { + // The button bar will work better if we make the parent composite + // a single column grid layout. For the widgets we add, we want a + // a two-column grid, so we just create a sub composite for that. + GridLayout gridLayout = new GridLayout(); + parent.setLayout( gridLayout ); + GridData gridData = new GridData( GridData.FILL_BOTH ); + parent.setLayoutData( gridData ); + Composite composite = new Composite( parent, SWT.None ); + gridLayout = new GridLayout(); + gridLayout.numColumns = 2; + composite.setLayout( gridLayout ); + parent = composite; + + // Create the controls + createExpressionControl( parent ); + boolean hasDebugContext = DebugUITools.getDebugContext() != null; + boolean hasMemorySpaces = hasDebugContext && fMemManagement != null && fMemManagement.getMemorySpaces() != null && fMemManagement.getMemorySpaces().length > 0; + fHasMemorySpaceControls = !hasDebugContext || hasMemorySpaces; + if ( fHasMemorySpaceControls ) { + createMemorySpaceControl( parent, hasMemorySpaces ); + } + createCountField( parent ); + createAccessWidgets( parent ); + + // Initialize the inter-control state + if ( fExpression != null && fExpression.length() > 0 ) { + fExpressionInput.add( fExpression, 0 ); + fExpressionInput.select( 0 ); + } + fExpressionInput.setFocus(); + if ( fHasMemorySpaceControls ) { + fMemorySpaceInput.setEnabled( fMemorySpaceEnableButton.getEnabled() ); + } + fRangeField.setEnabled( fRangeEnableButton.getEnabled() ); + updateUI(); + return parent; + } + + private void createExpressionControl(Composite parent ) { + + Label l = new Label( parent, GridData.FILL_HORIZONTAL ); + l.setText( ActionMessages.getString( "AddWatchpointDialog.1" ) ); //$NON-NLS-1$ + GridData gridData = new GridData( GridData.FILL_HORIZONTAL ); + gridData.horizontalSpan = 2; + l.setLayoutData( gridData ); + + fExpressionInput = new Combo( parent, SWT.BORDER ); + gridData = new GridData( GridData.FILL_HORIZONTAL ); + gridData.horizontalSpan = 2; + fExpressionInput.setLayoutData( gridData ); + fExpressionInput.addModifyListener( this ); + for (String expression : sExpressionHistory) { + fExpressionInput.add( expression ); + } + } + + private void createMemorySpaceControl( Composite parent, boolean hasMemorySpaces ) { + fMemorySpaceEnableButton = new Button( parent, SWT.CHECK ); + GridData gridData = new GridData( GridData.FILL_HORIZONTAL ); + gridData.horizontalSpan = 1; + fMemorySpaceEnableButton.setLayoutData( gridData ); + fMemorySpaceEnableButton.setText( ActionMessages.getString( "AddWatchpointDialog.5" ) ); //$NON-NLS-1$ + fMemorySpaceEnableButton.setSelection( false ); + fMemorySpaceEnableButton.addSelectionListener( this ); + + if ( hasMemorySpaces ) { + fMemorySpaceInput = new Combo( parent, SWT.BORDER | SWT.READ_ONLY ); + } else { + fMemorySpaceInput = new Combo( parent, SWT.BORDER ); + } + gridData = new GridData( GridData.FILL_HORIZONTAL ); + gridData.horizontalSpan = 1; + fMemorySpaceInput.setLayoutData( gridData ); + fMemorySpaceInput.addSelectionListener( this ); + if ( fMemManagement != null ) { + String [] memorySpaces = fMemManagement.getMemorySpaces(); + for ( int i = 0; i < memorySpaces.length; i++ ) { + fMemorySpaceInput.add( memorySpaces[i] ); + } + } + if ( fMemorySpace != null && fMemorySpace.length() > 0 ) { + int i = fMemorySpaceInput.indexOf( fMemorySpace ); + if ( i >= 0 ) { + fMemorySpaceInput.select( i ); + fMemorySpaceEnableButton.setSelection( true ); + } else { + fMemorySpaceInput.add( fMemorySpace ); + } + } + fMemorySpaceInput.addModifyListener( this ); + //234909 - for accessibility + fMemorySpaceInput.getAccessible().addAccessibleListener( + new AccessibleAdapter() { + @Override + public void getName(AccessibleEvent e) { + e.result = ActionMessages.getString( "AddWatchpointDialog.5" ); //$NON-NLS-1$ + } + + }); + } + + /** + * @param text + * @param c + * @return true if the concatenation of text + c results + * in a valid string representation of an integer + * @see verifyIntegerText() + */ + private static boolean verifyIntegerTextAddition( String text, char c ) { + + // pass through all control characters + if ( Character.isISOControl( c ) ) { + return true; + } + + // case-insensitive + c = Character.toLowerCase( c ); + text = text.toLowerCase(); + + // first character has to be 0-9 + if ( text.length() == 0 ) { + return Character.isDigit( c ); + } + + // second character must be x if preceded by a 0, otherwise 0-9 will do + if ( text.length() == 1 ) { + if ( text.equals( "0" ) ) { //$NON-NLS-1$ + return c == 'x'; + } + return Character.isDigit( c ); + } + + // all subsequent characters must be 0-9 or a-f if started with 0x + return Character.isDigit( c ) + || text.startsWith( "0x" ) && 'a' <= c && c <= 'f'; //$NON-NLS-1$ + } + + /** + * @param text integer string built up using verifyIntegerTextAddition() + * @return true if text represents a valid string representation of + * an integer + */ + private static boolean verifyIntegerText( String text ) { + if ( text.length() == 0 ) { + return false; + } + if ( text.length() == 1 ) { + return true; + } + if ( text.length() == 2 ) { + return !text.equals("0x"); //$NON-NLS-1$ + } + return true; + } + + private void createCountField( Composite parent ) { + fRangeEnableButton = new Button( parent, SWT.CHECK ); + GridData gridData = new GridData( GridData.FILL_HORIZONTAL ); + gridData.horizontalSpan = 1; + fRangeEnableButton.setLayoutData( gridData ); + fRangeEnableButton.setText( ActionMessages.getString( "AddWatchpointDialog.6" ) ); //$NON-NLS-1$ + fRangeEnableButton.setSelection( fRangeInitialEnable && fRange.length() > 0 ); + fRangeEnableButton.addSelectionListener( this ); + + fRangeField = new Text( parent, SWT.BORDER ); + gridData = new GridData( GridData.FILL_HORIZONTAL ); + gridData.horizontalSpan = 1; + GC gc = new GC( fRangeField ); + FontMetrics fm = gc.getFontMetrics(); + gridData.minimumWidth = 8 * fm.getAverageCharWidth(); + fRangeField.setLayoutData( gridData ); + fRangeField.setText( fRange ); + fRangeField.addVerifyListener( new VerifyListener() { + @Override + public void verifyText( VerifyEvent e ) { + e.doit = verifyIntegerTextAddition( fRangeField.getText(), e.character ); + } + }); + fRangeField.addModifyListener( this ); + //234909 - for accessibility + fRangeField.getAccessible().addAccessibleListener( + new AccessibleAdapter() { + @Override + public void getName(AccessibleEvent e) { + e.result = ActionMessages.getString( "AddWatchpointDialog.6" ); //$NON-NLS-1$ + } + + }); + } + + private void createAccessWidgets( Composite parent ) { + GridData gridData = new GridData( GridData.FILL_HORIZONTAL ); + gridData.horizontalSpan = 3; + + Group group = new Group( parent, SWT.NONE ); + group.setLayout( new GridLayout() ); + group.setLayoutData( gridData ); + group.setText( ActionMessages.getString( "AddWatchpointDialog.2" ) ); //$NON-NLS-1$ + fChkBtnWrite = new Button( group, SWT.CHECK ); + fChkBtnWrite.setText( ActionMessages.getString( "AddWatchpointDialog.3" ) ); //$NON-NLS-1$ + fChkBtnWrite.setSelection( true ); + fChkBtnWrite.addSelectionListener( this ); + fChkBtnRead = new Button( group, SWT.CHECK ); + fChkBtnRead.setText( ActionMessages.getString( "AddWatchpointDialog.4" ) ); //$NON-NLS-1$ + fChkBtnRead.setSelection( false ); + fChkBtnRead.addSelectionListener( this ); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) + */ + @Override + protected void configureShell( Shell newShell ) { + super.configureShell( newShell ); + + // use the same title used by the platform dialog + newShell.setText( ActionMessages.getString( "AddWatchpointDialog.0" ) ); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#okPressed() + */ + @Override + protected void okPressed() { + fExpression = fExpressionInput.getText().trim(); + if ( fExpression.length() > 0 ) { + addHistory( fExpression ); + } + if ( fHasMemorySpaceControls ) { + fMemorySpace = fMemorySpaceEnableButton.getSelection() ? fMemorySpaceInput.getText().trim() : ""; //$NON-NLS-1$ + } + fRange = fRangeEnableButton.getSelection() ? fRangeField.getText().trim() : "0"; //$NON-NLS-1$ + fRead = fChkBtnRead.getSelection(); + fWrite = fChkBtnWrite.getSelection(); + super.okPressed(); + } + + /* (non-Javadoc) + * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) + */ + @Override + public void modifyText( ModifyEvent e ) { + updateUI(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.TrayDialog#createButtonBar(org.eclipse.swt.widgets.Composite) + */ + @Override + protected Control createButtonBar( Composite parent ) { + return super.createButtonBar( parent ); + } + + public String getExpression() { + return fExpression; + } + + public String getMemorySpace() { + return fMemorySpace; + } + + private static void addHistory( String item ) { + if ( !sExpressionHistory.contains( item ) ) { + sExpressionHistory.add( 0, item ); + + if ( sExpressionHistory.size() > 5 ) + sExpressionHistory.remove( sExpressionHistory.size() - 1 ); + } + } + + /* (non-Javadoc) + * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) + */ + @Override + public void widgetDefaultSelected( SelectionEvent e ) { + // ignore + } + + /* (non-Javadoc) + * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) + */ + @Override + public void widgetSelected( SelectionEvent e ) { + updateUI(); + } + + private void updateUI() { + if ( fHasMemorySpaceControls ) { + fMemorySpaceInput.setEnabled( fMemorySpaceEnableButton.getSelection() ); + } + fRangeField.setEnabled( fRangeEnableButton.getSelection() ); + Button b = getButton( IDialogConstants.OK_ID ); + if ( b == null ) { + return; + } + b.setEnabled( okayEnabled() ); + } + + private boolean okayEnabled() { + if ( !fChkBtnRead.getSelection() && !fChkBtnWrite.getSelection() ) { + return false ; + } + if ( fExpressionInput.getText().length() == 0 ) { + return false; + } + if ( fHasMemorySpaceControls && fMemorySpaceInput.getEnabled() && fMemorySpaceInput.getText().length() == 0 ) { + return false; + } + if ( fRangeField.getEnabled() + && ( fRangeField.getText().length() == 0 || !verifyIntegerText( fRangeField.getText() ) ) ) { + return false; + } + return true; + } + + public boolean getWriteAccess() { + return fWrite; + } + + public boolean getReadAccess() { + return fRead; + } + + public void setExpression(String expressionString ) { + fExpression = expressionString; + } + + public BigInteger getRange() { + return BigInteger.valueOf( Long.decode(fRange).longValue() ); + } + + public void initializeRange( boolean enable, String range ) { + fRangeInitialEnable = enable; + fRange = range; + } + + public void initializeMemorySpace( String memorySpace ) { + fMemorySpace = memorySpace; + } + + @Override + protected void createButtonsForButtonBar(Composite parent) { + // override so we can change the initial okay enabled state + createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, + true ).setEnabled( okayEnabled() ); + createButton( parent, IDialogConstants.CANCEL_ID, + IDialogConstants.CANCEL_LABEL, false ); + } + } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointOnVariableActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointOnVariableActionDelegate.java new file mode 100644 index 00000000000..8cfe88f155a --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointOnVariableActionDelegate.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.internal.ui.actions; + +/** + * This class was moved to a public package and this implementation is left here + * for backward compatibility for clients that used this internal class. + * + * @deprecated Use the {@link org.eclipse.cdt.debug.ui.breakpoints.AddWatchpointOnVariableActionDelegate} + * class instead. + */ +public class AddWatchpointOnVariableActionDelegate extends org.eclipse.cdt.debug.ui.breakpoints.AddWatchpointOnVariableActionDelegate{ + +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddWatchpointDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddWatchpointDialog.java deleted file mode 100644 index 8144e4d4cd4..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddWatchpointDialog.java +++ /dev/null @@ -1,439 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2008, 2008 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - * Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299 - * IBM Corporation - *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.actions.breakpoints; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.cdt.debug.core.cdi.model.ICDIMemorySpaceManagement; -import org.eclipse.cdt.debug.internal.ui.actions.ActionMessages; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.swt.SWT; -import org.eclipse.swt.accessibility.AccessibleAdapter; -import org.eclipse.swt.accessibility.AccessibleEvent; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.events.VerifyEvent; -import org.eclipse.swt.events.VerifyListener; -import org.eclipse.swt.graphics.FontMetrics; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -/** - * The "Add Watchpoint" dialog of the "Toggle watchpoint" action. - * @deprecated Replaced by opening a properties dialog on a new breakpoint. - */ -public class AddWatchpointDialog extends Dialog implements ModifyListener, SelectionListener { - - private Combo fExpressionInput; - private String fExpression; - private static List sExpressionHistory = new ArrayList(); - - private boolean fHasMemorySpaceControls; - private Button fMemorySpaceEnableButton; - private Combo fMemorySpaceInput; - private String fMemorySpace; - - private boolean fRangeInitialEnable; - private Button fRangeEnableButton; - private Text fRangeField; - private String fRange = ""; //$NON-NLS-1$ - - private Button fChkBtnWrite; - private Button fChkBtnRead; - private boolean fRead; - private boolean fWrite; - - private ICDIMemorySpaceManagement fMemManagement; - - - /** - * Constructor for AddWatchpointDialog. - * - * @param parentShell - */ - public AddWatchpointDialog( Shell parentShell, ICDIMemorySpaceManagement memMgmt ) { - super( parentShell ); - setShellStyle( getShellStyle() | SWT.RESIZE ); - fMemManagement = memMgmt; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - @Override - protected Control createDialogArea( Composite parent ) { - // The button bar will work better if we make the parent composite - // a single column grid layout. For the widgets we add, we want a - // a two-column grid, so we just create a sub composite for that. - GridLayout gridLayout = new GridLayout(); - parent.setLayout( gridLayout ); - GridData gridData = new GridData( GridData.FILL_BOTH ); - parent.setLayoutData( gridData ); - Composite composite = new Composite( parent, SWT.None ); - gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - composite.setLayout( gridLayout ); - parent = composite; - - // Create the controls - createExpressionControl( parent ); - boolean hasDebugContext = DebugUITools.getDebugContext() != null; - boolean hasMemorySpaces = hasDebugContext && fMemManagement != null && fMemManagement.getMemorySpaces() != null && fMemManagement.getMemorySpaces().length > 0; - fHasMemorySpaceControls = !hasDebugContext || hasMemorySpaces; - if ( fHasMemorySpaceControls ) { - createMemorySpaceControl( parent, hasMemorySpaces ); - } - createCountField( parent ); - createAccessWidgets( parent ); - - // Initialize the inter-control state - if ( fExpression != null && fExpression.length() > 0 ) { - fExpressionInput.add( fExpression, 0 ); - fExpressionInput.select( 0 ); - } - fExpressionInput.setFocus(); - if ( fHasMemorySpaceControls ) { - fMemorySpaceInput.setEnabled( fMemorySpaceEnableButton.getEnabled() ); - } - fRangeField.setEnabled( fRangeEnableButton.getEnabled() ); - updateUI(); - return parent; - } - - private void createExpressionControl(Composite parent ) { - - Label l = new Label( parent, GridData.FILL_HORIZONTAL ); - l.setText( ActionMessages.getString( "AddWatchpointDialog.1" ) ); //$NON-NLS-1$ - GridData gridData = new GridData( GridData.FILL_HORIZONTAL ); - gridData.horizontalSpan = 2; - l.setLayoutData( gridData ); - - fExpressionInput = new Combo( parent, SWT.BORDER ); - gridData = new GridData( GridData.FILL_HORIZONTAL ); - gridData.horizontalSpan = 2; - fExpressionInput.setLayoutData( gridData ); - fExpressionInput.addModifyListener( this ); - for (String expression : sExpressionHistory) { - fExpressionInput.add( expression ); - } - } - - private void createMemorySpaceControl( Composite parent, boolean hasMemorySpaces ) { - fMemorySpaceEnableButton = new Button( parent, SWT.CHECK ); - GridData gridData = new GridData( GridData.FILL_HORIZONTAL ); - gridData.horizontalSpan = 1; - fMemorySpaceEnableButton.setLayoutData( gridData ); - fMemorySpaceEnableButton.setText( ActionMessages.getString( "AddWatchpointDialog.5" ) ); //$NON-NLS-1$ - fMemorySpaceEnableButton.setSelection( false ); - fMemorySpaceEnableButton.addSelectionListener( this ); - - if ( hasMemorySpaces ) { - fMemorySpaceInput = new Combo( parent, SWT.BORDER | SWT.READ_ONLY ); - } else { - fMemorySpaceInput = new Combo( parent, SWT.BORDER ); - } - gridData = new GridData( GridData.FILL_HORIZONTAL ); - gridData.horizontalSpan = 1; - fMemorySpaceInput.setLayoutData( gridData ); - fMemorySpaceInput.addSelectionListener( this ); - if ( fMemManagement != null ) { - String [] memorySpaces = fMemManagement.getMemorySpaces(); - for ( int i = 0; i < memorySpaces.length; i++ ) { - fMemorySpaceInput.add( memorySpaces[i] ); - } - } - if ( fMemorySpace != null && fMemorySpace.length() > 0 ) { - int i = fMemorySpaceInput.indexOf( fMemorySpace ); - if ( i >= 0 ) { - fMemorySpaceInput.select( i ); - fMemorySpaceEnableButton.setSelection( true ); - } else { - fMemorySpaceInput.add( fMemorySpace ); - } - } - fMemorySpaceInput.addModifyListener( this ); - //234909 - for accessibility - fMemorySpaceInput.getAccessible().addAccessibleListener( - new AccessibleAdapter() { - @Override - public void getName(AccessibleEvent e) { - e.result = ActionMessages.getString( "AddWatchpointDialog.5" ); //$NON-NLS-1$ - } - - }); - } - - /** - * @param text - * @param c - * @return true if the concatenation of text + c results - * in a valid string representation of an integer - * @see verifyIntegerText() - */ - private static boolean verifyIntegerTextAddition( String text, char c ) { - - // pass through all control characters - if ( Character.isISOControl( c ) ) { - return true; - } - - // case-insensitive - c = Character.toLowerCase( c ); - text = text.toLowerCase(); - - // first character has to be 0-9 - if ( text.length() == 0 ) { - return Character.isDigit( c ); - } - - // second character must be x if preceded by a 0, otherwise 0-9 will do - if ( text.length() == 1 ) { - if ( text.equals( "0" ) ) { //$NON-NLS-1$ - return c == 'x'; - } - return Character.isDigit( c ); - } - - // all subsequent characters must be 0-9 or a-f if started with 0x - return Character.isDigit( c ) - || text.startsWith( "0x" ) && 'a' <= c && c <= 'f'; //$NON-NLS-1$ - } - - /** - * @param text integer string built up using verifyIntegerTextAddition() - * @return true if text represents a valid string representation of - * an integer - */ - private static boolean verifyIntegerText( String text ) { - if ( text.length() == 0 ) { - return false; - } - if ( text.length() == 1 ) { - return true; - } - if ( text.length() == 2 ) { - return !text.equals("0x"); //$NON-NLS-1$ - } - return true; - } - - private void createCountField( Composite parent ) { - fRangeEnableButton = new Button( parent, SWT.CHECK ); - GridData gridData = new GridData( GridData.FILL_HORIZONTAL ); - gridData.horizontalSpan = 1; - fRangeEnableButton.setLayoutData( gridData ); - fRangeEnableButton.setText( ActionMessages.getString( "AddWatchpointDialog.6" ) ); //$NON-NLS-1$ - fRangeEnableButton.setSelection( fRangeInitialEnable && fRange.length() > 0 ); - fRangeEnableButton.addSelectionListener( this ); - - fRangeField = new Text( parent, SWT.BORDER ); - gridData = new GridData( GridData.FILL_HORIZONTAL ); - gridData.horizontalSpan = 1; - GC gc = new GC( fRangeField ); - FontMetrics fm = gc.getFontMetrics(); - gridData.minimumWidth = 8 * fm.getAverageCharWidth(); - fRangeField.setLayoutData( gridData ); - fRangeField.setText( fRange ); - fRangeField.addVerifyListener( new VerifyListener() { - @Override - public void verifyText( VerifyEvent e ) { - e.doit = verifyIntegerTextAddition( fRangeField.getText(), e.character ); - } - }); - fRangeField.addModifyListener( this ); - //234909 - for accessibility - fRangeField.getAccessible().addAccessibleListener( - new AccessibleAdapter() { - @Override - public void getName(AccessibleEvent e) { - e.result = ActionMessages.getString( "AddWatchpointDialog.6" ); //$NON-NLS-1$ - } - - }); - } - - private void createAccessWidgets( Composite parent ) { - GridData gridData = new GridData( GridData.FILL_HORIZONTAL ); - gridData.horizontalSpan = 3; - - Group group = new Group( parent, SWT.NONE ); - group.setLayout( new GridLayout() ); - group.setLayoutData( gridData ); - group.setText( ActionMessages.getString( "AddWatchpointDialog.2" ) ); //$NON-NLS-1$ - fChkBtnWrite = new Button( group, SWT.CHECK ); - fChkBtnWrite.setText( ActionMessages.getString( "AddWatchpointDialog.3" ) ); //$NON-NLS-1$ - fChkBtnWrite.setSelection( true ); - fChkBtnWrite.addSelectionListener( this ); - fChkBtnRead = new Button( group, SWT.CHECK ); - fChkBtnRead.setText( ActionMessages.getString( "AddWatchpointDialog.4" ) ); //$NON-NLS-1$ - fChkBtnRead.setSelection( false ); - fChkBtnRead.addSelectionListener( this ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) - */ - @Override - protected void configureShell( Shell newShell ) { - super.configureShell( newShell ); - - // use the same title used by the platform dialog - newShell.setText( ActionMessages.getString( "AddWatchpointDialog.0" ) ); //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#okPressed() - */ - @Override - protected void okPressed() { - fExpression = fExpressionInput.getText().trim(); - if ( fExpression.length() > 0 ) { - addHistory( fExpression ); - } - if ( fHasMemorySpaceControls ) { - fMemorySpace = fMemorySpaceEnableButton.getSelection() ? fMemorySpaceInput.getText().trim() : ""; //$NON-NLS-1$ - } - fRange = fRangeEnableButton.getSelection() ? fRangeField.getText().trim() : "0"; //$NON-NLS-1$ - fRead = fChkBtnRead.getSelection(); - fWrite = fChkBtnWrite.getSelection(); - super.okPressed(); - } - - /* (non-Javadoc) - * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) - */ - @Override - public void modifyText( ModifyEvent e ) { - updateUI(); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.TrayDialog#createButtonBar(org.eclipse.swt.widgets.Composite) - */ - @Override - protected Control createButtonBar( Composite parent ) { - return super.createButtonBar( parent ); - } - - public String getExpression() { - return fExpression; - } - - public String getMemorySpace() { - return fMemorySpace; - } - - private static void addHistory( String item ) { - if ( !sExpressionHistory.contains( item ) ) { - sExpressionHistory.add( 0, item ); - - if ( sExpressionHistory.size() > 5 ) - sExpressionHistory.remove( sExpressionHistory.size() - 1 ); - } - } - - /* (non-Javadoc) - * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) - */ - @Override - public void widgetDefaultSelected( SelectionEvent e ) { - // ignore - } - - /* (non-Javadoc) - * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) - */ - @Override - public void widgetSelected( SelectionEvent e ) { - updateUI(); - } - - private void updateUI() { - if ( fHasMemorySpaceControls ) { - fMemorySpaceInput.setEnabled( fMemorySpaceEnableButton.getSelection() ); - } - fRangeField.setEnabled( fRangeEnableButton.getSelection() ); - Button b = getButton( IDialogConstants.OK_ID ); - if ( b == null ) { - return; - } - b.setEnabled( okayEnabled() ); - } - - private boolean okayEnabled() { - if ( !fChkBtnRead.getSelection() && !fChkBtnWrite.getSelection() ) { - return false ; - } - if ( fExpressionInput.getText().length() == 0 ) { - return false; - } - if ( fHasMemorySpaceControls && fMemorySpaceInput.getEnabled() && fMemorySpaceInput.getText().length() == 0 ) { - return false; - } - if ( fRangeField.getEnabled() - && ( fRangeField.getText().length() == 0 || !verifyIntegerText( fRangeField.getText() ) ) ) { - return false; - } - return true; - } - - public boolean getWriteAccess() { - return fWrite; - } - - public boolean getReadAccess() { - return fRead; - } - - public void setExpression(String expressionString ) { - fExpression = expressionString; - } - - public BigInteger getRange() { - return BigInteger.valueOf( Long.decode(fRange).longValue() ); - } - - public void initializeRange( boolean enable, String range ) { - fRangeInitialEnable = enable; - fRange = range; - } - - public void initializeMemorySpace( String memorySpace ) { - fMemorySpace = memorySpace; - } - - @Override - protected void createButtonsForButtonBar(Composite parent) { - // override so we can change the initial okay enabled state - createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, - true ).setEnabled( okayEnabled() ); - createButton( parent, IDialogConstants.CANCEL_ID, - IDialogConstants.CANCEL_LABEL, false ); - } - -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddWatchpointOnMemoryActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddWatchpointOnMemoryActionDelegate.java deleted file mode 100644 index 01e61b53471..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddWatchpointOnMemoryActionDelegate.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 Nokia 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Nokia - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.actions.breakpoints; - - -import java.math.BigInteger; - -import org.eclipse.cdt.debug.internal.core.model.CMemoryBlockExtension; -import org.eclipse.cdt.debug.ui.CDebugUIPlugin; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.debug.core.DebugException; -import org.eclipse.debug.core.model.IMemoryBlock; -import org.eclipse.debug.core.model.IMemoryBlockExtension; -import org.eclipse.debug.core.model.MemoryByte; -import org.eclipse.debug.ui.memory.IRepositionableMemoryRendering; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.ui.IActionDelegate; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; - - -public class AddWatchpointOnMemoryActionDelegate extends AddWatchpointActionDelegate { - - /** - * Constructor for Action1. - */ - public AddWatchpointOnMemoryActionDelegate() { - super(); - } - - /** - * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) - */ - public void setActivePart(IAction action, IWorkbenchPart targetPart) {} - - /** - * @see IActionDelegate#run(IAction) - */ - @Override - public void run(IAction action) { - IStructuredSelection selection = getSelection(); - - if (selection == null || selection.isEmpty()) { - return; - } - - Object obj = selection.getFirstElement(); - if (obj != null) { - String memorySpace = null; - String address = ""; //$NON-NLS-1$ - String range = "1"; //$NON-NLS-1$ - - if (obj instanceof IAdaptable) { - IRepositionableMemoryRendering rendering = (IRepositionableMemoryRendering) ((IAdaptable)obj).getAdapter(IRepositionableMemoryRendering.class); - if (rendering != null) { - int addressableSize = 1; - IMemoryBlock memblock = rendering.getMemoryBlock(); - if (memblock instanceof IMemoryBlockExtension) { - try { - addressableSize = ((IMemoryBlockExtension)memblock).getAddressableSize(); - } catch (DebugException e) { - CDebugUIPlugin.log(e); - } - } - - memorySpace = getMemorySpace(rendering.getMemoryBlock(), memorySpace); - address = getSelectedAddress(rendering.getSelectedAddress(), address); - range = getRange(rendering.getSelectedAsBytes(), addressableSize, range); - } - } - - AddWatchpointDialog dlg = new AddWatchpointDialog(CDebugUIPlugin.getActiveWorkbenchShell(), - getMemorySpaceManagement()); - dlg.initializeMemorySpace(memorySpace); - dlg.setExpression(address); - dlg.initializeRange(true, range); - - if (dlg.open() == Window.OK) { - addWatchpoint(dlg.getWriteAccess(), dlg.getReadAccess(), dlg.getExpression(), dlg.getMemorySpace(), dlg.getRange()); - } - } - } - - private String getMemorySpace(IMemoryBlock memBlock, String def) { - if (memBlock != null && memBlock instanceof CMemoryBlockExtension) { - return ((CMemoryBlockExtension)memBlock).getMemorySpaceID(); - } - return def; - } - - private String getSelectedAddress(BigInteger selectedAddress, String def) { - if (selectedAddress != null) { - return "0x" + selectedAddress.toString(16); //$NON-NLS-1$ - } - return def; - } - - private String getRange(MemoryByte[] selectedBytes, int addressableSize, String def) { - if (selectedBytes != null && selectedBytes.length > 0) { - return Integer.toString(selectedBytes.length / addressableSize); - } - return def; - } - - /** - * @see IActionDelegate#selectionChanged(IAction, ISelection) - */ - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) - */ - @Override - public void selectionChanged(IAction action, ISelection selection) {} - - private IStructuredSelection getSelection() { - return (IStructuredSelection)getView().getViewSite().getSelectionProvider().getSelection(); - } -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddWatchpointOnVariableActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddWatchpointOnVariableActionDelegate.java deleted file mode 100644 index 66a5d5e03de..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddWatchpointOnVariableActionDelegate.java +++ /dev/null @@ -1,179 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Nokia 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Nokia - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.actions.breakpoints; - - -import org.eclipse.cdt.debug.internal.core.CRequest; -import org.eclipse.cdt.debug.internal.core.ICWatchpointTarget; -import org.eclipse.cdt.debug.internal.ui.actions.ActionMessages; -import org.eclipse.cdt.debug.ui.CDebugUIPlugin; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TreeSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.progress.WorkbenchJob; - -/** - * Invoked when user right clicks on an element in the Variables or Expressions - * view and selects 'Add Watchpoint (C/C++)' - */ -public class AddWatchpointOnVariableActionDelegate extends AddWatchpointActionDelegate implements IObjectActionDelegate { - - /** The target variable/expression */ - private ICWatchpointTarget fVar; - - /** The view where fVar was selected */ - private IWorkbenchPart fActivePart; - - /** - * Constructor - */ - public AddWatchpointOnVariableActionDelegate() { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) - */ - @Override - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - fActivePart = targetPart; - } - - private static class GetSizeRequest extends CRequest implements ICWatchpointTarget.GetSizeRequest { - int fSize = -1; - @Override - public int getSize() { - return fSize; - } - @Override - public void setSize(int size) { - fSize = size; - } - }; - - /* (non-Javadoc) - * @see org.eclipse.cdt.debug.internal.ui.actions.AddWatchpointActionDelegate#run(org.eclipse.jface.action.IAction) - */ - @Override - public void run(IAction action) { - if (fVar == null) { - return; - } - - final String expr = fVar.getExpression(); - if (expr == null) { - assert false : "how are we getting an empty expression?"; //$NON-NLS-1$ - return; - } - - // Getting the size of the variable/expression is an asynchronous - // operation...or at least the API is (the CDI implementation reacts - // synchronously) - final ICWatchpointTarget.GetSizeRequest request = new GetSizeRequest() { - @Override - public void done() { - if (isSuccess()) { - // Now that we have the size, put up a dialog to create the watchpoint - final int size = getSize(); - assert size > 0 : "unexpected variale/expression size"; //$NON-NLS-1$ - WorkbenchJob job = new WorkbenchJob("open watchpoint dialog") { //$NON-NLS-1$ - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - AddWatchpointDialog dlg = new AddWatchpointDialog(CDebugUIPlugin.getActiveWorkbenchShell(), - getMemorySpaceManagement()); - dlg.setExpression(expr); - dlg.initializeRange(false, Integer.toString(size)); - if (dlg.open() == Window.OK) { - addWatchpoint(dlg.getWriteAccess(), dlg.getReadAccess(), dlg.getExpression(), dlg.getMemorySpace(), dlg.getRange()); - } - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.schedule(); - } - else { - WorkbenchJob job = new WorkbenchJob("watchpoint error") { //$NON-NLS-1$ - @Override - public IStatus runInUIThread(IProgressMonitor monitor) { - if (fActivePart != null) { - ErrorDialog.openError( fActivePart.getSite().getWorkbenchWindow().getShell(), ActionMessages.getString( "AddWatchpointOnVariableActionDelegate.Error_Dlg_Title" ), ActionMessages.getString( "AddWatchpointOnVariableActionDelegate.No_Element_Size" ), getStatus() ); //$NON-NLS-1$ //$NON-NLS-2$ - } - return Status.OK_STATUS; - } - }; - job.setSystem(true); - job.schedule(); - } - } - }; - fVar.getSize(request); - } - - private class CanCreateWatchpointRequest extends CRequest implements ICWatchpointTarget.CanCreateWatchpointRequest { - boolean fCanCreate; - @Override - public boolean getCanCreate() { - return fCanCreate; - } - @Override - public void setCanCreate(boolean value) { - fCanCreate = value; - } - }; - - /** - * Record the target variable/expression - * - * @see org.eclipse.ui.actions.ActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, - * org.eclipse.jface.viewers.ISelection) - */ - @Override - public void selectionChanged(final IAction action, ISelection selection) { - fVar = null; - if (selection == null || selection.isEmpty()) { - action.setEnabled(false); - return; - } - if (selection instanceof TreeSelection) { - Object obj = ((TreeSelection)selection).getFirstElement(); - fVar = (ICWatchpointTarget)DebugPlugin.getAdapter(obj, ICWatchpointTarget.class); - if (fVar != null) { - final ICWatchpointTarget.CanCreateWatchpointRequest request = new CanCreateWatchpointRequest() { - @Override - public void done() { - action.setEnabled(getCanCreate()); - } - }; - fVar.canSetWatchpoint(request); - return; - } - assert false : "action should not have been available for object " + obj; //$NON-NLS-1$ - } - else if (selection instanceof StructuredSelection) { - // Not sure why, but sometimes we get an extraneous empty StructuredSelection. Seems harmless enough - assert ((StructuredSelection)selection).getFirstElement() == null : "action installed in unexpected type of view/part"; //$NON-NLS-1$ - } - else { - assert false : "action installed in unexpected type of view/part"; //$NON-NLS-1$ - } - action.setEnabled(false); - } -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleBreakpointAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleBreakpointAdapter.java index 41201f51497..c35d3537077 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleBreakpointAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleBreakpointAdapter.java @@ -89,12 +89,12 @@ public class ToggleBreakpointAdapter extends AbstractToggleBreakpointAdapter { @Override protected void createWatchpoint( boolean interactive, IWorkbenchPart part, String sourceHandle, IResource resource, - int charStart, int charEnd, int lineNumber, String expression) throws CoreException + int charStart, int charEnd, int lineNumber, String expression, String memorySpace, String range) throws CoreException { ICWatchpoint bp = CDIDebugModel.createBlankWatchpoint(); Map attributes = new HashMap(); CDIDebugModel.setWatchPointAttributes(attributes, sourceHandle, resource, true, false, - expression, "", new BigInteger("0"), true, 0, ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + expression, memorySpace, new BigInteger(range), true, 0, ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ openBreakpointPropertiesDialog(bp, part, resource, attributes); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleTracepointAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleTracepointAdapter.java index 375c8f7f00f..0510d80ecdb 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleTracepointAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleTracepointAdapter.java @@ -81,7 +81,7 @@ public class ToggleTracepointAdapter extends AbstractToggleBreakpointAdapter { } protected void createWatchpoint( boolean interactive, IWorkbenchPart part, String sourceHandle, IResource resource, - int charStart, int charEnd, int lineNumber, String expression) throws CoreException + int charStart, int charEnd, int lineNumber, String expression, String memorySpace, String range) throws CoreException { } 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 ecc61aa6bf0..45819b032fd 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 @@ -31,6 +31,8 @@ CBreakpointPropertyPage.watchpointType_read_label=Read CBreakpointPropertyPage.watchpointType_write_label=Write CBreakpointPropertyPage.watchpoint_expression_label=Expression to watch: CBreakpointPropertyPage.watchpoint_expression_errorMessage=Enter the expression to watch: +CBreakpointPropertyPage.watchpoint_range_label=Range: +CBreakpointPropertyPage.watchpoint_memorySpace_label=Memory Space: CBreakpointPropertyPage.condition_label=&Condition: CBreakpointPropertyPage.condition_invalidValue_message=Invalid condition. CBreakpointPropertyPage.ignoreCount_label=&Ignore count: diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPreferenceStore.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPreferenceStore.java index c558db83b63..6a284f5039e 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPreferenceStore.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPreferenceStore.java @@ -52,7 +52,6 @@ public class CBreakpointPreferenceStore implements IPersistentPreferenceStore { private ListenerList fListeners; private final CBreakpointContext fContext; - // TODO: remove after fixing add event breapoint dialog. public CBreakpointPreferenceStore() { this (null, null); } @@ -220,7 +219,7 @@ public class CBreakpointPreferenceStore implements IPersistentPreferenceStore { } public String getString(String name) { - String retVal = null; + String retVal = ""; //$NON-NLS-1$ Object o = fProperties.get(name); if (o instanceof String) { retVal = (String)o; 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 587abcbfa04..68b8a6beb22 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 @@ -13,11 +13,16 @@ package org.eclipse.cdt.debug.internal.ui.breakpoints; import org.eclipse.cdt.debug.core.CDIDebugModel; +import org.eclipse.cdt.debug.core.cdi.model.ICDIMemorySpaceManagement; +import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint; import org.eclipse.cdt.debug.core.model.ICBreakpoint; +import org.eclipse.cdt.debug.core.model.ICDebugTarget; import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint; import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; import org.eclipse.cdt.debug.core.model.ICWatchpoint; +import org.eclipse.cdt.debug.core.model.ICWatchpoint2; +import org.eclipse.cdt.debug.internal.ui.preferences.ComboFieldEditor; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.debug.ui.breakpoints.CBreakpointUIContributionFactory; import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointContext; @@ -28,14 +33,25 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.model.ILineBreakpoint; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.debug.ui.contexts.IDebugContextProvider; import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.FieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IntegerFieldEditor; import org.eclipse.jface.preference.StringFieldEditor; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbenchPropertyPage; import org.eclipse.ui.model.IWorkbenchAdapter; @@ -164,6 +180,227 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement } } + class WatchpointRangeFieldEditor extends IntegerFieldEditor { + + private static final String DISABLED_VALUE = "0"; //$NON-NLS-1$ + private Button fCheckbox; + private boolean fWasSelected; + + public WatchpointRangeFieldEditor( String name, String labelText, Composite parent ) { + super( name, labelText, parent ); + } + + @Override + protected void doFillIntoGrid(Composite parent, int numColumns) { + getCheckboxControl(parent); + super.doFillIntoGrid(parent, numColumns); + } + + private Button getCheckboxControl(Composite parent) { + if (fCheckbox == null) { + Composite inner= new Composite(parent, SWT.NULL); + final GridLayout layout= new GridLayout(2, false); + layout.marginWidth = 0; + inner.setLayout(layout); + fCheckbox= new Button(inner, SWT.CHECK); + fCheckbox.setFont(parent.getFont()); + fCheckbox.setText(getLabelText()); + // create and hide label from base class + Label label = getLabelControl(inner); + label.setText(""); //$NON-NLS-1$ + label.setVisible(false); + fCheckbox.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + boolean isSelected = fCheckbox.getSelection(); + valueChanged(fWasSelected, isSelected); + fWasSelected = isSelected; + } + }); + } else { + checkParent(fCheckbox.getParent(), parent); + } + return fCheckbox; + } + + @Override + protected boolean checkState() { + if (fCheckbox != null && !fCheckbox.getSelection()) { + clearErrorMessage(); + return true; + } + return super.checkState(); + } + + @Override + public Label getLabelControl(Composite parent) { + final Label label= getLabelControl(); + if (label == null) { + return super.getLabelControl(parent); + } else { + checkParent(label.getParent(), parent); + } + return label; + } + + @Override + protected void doLoad() { + if (getTextControl() != null && fCheckbox != null && getLabelControl() != null) { + oldValue = getPreferenceStore().getString(getPreferenceName()); + boolean enabled = !DISABLED_VALUE.equals(oldValue); + getTextControl().setText(enabled ? oldValue : ""); //$NON-NLS-1$ + fCheckbox.setSelection(enabled); + fWasSelected = enabled; + getTextControl().setEnabled(enabled); + getLabelControl().setEnabled(enabled); + } + } + + @Override + protected void doStore() { + if (fCheckbox != null && !fCheckbox.getSelection()) { + getPreferenceStore().setValue(getPreferenceName(), DISABLED_VALUE); + } else { + Text text = getTextControl(); + if (text != null) { + getPreferenceStore().setValue(getPreferenceName(), text.getText().trim()); + } + } + } + + @Override + public int getIntValue() throws NumberFormatException { + if (fCheckbox != null && !fCheckbox.getSelection()) { + return 0; + } else { + return super.getIntValue(); + } + } + + protected void valueChanged(boolean oldValue, boolean newValue) { + if (oldValue != newValue) { + valueChanged(); + fireStateChanged(VALUE, oldValue, newValue); + getTextControl().setEnabled(newValue); + getLabelControl().setEnabled(newValue); + } + } + + } + + class WatchpointMemorySpaceFieldEditor extends ComboFieldEditor { + + private static final String DISABLED_VALUE = ""; //$NON-NLS-1$ + private Button fCheckbox; + private boolean fWasSelected; + + public WatchpointMemorySpaceFieldEditor( String name, String labelText, String[] memorySpaces, Composite parent ) { + super( name, labelText, makeArray2D(memorySpaces), parent ); + } + + @Override + protected void doFillIntoGrid(Composite parent, int numColumns) { + getCheckboxControl(parent); + super.doFillIntoGrid(parent, numColumns); + } + + private Button getCheckboxControl(Composite parent) { + if (fCheckbox == null) { + Composite inner= new Composite(parent, SWT.NULL); + final GridLayout layout= new GridLayout(2, false); + layout.marginWidth = 0; + inner.setLayout(layout); + fCheckbox= new Button(inner, SWT.CHECK); + fCheckbox.setFont(parent.getFont()); + fCheckbox.setText(getLabelText()); + // create and hide label from base class + Label label = getLabelControl(inner); + label.setText(""); //$NON-NLS-1$ + label.setVisible(false); + fCheckbox.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + boolean isSelected = fCheckbox.getSelection(); + valueChanged(fWasSelected, isSelected); + fWasSelected = isSelected; + } + }); + } else { + checkParent(fCheckbox.getParent(), parent); + } + return fCheckbox; + } + + @Override + public Label getLabelControl(Composite parent) { + final Label label= getLabelControl(); + if (label == null) { + return super.getLabelControl(parent); + } else { + checkParent(label.getParent(), parent); + } + return label; + } + + @Override + protected void doLoad() { + super.doLoad(); + if (fCheckbox != null && getLabelControl() != null) { + String value = getPreferenceStore().getString(getPreferenceName()); + boolean enabled = !DISABLED_VALUE.equals(value); + fCheckbox.setSelection(enabled); + fWasSelected = enabled; + getComboBoxControl().setEnabled(enabled); + getLabelControl().setEnabled(enabled); + } + } + + @Override + protected void doStore() { + if (fCheckbox != null && !fCheckbox.getSelection()) { + getPreferenceStore().setValue(getPreferenceName(), DISABLED_VALUE); + } else { + super.doStore(); + } + } + + protected void valueChanged(boolean oldValue, boolean newValue) { + if (oldValue != newValue) { + fireStateChanged(VALUE, oldValue, newValue); + getComboBoxControl().setEnabled(newValue); + getLabelControl().setEnabled(newValue); + } + } + + } + + private String[][] makeArray2D(String[] array) { + String[][] array2d = new String[array.length][]; + for (int i = 0; i < array.length; i++) { + array2d[i] = new String[2]; + array2d[i][0] = array2d[i][1] = array[i]; + } + return array2d; + } + + private ICDIMemorySpaceManagement getMemorySpaceManagement(){ + Object debugViewElement = getDebugContext(); + ICDIMemorySpaceManagement memMgr = null; + + if ( debugViewElement != null ) { + ICDebugTarget debugTarget = (ICDebugTarget)DebugPlugin.getAdapter(debugViewElement, ICDebugTarget.class); + + if ( debugTarget != null ){ + ICDITarget target = (ICDITarget)debugTarget.getAdapter(ICDITarget.class); + + if (target instanceof ICDIMemorySpaceManagement) + memMgr = (ICDIMemorySpaceManagement)target; + } + } + + return memMgr; + } + class LabelFieldEditor extends ReadOnlyFieldEditor { private String fValue; @@ -272,6 +509,8 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement addField( createLabelEditor( getFieldEditorParent(), BreakpointsMessages.getString( "CBreakpointPropertyPage.sourceHandle_label" ), filename ) ); //$NON-NLS-1$ } createWatchExpressionEditor(getFieldEditorParent()); + createWatchMemorySpaceEditor(getFieldEditorParent()); + createWatchRangeEditor(getFieldEditorParent()); createWatchTypeEditors(getFieldEditorParent()); } @@ -355,6 +594,46 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement } } + protected void createWatchMemorySpaceEditor( Composite parent ) { + ICBreakpoint breakpoint = getBreakpoint(); + if (breakpoint == null || breakpoint.getMarker() == null) { + ICDIMemorySpaceManagement memSpaceMgmt = getMemorySpaceManagement(); + if (memSpaceMgmt != null) { + String[] memorySpaces = memSpaceMgmt.getMemorySpaces(); + if (memorySpaces != null && memorySpaces.length != 0) { + addField( new WatchpointMemorySpaceFieldEditor( + ICWatchpoint2.MEMORYSPACE, + BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_memorySpace_label"), //$NON-NLS-1$ + memorySpaces, + parent) ); + } + } + } else { + String memorySpace = getPreferenceStore().getString(ICWatchpoint2.MEMORYSPACE); + if (memorySpace != null && memorySpace.length() != 0) { + addField(createLabelEditor( + parent, + BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_memorySpace_label"), //$NON-NLS-1$ + getPreferenceStore().getString(ICWatchpoint2.MEMORYSPACE) )); + } + } + } + + protected void createWatchRangeEditor( Composite parent ) { + ICBreakpoint breakpoint = getBreakpoint(); + if (breakpoint == null || breakpoint.getMarker() == null) { + addField( new WatchpointRangeFieldEditor( + ICWatchpoint2.RANGE, + BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_range_label"), //$NON-NLS-1$ + parent) ); + } else { + addField(createLabelEditor( + parent, + BreakpointsMessages.getString("CBreakpointPropertyPage.watchpoint_range_label"), //$NON-NLS-1$ + getPreferenceStore().getString(ICWatchpoint2.RANGE) )); + } + } + protected void createWatchTypeEditors( Composite parent ) { // Edit read/write options only when creating the breakpoint. ICBreakpoint breakpoint = getBreakpoint(); @@ -404,6 +683,19 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement return (ICBreakpoint)element.getAdapter(ICBreakpoint.class); } } + + protected Object getDebugContext() { + IDebugContextProvider provider = (IDebugContextProvider)getElement().getAdapter(IDebugContextProvider.class); + if (provider != null) { + ISelection selection = provider.getActiveContext(); + if (selection instanceof IStructuredSelection) { + return ((IStructuredSelection) selection).getFirstElement(); + } + return null; + } + return DebugUITools.getDebugContext(); + } + protected IResource getResource() { IAdaptable element = getElement(); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ComboFieldEditor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ComboFieldEditor.java index bf197c2186c..40bceb60178 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ComboFieldEditor.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/ComboFieldEditor.java @@ -139,7 +139,7 @@ public class ComboFieldEditor extends FieldEditor { /** * Lazily create and return the Combo control. */ - public Combo getComboBoxControl(Composite parent) { + protected Combo getComboBoxControl(Composite parent) { if (fCombo == null) { fCombo = new Combo(parent, SWT.READ_ONLY); for (int i = 0; i < fEntryNamesAndValues.length; i++) { @@ -160,6 +160,10 @@ public class ComboFieldEditor extends FieldEditor { return fCombo; } + protected Combo getComboBoxControl() { + return fCombo; + } + /** * Given the name (label) of an entry, return the corresponding value. */ diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AbstractToggleBreakpointAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AbstractToggleBreakpointAdapter.java index 22dd8d73e79..5e5d2f3edfa 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AbstractToggleBreakpointAdapter.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AbstractToggleBreakpointAdapter.java @@ -11,6 +11,7 @@ package org.eclipse.cdt.debug.ui.breakpoints; +import java.math.BigInteger; import java.util.Iterator; import java.util.Map; @@ -24,10 +25,13 @@ import org.eclipse.cdt.core.model.IMethod; import org.eclipse.cdt.core.model.ISourceRange; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.IVariable; +import org.eclipse.cdt.debug.core.ICWatchpointTarget; import org.eclipse.cdt.debug.core.model.ICBreakpoint; import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint; import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; import org.eclipse.cdt.debug.core.model.ICWatchpoint; +import org.eclipse.cdt.debug.internal.core.CRequest; +import org.eclipse.cdt.debug.internal.core.model.CMemoryBlockExtension; import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils; import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants; import org.eclipse.cdt.debug.internal.ui.actions.ActionMessages; @@ -43,13 +47,20 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.model.IBreakpoint; +import org.eclipse.debug.core.model.IMemoryBlock; +import org.eclipse.debug.core.model.IMemoryBlockExtension; +import org.eclipse.debug.core.model.MemoryByte; import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension2; +import org.eclipse.debug.ui.memory.IRepositionableMemoryRendering; import org.eclipse.jface.preference.PreferenceDialog; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; @@ -68,6 +79,7 @@ import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.ui.editors.text.ILocationProvider; +import org.eclipse.ui.progress.WorkbenchJob; import org.eclipse.ui.texteditor.IEditorStatusLine; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.SimpleMarkerAnnotation; @@ -131,11 +143,19 @@ abstract public class AbstractToggleBreakpointAdapter if ( variable != null ) { updateVariableWatchpoint(true, false, part, variable); } + IRepositionableMemoryRendering rendering = getMemoryRendering(part, selection); + if (rendering != null) { + updateMemoryWatchpoint(true, false, part, rendering); + } + + } @Override public boolean canToggleWatchpoints( IWorkbenchPart part, ISelection selection ) { - return getVariableFromSelection( part, selection ) != null; + return getVariableFromSelection( part, selection ) != null || + getMemoryRendering(part, selection) != null || + getWatchpointTarget(part, selection) != null; } @Override @@ -171,13 +191,26 @@ abstract public class AbstractToggleBreakpointAdapter ICElement element = getCElementFromSelection( part, selection ); if (element instanceof IVariable) { updateVariableWatchpoint(false, true, part, (IVariable)element); - } else { - String text = ""; //$NON-NLS-1$ - if (selection instanceof ITextSelection) { - text = ((ITextSelection)selection).getText(); - } - createWatchpoint(true, part, null, ResourcesPlugin.getWorkspace().getRoot(), -1, -1, -1, text); + return; + } + + IRepositionableMemoryRendering rendering = getMemoryRendering(part, selection); + if (rendering != null) { + updateMemoryWatchpoint(false, true, part, rendering); + return; + } + + ICWatchpointTarget watchpointTarget = getWatchpointTarget(part, selection); + if (watchpointTarget != null) { + updateTargetWatchpoint(false, true, part, watchpointTarget); + return; } + + String text = ""; //$NON-NLS-1$ + if (selection instanceof ITextSelection) { + text = ((ITextSelection)selection).getText(); + } + createWatchpoint(true, part, null, ResourcesPlugin.getWorkspace().getRoot(), -1, -1, -1, text, null, "0"); //$NON-NLS-1$ } @Override @@ -366,10 +399,107 @@ abstract public class AbstractToggleBreakpointAdapter } catch (CModelException e) { CDebugUIPlugin.log(e); } - createWatchpoint(interactive, part, sourceHandle, resource, charStart, charEnd, lineNumber, expression); + createWatchpoint(interactive, part, sourceHandle, resource, charStart, charEnd, lineNumber, expression, null, "0"); //$NON-NLS-1$ } } + private void updateMemoryWatchpoint(boolean toggle, boolean interactive, IWorkbenchPart part, + IRepositionableMemoryRendering rendering) throws CoreException + { + int addressableSize = 1; + IMemoryBlock memblock = rendering.getMemoryBlock(); + if (memblock instanceof IMemoryBlockExtension) { + try { + addressableSize = ((IMemoryBlockExtension)memblock).getAddressableSize(); + } catch (DebugException e) { + CDebugUIPlugin.log(e); + } + } + + String memorySpace = getMemorySpace(rendering.getMemoryBlock(), null); + String address = getSelectedAddress(rendering.getSelectedAddress(), ""); //$NON-NLS-1$ + String range = getRange(rendering.getSelectedAsBytes(), addressableSize, "1"); //$NON-NLS-1$ + + createWatchpoint(interactive, part, "", ResourcesPlugin.getWorkspace().getRoot(), -1, -1, -1, address, //$NON-NLS-1$ + memorySpace, range); + } + + private String getMemorySpace(IMemoryBlock memBlock, String def) { + if (memBlock != null && memBlock instanceof CMemoryBlockExtension) { + return ((CMemoryBlockExtension)memBlock).getMemorySpaceID(); + } + return def; + } + + private String getSelectedAddress(BigInteger selectedAddress, String def) { + if (selectedAddress != null) { + return "0x" + selectedAddress.toString(16); //$NON-NLS-1$ + } + return def; + } + + private String getRange(MemoryByte[] selectedBytes, int addressableSize, String def) { + if (selectedBytes != null && selectedBytes.length > 0) { + return Integer.toString(selectedBytes.length / addressableSize); + } + return def; + } + + private void updateTargetWatchpoint(boolean toggle, final boolean interactive, final IWorkbenchPart part, + ICWatchpointTarget watchpointTarget) throws CoreException + { + String _expr = watchpointTarget.getExpression(); + if (_expr == null) { + _expr = ""; //$NON-NLS-1$ + } + final String expr = _expr; + + // Getting the size of the variable/expression is an asynchronous + // operation...or at least the API is (the CDI implementation reacts + // synchronously) + + class GetSizeRequest extends CRequest implements ICWatchpointTarget.GetSizeRequest { + int fSize = -1; + @Override + public int getSize() { + return fSize; + } + @Override + public void setSize(int size) { + fSize = size; + } + + @Override + public void done() { + int _size = 0; + if (isSuccess()) { + // Now that we have the size, put up a dialog to create the watchpoint + _size = getSize(); + assert _size > 0 : "unexpected variale/expression size"; //$NON-NLS-1$ + } + final int size = _size; + + WorkbenchJob job = new WorkbenchJob("open watchpoint dialog") { //$NON-NLS-1$ + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { + try { + createWatchpoint(interactive, part, "", ResourcesPlugin.getWorkspace().getRoot(), //$NON-NLS-1$ + -1, -1, -1, expr, null, Integer.toString(size)); + } catch (CoreException e) { + return e.getStatus(); + } + return Status.OK_STATUS; + } + }; + job.setSystem(true); + job.schedule(); + } + }; + + watchpointTarget.getSize(new GetSizeRequest()); + + } + /** * Returns the C model element at the given selection. * @param part Workbench part where the selection is. @@ -440,7 +570,37 @@ abstract public class AbstractToggleBreakpointAdapter } return null; } + + protected IRepositionableMemoryRendering getMemoryRendering( IWorkbenchPart part, ISelection selection ) { + if (selection != null && selection instanceof IStructuredSelection && !selection.isEmpty()) { + Object obj = ((IStructuredSelection)selection).getFirstElement(); + if (obj != null) { + if (obj instanceof IAdaptable) { + return (IRepositionableMemoryRendering) ((IAdaptable)obj).getAdapter(IRepositionableMemoryRendering.class); + } + } + } + return null; + } + protected ICWatchpointTarget getWatchpointTarget( IWorkbenchPart part, ISelection selection ) { + if (selection != null && selection instanceof IStructuredSelection && !selection.isEmpty()) { + Object obj = ((IStructuredSelection)selection).getFirstElement(); + if (obj != null) { + if (obj instanceof IAdaptable) { + ICWatchpointTarget target = (ICWatchpointTarget) ((IAdaptable)obj).getAdapter(ICWatchpointTarget.class); + if (target == null) { + target = (ICWatchpointTarget) ((IAdaptable)obj).getAdapter( + org.eclipse.cdt.debug.internal.core.ICWatchpointTarget.class); + } + return target; + } + } + } + return null; + } + + /** * Reports the given error message to the user. * @param message Message to report. @@ -747,6 +907,7 @@ abstract public class AbstractToggleBreakpointAdapter * @throws CoreException Exception while creating breakpoint. */ protected abstract void createWatchpoint(boolean interactive, IWorkbenchPart part, String sourceHandle, - IResource resource, int charStart, int charEnd, int lineNumber, String expression) throws CoreException; + IResource resource, int charStart, int charEnd, int lineNumber, String expression, String memorySpace, + String range) throws CoreException; } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddWatchpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AddWatchpointActionDelegate.java similarity index 53% rename from debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddWatchpointActionDelegate.java rename to debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AddWatchpointActionDelegate.java index 9fab7944647..d7993ef10a5 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddWatchpointActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AddWatchpointActionDelegate.java @@ -1,4 +1,4 @@ -/******************************************************************************* +/*******************************************************************************sb * Copyright (c) 2004, 2007-7 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 @@ -9,35 +9,32 @@ * QNX Software Systems - Initial API and implementation * Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299 *******************************************************************************/ -package org.eclipse.cdt.debug.internal.ui.actions.breakpoints; +package org.eclipse.cdt.debug.ui.breakpoints; -import java.math.BigInteger; - -import org.eclipse.cdt.debug.core.CDIDebugModel; -import org.eclipse.cdt.debug.core.cdi.model.ICDIMemorySpaceManagement; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; -import org.eclipse.cdt.debug.core.model.ICDebugTarget; import org.eclipse.cdt.debug.internal.ui.actions.ActionMessages; +import org.eclipse.cdt.debug.internal.ui.actions.breakpoints.ToggleBreakpointAdapter; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; -import org.eclipse.cdt.debug.ui.breakpoints.IToggleBreakpointsTargetCExtension; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IObjectActionDelegate; import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.actions.ActionDelegate; /** - * A delegate for the "Add Watchpoint" action. + * A delegate for the "Add Watchpoint" action. Clients can register this object on + * a model-specific element which supports a toggle breakpoints target. + * + * @noextend This class is not intended to be subclassed by clients. + * @since 7.2 */ -public class AddWatchpointActionDelegate extends ActionDelegate implements IViewActionDelegate { +public class AddWatchpointActionDelegate extends ActionDelegate implements IViewActionDelegate, IObjectActionDelegate { - private IViewPart fView; + private IWorkbenchPart fPart; private ISelection fSelection; private ToggleBreakpointAdapter fDefaultToggleTarget = new ToggleBreakpointAdapter(); @@ -50,11 +47,11 @@ public class AddWatchpointActionDelegate extends ActionDelegate implements IView } private void setView(IViewPart view) { - fView = view; + fPart = view; } - protected IViewPart getView() { - return fView; + protected IWorkbenchPart getPart() { + return fPart; } @Override @@ -62,12 +59,17 @@ public class AddWatchpointActionDelegate extends ActionDelegate implements IView fSelection = selection; } + @Override + public void setActivePart(IAction action, IWorkbenchPart targetPart) { + fPart = targetPart; + } + /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ @Override public void run( IAction action ) { - IToggleBreakpointsTarget toggleTarget = DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fView, fSelection); + IToggleBreakpointsTarget toggleTarget = DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fPart, fSelection); IToggleBreakpointsTargetCExtension cToggleTarget = null; if (toggleTarget instanceof IToggleBreakpointsTargetCExtension) { cToggleTarget = (IToggleBreakpointsTargetCExtension)toggleTarget; @@ -76,46 +78,9 @@ public class AddWatchpointActionDelegate extends ActionDelegate implements IView } try { - cToggleTarget.createWatchpointsInteractive(fView, fSelection); + cToggleTarget.createWatchpointsInteractive(fPart, fSelection); } catch (CoreException e) { CDebugUIPlugin.errorDialog( ActionMessages.getString( "AddWatchpointActionDelegate1.0" ), e ); //$NON-NLS-1$ } } - - protected void addWatchpoint(boolean write, boolean read, String expression, String memorySpace, BigInteger range) { - if ( getResource() == null ) - return; - try { - CDIDebugModel.createWatchpoint( getSourceHandle(), getResource(), write, read, expression, memorySpace, range, true, 0, "", true ); //$NON-NLS-1$ - } - catch( CoreException ce ) { - CDebugUIPlugin.errorDialog( ActionMessages.getString( "AddWatchpointActionDelegate1.0" ), ce ); //$NON-NLS-1$ - } - } - - private IResource getResource() { - return ResourcesPlugin.getWorkspace().getRoot(); - } - - private String getSourceHandle() { - return ""; //$NON-NLS-1$ - } - - public static ICDIMemorySpaceManagement getMemorySpaceManagement(){ - IAdaptable debugViewElement = DebugUITools.getDebugContext(); - ICDIMemorySpaceManagement memMgr = null; - - if ( debugViewElement != null ) { - ICDebugTarget debugTarget = (ICDebugTarget)debugViewElement.getAdapter(ICDebugTarget.class); - - if ( debugTarget != null ){ - ICDITarget target = (ICDITarget)debugTarget.getAdapter(ICDITarget.class); - - if (target instanceof ICDIMemorySpaceManagement) - memMgr = (ICDIMemorySpaceManagement)target; - } - } - - return memMgr; - } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AddWatchpointOnVariableActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AddWatchpointOnVariableActionDelegate.java new file mode 100644 index 00000000000..a9675a527a4 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AddWatchpointOnVariableActionDelegate.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (c) 2007, 2010 Nokia 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.breakpoints; + + +import org.eclipse.cdt.debug.core.ICWatchpointTarget; +import org.eclipse.cdt.debug.internal.core.CRequest; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TreeSelection; + +/** + * Invoked when user right clicks on an element in the Variables or Expressions + * view and selects 'Add Watchpoint (C/C++)' Clients can register this action for + * their specific element type which adapts to {@link ICWatchpointTarget}. + * + * + * @noextend This class is not intended to be subclassed by clients. + * @since 7.2 + */ +public class AddWatchpointOnVariableActionDelegate extends AddWatchpointActionDelegate { + + /** The target variable/expression */ + private ICWatchpointTarget fVar; + + /** + * Constructor + */ + public AddWatchpointOnVariableActionDelegate() { + super(); + } + + private class CanCreateWatchpointRequest extends CRequest implements ICWatchpointTarget.CanCreateWatchpointRequest { + boolean fCanCreate; + @Override + public boolean getCanCreate() { + return fCanCreate; + } + @Override + public void setCanCreate(boolean value) { + fCanCreate = value; + } + }; + + /** + * Record the target variable/expression + * + * @see org.eclipse.ui.actions.ActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, + * org.eclipse.jface.viewers.ISelection) + */ + @Override + public void selectionChanged(final IAction action, ISelection selection) { + super.selectionChanged(action, selection); + fVar = null; + if (selection == null || selection.isEmpty()) { + action.setEnabled(false); + return; + } + if (selection instanceof TreeSelection) { + Object obj = ((TreeSelection)selection).getFirstElement(); + fVar = (ICWatchpointTarget)DebugPlugin.getAdapter(obj, ICWatchpointTarget.class); + if (fVar != null) { + final ICWatchpointTarget.CanCreateWatchpointRequest request = new CanCreateWatchpointRequest() { + @Override + public void done() { + action.setEnabled(getCanCreate()); + } + }; + fVar.canSetWatchpoint(request); + return; + } + assert false : "action should not have been available for object " + obj; //$NON-NLS-1$ + } + else if (selection instanceof StructuredSelection) { + // Not sure why, but sometimes we get an extraneous empty StructuredSelection. Seems harmless enough + assert ((StructuredSelection)selection).getFirstElement() == null : "action installed in unexpected type of view/part"; //$NON-NLS-1$ + } + else { + assert false : "action installed in unexpected type of view/part"; //$NON-NLS-1$ + } + action.setEnabled(false); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMNode.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMNode.java index 2d6eaf50e24..3876ceed5b0 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMNode.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMNode.java @@ -16,7 +16,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.eclipse.cdt.debug.internal.core.ICWatchpointTarget; +import org.eclipse.cdt.debug.core.ICWatchpointTarget; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.datamodel.DMContexts; From dcc522e86e2be2625184aab38e44002055338af6 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Fri, 23 Mar 2012 00:35:55 -0700 Subject: [PATCH 09/15] Cosmetics. --- .../org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFieldReference.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFieldReference.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFieldReference.java index 3036f284c0b..367eaa53e5c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFieldReference.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTFieldReference.java @@ -25,7 +25,6 @@ import org.eclipse.cdt.core.dom.ast.IType; public interface ICPPASTFieldReference extends IASTFieldReference, IASTImplicitNameOwner { /** * Was template keyword used? - * */ public boolean isTemplate(); From 018eb7334b8133df58fbb05126147e9f85d81fb8 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Fri, 23 Mar 2012 14:59:04 -0700 Subject: [PATCH 10/15] Few bug fixes for Extract Function refactoring. --- .../ExtractFunctionRefactoringTest.java | 32 +++++++++++++++++++ .../refactoring/code/flow/FlowAnalyzer.java | 19 +++++++++-- .../refactoring/code/flow/FlowInfo.java | 25 ++++++--------- .../code/flow/InputFlowAnalyzer.java | 2 +- 4 files changed, 60 insertions(+), 18 deletions(-) diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java index 2c2a6f34faf..a9c17f01e13 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/extractfunction/ExtractFunctionRefactoringTest.java @@ -819,6 +819,38 @@ public class ExtractFunctionRefactoringTest extends RefactoringTestBase { assertRefactoringSuccess(); } + //A.h + //class A { + //public: + // A(int i, const char* s); + // int method(); + //}; + + //A.cpp + //#include "A.h" + // + //void test(int i, const char* s) { + // /*$*/A a(i, s);/*$$*/ + // if (i != 0) + // a.method(); + //} + //==================== + //#include "A.h" + // + //A extracted(int i, const char* s) { + // A a(i, s); + // return a; + //} + // + //void test(int i, const char* s) { + // A a = extracted(i, s); + // if (i != 0) + // a.method(); + //} + public void testReturnValueWithCtorInitializer() throws Exception { + assertRefactoringSuccess(); + } + //A.h //#ifndef A_H_ //#define A_H_ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java index 15bee0552bc..ff38cd1a927 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowAnalyzer.java @@ -84,6 +84,7 @@ import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVariableReadWriteFlags; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; +import org.eclipse.cdt.internal.core.pdom.dom.PDOMName; /** * Special flow analyzer to determine the return value of the extracted method @@ -919,7 +920,21 @@ abstract class FlowAnalyzer extends ASTGenericVisitor { int index = fFlowContext.getIndexFromLocal(variable); if (index >= 0) { int accessMode = CPPVariableReadWriteFlags.getReadWriteFlags(node); - setFlowInfo(node, new LocalFlowInfo(variable, index, accessMode, fFlowContext)); + if (accessMode != 0) { + int flowInfoMode = FlowInfo.UNUSED; + switch (accessMode) { + case PDOMName.READ_ACCESS: + flowInfoMode = FlowInfo.READ; + break; + case PDOMName.WRITE_ACCESS: + flowInfoMode = FlowInfo.WRITE; + break; + case PDOMName.READ_ACCESS | PDOMName.WRITE_ACCESS: + flowInfoMode = FlowInfo.UNKNOWN; + break; + } + setFlowInfo(node, new LocalFlowInfo(variable, index, flowInfoMode, fFlowContext)); + } } } } @@ -1010,9 +1025,9 @@ abstract class FlowAnalyzer extends ASTGenericVisitor { return; FunctionCallFlowInfo info= createFunctionCallFlowInfo(); setFlowInfo(node, info); + info.mergeReceiver(getFlowInfo(functionNameExpression), fFlowContext); for (IASTInitializerClause arg : arguments) { info.mergeArgument(getFlowInfo(arg), fFlowContext); } - info.mergeReceiver(getFlowInfo(functionNameExpression), fFlowContext); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowInfo.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowInfo.java index 6f59e93354c..f281f966363 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowInfo.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/FlowInfo.java @@ -19,8 +19,6 @@ import java.util.Set; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IVariable; -import org.eclipse.cdt.internal.core.pdom.dom.PDOMName; - public abstract class FlowInfo { // Return statement handling. protected static final int NOT_POSSIBLE= 0; @@ -32,12 +30,12 @@ public abstract class FlowInfo { protected static final int THROW= 6; // Local access handling. - public static final int READ= PDOMName.READ_ACCESS; // 1 << 9 - public static final int WRITE= PDOMName.WRITE_ACCESS; // 1 << 10 public static final int UNUSED= 1 << 0; - public static final int READ_POTENTIAL= 1 << 1; - public static final int WRITE_POTENTIAL= 1 << 2; - public static final int UNKNOWN= 1 << 3; + public static final int READ= 1 << 1; + public static final int READ_POTENTIAL= 1 << 2; + public static final int WRITE= 1 << 3; + public static final int WRITE_POTENTIAL= 1 << 4; + public static final int UNKNOWN= 1 << 5; // Table to merge access modes for condition statements (e.g branch[x] || branch[y]). private static final int[][] ACCESS_MODE_CONDITIONAL_TABLE= { @@ -236,8 +234,7 @@ public abstract class FlowInfo { } /** - * Checks whether the given local variable binding has the given access - * mode. + * Checks whether the given local variable binding has the given access mode. * * @param context the flow context used during flow analysis * @param local local variable of interest @@ -374,9 +371,9 @@ public abstract class FlowInfo { return; } else { if (others == null) { + int index_unused= getIndex(UNUSED); for (int i= 0; i < fAccessModes.length; i++) { - int unused_index= getIndex(UNUSED); - fAccessModes[i]= ACCESS_MODE_CONDITIONAL_TABLE[getIndex(fAccessModes[i])][unused_index]; + fAccessModes[i]= ACCESS_MODE_CONDITIONAL_TABLE[getIndex(fAccessModes[i])][index_unused]; } } else { for (int i= 0; i < fAccessModes.length; i++) { @@ -398,14 +395,13 @@ public abstract class FlowInfo { return; } - int unused_index= getIndex(UNUSED); + int index_unused= getIndex(UNUSED); for (int i= 0; i < fAccessModes.length; i++) { - fAccessModes[i]= ACCESS_MODE_CONDITIONAL_TABLE[getIndex(fAccessModes[i])][unused_index]; + fAccessModes[i]= ACCESS_MODE_CONDITIONAL_TABLE[getIndex(fAccessModes[i])][index_unused]; } } private static int getIndex(int accessMode) { - // Fast log function switch (accessMode) { case UNUSED: return 0; @@ -414,7 +410,6 @@ public abstract class FlowInfo { case READ_POTENTIAL: return 2; case WRITE: - case READ | WRITE: return 3; case WRITE_POTENTIAL: return 4; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/InputFlowAnalyzer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/InputFlowAnalyzer.java index d851d153b1e..cf9f29e7440 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/InputFlowAnalyzer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/refactoring/code/flow/InputFlowAnalyzer.java @@ -248,7 +248,7 @@ public class InputFlowAnalyzer extends FlowAnalyzer { @Override protected boolean traverseNode(IASTNode node) { - return !isBefore(node, loopRegion.firstLabelStatement) && + return !selection.covers(node) && !isBefore(node, loopRegion.firstLabelStatement) && !isBefore(loopRegion.lastGotoStatement, node); } From 12f003ec6013f351fa2ae18e108efac303bc3af5 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Fri, 23 Mar 2012 18:46:12 -0700 Subject: [PATCH 11/15] Fixed interaction between refactoring and a team provider. --- .../internal/ui/refactoring/CRefactoring.java | 30 ++++++++++--------- .../ui/refactoring/CreateFileChange.java | 7 +++-- .../ui/refactoring/ModificationCollector.java | 17 +++++++++++ .../ParameterNamesInputPage.java | 2 +- 4 files changed, 39 insertions(+), 17 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java index b93cefc2e78..a9bc21bfc1c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java @@ -15,6 +15,7 @@ package org.eclipse.cdt.internal.ui.refactoring; import java.util.ArrayList; import java.util.List; +import org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -72,6 +73,7 @@ public abstract class CRefactoring extends Refactoring { protected Region selectedRegion; protected final RefactoringStatus initStatus; protected CRefactoringContext refactoringContext; + private ModificationCollector modificationCollector; public CRefactoring(ICElement element, ISelection selection, ICProject project) { this.project = project; @@ -107,10 +109,15 @@ public abstract class CRefactoring extends Refactoring { throws CoreException, OperationCanceledException { if (pm == null) pm = new NullProgressMonitor(); - pm.beginTask(Messages.CRefactoring_checking_final_conditions, 6); + pm.beginTask(Messages.CRefactoring_checking_final_conditions, 10); - CheckConditionsContext context = createCheckConditionsContext(); - RefactoringStatus result = checkFinalConditions(new SubProgressMonitor(pm, 5), context); + CheckConditionsContext context= new CheckConditionsContext(); + context.add(new ValidateEditChecker(getValidationContext())); + ResourceChangeChecker resourceChecker = new ResourceChangeChecker(); + IResourceChangeDescriptionFactory deltaFactory = resourceChecker.getDeltaFactory(); + context.add(resourceChecker); + + RefactoringStatus result = checkFinalConditions(new SubProgressMonitor(pm, 8), context); if (result.hasFatalError()) { pm.done(); return result; @@ -118,7 +125,11 @@ public abstract class CRefactoring extends Refactoring { if (pm.isCanceled()) throw new OperationCanceledException(); - result.merge(context.check(new SubProgressMonitor(pm, 1))); + modificationCollector = new ModificationCollector(deltaFactory); + collectModifications(pm, modificationCollector); + + result.merge(context.check(new SubProgressMonitor(pm, 2))); + pm.done(); return result; } @@ -162,9 +173,7 @@ public abstract class CRefactoring extends Refactoring { @Override public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException { - ModificationCollector collector = new ModificationCollector(); - collectModifications(pm, collector); - CCompositeChange finalChange = collector.createFinalChange(); + CCompositeChange finalChange = modificationCollector.createFinalChange(); finalChange.setDescription(new RefactoringChangeDescriptor(getRefactoringDescriptor())); return finalChange; } @@ -222,13 +231,6 @@ public abstract class CRefactoring extends Refactoring { return names; } - private CheckConditionsContext createCheckConditionsContext() throws CoreException { - CheckConditionsContext result= new CheckConditionsContext(); - result.add(new ValidateEditChecker(getValidationContext())); - result.add(new ResourceChangeChecker()); - return result; - } - private class ProblemFinder extends ASTVisitor { private boolean problemFound = false; private final RefactoringStatus status; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CreateFileChange.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CreateFileChange.java index f72c1b8b78f..5b8f2990760 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CreateFileChange.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CreateFileChange.java @@ -8,6 +8,7 @@ * * Contributors: * Institute for Software - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring; @@ -16,6 +17,7 @@ import java.io.InputStream; import java.net.URI; import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; @@ -24,6 +26,7 @@ import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.ltk.core.refactoring.Change; import org.eclipse.ltk.core.refactoring.RefactoringStatus; +import org.eclipse.ltk.core.refactoring.resource.ResourceChange; import org.eclipse.osgi.util.NLS; /** @@ -31,7 +34,7 @@ import org.eclipse.osgi.util.NLS; * * @author Emanuel Graf */ -public class CreateFileChange extends Change { +public class CreateFileChange extends ResourceChange { private String name; private final IPath path; private final String source; @@ -50,7 +53,7 @@ public class CreateFileChange extends Change { } @Override - public Object getModifiedElement() { + public IResource getModifiedResource() { return ResourcesPlugin.getWorkspace().getRoot().getFile(path); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ModificationCollector.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ModificationCollector.java index 7a8864b714f..b1da07702fd 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ModificationCollector.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ModificationCollector.java @@ -8,6 +8,7 @@ * * Contributors: * Institute for Software - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring; @@ -16,6 +17,8 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.mapping.IResourceChangeDescriptionFactory; import org.eclipse.ltk.core.refactoring.Change; import org.eclipse.ltk.core.refactoring.CompositeChange; @@ -29,15 +32,27 @@ import org.eclipse.cdt.core.dom.rewrite.ASTRewrite; * @author Mirko Stocker */ public class ModificationCollector { + private final IResourceChangeDescriptionFactory deltaFactory; + // Each translation unit can have only one ASTRewrite private final Map rewriters = new HashMap(); private Collection changes; + public ModificationCollector() { + this(null); + } + + public ModificationCollector(IResourceChangeDescriptionFactory deltaFactory) { + this.deltaFactory = deltaFactory; + } + public ASTRewrite rewriterForTranslationUnit(IASTTranslationUnit ast) { if (!rewriters.containsKey(ast)) { rewriters.put(ast, ASTRewrite.create(ast)); + if (deltaFactory != null) + deltaFactory.change((IFile) ast.getOriginatingTranslationUnit().getResource()); } return rewriters.get(ast); } @@ -48,6 +63,8 @@ public class ModificationCollector { changes = new ArrayList(); } changes.add(change); + if (deltaFactory != null) + deltaFactory.create(change.getModifiedResource()); } public CCompositeChange createFinalChange() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterNamesInputPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterNamesInputPage.java index eeac152ad81..f66f1b442cc 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterNamesInputPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/ParameterNamesInputPage.java @@ -129,7 +129,7 @@ public class ParameterNamesInputPage extends UserInputWizardPage { public String createFunctionDefinitionSignature(IProgressMonitor monitor) { try { ModificationCollector collector = new ModificationCollector(); - ImplementMethodRefactoring implementMethodRefactoring = (ImplementMethodRefactoring)wizard.getRefactoring(); + ImplementMethodRefactoring implementMethodRefactoring = (ImplementMethodRefactoring) wizard.getRefactoring(); CCompositeChange finalChange = null; // We can have multiple preview jobs. We don't // want multiple jobs concurrently using the same ASTs From 839a50b9b8729ae2ead43dada7b4f2fabb288b5c Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Fri, 23 Mar 2012 18:48:59 -0700 Subject: [PATCH 12/15] Adjusted menu ordering. --- core/org.eclipse.cdt.ui/plugin.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index ee8b4fbebe6..97ad0f894f8 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -1736,13 +1736,6 @@ id="org.eclipse.cdt.ui.actions.HideMethod" retarget="true"> - - + + Date: Fri, 23 Mar 2012 23:42:25 -0400 Subject: [PATCH 13/15] Bug 375227: Tracepoints cannot be set in the Disassembly view --- dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml index 0f152c7eba8..9e68fbd126c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml @@ -469,7 +469,7 @@ definitionId="org.eclipse.cdt.debug.ui.testIsTracepointActionSetActive"> + property="org.eclipse.cdt.dsf.debug.ui.isDisassemblyViewSupportsCBreakpoint"> From 5d924afa08ea3c1be7a3302d4ee89bdeb7f1dd2d Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Sat, 24 Mar 2012 13:38:42 -0400 Subject: [PATCH 14/15] Bug 375256: Use the wording: 'normal' instead of 'slow' for tracepoints --- .../ui/launching/GdbDebuggerPage.java | 18 ++++----- .../ui/launching/LaunchUIMessages.properties | 2 +- .../gdb/IGDBLaunchConfigurationConstants.java | 10 ++--- .../dsf/gdb/service/GDBBreakpoints_7_2.java | 32 +++++++-------- .../service/command/output/MIBreakpoint.java | 6 +-- .../GDBRemoteTracepointsTest_7_0.java | 40 +++++++++---------- 6 files changed, 54 insertions(+), 54 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java index 64193d74e70..23474d8c35d 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java @@ -62,7 +62,7 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { */ protected Combo fTracepointModeCombo; protected static final String TP_FAST_ONLY = LaunchUIMessages.getString("GDBDebuggerPage.tracepoint_mode_fast"); //$NON-NLS-1$ - protected static final String TP_SLOW_ONLY = LaunchUIMessages.getString("GDBDebuggerPage.tracepoint_mode_slow"); //$NON-NLS-1$ + protected static final String TP_NORMAL_ONLY = LaunchUIMessages.getString("GDBDebuggerPage.tracepoint_mode_normal"); //$NON-NLS-1$ protected static final String TP_AUTOMATIC = LaunchUIMessages.getString("GDBDebuggerPage.tracepoint_mode_auto"); //$NON-NLS-1$ private IMILaunchConfigurationComponent fSolibBlock; @@ -168,15 +168,15 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { String tracepointMode = getStringAttr(config, IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE, IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_MODE_DEFAULT); - if (tracepointMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_SLOW_ONLY)) { - fTracepointModeCombo.setText(TP_SLOW_ONLY); + if (tracepointMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_NORMAL_ONLY)) { + fTracepointModeCombo.setText(TP_NORMAL_ONLY); } else if (tracepointMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_ONLY)) { fTracepointModeCombo.setText(TP_FAST_ONLY); - } else if (tracepointMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_SLOW)) { + } else if (tracepointMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_NORMAL)) { fTracepointModeCombo.setText(TP_AUTOMATIC); } else { assert false : "Unknown Tracepoint Mode: " + tracepointMode; //$NON-NLS-1$ - fTracepointModeCombo.setText(TP_SLOW_ONLY); + fTracepointModeCombo.setText(TP_NORMAL_ONLY); } } } @@ -184,12 +184,12 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { protected String getSelectedTracepointMode() { if (fTracepointModeCombo != null) { int selectedIndex = fTracepointModeCombo.getSelectionIndex(); - if (fTracepointModeCombo.getItem(selectedIndex).equals(TP_SLOW_ONLY)) { - return IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_SLOW_ONLY; + if (fTracepointModeCombo.getItem(selectedIndex).equals(TP_NORMAL_ONLY)) { + return IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_NORMAL_ONLY; } else if (fTracepointModeCombo.getItem(selectedIndex).equals(TP_FAST_ONLY)) { return IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_ONLY; } else if (fTracepointModeCombo.getItem(selectedIndex).equals(TP_AUTOMATIC)) { - return IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_SLOW; + return IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_NORMAL; } else { assert false : "Unknown Tracepoint mode: " + fTracepointModeCombo.getItem(selectedIndex); //$NON-NLS-1$ } @@ -379,7 +379,7 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { fTracepointModeCombo = new Combo(parent, SWT.READ_ONLY | SWT.DROP_DOWN); fTracepointModeCombo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1)); - fTracepointModeCombo.add(TP_SLOW_ONLY); + fTracepointModeCombo.add(TP_NORMAL_ONLY); fTracepointModeCombo.add(TP_FAST_ONLY); fTracepointModeCombo.add(TP_AUTOMATIC); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.properties b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.properties index 4f51027f4a8..19595f385e6 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.properties +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/LaunchUIMessages.properties @@ -28,7 +28,7 @@ GDBDebuggerPage.update_thread_list_on_suspend=Force thread list update on suspen GDBDebuggerPage.Automatically_debug_forked_processes=Automatically debug forked processes (Note: Requires Multi Process GDB) GDBDebuggerPage.tracepoint_mode_label=Tracepoint mode: GDBDebuggerPage.tracepoint_mode_fast=Fast -GDBDebuggerPage.tracepoint_mode_slow=Slow +GDBDebuggerPage.tracepoint_mode_normal=Normal GDBDebuggerPage.tracepoint_mode_auto=Automatic StandardGDBDebuggerPage.0=Debugger executable must be specified. StandardGDBDebuggerPage.1=GDB Debugger Options diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGDBLaunchConfigurationConstants.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGDBLaunchConfigurationConstants.java index 9807ec2f5ec..0f1cf56d63b 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGDBLaunchConfigurationConstants.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGDBLaunchConfigurationConstants.java @@ -185,10 +185,10 @@ public class IGDBLaunchConfigurationConstants { /** * Possible attribute value for the key is ATTR_DEBUGGER_TRACEPOINT_MODE. - * Indicates that only slow tracepoints should be used. + * Indicates that only normal tracepoints should be used. * @since 4.1 */ - public static final String DEBUGGER_TRACEPOINT_SLOW_ONLY = "TP_SLOW_ONLY"; //$NON-NLS-1$ + public static final String DEBUGGER_TRACEPOINT_NORMAL_ONLY = "TP_NORMAL_ONLY"; //$NON-NLS-1$ /** * Possible attribute value for the key is ATTR_DEBUGGER_TRACEPOINT_MODE. @@ -199,17 +199,17 @@ public class IGDBLaunchConfigurationConstants { /** * Possible attribute value for the key is ATTR_DEBUGGER_TRACEPOINT_MODE. - * Indicates that slow tracepoints should be used whenever a fast tracepoint + * Indicates that normal tracepoints should be used whenever a fast tracepoint * cannot be inserted. * @since 4.1 */ - public static final String DEBUGGER_TRACEPOINT_FAST_THEN_SLOW = "TP_FAST_THEN_SLOW"; //$NON-NLS-1$ + public static final String DEBUGGER_TRACEPOINT_FAST_THEN_NORMAL = "TP_FAST_THEN_NORMAL"; //$NON-NLS-1$ /** * Default attribute value for the key is ATTR_DEBUGGER_TRACEPOINT_MODE. * @since 4.1 */ - public static final String DEBUGGER_TRACEPOINT_MODE_DEFAULT = DEBUGGER_TRACEPOINT_SLOW_ONLY; + public static final String DEBUGGER_TRACEPOINT_MODE_DEFAULT = DEBUGGER_TRACEPOINT_NORMAL_ONLY; /** * The default value of DebugPlugin.ATTR_PROCESS_FACTORY_ID. diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_2.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_2.java index 1ed6a835f44..088c3591b20 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_2.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_2.java @@ -37,7 +37,7 @@ import org.eclipse.debug.core.ILaunch; /** * Breakpoint service for GDB 7.2. * It support MI for tracepoints. - * It also support for fast vs slow tracepoints. + * It also support for fast vs normal tracepoints. * * @since 4.1 */ @@ -45,9 +45,9 @@ public class GDBBreakpoints_7_2 extends GDBBreakpoints_7_0 { private IMICommandControl fConnection; - private enum TracepointMode { FAST_THEN_SLOW, FAST_ONLY, SLOW_ONLY }; + private enum TracepointMode { FAST_THEN_NORMAL, FAST_ONLY, NORMAL_ONLY }; - private TracepointMode fTracepointMode = TracepointMode.SLOW_ONLY; + private TracepointMode fTracepointMode = TracepointMode.NORMAL_ONLY; public GDBBreakpoints_7_2(DsfSession session) { super(session); @@ -100,13 +100,13 @@ public class GDBBreakpoints_7_2 extends GDBBreakpoints_7_0 if (tpMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_ONLY)) { fTracepointMode = TracepointMode.FAST_ONLY; - } else if (tpMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_SLOW_ONLY)) { - fTracepointMode = TracepointMode.SLOW_ONLY; - } else if (tpMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_SLOW)) { - fTracepointMode = TracepointMode.FAST_THEN_SLOW; + } else if (tpMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_NORMAL_ONLY)) { + fTracepointMode = TracepointMode.NORMAL_ONLY; + } else if (tpMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_NORMAL)) { + fTracepointMode = TracepointMode.FAST_THEN_NORMAL; } else { assert false : "Invalid tracepoint mode: " + tpMode; //$NON-NLS-1$ - fTracepointMode = TracepointMode.SLOW_ONLY; + fTracepointMode = TracepointMode.NORMAL_ONLY; } } @@ -178,14 +178,14 @@ public class GDBBreakpoints_7_2 extends GDBBreakpoints_7_0 } /** * Add a tracepoint using MI. We have three settings: - * 1- set only a fast tracepoint but if it fails, set a slow tracepoint + * 1- set only a fast tracepoint but if it fails, set a normal tracepoint * 2- only set a fast tracepoint even if it fails - * 3- only set a slow tracepoint even if a fast tracepoint could have been used + * 3- only set a normal tracepoint even if a fast tracepoint could have been used */ @Override protected void addTracepoint(final IBreakpointsTargetDMContext context, final Map attributes, final DataRequestMonitor drm) { - // Unless we should only set slow tracepoints, we try to set a fast tracepoint. - boolean isFastTracepoint = fTracepointMode != TracepointMode.SLOW_ONLY; + // Unless we should only set normal tracepoints, we try to set a fast tracepoint. + boolean isFastTracepoint = fTracepointMode != TracepointMode.NORMAL_ONLY; sendTracepointCommand(context, attributes, isFastTracepoint, new ImmediateDataRequestMonitor(drm) { @Override @@ -197,12 +197,12 @@ public class GDBBreakpoints_7_2 extends GDBBreakpoints_7_0 @Override protected void handleError() { // Tracepoint failed to be set. - if (fTracepointMode == TracepointMode.FAST_THEN_SLOW) { - // In this case, we failed to set a fast tracepoint, but we should try to set a slow one. + if (fTracepointMode == TracepointMode.FAST_THEN_NORMAL) { + // In this case, we failed to set a fast tracepoint, but we should try to set a normal one. sendTracepointCommand(context, attributes, false, drm); } else { - // We either failed to set a fast tracepoint and we should not try to set a slow one, - // or we failed to set a slow one. Either way, we are done. + // We either failed to set a fast tracepoint and we should not try to set a normal one, + // or we failed to set a normal one. Either way, we are done. drm.setStatus(getStatus()); drm.done(); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakpoint.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakpoint.java index 6c67e986119..310901feb1c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakpoint.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakpoint.java @@ -88,7 +88,7 @@ public class MIBreakpoint { boolean isHdw = false; // Indicate if we are dealing with a tracepoint. - // (if its a fast or slow tracepoint can be known through the 'type' field) + // (if its a fast or normal tracepoint can be known through the 'type' field) boolean isTpt = false; /** See {@link #isCatchpoint()} */ @@ -343,8 +343,8 @@ public class MIBreakpoint { /** * Return whether this breakpoint is actually a tracepoint. - * This method will return true for both fast and slow tracepoints. - * To know of fast vs slow tracepoint use {@link getType()} and look + * This method will return true for both fast and normal tracepoints. + * To know of fast vs normal tracepoint use {@link getType()} and look * for "tracepoint" or "fast tracepoint" * * @since 3.0 diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBRemoteTracepointsTest_7_0.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBRemoteTracepointsTest_7_0.java index ff640bd9fa8..84f60e59ea5 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBRemoteTracepointsTest_7_0.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBRemoteTracepointsTest_7_0.java @@ -63,9 +63,9 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE, IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); - // To test both fast and slow tracepoint we just the FAST_THEN_SLOW setting + // To test both fast and normal tracepoints, we use the FAST_THEN_NORMAL setting setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_TRACEPOINT_MODE, - IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_SLOW); + IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_NORMAL); } private DsfSession fSession; @@ -631,7 +631,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { MIBreakpointDMData tp = (MIBreakpointDMData) getBreakpoint(fTracepoints[i]); assertTrue("tracepoint "+i+" is not a tracepoint but a " + tp.getBreakpointType(), tp.getBreakpointType().equals(MIBreakpoints.TRACEPOINT)); - assertTrue("tracepoint "+i+" should be a " + (data.isFastTp?"fast":"slow")+" tracepoint but is not", + assertTrue("tracepoint "+i+" should be a " + (data.isFastTp?"fast":"normal")+" tracepoint but is not", tp.getType().equals("fast tracepoint") == data.isFastTp); assertTrue("tracepoint "+i+" mismatch (wrong file name) got " + tp.getFileName(), tp.getFileName().equals(data.sourceFile)); @@ -677,7 +677,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { Map attributes = null; int index = 0; - // First tracepoint (will be a slow tracepoint) + // First tracepoint (will be a normal tracepoint) attributes = new HashMap(); attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); attributes.put(MIBreakpoints.FUNCTION, "*"+METHOD_NAME); @@ -690,7 +690,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); - // Second tracepoint (will be a slow tracepoint) + // Second tracepoint (will be a normal tracepoint) attributes = new HashMap(); attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); @@ -732,7 +732,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); - // Fifth tracepoint (will be a slow tracepoint) + // Fifth tracepoint (will be a normal tracepoint) attributes = new HashMap(); attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); @@ -912,7 +912,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { Map attributes = null; int index = 0; - // First tracepoint will be a slow tracepoint + // First tracepoint will be a normal tracepoint attributes = new HashMap(); attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); @@ -942,7 +942,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); - // Third tracepoint (will be a slow tracepoint) + // Third tracepoint (will be a normal tracepoint) attributes = new HashMap(); attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); @@ -973,7 +973,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { Map attributes = null; int index = 0; - // First tracepoint will be a slow tracepoint + // First tracepoint will be a normal tracepoint attributes = new HashMap(); attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); @@ -1003,7 +1003,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); - // Third tracepoint (will be a slow tracepoint) + // Third tracepoint (will be a normal tracepoint) attributes = new HashMap(); attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); @@ -1034,7 +1034,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { Map attributes = null; int index = 0; - // First tracepoint will be a slow tracepoint + // First tracepoint will be a normal tracepoint attributes = new HashMap(); attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); @@ -1064,7 +1064,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); - // Third tracepoint (will be a slow tracepoint) + // Third tracepoint (will be a normal tracepoint) attributes = new HashMap(); attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); @@ -1095,7 +1095,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { Map attributes = null; int index = 0; - // First tracepoint will be a slow tracepoint + // First tracepoint will be a normal tracepoint attributes = new HashMap(); attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); @@ -1125,7 +1125,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); - // Third tracepoint (will be a slow tracepoint) + // Third tracepoint (will be a normal tracepoint) attributes = new HashMap(); attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); @@ -1156,7 +1156,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { Map attributes = null; int index = 0; - // First tracepoint will be a slow tracepoint + // First tracepoint will be a normal tracepoint attributes = new HashMap(); attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); @@ -1198,7 +1198,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); - // Third tracepoint (will be a slow tracepoint) + // Third tracepoint (will be a normal tracepoint) attributes = new HashMap(); attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); @@ -1235,7 +1235,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { Map attributes = null; int index = 0; - // First tracepoint will be a slow tracepoint + // First tracepoint will be a normal tracepoint attributes = new HashMap(); attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); @@ -1271,7 +1271,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); - // Third tracepoint (will be a slow tracepoint) + // Third tracepoint (will be a normal tracepoint) attributes = new HashMap(); attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); @@ -1305,7 +1305,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { Map attributes = null; int index = 0; - // First tracepoint will be a slow tracepoint + // First tracepoint will be a normal tracepoint attributes = new HashMap(); attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); @@ -1341,7 +1341,7 @@ public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase { + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1); clearEventCounters(); - // Third tracepoint (will be a slow tracepoint) + // Third tracepoint (will be a normal tracepoint) attributes = new HashMap(); attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT); attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE); From a13c09f28dd285688b8a863c7eb2ebe789111253 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Sat, 24 Mar 2012 13:59:04 -0400 Subject: [PATCH 15/15] Bug 375256: Disable assertion to allow existing launches to migrate to the new 'normal' tracepoint terminology. --- .../cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java index 23474d8c35d..358197e73c6 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java @@ -175,7 +175,12 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { } else if (tracepointMode.equals(IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_FAST_THEN_NORMAL)) { fTracepointModeCombo.setText(TP_AUTOMATIC); } else { - assert false : "Unknown Tracepoint Mode: " + tracepointMode; //$NON-NLS-1$ + // Comment out assertion in the short term to allow for existing launches + // that used the old names to migrate to the new names. + // It can be uncommented after we have released Juno. + // Bug 375256 + // + // assert false : "Unknown Tracepoint Mode: " + tracepointMode; //$NON-NLS-1$ fTracepointModeCombo.setText(TP_NORMAL_ONLY); } }