Skip to content

Commit bda8905

Browse files
committed
AlwaysHalt tag on call to breakpoint built-in
1 parent d30d095 commit bda8905

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/debug/PythonDebugTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,37 @@ public void testSourceFileURI() throws Throwable {
601601
}
602602
}
603603

604+
@Test
605+
public void testInlineEvaluationBreakpointBuiltin() throws Throwable {
606+
final Source source = Source.newBuilder("python", """
607+
a = 1
608+
breakpoint()
609+
b = 2
610+
breakpoint # not invoking, therefore no breakpoint inserted
611+
""", "test_inline.py").buildLiteral();
612+
613+
try (DebuggerSession session = tester.startSession()) {
614+
session.install(Breakpoint.newBuilder(DebuggerTester.getSourceImpl(source)).lineIs(1).build());
615+
session.install(Breakpoint.newBuilder(DebuggerTester.getSourceImpl(source)).lineIs(3).build());
616+
tester.startEval(source);
617+
expectSuspended((SuspendedEvent event) -> {
618+
DebugStackFrame frame = event.getTopStackFrame();
619+
assertEquals(1, frame.getSourceSection().getStartLine());
620+
event.prepareContinue();
621+
});
622+
expectSuspended((SuspendedEvent event) -> {
623+
DebugStackFrame frame = event.getTopStackFrame();
624+
assertEquals(2, frame.getSourceSection().getStartLine());
625+
event.prepareContinue();
626+
});
627+
expectSuspended((SuspendedEvent event) -> {
628+
DebugStackFrame frame = event.getTopStackFrame();
629+
assertEquals(3, frame.getSourceSection().getStartLine());
630+
event.prepareContinue();
631+
});
632+
}
633+
}
634+
604635
private void expectSuspended(SuspendedCallback callback) {
605636
tester.expectSuspended(callback);
606637
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/RootNodeCompiler.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import static com.oracle.graal.python.compiler.bytecode_dsl.BytecodeDSLCompilerUtils.hasDefaultArgs;
5858
import static com.oracle.graal.python.compiler.bytecode_dsl.BytecodeDSLCompilerUtils.hasDefaultKwargs;
5959
import static com.oracle.graal.python.compiler.bytecode_dsl.BytecodeDSLCompilerUtils.len;
60+
import static com.oracle.graal.python.nodes.BuiltinNames.J_BREAKPOINT;
6061
import static com.oracle.graal.python.nodes.SpecialAttributeNames.J___CLASS__;
6162
import static com.oracle.graal.python.nodes.SpecialAttributeNames.J___TYPE_PARAMS__;
6263
import static com.oracle.graal.python.util.PythonUtils.codePointsToInternedTruffleString;
@@ -156,6 +157,7 @@
156157
import com.oracle.truffle.api.bytecode.BytecodeParser;
157158
import com.oracle.truffle.api.bytecode.BytecodeRootNodes;
158159
import com.oracle.truffle.api.bytecode.serialization.BytecodeSerializer;
160+
import com.oracle.truffle.api.debug.DebuggerTags;
159161
import com.oracle.truffle.api.instrumentation.StandardTags.StatementTag;
160162
import com.oracle.truffle.api.source.Source;
161163
import com.oracle.truffle.api.strings.TruffleString;
@@ -2188,8 +2190,18 @@ private void emitCall(ExprTy func, ExprTy[] args, KeywordTy[] keywords) {
21882190
} else {
21892191
assert len(keywords) == 0;
21902192

2193+
boolean isBreakpoint = func instanceof ExprTy.Name && ((ExprTy.Name) func).id.equals(J_BREAKPOINT);
2194+
2195+
if (isBreakpoint) {
2196+
b.beginTag(DebuggerTags.AlwaysHalt.class);
2197+
}
2198+
21912199
func.accept(this); // callable
21922200
visitArguments(func, args, numArgs);
2201+
2202+
if (isBreakpoint) {
2203+
b.endTag(DebuggerTags.AlwaysHalt.class);
2204+
}
21932205
}
21942206
}
21952207

0 commit comments

Comments
 (0)