Debugger interface changes:

1. Replacing omj.debug.Debugger.enterFrame() by omj.debug.Debugger.getFrame() and omj.debug.DebugFrame.onEnter() to allow to return null from omj.debug.Debugger.getFrame to enable full optimization with debugger set if it is not interested in monitoring a particular frame

2. Changing type for the source argument in omj.debug.Debugger.handleCompilationDone from StringBuffer to String as Debugger instances should not be able to modify source even by chance.
This commit is contained in:
igor%mir2.org 2002-04-22 20:46:43 +00:00
parent caad76ef9c
commit 1d93746ffc
4 changed files with 25 additions and 18 deletions

View File

@ -154,7 +154,7 @@ public class Interpreter extends LabelTable {
itsSourceFile = (String) tree.getProp(Node.SOURCENAME_PROP);
itsData.itsSourceFile = itsSourceFile;
itsFunctionList = (Vector) tree.getProp(Node.FUNCTION_PROP);
debugSource = (StringBuffer) tree.getProp(Node.DEBUGSOURCE_PROP);
debugSource = (String) tree.getProp(Node.DEBUGSOURCE_PROP);
if (itsFunctionList != null)
generateNestedFunctions(scope, cx, securityDomain);
Object[] regExpLiterals = null;
@ -1481,6 +1481,12 @@ public class Interpreter extends LabelTable {
stack[VAR_SHFT + i] = undefined;
}
DebugFrame debuggerFrame = null;
if (cx.debugger != null) {
DebuggableScript dscript = (DebuggableScript)fnOrScript;
debuggerFrame = cx.debugger.getFrame(cx, dscript);
}
if (theData.itsFunctionType != 0) {
if (fnOrScript.itsClosure != null) {
scope = fnOrScript.itsClosure;
@ -1510,16 +1516,14 @@ public class Interpreter extends LabelTable {
theData.itsFromEvalCode);
}
DebugFrame debuggerFrame = null;
boolean useActivationVars = false;
if (cx.debugger != null) {
if (debuggerFrame != null) {
if (theData.itsFunctionType != 0 && !theData.itsNeedsActivation) {
useActivationVars = true;
scope = ScriptRuntime.initVarObj(cx, scope, fnOrScript,
thisObj, args);
}
debuggerFrame = cx.debugger.enterFrame
(cx, scope, thisObj, args, (DebuggableScript)fnOrScript);
debuggerFrame.onEnter(cx, scope, thisObj, args);
}
Object result = undefined;
@ -2737,7 +2741,7 @@ public class Interpreter extends LabelTable {
private int version;
private boolean inLineStepMode;
private StringBuffer debugSource;
private String debugSource;
private static final Object DBL_MRK = new Object();
}

View File

@ -38,6 +38,7 @@
package org.mozilla.javascript.debug;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;
/**
Interface to implement if the application is interested in receiving debug
@ -45,6 +46,16 @@ information during execution of a particular script or function.
*/
public interface DebugFrame {
/**
Called when execution is ready to start bytecode interpretation for entered a particular function or script.
@param cx current Context for this thread
@param activation the activation scope for the function or script.
@param thisObj value of the JavaScript <code>this</code> object
@param args the array of arguments
*/
public void onEnter(Context cx, Scriptable activation,
Scriptable thisObj, Object[] args);
/**
Called when executed code reaches new line in the source.
@param cx current Context for this thread

View File

@ -43,8 +43,8 @@ public class DebugReader extends Reader {
this.saved = new StringBuffer();
}
public StringBuffer getSaved() {
return saved;
public String getSaved() {
return saved.toString();
}
public int read() throws IOException {

View File

@ -38,7 +38,6 @@
package org.mozilla.javascript.debug;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;
/**
Interface to implement if the application is interested in receiving debug
@ -55,20 +54,13 @@ bytecode is done.
@param source the function or script source
*/
void handleCompilationDone(Context cx, DebuggableScript fnOrScript,
StringBuffer source);
String source);
/**
Called when execution entered a particular function or script.
@param cx current Context for this thread
@param scope the scope to execute the function or script relative to.
@param thisObj value of the JavaScript <code>this</code> object
@param args the array of arguments
@param fnOrScript object describing the function or script
@return implementation of DebugFrame which receives debug information during
the function or script execution or null otherwise
*/
DebugFrame enterFrame(Context cx, Scriptable scope,
Scriptable thisObj, Object[] args,
DebuggableScript fnOrScript);
DebugFrame getFrame(Context cx, DebuggableScript fnOrScript);
}