Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonah Graham2017-05-03 06:42:57 -0400
committerGerrit Code Review @ Eclipse.org2017-05-05 08:32:35 -0400
commita36ecd3839c95226ff27ee5d247f720328ffe765 (patch)
treecf3a182cb91bf0ebfffb78c876696f70499df670 /dsf-gdb
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')
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_4.java2
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpoints.java15
-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
6 files changed, 101 insertions, 13 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_4.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_4.java
index 37e0b803b6..55808cfaa2 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_4.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_4.java
@@ -145,7 +145,7 @@ public class GDBBreakpoints_7_4 extends GDBBreakpoints_7_2 implements IEventList
MIValue val = results[i].getMIValue();
if (var.equals("bkpt")) { //$NON-NLS-1$
if (val instanceof MITuple) {
- bpt = new MIBreakpoint((MITuple)val);
+ bpt = createMIBreakpoint((MITuple)val);
}
}
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpoints.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpoints.java
index 3c664e3a85..ecf10d6b08 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpoints.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpoints.java
@@ -27,6 +27,7 @@ import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.Immutable;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.concurrent.Sequence.Step;
+import org.eclipse.cdt.dsf.concurrent.ThreadSafe;
import org.eclipse.cdt.dsf.datamodel.AbstractDMContext;
import org.eclipse.cdt.dsf.datamodel.AbstractDMEvent;
import org.eclipse.cdt.dsf.datamodel.DMContexts;
@@ -49,6 +50,7 @@ import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo;
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakListInfo;
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakpoint;
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
+import org.eclipse.cdt.dsf.mi.service.command.output.MITuple;
import org.eclipse.cdt.dsf.service.AbstractDsfService;
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
import org.eclipse.cdt.dsf.service.DsfSession;
@@ -165,6 +167,19 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints, I
return map;
}
+ /**
+ * Create a new MI breakpoint
+ *
+ * @param tuple
+ * from backend communication
+ * @return breakpoint
+ * @since 5.3
+ */
+ @ThreadSafe
+ public MIBreakpoint createMIBreakpoint(MITuple tuple) {
+ return new MIBreakpoint(tuple);
+ }
+
// Error messages
/** @since 3.0 */
public static final String NULL_STRING = ""; //$NON-NLS-1$
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 7eecf28f06..3fca7008fc 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 8609866444..1fe5514a3c 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 bb1385ecb1..25409fba58 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 803ac82c70..3b8d42f6ce 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