| Method from org.apache.bsf.engines.javascript.RhinoEngineDebugger Detail: |
public void _handleBreakpointHit(DocumentCell cell,
int lineno) {
JsCallbacks debugger;
BreakPoint bp;
Enumeration e;
JsContext stub=null;
boolean breakpointFound=false;
boolean suspend=false;
try {
bp = cell.findBreakpointAtLine(lineno);
} catch (BSFException bsfex) {
bp = null;
}
if (bp != null) {
breakpointFound = true;
try {
stub = m_rcp.hitBreakpoint();
DebugLog.stdoutPrintln(" breakpoint callback...", DebugLog.BSF_LOG_L3);
m_callbacks.createFuture(m_rcp);
m_callbacks.handleBreakpointHit(stub);
suspend = true;
} catch (RemoteException rex) {
DebugLog.stderrPrintln(" EXCEPTION OCCURED DURING BREAKPOINT CALLBACK", DebugLog.BSF_LOG_L0);
DebugLog.stderrPrintln(rex.getMessage(), DebugLog.BSF_LOG_L0);
rex.printStackTrace();
suspend = false;
}
} else {
DebugLog.stdoutPrintln(" didn't find a breakpoint...", DebugLog.BSF_LOG_L3);
breakpointFound = false;
}
if (!breakpointFound) {
// we haven't found a breakpoint at the current
// line in the current document, we must be stepping
// or in entry/exit mode
try {
stub = m_rcp.stepping();
FnOrScript current = cell.findFnOrScriptContaining(lineno);
if (stub != null) {
cell.setLastFnOrScript(current);
DebugLog.stdoutPrintln(" stepping-done callback...",
DebugLog.BSF_LOG_L3);
m_callbacks.createFuture(m_rcp);
m_callbacks.handleSteppingDone(stub);
suspend = true;
}
else if (cell.getEntryExit() &&
(current != cell.getLastFnOrScript()) &&
(m_rcp.getContextCount() == 0)) {
cell.setLastFnOrScript(current);
stub = m_rcp.entry_exit_mode();
DebugLog.stdoutPrintln(" entry/exit mode...",
DebugLog.BSF_LOG_L3);
m_callbacks.createFuture(m_rcp);
m_callbacks.handleSteppingDone(stub);
suspend = true;
}
else {
DebugLog.stdoutPrintln(" No reason to suspend execution.", DebugLog.BSF_LOG_L3);
suspend = false;
}
} catch (RemoteException rex) {
DebugLog.stderrPrintln(" EXCEPTION OCCURED DURING STEPPING-DONE CALLBACK", DebugLog.BSF_LOG_L0);
DebugLog.stderrPrintln(rex.getMessage(), DebugLog.BSF_LOG_L0);
rex.printStackTrace();
suspend = false;
}
}
if (suspend) {
// now, suspend this thread... until
// we restart.
try {
m_callbacks.suspendFuture(m_rcp);
} catch (Exception ex) {
DebugLog.stdoutPrintln("Future creation failed... releasing the engine", DebugLog.BSF_LOG_L3);
m_rcp.run();
}
}
}
|
void addStub(Context cx,
RhinoContextProxy jscx) {
stubs.put(cx, jscx);
}
|
void addStub(DebugFrame frame,
JsContextStub stub) {
stubs.put(frame, stub);
}
|
void addStub(Scriptable sobj,
JsObject jsobj) {
stubs.put(sobj, jsobj);
}
|
public void disconnectedDebuggerNotify() {
m_callbacks = null;
}
Called when our debugger has been disconnected. |
void dropStub(Object key) {
stubs.remove(key);
}
|
public Object eval(String docname,
String fnOrScript,
int lineno) throws RemoteException {
Object retval;
try {
retval = m_eng.eval(docname, lineno, -1, fnOrScript);
return marshallProperty(retval);
} catch (BSFException ex) {
throw new RemoteException("Failed eval", ex);
}
}
|
public JsContext getContext(int depth) {
if (m_rcp != null) return m_rcp.getContext(depth);
return null;
}
|
public int getContextCount() {
if (m_rcp != null) return m_rcp.getContextCount();
return -1;
}
|
public Object getDebugInterface() {
return engineStub;
}
|
public JsCallbacks getDebugger() {
return m_callbacks;
}
Return the current debugger. |
public synchronized DocumentCell getDocumentCell(String name) {
return (DocumentCell) m_documents.get(name);
}
|
public JsObject getGlobalObject() {
return globalstub;
}
|
public RhinoContextProxy getRhinoContextProxy() {
return m_rcp;
}
|
RhinoContextProxy getStub(Context cx) {
return (RhinoContextProxy) stubs.get(cx);
}
|
JsContextStub getStub(DebugFrame frame) {
return (JsContextStub) stubs.get(frame);
}
|
JsObject getStub(Scriptable sobj) {
return (JsObject) stubs.get(sobj);
}
|
public String getThread() {
String resultstr = "";
if (m_thread != null) {
try {
final String resultstrf = (String)
AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws Exception {
return m_thread.getName();
}
});
resultstr = resultstrf;
}
catch (PrivilegedActionException prive) {
resultstr = "Security Exception triggered. " +
"Thread info unavailable";
}
}
return resultstr;
}
|
public String getThreadGroup() {
String resultstr = "";
if (m_thread != null) {
try {
final String resultstrf = (String)
AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws Exception {
return m_thread.getThreadGroup().getName();
}
});
resultstr = resultstrf;
}
catch (PrivilegedActionException prive) {
resultstr = "Security Exception triggered. " +
"ThreadGroup info unavailable";
}
}
return resultstr;
}
|
public JsObject getUndefinedValue() {
return undefinedStub;
}
|
public void handleBreakpointHit(Context cx) {
JsCallbacks debugger;
BreakPoint bp;
Enumeration e;
DocumentCell cell;
boolean breakpointFound=false;
String name;
int lineno;
boolean suspend=false;
m_thread = Thread.currentThread();
DebugLog.stdoutPrintln("**** Handling a breakpoint hit...",
DebugLog.BSF_LOG_L3);
m_rcp = getStub(cx);
if (m_rcp == null) {
m_rcp = new RhinoContextProxy(this, cx);
addStub(cx, m_rcp);
}
// if we have no callbacks... then just
// ignore the breakpoint hit, do a run
// so that execution resumes...
if (m_callbacks==null) {
DebugLog.stdoutPrintln(" No callbacks, resuming...", DebugLog.BSF_LOG_L3);
m_rcp.run();
} else {
// First, check that we didn't hit a known breakpoint.
// First, search if we have breakpoints for the current documents
name = m_rcp.getSourceName();
lineno = m_rcp.getLineNumber();
DebugLog.stdoutPrintln(" in "+name+" at "+lineno, DebugLog.BSF_LOG_L3);
cell = getDocumentCell(name);
if (cell != null)
_handleBreakpointHit(cell,lineno);
}
m_rcp = null;
}
|
public void handleCompilationDone(Context cx,
DebuggableScript fnOrScript,
StringBuffer source) {
m_thread = Thread.currentThread();
m_compilingFnOrScript.addCompilationUnit(cx, fnOrScript, source);
}
|
public void handleExceptionThrown(Context cx,
Object exceptionThrown) {
JsContext stub;
JsCallbacks debugger;
BreakPoint bp;
Enumeration e;
DocumentCell cell;
String name,msg;
Exception ex;
int lineno;
NativeError error;
m_thread = Thread.currentThread();
m_rcp = getStub(cx);
if (m_rcp == null) {
m_rcp = new RhinoContextProxy(this, cx);
addStub(cx, m_rcp);
}
try {
// if we have no callbacks... then just
// ignore the breakpoint hit, do a run
// so that execution resumes...
if (m_callbacks==null) {
m_rcp.run();
return;
}
// First, check that we didn't hit a known breakpoint.
// First, search if we have breakpoints for the current documents
name = m_rcp.getSourceName();
lineno = m_rcp.getLineNumber();
try {
error = (NativeError)exceptionThrown;
msg = error.getName() + ": " + error.getMessage();
} catch (ClassCastException ccex) {
msg = "Unknown JavaScript Exception";
}
ex = new Exception(msg);
cell = getDocumentCell(name);
if (cell == null) return;
try {
stub = m_rcp.exceptionThrown();
m_callbacks.createFuture(m_rcp);
m_callbacks.handleExceptionThrown(stub,ex);
// now, suspend this thread... until
// we restart.
m_callbacks.suspendFuture(m_rcp);
} catch (Exception ex2) {
m_rcp.run();
}
} finally {
m_rcp = null;
}
}
|
public synchronized DocumentCell loadDocumentNotify(String name) {
DocumentCell cell;
cell = (DocumentCell) m_documents.get(name);
if (cell == null) {
cell = new DocumentCell(this, name);
m_documents.put(name, cell);
if (dbgmgr!=null)
dbgmgr.loadDocumentNotify(m_eng, name);
}
return cell;
}
|
Object marshallProperty(Object prop) throws RemoteException {
if (prop == null)
return null;
if (prop == Scriptable.NOT_FOUND)
return null;
if (prop == Context.getUndefinedValue())
return undefinedStub;
if (prop instanceof Scriptable) {
JsObject stub;
Scriptable sprop = (Scriptable) prop;
stub = getStub(sprop);
if (stub == null) {
stub = new JsObjectStub(this, sprop);
this.addStub(sprop, stub);
}
return stub;
}
return prop;
}
|
JsObject marshallScriptable(Scriptable prop) throws RemoteException {
if (prop == null)
return null;
if (prop == Scriptable.NOT_FOUND)
return null;
if (prop == Context.getUndefinedValue())
return undefinedStub;
JsObject stub;
Scriptable sprop = (Scriptable) prop;
stub = getStub(sprop);
if (stub == null) {
stub = new JsObjectStub(this, sprop);
this.addStub(sprop, stub);
}
return stub;
}
|
public synchronized void placeBreakpointAtLine(int brkptid,
String docname,
int lineno) {
DocumentCell cell;
cell = (DocumentCell) m_documents.get(docname);
cell.addBreakpointAtLine(brkptid, lineno);
}
|
public synchronized void placeBreakpointAtOffset(int brkptid,
String docname,
int offset) {
DocumentCell cell;
cell = (DocumentCell) m_documents.get(docname);
cell.addBreakpointAtOffset(brkptid, offset);
}
|
public void removeBreakpoint(String docname,
int brkptid) throws BSFException {
DocumentCell cell;
cell = (DocumentCell) m_documents.get(docname);
cell.removeBreakpoint(brkptid);
}
|
public void run(JsEngineStub eng) throws Exception {
DebugLog.stdoutPrintln("RhinoEngineDebugger::run()...",
DebugLog.BSF_LOG_L3);
m_rcp.run();
m_callbacks.completeFuture(m_rcp);
}
|
public void setBreakNextLine(JsContext context,
boolean isLineStep) {
}
Set whether the engine should break when it encounters
the next line.
The engine will call the attached debugger's handleBreakpointHit
method on the next line it executes if isLineStep is true.
May be used from another thread to interrupt execution. |
void setCompilingFnOrScript(FnOrScript fnOrScript) {
m_compilingFnOrScript = fnOrScript;
}
|
public void setDebugger(JsCallbacks debugger) {
m_callbacks = debugger;
}
Set the associated debugger. |
public void setEntryExit(String docname,
boolean on) throws BSFException {
DocumentCell cell;
cell = (DocumentCell) m_documents.get(docname);
cell.setEntryExit(on);
}
|
public void stepIn(JsEngineStub eng) throws Exception {
DebugLog.stdoutPrintln("RhinoEngineDebugger::stepIn()...",
DebugLog.BSF_LOG_L3);
m_rcp.stepIn();
m_callbacks.completeFuture(m_rcp);
}
|
public void stepOut(JsEngineStub eng) throws Exception {
DebugLog.stdoutPrintln("RhinoEngineDebugger::stepOut()...",
DebugLog.BSF_LOG_L3);
m_rcp.stepOut();
m_callbacks.completeFuture(m_rcp);
}
|
public void stepOver(JsEngineStub eng) throws Exception {
DebugLog.stdoutPrintln("RhinoEngineDebugger::stepOver()...",
DebugLog.BSF_LOG_L3);
m_rcp.stepOver();
m_callbacks.completeFuture(m_rcp);
}
|