use of org.eclipse.che.api.debug.shared.model.Location in project che by eclipse.
the class GdbBacktraceTest method testParseLibraryLocation.
@Test
public void testParseLibraryLocation() throws Exception {
GdbOutput gdbOutput = GdbOutput.of(BACKTRACE_OUTPUT);
GdbBacktrace backtrace = GdbBacktrace.parse(gdbOutput);
Map<Integer, Location> frames = backtrace.getFrames();
Location frame1 = frames.get(1);
Location frame2 = frames.get(2);
assertEquals(frame1.getTarget(), "/usr/lib/x86_64-linux-gnu/libstdc++.so.6");
assertEquals(frame2.getTarget(), "/usr/lib/x86_64-linux-gnu/libstdc++.so.6");
}
use of org.eclipse.che.api.debug.shared.model.Location in project che by eclipse.
the class GdbInfoLineTest method testParse1.
@Test
public void testParse1() throws Exception {
GdbOutput gdbOutput = GdbOutput.of("Line 6 of \"h.cpp\" starts at address 0x4008ae <main()+17> and ends at 0x4008ca <main()+45>.\n");
GdbInfoLine gdbInfoLine = GdbInfoLine.parse(gdbOutput);
Location location = gdbInfoLine.getLocation();
assertEquals(location.getTarget(), "h.cpp");
assertEquals(location.getLineNumber(), 6);
}
use of org.eclipse.che.api.debug.shared.model.Location in project che by eclipse.
the class JavaDebugger method processBreakPointEvent.
private boolean processBreakPointEvent(com.sun.jdi.event.BreakpointEvent event) throws DebuggerException {
setCurrentThread(event.thread());
boolean hitBreakpoint;
ExpressionParser parser = (ExpressionParser) event.request().getProperty("org.eclipse.che.ide.java.debug.condition.expression.parser");
if (parser != null) {
com.sun.jdi.Value result = evaluate(parser);
hitBreakpoint = result instanceof com.sun.jdi.BooleanValue && ((com.sun.jdi.BooleanValue) result).value();
} else {
// If there is no expression.
hitBreakpoint = true;
}
if (hitBreakpoint) {
com.sun.jdi.Location jdiLocation = event.location();
Location location;
try {
location = debuggerUtil.getLocation(jdiLocation);
} catch (DebuggerException e) {
location = new LocationImpl(jdiLocation.declaringType().name(), jdiLocation.lineNumber());
}
debuggerCallback.onEvent(new SuspendEventImpl(location));
}
// or if condition expression is not set.
return !hitBreakpoint;
}
use of org.eclipse.che.api.debug.shared.model.Location in project che by eclipse.
the class GdbDebugger method addBreakpoint.
@Override
public void addBreakpoint(Breakpoint breakpoint) throws DebuggerException {
try {
Location location = breakpoint.getLocation();
if (location.getTarget() == null) {
gdb.breakpoint(location.getLineNumber());
} else {
gdb.breakpoint(location.getTarget(), location.getLineNumber());
}
debuggerCallback.onEvent(new BreakpointActivatedEventImpl(breakpoint));
} catch (GdbTerminatedException e) {
disconnect();
throw e;
} catch (IOException | GdbParseException | InterruptedException e) {
throw new DebuggerException("Can't add breakpoint: " + breakpoint + ". " + e.getMessage(), e);
}
}
use of org.eclipse.che.api.debug.shared.model.Location in project che by eclipse.
the class GdbBacktrace method parse.
/**
* Factory method.
*/
public static GdbBacktrace parse(GdbOutput gdbOutput) throws GdbParseException {
Matcher matcher;
final String output = gdbOutput.getOutput();
final String[] framesInfo = output.split("#");
final Map<Integer, Location> frames = new HashMap<>(framesInfo.length);
for (String frame : framesInfo) {
try {
matcher = GDB_FILE_LOCATION.matcher(frame);
if (matcher.find()) {
final String fileLocation = matcher.group(2);
final int lineNumber = Integer.parseInt(matcher.group(3));
final int frameNumber = Integer.parseInt(matcher.group(1));
final Location location = new LocationImpl(fileLocation, lineNumber);
frames.put(frameNumber, location);
continue;
}
matcher = GDB_LIBRARY_LOCATION.matcher(frame);
if (matcher.find()) {
final int frameNumber = Integer.parseInt(matcher.group(1));
final String libraryLocation = matcher.group(2);
final Location location = new LocationImpl(libraryLocation);
frames.put(frameNumber, location);
}
} catch (NumberFormatException e) {
//we can't get info about current frame, but we are trying to get info about another frames
}
}
if (!frames.isEmpty()) {
return new GdbBacktrace(frames);
}
throw new GdbParseException(GdbBacktrace.class, output);
}
Aggregations