1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

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
This commit is contained in:
Jonah Graham 2017-05-03 11:42:57 +01:00 committed by Gerrit Code Review @ Eclipse.org
parent bda21e55ab
commit a36ecd3839
6 changed files with 101 additions and 13 deletions

View file

@ -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);
}
}
}

View file

@ -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$

View file

@ -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);
}
/**

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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 {
@ -123,10 +130,26 @@ public class MIBreakpoint {
*/
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)"