use of org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl in project che by eclipse.
the class GdbInfoBreak method parse.
/**
* Factory method.
*/
public static GdbInfoBreak parse(GdbOutput gdbOutput) throws GdbParseException {
String output = gdbOutput.getOutput();
List<Breakpoint> breakpoints = new ArrayList<>();
for (String line : output.split("\n")) {
Matcher matcher = GDB_INFO_B.matcher(line);
if (matcher.find()) {
String file = matcher.group(2);
String lineNumber = matcher.group(3);
Location location = new LocationImpl(file, Integer.parseInt(lineNumber));
breakpoints.add(new BreakpointImpl(location));
}
}
return new GdbInfoBreak(breakpoints);
}
use of org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl in project che by eclipse.
the class ZendDbgSessionTest method testBreakpoints.
@Test(groups = { "zendDbg" }, dependsOnGroups = { "checkPHP" })
public void testBreakpoints() throws Exception {
List<Breakpoint> breakpoints = new ArrayList<>();
Breakpoint bp1 = new BreakpointImpl(ZendDbgLocationHandler.createDBG(dbgHelloFile, 4));
Breakpoint bp2 = new BreakpointImpl(ZendDbgLocationHandler.createDBG(dbgHelloFile, 8));
breakpoints.add(bp1);
breakpoints.add(bp2);
triggerSession(dbgHelloFile, getDbgSettings(true, false), breakpoints);
awaitBreakpointActivated(bp1);
awaitBreakpointActivated(bp2);
awaitSuspend(dbgHelloFile, 2);
Breakpoint bp3 = new BreakpointImpl(ZendDbgLocationHandler.createDBG(dbgClassesFile, 10));
debugger.addBreakpoint(bp3);
awaitBreakpointActivated(bp3);
Breakpoint bp4 = new BreakpointImpl(ZendDbgLocationHandler.createDBG(dbgClassesFile, 16));
debugger.addBreakpoint(bp4);
awaitBreakpointActivated(bp4);
debugger.deleteBreakpoint(ZendDbgLocationHandler.createDBG(dbgHelloFile, 8));
debugger.deleteBreakpoint(ZendDbgLocationHandler.createDBG(dbgClassesFile, 16));
assertEquals(debugger.getAllBreakpoints().size(), 2);
debugger.deleteAllBreakpoints();
assertTrue(debugger.getAllBreakpoints().isEmpty());
}
use of org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl in project che by eclipse.
the class ZendDbgSessionTest method testGetValue.
@Test(groups = { "zendDbg" }, dependsOnGroups = { "checkPHP" })
public void testGetValue() throws Exception {
List<Breakpoint> breakpoints = new ArrayList<>();
Breakpoint bp1 = new BreakpointImpl(ZendDbgLocationHandler.createDBG(dbgClassesFile, 16));
breakpoints.add(bp1);
triggerSession(dbgHelloFile, getDbgSettings(false, false), breakpoints);
awaitBreakpointActivated(bp1);
awaitSuspend(dbgClassesFile, 16);
debugger.dumpStackFrame();
VariablePath variablePath = new VariablePathImpl("0");
SimpleValue simpleValue = debugger.getValue(variablePath);
assertEquals(simpleValue.getVariables().size(), 3);
List<String> path = Arrays.asList("0", "0");
variablePath = new VariablePathImpl(path);
simpleValue = debugger.getValue(variablePath);
assertEquals(simpleValue.getValue(), "\"A\"");
path = Arrays.asList("0", "1");
variablePath = new VariablePathImpl(path);
simpleValue = debugger.getValue(variablePath);
assertEquals(simpleValue.getValue(), "123");
path = Arrays.asList("0", "2");
variablePath = new VariablePathImpl(path);
simpleValue = debugger.getValue(variablePath);
assertEquals(simpleValue.getValue(), "array [3]");
}
use of org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl in project che by eclipse.
the class ZendDbgSessionTest method testBreaking.
@Test(groups = { "zendDbg" }, dependsOnGroups = { "checkPHP" })
public void testBreaking() throws Exception {
List<Breakpoint> breakpoints = new ArrayList<>();
Breakpoint bp1 = new BreakpointImpl(ZendDbgLocationHandler.createDBG(dbgHelloFile, 4));
Breakpoint bp2 = new BreakpointImpl(ZendDbgLocationHandler.createDBG(dbgClassesFile, 10));
breakpoints.add(bp1);
breakpoints.add(bp2);
triggerSession(dbgHelloFile, getDbgSettings(false, false), breakpoints);
awaitBreakpointActivated(bp1);
awaitBreakpointActivated(bp2);
awaitSuspend(dbgHelloFile, 4);
debugger.resume(new ResumeActionImpl());
awaitSuspend(dbgClassesFile, 10);
}
use of org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl in project che by eclipse.
the class JavaDebugger method addBreakpoint.
@Override
public void addBreakpoint(Breakpoint breakpoint) throws DebuggerException {
final String className = findFQN(breakpoint);
final int lineNumber = breakpoint.getLocation().getLineNumber();
List<ReferenceType> classes = vm.classesByName(className);
// it may mean that class doesn't loaded by a target JVM yet
if (classes.isEmpty()) {
deferBreakpoint(breakpoint);
throw new DebuggerException("Class not loaded");
}
ReferenceType clazz = classes.get(0);
List<com.sun.jdi.Location> locations;
try {
locations = clazz.locationsOfLine(lineNumber);
} catch (AbsentInformationException | ClassNotPreparedException e) {
throw new DebuggerException(e.getMessage(), e);
}
if (locations.isEmpty()) {
throw new DebuggerException("Line " + lineNumber + " not found in class " + className);
}
com.sun.jdi.Location location = locations.get(0);
if (location.method() == null) {
// Line is out of method.
throw new DebuggerException("Invalid line " + lineNumber + " in class " + className);
}
// Ignore new breakpoint if already have breakpoint at the same location.
EventRequestManager requestManager = getEventManager();
for (BreakpointRequest breakpointRequest : requestManager.breakpointRequests()) {
if (location.equals(breakpointRequest.location())) {
LOG.debug("Breakpoint at {} already set", location);
return;
}
}
try {
EventRequest breakPointRequest = requestManager.createBreakpointRequest(location);
breakPointRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
String expression = breakpoint.getCondition();
if (!(expression == null || expression.isEmpty())) {
ExpressionParser parser = ExpressionParser.newInstance(expression);
breakPointRequest.putProperty("org.eclipse.che.ide.java.debug.condition.expression.parser", parser);
}
breakPointRequest.setEnabled(true);
} catch (NativeMethodException | IllegalThreadStateException | InvalidRequestStateException e) {
throw new DebuggerException(e.getMessage(), e);
}
debuggerCallback.onEvent(new BreakpointActivatedEventImpl(new BreakpointImpl(breakpoint.getLocation(), true, breakpoint.getCondition())));
LOG.debug("Add breakpoint: {}", location);
}
Aggregations