|
47 | 47 | import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
|
48 | 48 | import com.oracle.graal.python.runtime.exception.PException;
|
49 | 49 | import com.oracle.graal.python.runtime.object.PythonObjectFactory;
|
| 50 | +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; |
50 | 51 | import com.oracle.truffle.api.TruffleStackTraceElement;
|
51 | 52 | import com.oracle.truffle.api.dsl.Cached;
|
52 | 53 | import com.oracle.truffle.api.dsl.GenerateNodeFactory;
|
@@ -122,12 +123,7 @@ void doMaterialize(PTraceback tb,
|
122 | 123 | boolean skipFirst = pException.shouldHideLocation();
|
123 | 124 | for (TruffleStackTraceElement element : pException.getTruffleStackTrace()) {
|
124 | 125 | if (pException.shouldCutOffTraceback(element)) {
|
125 |
| - if (element.getLocation() != null) { |
126 |
| - SourceSection sourceSection = element.getLocation().getEncapsulatingSourceSection(); |
127 |
| - if (sourceSection != null) { |
128 |
| - lineno = sourceSection.getStartLine(); |
129 |
| - } |
130 |
| - } |
| 126 | + lineno = getLineno(element); |
131 | 127 | break;
|
132 | 128 | }
|
133 | 129 | if (skipFirst) {
|
@@ -165,6 +161,17 @@ void doMaterialize(PTraceback tb,
|
165 | 161 | tb.markMaterialized(); // Marks the Truffle stacktrace part as materialized
|
166 | 162 | }
|
167 | 163 |
|
| 164 | + @TruffleBoundary |
| 165 | + private static int getLineno(TruffleStackTraceElement element) { |
| 166 | + if (element.getLocation() != null) { |
| 167 | + SourceSection sourceSection = element.getLocation().getEncapsulatingSourceSection(); |
| 168 | + if (sourceSection != null) { |
| 169 | + return sourceSection.getStartLine(); |
| 170 | + } |
| 171 | + } |
| 172 | + return -2; |
| 173 | + } |
| 174 | + |
168 | 175 | private static PFrame materializeFrame(TruffleStackTraceElement element, MaterializeFrameNode materializeFrameNode) {
|
169 | 176 | // create the PFrame and refresh frame values
|
170 | 177 | return materializeFrameNode.execute(null, element.getLocation(), false, true, element.getFrame());
|
|
0 commit comments