Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonah Graham2017-05-03 10:42:57 +0000
committerGerrit Code Review @ Eclipse.org2017-05-05 12:32:35 +0000
commita36ecd3839c95226ff27ee5d247f720328ffe765 (patch)
treecf3a182cb91bf0ebfffb78c876696f70499df670 /dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command
parentbda21e55ab902d387e303c096d2c7fca041548c6 (diff)
downloadorg.eclipse.cdt-a36ecd3839c95226ff27ee5d247f720328ffe765.tar.gz
org.eclipse.cdt-a36ecd3839c95226ff27ee5d247f720328ffe765.tar.xz
org.eclipse.cdt-a36ecd3839c95226ff27ee5d247f720328ffe765.zip
Bug 516053: Allow MIBreakpoint to be extended
New API to allow third-parties to extend MIBreakpoint with their own custom Breakpoint handling. Change-Id: I64abfc41916a2053cfbed7e3db2357fbf2572050
Diffstat (limited to 'dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command')
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLICatchInfo.java14
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakInsertInfo.java21
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakListInfo.java14
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakpoint.java48
4 files changed, 85 insertions, 12 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLICatchInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLICatchInfo.java
index 7eecf28f061..3fca7008fc4 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLICatchInfo.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLICatchInfo.java
@@ -48,7 +48,19 @@ public class CLICatchInfo extends MIInfo {
}
private MIBreakpoint parseCatchpoint(String str) {
- return str.startsWith("Catchpoint ") ? new MIBreakpoint(str) : null; //$NON-NLS-1$
+ return str.startsWith("Catchpoint ") ? createMIBreakpoint(str) : null; //$NON-NLS-1$
+ }
+
+ /**
+ * Create a target specific MIBreakpoint
+ *
+ * @param value
+ * tuple suitable for passing to MIBreakpoint constructor
+ * @return new breakpoint
+ * @since 5.3
+ */
+ protected MIBreakpoint createMIBreakpoint(String str) {
+ return new MIBreakpoint(str);
}
/**
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakInsertInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakInsertInfo.java
index 8609866444c..1fe5514a3c4 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakInsertInfo.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakInsertInfo.java
@@ -43,23 +43,23 @@ public class MIBreakInsertInfo extends MIInfo {
MIBreakpoint bpt = null;
if (var.equals("wpt")) { //$NON-NLS-1$
if (val instanceof MITuple) {
- bpt = new MIBreakpoint((MITuple)val);
+ bpt = createMIBreakpoint((MITuple)val);
bpt.setEnabled(true);
bpt.setWriteWatchpoint(true);
}
} else if (var.equals("bkpt")) { //$NON-NLS-1$
if (val instanceof MITuple) {
- bpt = new MIBreakpoint((MITuple)val);
+ bpt = createMIBreakpoint((MITuple)val);
}
} else if (var.equals("hw-awpt")) { //$NON-NLS-1$
if (val instanceof MITuple) {
- bpt = new MIBreakpoint((MITuple)val);
+ bpt = createMIBreakpoint((MITuple)val);
bpt.setAccessWatchpoint(true);
bpt.setEnabled(true);
}
} else if (var.equals("hw-rwpt")) { //$NON-NLS-1$
if (val instanceof MITuple) {
- bpt = new MIBreakpoint((MITuple)val);
+ bpt = createMIBreakpoint((MITuple)val);
bpt.setReadWatchpoint(true);
bpt.setEnabled(true);
}
@@ -76,4 +76,17 @@ public class MIBreakInsertInfo extends MIInfo {
public MIBreakpoint[] getMIBreakpoints() {
return breakpoints;
}
+
+
+ /**
+ * Create a target specific MIBreakpoint
+ *
+ * @param value
+ * tuple suitable for passing to MIBreakpoint constructor
+ * @return new breakpoint
+ * @since 5.3
+ */
+ protected MIBreakpoint createMIBreakpoint(MITuple tuple) {
+ return new MIBreakpoint(tuple);
+ }
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakListInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakListInfo.java
index bb1385ecb15..25409fba58c 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakListInfo.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakListInfo.java
@@ -77,10 +77,22 @@ public class MIBreakListInfo extends MIInfo {
if (b.equals("bkpt")) { //$NON-NLS-1$
MIValue value = bkpts[i].getMIValue();
if (value instanceof MITuple) {
- aList.add(new MIBreakpoint((MITuple)value));
+ aList.add(createMIBreakpoint((MITuple)value));
}
}
}
}
}
+
+ /**
+ * Create a target specific MIBreakpoint
+ *
+ * @param value
+ * tuple suitable for passing to MIBreakpoint constructor
+ * @return new breakpoint
+ * @since 5.3
+ */
+ protected MIBreakpoint createMIBreakpoint(MITuple tuple) {
+ return new MIBreakpoint(tuple);
+ }
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakpoint.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakpoint.java
index 803ac82c709..3b8d42f6ce0 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakpoint.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakpoint.java
@@ -23,6 +23,7 @@ import java.util.List;
import java.util.StringTokenizer;
import org.eclipse.cdt.dsf.gdb.internal.tracepointactions.TracepointActionManager;
+import org.eclipse.cdt.dsf.mi.service.MIBreakpoints;
/**
* Contain info about the GDB/MI breakpoint.
@@ -64,6 +65,12 @@ import org.eclipse.cdt.dsf.gdb.internal.tracepointactions.TracepointActionManage
* ^done,bkpt={number="9",type="breakpoint",disp="keep",enabled="y",addr="<PENDING>",pending="NotLoadedLibrary.c:26",times="0",original-location="NotLoadedLibrary.c:26"}
*
* Note that any breakpoint that fails to install will be marked as pending when the -f option is used.
+ * <p>
+ * <b>Note on using constructor directly:</b></a> As this class can be extended by third-parties it is
+ * important to allow third parties the ability to have the correct version of MIBreakpoint
+ * created. {@code MIBreakpoint}s should therefore be created via factory methods that can be overloaded.
+ * For examples, see {@link MIBreakpoints#createMIBreakpoint(MITuple)} or
+ * {@link MIBreakInsertInfo#createMIBreakpoint(MITuple)}
*/
public class MIBreakpoint {
@@ -122,11 +129,27 @@ public class MIBreakpoint {
* null will be returned if this field is not present.
*/
private String[] groupIds;
-
- public MIBreakpoint() {
+
+ /**
+ * No arguments constructor.
+ * <p>
+ * See {@link MIBreakpoint} class comment "Note on using constructor
+ * directly"
+ */
+ public MIBreakpoint() {
}
- public MIBreakpoint(MIBreakpoint other) {
+ /**
+ * Copy-constructor
+ * <p>
+ * See {@link MIBreakpoint} class comment "Note on using constructor
+ * directly"
+ * <p>
+ *
+ * @param other
+ * breakpoint to copy from
+ */
+ public MIBreakpoint(MIBreakpoint other) {
number = other.number;
type = other.type;
disp = other.disp;
@@ -159,9 +182,19 @@ public class MIBreakpoint {
}
}
- public MIBreakpoint(MITuple tuple) {
- parse(tuple);
- }
+ /**
+ * Construct an MIBreakpoint from the MI Tuple received from GDB
+ * <p>
+ * See {@link MIBreakpoint} class comment "Note on using constructor
+ * directly"
+ * <p>
+ *
+ * @param tuple
+ * data received from GDB
+ */
+ public MIBreakpoint(MITuple tuple) {
+ parse(tuple);
+ }
/**
* This constructor is used for catchpoints. Catchpoints are not yet
@@ -192,6 +225,9 @@ public class MIBreakpoint {
* able to tell it's a catchpoint. Quite the mess. Wish gdb would treat
* catchpoints like first class citizens.
*
+ * <p>
+ * See {@link MIBreakpoint} class comment "Note on using constructor directly"
+ *
* @param cliResult
* the output from the CLI command. Example:
* "Catchpoint 1 (catch)"

Back to the top