Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,37 @@ public void testSourceFileURI() throws Throwable {
}
}

@Test
public void testInlineEvaluationBreakpointBuiltin() throws Throwable {
final Source source = Source.newBuilder("python", """
a = 1
breakpoint()
b = 2
breakpoint # not invoking, therefore no breakpoint inserted
""", "test_inline.py").buildLiteral();

try (DebuggerSession session = tester.startSession()) {
session.install(Breakpoint.newBuilder(DebuggerTester.getSourceImpl(source)).lineIs(1).build());
session.install(Breakpoint.newBuilder(DebuggerTester.getSourceImpl(source)).lineIs(3).build());
tester.startEval(source);
expectSuspended((SuspendedEvent event) -> {
DebugStackFrame frame = event.getTopStackFrame();
assertEquals(1, frame.getSourceSection().getStartLine());
event.prepareContinue();
});
expectSuspended((SuspendedEvent event) -> {
DebugStackFrame frame = event.getTopStackFrame();
assertEquals(2, frame.getSourceSection().getStartLine());
event.prepareContinue();
});
expectSuspended((SuspendedEvent event) -> {
DebugStackFrame frame = event.getTopStackFrame();
assertEquals(3, frame.getSourceSection().getStartLine());
event.prepareContinue();
});
}
}

private void expectSuspended(SuspendedCallback callback) {
tester.expectSuspended(callback);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import static com.oracle.graal.python.compiler.bytecode_dsl.BytecodeDSLCompilerUtils.hasDefaultArgs;
import static com.oracle.graal.python.compiler.bytecode_dsl.BytecodeDSLCompilerUtils.hasDefaultKwargs;
import static com.oracle.graal.python.compiler.bytecode_dsl.BytecodeDSLCompilerUtils.len;
import static com.oracle.graal.python.nodes.BuiltinNames.J_BREAKPOINT;
import static com.oracle.graal.python.nodes.SpecialAttributeNames.J___CLASS__;
import static com.oracle.graal.python.nodes.SpecialAttributeNames.J___TYPE_PARAMS__;
import static com.oracle.graal.python.util.PythonUtils.codePointsToInternedTruffleString;
Expand Down Expand Up @@ -156,6 +157,7 @@
import com.oracle.truffle.api.bytecode.BytecodeParser;
import com.oracle.truffle.api.bytecode.BytecodeRootNodes;
import com.oracle.truffle.api.bytecode.serialization.BytecodeSerializer;
import com.oracle.truffle.api.debug.DebuggerTags;
import com.oracle.truffle.api.instrumentation.StandardTags.StatementTag;
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.strings.TruffleString;
Expand Down Expand Up @@ -2188,8 +2190,18 @@ private void emitCall(ExprTy func, ExprTy[] args, KeywordTy[] keywords) {
} else {
assert len(keywords) == 0;

boolean isBreakpoint = func instanceof ExprTy.Name && ((ExprTy.Name) func).id.equals(J_BREAKPOINT);

if (isBreakpoint) {
b.beginTag(DebuggerTags.AlwaysHalt.class);
}

func.accept(this); // callable
visitArguments(func, args, numArgs);

if (isBreakpoint) {
b.endTag(DebuggerTags.AlwaysHalt.class);
}
}
}

Expand Down
Loading