Skip to content

Commit

Permalink
Fix GDB regression (#7423)
Browse files Browse the repository at this point in the history
Fixes GDB regression with stopping on breakpoints.
Moves integration tests into docker container.
  • Loading branch information
mmorhun committed Nov 20, 2017
1 parent ae1378c commit d6083f4
Show file tree
Hide file tree
Showing 12 changed files with 248 additions and 108 deletions.
43 changes: 1 addition & 42 deletions plugins/plugin-gdb/che-plugin-gdb-ide/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@
<packaging>gwt-lib</packaging>
<name>Che Plugin :: GDB :: GDB IDE</name>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-elemental</artifactId>
</dependency>
<dependency>
<groupId>com.google.gwt.inject</groupId>
<artifactId>gin</artifactId>
Expand All @@ -38,30 +30,13 @@
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-core</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-core</artifactId>
<classifier>sources</classifier>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-workspace</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-annotations</artifactId>
<artifactId>che-core-api-debug-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
Expand All @@ -75,10 +50,6 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-ide-app</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-ide-ui</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-debugger-ide</artifactId>
Expand Down Expand Up @@ -128,18 +99,6 @@
<moduleName>org.eclipse.che.plugin.gdb.Gdb</moduleName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>analyze</id>
<configuration>
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down
89 changes: 85 additions & 4 deletions plugins/plugin-gdb/che-plugin-gdb-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<artifactId>che-plugin-gdb-server</artifactId>
<packaging>jar</packaging>
<name>Che Plugin :: GDB :: GDB Server</name>
<properties>
<docker.showLogs>true</docker.showLogs>
</properties>
<dependencies>
<dependency>
<groupId>com.google.inject</groupId>
Expand Down Expand Up @@ -58,6 +61,11 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand Down Expand Up @@ -96,34 +104,107 @@
</build>
<profiles>
<profile>
<id>gdb-tests</id>
<id>integration</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<skipTests>false</skipTests>
<systemPropertyVariables>
<debug.port>${debug.port}</debug.port>
</systemPropertyVariables>
<suiteXmlFiles>
<suiteXmlFile>${project.build.testOutputDirectory}/GdbDebuggerTestsSuite.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>process-test-resources</id>
<id>process-resources</id>
<phase>process-test-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<chmod file="target/test-classes/hello" perm="755" />
<chmod file="${project.build.testOutputDirectory}/docker/entrypoint.sh" perm="+x" />
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<executions>
<execution>
<id>build</id>
<phase>process-test-resources</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>stop</goal>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<images>
<image>
<alias>gcc_gdb</alias>
<name>gdb-tests</name>
<build>
<from>eclipse/cpp_gcc</from>
<assembly>
<descriptor>${project.build.testOutputDirectory}/docker/assembly.xml</descriptor>
</assembly>
<workdir>/maven</workdir>
<entryPoint>
<exec>./entrypoint.sh</exec>
</entryPoint>
</build>
<run>
<privileged>true</privileged>
<ports>
<port>debug.port:8000</port>
</ports>
<wait>
<log>Listening on port 8000</log>
<time>5000</time>
</wait>
</run>
</image>
</images>
</configuration>
</plugin>
</plugins>
</build>
</profile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.eclipse.che.api.debug.shared.model.action.StepOutAction;
import org.eclipse.che.api.debug.shared.model.action.StepOverAction;
import org.eclipse.che.api.debug.shared.model.impl.DebuggerInfoImpl;
import org.eclipse.che.api.debug.shared.model.impl.LocationImpl;
import org.eclipse.che.api.debug.shared.model.impl.SimpleValueImpl;
import org.eclipse.che.api.debug.shared.model.impl.StackFrameDumpImpl;
import org.eclipse.che.api.debug.shared.model.impl.VariableImpl;
Expand Down Expand Up @@ -180,7 +181,7 @@ public void disconnect() {
@Override
public void addBreakpoint(Breakpoint breakpoint) throws DebuggerException {
try {
Location location = breakpoint.getLocation();
Location location = relativeToWorkDir(breakpoint.getLocation());
if (location.getTarget() == null) {
gdb.breakpoint(location.getLineNumber());
} else {
Expand Down Expand Up @@ -450,4 +451,21 @@ public StackFrameDump dumpStackFrame() throws DebuggerException {
throw new DebuggerException("Can't dump stack frame. " + e.getMessage(), e);
}
}

private Location relativeToWorkDir(Location location)
throws InterruptedException, GdbParseException, GdbTerminatedException, IOException {
String targetFilePath = location.getTarget();
if (targetFilePath.startsWith("/")) {
return new LocationImpl(
targetFilePath.substring(1),
location.getLineNumber(),
location.isExternalResource(),
location.getExternalResourceId(),
location.getResourceProjectPath(),
location.getMethod(),
location.getThreadId());
} else {
return location;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,44 +45,31 @@
import org.eclipse.che.api.debug.shared.model.impl.action.StepOverActionImpl;
import org.eclipse.che.api.debugger.server.Debugger;
import org.eclipse.che.api.debugger.server.exceptions.DebuggerException;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

/** @author Anatoliy Bazko */
public class GdbDebuggerTest {

private String file;
private Path sourceDirectory;
private GdbServer gdbServer;
private Debugger gdbDebugger;
private BlockingQueue<DebuggerEvent> events;

@BeforeClass
public void beforeClass() throws Exception {
file = GdbTest.class.getResource("/hello").getFile();
sourceDirectory = Paths.get(GdbTest.class.getResource("/h.cpp").getFile());
sourceDirectory = Paths.get(GdbTest.class.getResource("/h.cpp").getFile()).getParent();
events = new ArrayBlockingQueue<>(10);
}

@BeforeMethod
public void setUp() throws Exception {
gdbServer = GdbServer.start("localhost", 1111, file);
}

@AfterMethod
public void tearDown() throws Exception {
gdbServer.stop();
}

@Test
public void testDebugger() throws Exception {
initializeDebugger();
addBreakpoint();
startDebugger();
doSetAndGetValues();
// stepInto();
// stepInto();
stepOver();
stepOut();
resume();
Expand Down Expand Up @@ -217,16 +204,18 @@ private void addBreakpoint() throws DebuggerException, InterruptedException {
}

private void initializeDebugger() throws DebuggerException {
final String gdbPort = System.getProperty("debug.port");

Map<String, String> properties =
ImmutableMap.of(
"host",
"localhost",
"port",
"1111",
gdbPort,
"binary",
file,
"sources",
sourceDirectory.getParent().toString());
sourceDirectory.toString());

GdbDebuggerFactory gdbDebuggerFactory = new GdbDebuggerFactory();
gdbDebugger = gdbDebuggerFactory.create(properties, events::add);
Expand All @@ -235,7 +224,7 @@ private void initializeDebugger() throws DebuggerException {

assertEquals(debuggerInfo.getFile(), file);
assertEquals(debuggerInfo.getHost(), "localhost");
assertEquals(debuggerInfo.getPort(), 1111);
assertEquals(debuggerInfo.getPort(), Integer.parseInt(gdbPort));
assertNotNull(debuggerInfo.getName());
assertNotNull(debuggerInfo.getVersion());
}
Expand Down

This file was deleted.

Loading

0 comments on commit d6083f4

Please sign in to comment.