Search in sources :

Example 16 with LocationImpl

use of org.eclipse.che.api.debug.shared.model.impl.LocationImpl in project che by eclipse.

the class JavaDebuggerTest method testGetAllBreakpoints.

@Test(priority = 8)
public void testGetAllBreakpoints() throws Exception {
    assertFalse(debugger.getAllBreakpoints().isEmpty());
    debugger.deleteAllBreakpoints();
    assertTrue(debugger.getAllBreakpoints().isEmpty());
    debugger.addBreakpoint(new BreakpointImpl(new LocationImpl("com.HelloWorld", 18), false, null));
    DebuggerEvent debuggerEvent = events.take();
    assertTrue(debuggerEvent instanceof BreakpointActivatedEvent);
    assertEquals(debugger.getAllBreakpoints().size(), 1);
    Breakpoint breakpoint = debugger.getAllBreakpoints().get(0);
    assertEquals(breakpoint.getLocation().getLineNumber(), 18);
    assertEquals(breakpoint.getLocation().getTarget(), "com.HelloWorld");
    assertTrue(breakpoint.isEnabled());
}
Also used : Breakpoint(org.eclipse.che.api.debug.shared.model.Breakpoint) BreakpointImpl(org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl) LocationImpl(org.eclipse.che.api.debug.shared.model.impl.LocationImpl) BreakpointActivatedEvent(org.eclipse.che.api.debug.shared.model.event.BreakpointActivatedEvent) DebuggerEvent(org.eclipse.che.api.debug.shared.model.event.DebuggerEvent) Test(org.testng.annotations.Test)

Example 17 with LocationImpl

use of org.eclipse.che.api.debug.shared.model.impl.LocationImpl in project che by eclipse.

the class JavaDebuggerTest method testRemoveBreakpoint.

@Test(priority = 6)
public void testRemoveBreakpoint() throws Exception {
    debugger.deleteBreakpoint(new LocationImpl("com.HelloWorld", 17));
    assertEquals(debugger.getAllBreakpoints().size(), 1);
}
Also used : LocationImpl(org.eclipse.che.api.debug.shared.model.impl.LocationImpl) Test(org.testng.annotations.Test)

Example 18 with LocationImpl

use of org.eclipse.che.api.debug.shared.model.impl.LocationImpl in project che by eclipse.

the class JavaDebuggerTest method testRemoveUnExistedBreakpoint.

@Test(priority = 7)
public void testRemoveUnExistedBreakpoint() throws Exception {
    int breakpointsCount = debugger.getAllBreakpoints().size();
    debugger.deleteBreakpoint(new LocationImpl("com.HelloWorld", 2));
    assertEquals(debugger.getAllBreakpoints().size(), breakpointsCount);
}
Also used : LocationImpl(org.eclipse.che.api.debug.shared.model.impl.LocationImpl) Breakpoint(org.eclipse.che.api.debug.shared.model.Breakpoint) Test(org.testng.annotations.Test)

Example 19 with LocationImpl

use of org.eclipse.che.api.debug.shared.model.impl.LocationImpl in project che by eclipse.

the class JavaDebuggerUtils method getLocation.

/**
     * Returns Location for current debugger resource.
     *
     * @param location
     *         location type from JVM
     * @throws DebuggerException
     *         in case {@link org.eclipse.jdt.core.JavaModelException} or if Java {@link org.eclipse.jdt.core.IType}
     *         was not find
     */
public Location getLocation(com.sun.jdi.Location location) throws DebuggerException {
    String fqn = location.declaringType().name();
    List<IType> types;
    try {
        Pair<char[][], char[][]> fqnPair = prepareFqnToSearch(fqn);
        types = findTypeByFqn(fqnPair.first, fqnPair.second, createWorkspaceScope());
    } catch (JavaModelException e) {
        throw new DebuggerException("Can't find class models by fqn: " + fqn, e);
    }
    if (types.isEmpty()) {
        throw new DebuggerException("Type with fully qualified name: " + fqn + " was not found");
    }
    //TODO we need handle few result! It's temporary solution.
    IType type = types.get(0);
    String typeProjectPath = type.getJavaProject().getPath().toOSString();
    if (type.isBinary()) {
        IClassFile classFile = type.getClassFile();
        int libId = classFile.getAncestor(IPackageFragmentRoot.PACKAGE_FRAGMENT_ROOT).hashCode();
        return new LocationImpl(fqn, location.lineNumber(), null, true, libId, typeProjectPath);
    } else {
        ICompilationUnit compilationUnit = type.getCompilationUnit();
        typeProjectPath = type.getJavaProject().getPath().toOSString();
        String resourcePath = compilationUnit.getPath().toOSString();
        return new LocationImpl(fqn, location.lineNumber(), resourcePath, false, -1, typeProjectPath);
    }
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) JavaModelException(org.eclipse.jdt.core.JavaModelException) IClassFile(org.eclipse.jdt.core.IClassFile) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException) LocationImpl(org.eclipse.che.api.debug.shared.model.impl.LocationImpl) IType(org.eclipse.jdt.core.IType)

Example 20 with LocationImpl

use of org.eclipse.che.api.debug.shared.model.impl.LocationImpl 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);
}
Also used : Matcher(java.util.regex.Matcher) HashMap(java.util.HashMap) LocationImpl(org.eclipse.che.api.debug.shared.model.impl.LocationImpl) GdbParseException(org.eclipse.che.plugin.gdb.server.exception.GdbParseException) Location(org.eclipse.che.api.debug.shared.model.Location)

Aggregations

LocationImpl (org.eclipse.che.api.debug.shared.model.impl.LocationImpl)22 Location (org.eclipse.che.api.debug.shared.model.Location)11 BreakpointImpl (org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl)11 Breakpoint (org.eclipse.che.api.debug.shared.model.Breakpoint)8 Matcher (java.util.regex.Matcher)7 Test (org.testng.annotations.Test)7 BreakpointActivatedEvent (org.eclipse.che.api.debug.shared.model.event.BreakpointActivatedEvent)6 DebuggerEvent (org.eclipse.che.api.debug.shared.model.event.DebuggerEvent)5 NodeJsDebuggerParseException (org.eclipse.che.plugin.nodejsdbg.server.exception.NodeJsDebuggerParseException)3 ArrayList (java.util.ArrayList)2 SuspendEvent (org.eclipse.che.api.debug.shared.model.event.SuspendEvent)2 DebuggerException (org.eclipse.che.api.debugger.server.exceptions.DebuggerException)2 GdbParseException (org.eclipse.che.plugin.gdb.server.exception.GdbParseException)2 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 JsonParser (com.google.gson.JsonParser)1 HashMap (java.util.HashMap)1 DELETE (javax.ws.rs.DELETE)1 Path (javax.ws.rs.Path)1 VariablePath (org.eclipse.che.api.debug.shared.model.VariablePath)1