Skip to content

Commit b29d63a

Browse files
committed
Support stack traces even when "debug" is off
When the generated bytecode has no debug symbols, it still has line numbers. Generate a stack trace that replaces the missing file name with "unknown." This at least means that there are line numbers and sometimes function names.
1 parent cc02c78 commit b29d63a

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/org/mozilla/javascript/RhinoException.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,7 @@ public ScriptStackElement[] getScriptStack(int limit, String hideFunction) {
275275
String fileName = e.getFileName();
276276
if (e.getMethodName().startsWith("_c_")
277277
&& e.getLineNumber() > -1
278-
&& fileName != null
279-
&& !fileName.endsWith(".java")) {
278+
&& (fileName == null || !fileName.endsWith(".java"))) {
280279
String methodName = e.getMethodName();
281280
Matcher match = JAVA_STACK_PATTERN.matcher(methodName);
282281
// the method representing the main script is always "_c_script_0" -
@@ -287,6 +286,9 @@ public ScriptStackElement[] getScriptStack(int limit, String hideFunction) {
287286
if (!printStarted && hideFunction.equals(methodName)) {
288287
printStarted = true;
289288
} else if (printStarted && ((limit < 0) || (count < limit))) {
289+
if (fileName == null) {
290+
fileName = "unknown";
291+
}
290292
list.add(new ScriptStackElement(fileName, methodName, e.getLineNumber()));
291293
count++;
292294
}

0 commit comments

Comments
 (0)