From e785b88f306972393a80d44842c9bc47195ae2e4 Mon Sep 17 00:00:00 2001 From: Shu Lei Date: Mon, 5 Nov 2007 19:55:29 +0000 Subject: [PATCH] fix the bug that the current line number for the calling frame is off by one --- src/main/java/lua/debug/DebugStackState.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/lua/debug/DebugStackState.java b/src/main/java/lua/debug/DebugStackState.java index e807bb38..b723a050 100644 --- a/src/main/java/lua/debug/DebugStackState.java +++ b/src/main/java/lua/debug/DebugStackState.java @@ -268,9 +268,10 @@ public class DebugStackState extends StackState implements DebugRequestListener */ private int getLineNumber(CallInfo ci) { int[] lineNumbers = ci.closure.p.lineinfo; - int pc = ci.pc; - int line = (lineNumbers != null && lineNumbers.length > pc ? lineNumbers[pc] - : -1); + int pc = (ci != calls[cc] ? ci.pc - 1 : ci.pc); + int line = (lineNumbers != null && lineNumbers.length > pc ? + lineNumbers[pc] : + -1); return line; } @@ -455,6 +456,11 @@ public class DebugStackState extends StackState implements DebugRequestListener return frames; } + /** + * Returns the visible local variables on a stack frame. + * @param index The stack frame index + * @return the visible local variables on the given stack frame. + */ public Variable[] getStack(int index) { if (index < 0 || index >= calls.length) { throw new RuntimeException("invalid stack index");