mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Merge remote-tracking branch 'cdt/master' into sd90
This commit is contained in:
commit
14b3dc054b
47 changed files with 1399 additions and 1057 deletions
|
@ -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()) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<IConsoleParser> parsers = new ArrayList<IConsoleParser>();
|
||||
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));
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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_
|
||||
|
@ -1775,9 +1807,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 +1818,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 +1917,7 @@ public class ExtractFunctionRefactoringTest extends RefactoringTestBase {
|
|||
//void method() {
|
||||
// loop();
|
||||
//}
|
||||
public void testDontReturnVariablesThatArentUsed() throws Exception {
|
||||
public void testDoNotReturnVariablesThatAreNotUsed() throws Exception {
|
||||
extractedFunctionName = "loop";
|
||||
assertRefactoringSuccess();
|
||||
}
|
||||
|
@ -1898,7 +1928,7 @@ public class ExtractFunctionRefactoringTest extends RefactoringTestBase {
|
|||
// return;/*$$*/
|
||||
// //unreachable
|
||||
//}
|
||||
public void testDontExtractCodeContainingReturn() throws Exception {
|
||||
public void testDoNotExtractCodeContainingReturn() throws Exception {
|
||||
assertRefactoringFailure();
|
||||
}
|
||||
|
||||
|
@ -1909,7 +1939,7 @@ public class ExtractFunctionRefactoringTest extends RefactoringTestBase {
|
|||
// continue;/*$$*/
|
||||
// }
|
||||
//}
|
||||
public void testDontExtractCodeContainingContinue() throws Exception {
|
||||
public void testDoNotExtractCodeContainingContinue() throws Exception {
|
||||
assertRefactoringFailure();
|
||||
}
|
||||
|
||||
|
|
|
@ -1737,13 +1737,6 @@
|
|||
id="org.eclipse.cdt.ui.actions.HideMethod"
|
||||
retarget="true">
|
||||
</action>
|
||||
<action
|
||||
definitionId="org.eclipse.cdt.ui.refactor.extract.function"
|
||||
label="%Refactoring.extractFunction.label"
|
||||
menubarPath="org.eclipse.jdt.ui.refactoring.menu/codingGroup"
|
||||
id="org.eclipse.cdt.ui.actions.ExtractMethod"
|
||||
retarget="true">
|
||||
</action>
|
||||
<action
|
||||
definitionId="org.eclipse.cdt.ui.refactor.toggle.function"
|
||||
label="%Refactoring.toggleFunction.label"
|
||||
|
@ -1751,6 +1744,13 @@
|
|||
id="org.eclipse.cdt.ui.actions.ToggleFunction"
|
||||
retarget="true">
|
||||
</action>
|
||||
<action
|
||||
definitionId="org.eclipse.cdt.ui.refactor.extract.function"
|
||||
label="%Refactoring.extractFunction.label"
|
||||
menubarPath="org.eclipse.jdt.ui.refactoring.menu/codingGroup"
|
||||
id="org.eclipse.cdt.ui.actions.ExtractMethod"
|
||||
retarget="true">
|
||||
</action>
|
||||
<action
|
||||
definitionId="org.eclipse.cdt.ui.refactor.extract.constant"
|
||||
label="%Refactoring.extractConstant.label"
|
||||
|
|
|
@ -79,10 +79,12 @@ 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;
|
||||
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
|
||||
|
@ -668,6 +670,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;
|
||||
|
@ -914,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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1005,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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<IASTTranslationUnit, ASTRewrite> rewriters =
|
||||
new HashMap<IASTTranslationUnit, ASTRewrite>();
|
||||
|
||||
private Collection<CreateFileChange> 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<CreateFileChange>();
|
||||
}
|
||||
changes.add(change);
|
||||
if (deltaFactory != null)
|
||||
deltaFactory.create(change.getModifiedResource());
|
||||
}
|
||||
|
||||
public CCompositeChange createFinalChange() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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.
|
||||
*
|
||||
* <p>
|
||||
* 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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -636,7 +636,7 @@
|
|||
objectClass="org.eclipse.cdt.debug.internal.core.ICWatchpointTarget"
|
||||
id="org.eclipse.cdt.debug.ui.WatchpointActions">
|
||||
<action
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.AddWatchpointOnVariableActionDelegate"
|
||||
class="org.eclipse.cdt.debug.ui.breakpoints.AddWatchpointOnVariableActionDelegate"
|
||||
enablesFor="1"
|
||||
icon="icons/elcl16/watchpoint_co.gif"
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.AddWatchpointOnVariableActionDelegate"
|
||||
|
@ -861,7 +861,7 @@
|
|||
id="org.eclipse.debug.ui.MemoryView.RenderingViewPane.popupMenu.1"
|
||||
targetID="org.eclipse.debug.ui.MemoryView.RenderingViewPane.1">
|
||||
<action
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.AddWatchpointOnMemoryActionDelegate"
|
||||
class="org.eclipse.cdt.debug.ui.breakpoints.AddWatchpointActionDelegate"
|
||||
enablesFor="1"
|
||||
icon="icons/elcl16/watchpoint_co.gif"
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.AddWatchpointOnMemoryActionDelegate.1"
|
||||
|
@ -874,7 +874,7 @@
|
|||
id="org.eclipse.debug.ui.MemoryView.RenderingViewPane.popupMenu.2"
|
||||
targetID="org.eclipse.debug.ui.MemoryView.RenderingViewPane.2">
|
||||
<action
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.AddWatchpointOnMemoryActionDelegate"
|
||||
class="org.eclipse.cdt.debug.ui.breakpoints.AddWatchpointActionDelegate"
|
||||
enablesFor="1"
|
||||
icon="icons/elcl16/watchpoint_co.gif"
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.AddWatchpointOnMemoryActionDelegate.2"
|
||||
|
@ -953,7 +953,7 @@
|
|||
</enablement>
|
||||
</action>
|
||||
<action
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.AddWatchpointActionDelegate"
|
||||
class="org.eclipse.cdt.debug.ui.breakpoints.AddWatchpointActionDelegate"
|
||||
icon="icons/elcl16/watchpoint_co.gif"
|
||||
id="org.eclipse.cdt.debug.ui.addWatchpoint"
|
||||
label="%AddWatchpoint.label"
|
||||
|
|
|
@ -10,20 +10,427 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIMemorySpaceManagement;
|
||||
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;
|
||||
|
||||
/**
|
||||
* This class was moved to the org.eclipse.cdt.debug.internal.ui.actions.breakpoints
|
||||
* package. This class is left here for backward compatibility for extenders that
|
||||
* reference this internal class (see Bug 374983).
|
||||
*
|
||||
* The "Add Watchpoint" dialog of the "Toggle watchpoint" action.
|
||||
* @deprecated Replaced by opening a properties dialog on a new breakpoint.
|
||||
*/
|
||||
public class AddWatchpointDialog extends org.eclipse.cdt.debug.internal.ui.actions.breakpoints.AddWatchpointDialog {
|
||||
public class AddWatchpointDialog extends Dialog implements ModifyListener, SelectionListener {
|
||||
|
||||
private Combo fExpressionInput;
|
||||
private String fExpression;
|
||||
private static List<String> sExpressionHistory = new ArrayList<String>();
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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{
|
||||
|
||||
}
|
|
@ -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<String> sExpressionHistory = new ArrayList<String>();
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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<String, Object> attributes = new HashMap<String, Object>();
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -469,7 +469,7 @@
|
|||
definitionId="org.eclipse.cdt.debug.ui.testIsTracepointActionSetActive">
|
||||
</reference>
|
||||
<test
|
||||
property="org.eclipse.cdt.dsf.debug.ui.isCLaunchTypeDisassembly">
|
||||
property="org.eclipse.cdt.dsf.debug.ui.isDisassemblyViewSupportsCBreakpoint">
|
||||
</test>
|
||||
</and>
|
||||
</enablement>
|
||||
|
|
|
@ -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,20 @@ 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);
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -184,12 +189,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 +384,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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> 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<IBreakpointDMContext>(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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<String, Object> attributes = null;
|
||||
int index = 0;
|
||||
|
||||
// First tracepoint (will be a slow tracepoint)
|
||||
// First tracepoint (will be a normal tracepoint)
|
||||
attributes = new HashMap<String, Object>();
|
||||
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<String, Object>();
|
||||
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<String, Object>();
|
||||
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<String, Object> attributes = null;
|
||||
int index = 0;
|
||||
|
||||
// First tracepoint will be a slow tracepoint
|
||||
// First tracepoint will be a normal tracepoint
|
||||
attributes = new HashMap<String, Object>();
|
||||
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<String, Object>();
|
||||
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<String, Object> attributes = null;
|
||||
int index = 0;
|
||||
|
||||
// First tracepoint will be a slow tracepoint
|
||||
// First tracepoint will be a normal tracepoint
|
||||
attributes = new HashMap<String, Object>();
|
||||
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<String, Object>();
|
||||
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<String, Object> attributes = null;
|
||||
int index = 0;
|
||||
|
||||
// First tracepoint will be a slow tracepoint
|
||||
// First tracepoint will be a normal tracepoint
|
||||
attributes = new HashMap<String, Object>();
|
||||
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<String, Object>();
|
||||
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<String, Object> attributes = null;
|
||||
int index = 0;
|
||||
|
||||
// First tracepoint will be a slow tracepoint
|
||||
// First tracepoint will be a normal tracepoint
|
||||
attributes = new HashMap<String, Object>();
|
||||
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<String, Object>();
|
||||
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<String, Object> attributes = null;
|
||||
int index = 0;
|
||||
|
||||
// First tracepoint will be a slow tracepoint
|
||||
// First tracepoint will be a normal tracepoint
|
||||
attributes = new HashMap<String, Object>();
|
||||
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<String, Object>();
|
||||
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<String, Object> attributes = null;
|
||||
int index = 0;
|
||||
|
||||
// First tracepoint will be a slow tracepoint
|
||||
// First tracepoint will be a normal tracepoint
|
||||
attributes = new HashMap<String, Object>();
|
||||
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<String, Object>();
|
||||
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<String, Object> attributes = null;
|
||||
int index = 0;
|
||||
|
||||
// First tracepoint will be a slow tracepoint
|
||||
// First tracepoint will be a normal tracepoint
|
||||
attributes = new HashMap<String, Object>();
|
||||
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<String, Object>();
|
||||
attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
|
||||
attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
<feature url="features/org.eclipse.cdt.sdk_0.0.0.qualifier.jar" id="org.eclipse.cdt.sdk" version="0.0.0">
|
||||
<category name="main"/>
|
||||
</feature>
|
||||
<feature url="features/org.eclipse.cdt.core.lrparser.feature_0.0.0.qualifier.jar" id="org.eclipse.cdt.core.lrparser.feature" version="0.0.0">
|
||||
<category name="extra"/>
|
||||
</feature>
|
||||
<feature url="features/org.eclipse.cdt.core.lrparser.sdk_0.0.0.qualifier.jar" id="org.eclipse.cdt.core.lrparser.sdk" version="0.0.0">
|
||||
<category name="extra"/>
|
||||
</feature>
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue