/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
package netscape.jsdebug;
import netscape.util.Hashtable;
import netscape.security.PrivilegeManager;
import netscape.security.ForbiddenTargetException;
/**
* This is the master control panel for observing events in the VM.
* Each method setXHook() must be passed an object that extends
* the class XHook. When an event of the specified type
* occurs, a well-known method on XHook will be called (see the
* various XHook classes for details). The method call takes place
* on the same thread that triggered the event in the first place,
* so that any monitors held by the thread which triggered the hook
* will still be owned in the hook method.
* <p>
* This class is meant to be a singleton and has a private constructor.
* Call the static <code>getDebugController()</code> to get this object.
* <p>
* Note that all functions use netscape.security.PrivilegeManager to verify
* that the caller has the "Debugger" privilege. The exception
* netscape.security.ForbiddenTargetException will be throw if this is
* not enabled.
*
* @author John Bandhauer
* @author Nick Thompson
* @version 1.0
* @since 1.0
* @see netscape.security.PrivilegeManager
* @see netscape.security.ForbiddenTargetException
*/
public final class DebugController {
private static final int majorVersion = 1;
private static final int minorVersion = 0;
private static DebugController controller;
private ScriptHook scriptHook;
private Hashtable instructionHookTable;
private InterruptHook interruptHook;
private DebugBreakHook debugBreakHook;
private JSErrorReporter errorReporter;
/**
* Get the DebugController object for the current VM.
* <p>
* @return the singleton DebugController
*/
public static synchronized DebugController getDebugController()
throws ForbiddenTargetException
{
try {
PrivilegeManager.checkPrivilegeEnabled("Debugger");
if (controller == null)
controller = new DebugController();
return controller;
} catch (ForbiddenTargetException e) {
System.out.println("failed in check Priv in DebugController.getDebugController()");
e.printStackTrace(System.out);
throw e;
}
}
private DebugController()
{
scriptTable = new Hashtable();
_setController(true);
}
/**
* Request notification of Script loading events.
* <p>
* Whenever a Script is loaded into or unloaded from the VM
* the appropriate method of the ScriptHook argument will be called.
* Callers are responsible for chaining hooks if chaining is required.
*
* @param h new script hook
* @return the previous hook object (null if none)
*/
public synchronized ScriptHook setScriptHook(ScriptHook h)
throws ForbiddenTargetException
{
PrivilegeManager.checkPrivilegeEnabled("Debugger");
ScriptHook oldHook = scriptHook;
scriptHook = h;
return oldHook;
}
/**
* Get the current observer of Script events.
* <p>
* @return the current script hook (null if none)
*/
public ScriptHook getScriptHook()
throws ForbiddenTargetException
{
PrivilegeManager.checkPrivilegeEnabled("Debugger");
return scriptHook;
}
/**
* Set a hook at the given program counter value.
* <p>
* When a thread reaches that instruction, a ThreadState
* object will be created and the appropriate method
* of the hook object will be called. Callers are responsible
* for chaining hooks if chaining is required.
*
* @param pc pc at which hook should be set
* @param h new hook for this pc
* @return the previous hook object (null if none)
*/
public synchronized InstructionHook setInstructionHook(
PC pc,
InstructionHook h)
throws ForbiddenTargetException
{
PrivilegeManager.checkPrivilegeEnabled("Debugger");
InstructionHook oldHook;
if (instructionHookTable == null) {
instructionHookTable = new Hashtable();
}
oldHook = (InstructionHook) instructionHookTable.get(pc);
instructionHookTable.put(pc, h);
setInstructionHook0(pc);
return oldHook;
}
private native void setInstructionHook0(PC pc);
/**
* Get the hook at the given program counter value.
* <p>
* @param pc pc for which hook should be found
* @return the hook (null if none)
*/
public InstructionHook getInstructionHook(PC pc)
throws ForbiddenTargetException
{
PrivilegeManager.checkPrivilegeEnabled("Debugger");
return getInstructionHook0(pc);
}
// called by native function
private InstructionHook getInstructionHook0(PC pc)
{
if (instructionHookTable == null)
return null;
else
return (InstructionHook) instructionHookTable.get(pc);
}
/**************************************************************/
/**
* Set the hook at to be called when interrupts occur.
* <p>
* The next instruction which starts to execute after
* <code>sendInterrupt()</code> has been called will
* trigger a call to this hook. A ThreadState
* object will be created and the appropriate method
* of the hook object will be called. Callers are responsible
* for chaining hooks if chaining is required.
*
* @param h new hook
* @return the previous hook object (null if none)
* @see netscape.jsdebug.DebugController#sendInterrupt
*/
public synchronized InterruptHook setInterruptHook( InterruptHook h )
throws ForbiddenTargetException
{
PrivilegeManager.checkPrivilegeEnabled("Debugger");
InterruptHook oldHook = interruptHook;
interruptHook = h;
return oldHook;
}
/**
* Get the current hook to be called on interrupt
* <p>
* @return the hook (null if none)
*/
public InterruptHook getInterruptHook()
throws ForbiddenTargetException
{
PrivilegeManager.checkPrivilegeEnabled("Debugger");
return interrup
没有合适的资源?快使用搜索试试~ 我知道了~
spiderMoney
需积分: 0 8 下载量 11 浏览量
2009-05-27
15:02:12
上传
评论
收藏 1.25MB GZ 举报
温馨提示
共531个文件
c:161个
h:74个
mk:58个
js引擎实现 不说了,经典中的经典....令人叹为观止
资源推荐
资源详情
资源评论
收起资源包目录
spiderMoney (531个子文件)
editline.3 5KB
jslocko.asm 2KB
cutlines.awk 2KB
mk.bat 4KB
mkshell.bat 153B
mk.bat 45B
mk.bat 37B
jsinterp.c 254KB
jsxml.c 248KB
jsemit.c 236KB
jsparse.c 211KB
jsopcode.c 180KB
jsstr.c 170KB
jsobj.c 161KB
jsapi.c 161KB
jsregexp.c 143KB
jsgc.c 115KB
js.c 107KB
jsdtoa.c 88KB
jsarray.c 88KB
jsfile.c 81KB
jsd_jntv.c 80KB
jsfun.c 79KB
jsscope.c 67KB
jsdate.c 66KB
jsdrefl.c 66KB
jsj_method.c 63KB
jsscan.c 61KB
jsscript.c 54KB
jsdbgapi.c 50KB
jsj_JSObject.c 44KB
jsexn.c 44KB
jscntxt.c 41KB
jslock.c 37KB
jsdebug.c 37KB
jsj.c 36KB
jsj_JavaObject.c 36KB
jsatom.c 34KB
jsj_convert.c 34KB
jsnum.c 34KB
jsiter.c 32KB
jsprf.c 31KB
jsdhash.c 28KB
prmjtime.c 26KB
jsd_java.c 26KB
jsj_class.c 25KB
editline.c 24KB
jsj_JavaClass.c 23KB
jsxdrapi.c 22KB
jsd_scpt.c 21KB
k_standard.c 20KB
jsj_JavaPackage.c 20KB
e_j0.c 18KB
e_j1.c 18KB
jsd_val.c 17KB
jsd_stak.c 17KB
jsdb.c 17KB
jsj_utils.c 16KB
e_sqrt.c 16KB
nativejsengine.c 16KB
jsarena.c 15KB
jsd_text.c 15KB
jsmath.c 15KB
jsj_field.c 14KB
jsj_JavaArray.c 14KB
jsj_hash.c 13KB
jskwgen.c 13KB
jshash.c 13KB
s_erf.c 13KB
e_lgamma_r.c 13KB
jscpucfg.c 13KB
e_pow.c 12KB
jsd_step.c 11KB
jsd_high.c 11KB
k_rem_pio2.c 10KB
jsd_hook.c 10KB
jsutil.c 9KB
s_expm1.c 9KB
jsd_jvm.c 9KB
jsdtracef.c 9KB
e_jn.c 9KB
jsd_obj.c 9KB
jre_md.c 8KB
jslong.c 8KB
jsj_array.c 7KB
e_rem_pio2.c 7KB
s_log1p.c 7KB
e_exp.c 7KB
jsj_simpleapi.c 7KB
jsd_lock.c 7KB
e_log.c 6KB
jsj_JavaMember.c 6KB
s_atan.c 6KB
k_tan.c 6KB
e_atan2.c 6KB
e_fmod.c 5KB
e_asin.c 5KB
e_hypot.c 5KB
jsbool.c 5KB
sysunix.c 5KB
共 531 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
xiongzhijian
- 粉丝: 12
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- python-leetcode面试题解之第157题用Read4读取N个字符-题解.zip
- python-leetcode面试题解之第156题上下翻转二叉树-题解.zip
- python-leetcode面试题解之第155题最小栈-题解.zip
- python-leetcode面试题解之第153题寻找旋转排序数组中的最小值-题解.zip
- python-leetcode面试题解之第152题乘积最大子数组-题解.zip
- python-leetcode面试题解之第151题反转字符串中的单词-题解.zip
- python-leetcode面试题解之第150题逆波兰表达式求值-题解.zip
- python-leetcode面试题解之第149题直线上最多的点数-题解.zip
- python-leetcode面试题解之第148题排序链表-题解.zip
- python-leetcode面试题解之第147题对链表进行插入排序-题解.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功