From d8b44dedae19b25d6c584e3bd93fc8685ae4a4ef Mon Sep 17 00:00:00 2001 From: Matt D'Souza Date: Wed, 4 Mar 2026 16:39:50 -0500 Subject: [PATCH 1/2] Ensure synthetic SourceRanges map to unavailable sections --- .../oracle/graal/python/pegparser/tokenizer/SourceRange.java | 2 +- .../graal/python/compiler/bytecode_dsl/RootNodeCompiler.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/tokenizer/SourceRange.java b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/tokenizer/SourceRange.java index 5bc0e0d9c1..14c494e99b 100644 --- a/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/tokenizer/SourceRange.java +++ b/graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/tokenizer/SourceRange.java @@ -66,7 +66,7 @@ public SourceRange withEnd(int newEndLine, int newEndColumn) { public SourceRange startLineShiftColumn(int shift) { assert shift >= 0; - if (shift == 0) { + if (shift == 0 || this == ARTIFICIAL_RANGE) { return this; } return new SourceRange(startLine, startColumn, startLine, startColumn + shift); diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/RootNodeCompiler.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/RootNodeCompiler.java index 5ec45f3742..4c818e3428 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/RootNodeCompiler.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/RootNodeCompiler.java @@ -816,7 +816,7 @@ void beginRootSourceSection(SSTNode node, Builder b) { } private static void beginSourceSectionInner(Builder b, SourceRange sourceRange) { - if (sourceRange.startLine >= 1) { + if (sourceRange.startLine >= 1 && sourceRange != SourceRange.ARTIFICIAL_RANGE) { if (sourceRange.startColumn >= 0 && sourceRange.endLine >= sourceRange.startLine && sourceRange.endColumn >= 0) { if (sourceRange.endColumn > 0) { b.beginSourceSection(sourceRange.startLine, sourceRange.startColumn + 1, sourceRange.endLine, sourceRange.endColumn); From 12dfa24e8c8594b614815d1d4b3131791a9b7208 Mon Sep 17 00:00:00 2001 From: Matt D'Souza Date: Thu, 5 Mar 2026 08:54:43 -0500 Subject: [PATCH 2/2] Remove accidentally-deleted comment --- .../graal/python/compiler/bytecode_dsl/RootNodeCompiler.java | 1 + 1 file changed, 1 insertion(+) diff --git a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/RootNodeCompiler.java b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/RootNodeCompiler.java index 4c818e3428..f0ae8d5439 100644 --- a/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/RootNodeCompiler.java +++ b/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/RootNodeCompiler.java @@ -4120,6 +4120,7 @@ public Void visit(StmtTy.FunctionDef node) { } public void emitFunctionDef(StmtTy node, String name, ArgumentsTy args, StmtTy[] body, ExprTy[] decoratorList, ExprTy returns, TypeParamTy[] typeParams) { + // For instrumentation, we want to map this statement only to the declaration line, such // that, e.g., breakpoints inside the body fire only once the body actually executes and // not is declared. There is no simple way to get the exact line width here, so we just // approximate it with name width.