Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 183875409370
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: aee13acee3f4
Choose a head ref
  • 5 commits
  • 2 files changed
  • 1 contributor

Commits on Aug 22, 2016

  1. Copy the full SHA
    758699b View commit details
  2. Copy the full SHA
    dbf2812 View commit details
  3. Copy the full SHA
    c95483a View commit details
  4. Copy the full SHA
    224006d View commit details
  5. Revert "[Truffle] Remove last source section identifier."

    This reverts commit 1838754.
    chrisseaton committed Aug 22, 2016
    Copy the full SHA
    aee13ac View commit details
Original file line number Diff line number Diff line change
@@ -160,7 +160,7 @@ private SourceSection translate(Source source, ISourcePosition sourcePosition) {
return parentSourceSection.peek();
}
} else {
return source.createSection(sourcePosition.getLine() + 1);
return source.createSection("(identifier)", sourcePosition.getLine() + 1);
}
}

138 changes: 48 additions & 90 deletions truffle/src/test/java/org/jruby/truffle/tck/RubyDebugTest.java
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@
import org.junit.Test;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import java.util.Objects;
@@ -75,7 +76,7 @@ protected void on(SuspendedEvent event) {

}).build();

engine.eval(Source.fromFileName("src/test/ruby/init.rb"));
engine.eval(Source.newBuilder(new File("src/test/ruby/init.rb")).build());

run.clear();
}
@@ -91,34 +92,24 @@ public void dispose() {
public void testBreakpoint() throws Throwable {
final Source factorial = createFactorial();

run.addLast(new Runnable() {

@Override
public void run() {
try {
assertNull(suspendedEvent);
assertNotNull(executionEvent);
LineLocation returnOne = factorial.createLineLocation(3);
debugger.setLineBreakpoint(0, returnOne, false);
executionEvent.prepareContinue();
} catch (IOException e) {
throw new JavaException(e);
}
run.addLast(() -> {
try {
assertNull(suspendedEvent);
assertNotNull(executionEvent);
LineLocation returnOne = factorial.createLineLocation(3);
debugger.setLineBreakpoint(0, returnOne, false);
executionEvent.prepareContinue();
} catch (IOException e) {
throw new JavaException(e);
}

});

engine.eval(factorial);

assertExecutedOK("Algorithm loaded");

run.addLast(new Runnable() {

@Override
public void run() {
//fail("the breakpoint should hit instead");
}

run.addLast(() -> {
//fail("the breakpoint should hit instead");
});

assertLocation(3, "1",
@@ -143,15 +134,10 @@ public void stepInStepOver() throws Throwable {
final Source factorial = createFactorial();
engine.eval(factorial);

run.addLast(new Runnable() {

@Override
public void run() {
assertNull(suspendedEvent);
assertNotNull(executionEvent);
executionEvent.prepareStepInto();
}

run.addLast(() -> {
assertNull(suspendedEvent);
assertNotNull(executionEvent);
executionEvent.prepareStepInto();
});

assertLocation(13, "res = fac(2)", "res", null);
@@ -207,82 +193,54 @@ private void performWork() {
}

private void stepOver(final int size) {
run.addLast(new Runnable() {

public void run() {
suspendedEvent.prepareStepOver(size);
}

});
run.addLast(() -> suspendedEvent.prepareStepOver(size));
}

private void stepOut() {
run.addLast(new Runnable() {

public void run() {
suspendedEvent.prepareStepOut();
}

});
run.addLast(() -> suspendedEvent.prepareStepOut());
}

private void continueExecution() {
run.addLast(new Runnable() {

public void run() {
suspendedEvent.prepareContinue();
}

});
run.addLast(() -> suspendedEvent.prepareContinue());
}

private void stepInto(final int size) {
run.addLast(new Runnable() {

public void run() {
suspendedEvent.prepareStepInto(size);
}

});
run.addLast(() -> suspendedEvent.prepareStepInto(size));
}

private void assertLocation(final int line, final String code, final Object... expectedFrame) {
run.addLast(new Runnable() {

public void run() {
assertNotNull(suspendedEvent);
final int currentLine = suspendedEvent.getNode().getSourceSection().getLineLocation().getLineNumber();
assertEquals(line, currentLine);
final String currentCode = suspendedEvent.getNode().getSourceSection().getCode().trim();
assertEquals(code, currentCode);
final MaterializedFrame frame = suspendedEvent.getFrame();

assertEquals(expectedFrame.length / 2, frame.getFrameDescriptor().getSize());

for (int i = 0; i < expectedFrame.length; i = i + 2) {
String expectedIdentifier = (String) expectedFrame[i];
Object expectedValue = expectedFrame[i + 1];
FrameSlot slot = frame.getFrameDescriptor().findFrameSlot(expectedIdentifier);
assertNotNull(slot);
Object value = frame.getValue(slot);

if (Objects.equals(expectedValue, value)) {
continue;
}

Node findContextNode = RubyLanguage.INSTANCE.unprotectedCreateFindContextNode();
RubyContext context = RubyLanguage.INSTANCE.unprotectedFindContext(findContextNode);
run.addLast(() -> {
assertNotNull(suspendedEvent);
final int currentLine = suspendedEvent.getNode().getSourceSection().getLineLocation().getLineNumber();
assertEquals(line, currentLine);
final String currentCode = suspendedEvent.getNode().getSourceSection().getCode().trim();
assertEquals(code, currentCode);
final MaterializedFrame frame = suspendedEvent.getFrame();

assertEquals(expectedFrame.length / 2, frame.getFrameDescriptor().getSize() - 1);

for (int i = 0; i < expectedFrame.length; i = i + 2) {
String expectedIdentifier = (String) expectedFrame[i];
Object expectedValue = expectedFrame[i + 1];
FrameSlot slot = frame.getFrameDescriptor().findFrameSlot(expectedIdentifier);
assertNotNull(slot);
Object value = frame.getValue(slot);

if (Objects.equals(expectedValue, value)) {
continue;
}

if (value == context.getCoreLibrary().getNilObject()) {
value = null;
}
Node findContextNode = RubyLanguage.INSTANCE.unprotectedCreateFindContextNode();
RubyContext context = RubyLanguage.INSTANCE.unprotectedFindContext(findContextNode);

assertEquals(expectedValue, value);
if (value == context.getCoreLibrary().getNilObject()) {
value = null;
}

run.removeFirst().run();
assertEquals(expectedValue, value);
}

run.removeFirst().run();
});
}

@@ -301,7 +259,7 @@ private void assertExecutedOK(String msg) throws Throwable {
}

private static Source createFactorial() throws IOException {
return Source.fromFileName("src/test/ruby/factorial.rb");
return Source.newBuilder(new File("src/test/ruby/factorial.rb")).build();
}

private final String getErr() {