home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / js / src / jsdbgapi.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  6.7 KB  |  225 lines

  1. /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef jsdbgapi_h___
  20. #define jsdbgapi_h___
  21. /*
  22.  * JS debugger API.
  23.  */
  24. #include "jsapi.h"
  25. #include "jsopcode.h"
  26. #include "jsprvtd.h"
  27.  
  28. PR_BEGIN_EXTERN_C
  29.  
  30. typedef enum JSTrapStatus {
  31.     JSTRAP_ERROR,
  32.     JSTRAP_CONTINUE,
  33.     JSTRAP_RETURN,
  34.     JSTRAP_LIMIT
  35. } JSTrapStatus;
  36.  
  37. typedef JSTrapStatus
  38. (*JSTrapHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
  39.          void *closure);
  40.  
  41. extern void
  42. js_PatchOpcode(JSContext *cx, JSScript *script, jsbytecode *pc, JSOp op);
  43.  
  44. PR_EXTERN(JSBool)
  45. JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
  46.        JSTrapHandler handler, void *closure);
  47.  
  48. PR_EXTERN(JSOp)
  49. JS_GetTrapOpcode(JSContext *cx, JSScript *script, jsbytecode *pc);
  50.  
  51. PR_EXTERN(void)
  52. JS_ClearTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
  53.          JSTrapHandler *handlerp, void **closurep);
  54.  
  55. PR_EXTERN(void)
  56. JS_ClearScriptTraps(JSContext *cx, JSScript *script);
  57.  
  58. PR_EXTERN(void)
  59. JS_ClearAllTraps(JSContext *cx);
  60.  
  61. PR_EXTERN(JSTrapStatus)
  62. JS_HandleTrap(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval);
  63.  
  64. PR_EXTERN(JSBool)
  65. JS_SetInterrupt(JSRuntime *rt, JSTrapHandler handler, void *closure);
  66.  
  67. PR_EXTERN(JSBool)
  68. JS_ClearInterrupt(JSRuntime *rt, JSTrapHandler *handlerp, void **closurep);
  69.  
  70. /************************************************************************/
  71.  
  72. typedef JSBool
  73. (*JSWatchPointHandler)(JSContext *cx, JSObject *obj, jsval id,
  74.                jsval old, jsval *newp, void *closure);
  75.  
  76. PR_EXTERN(JSBool)
  77. JS_SetWatchPoint(JSContext *cx, JSObject *obj, jsval id,
  78.          JSWatchPointHandler handler, void *closure);
  79.  
  80. PR_EXTERN(void)
  81. JS_ClearWatchPoint(JSContext *cx, JSObject *obj, jsval id,
  82.            JSWatchPointHandler *handlerp, void **closurep);
  83.  
  84. PR_EXTERN(void)
  85. JS_ClearWatchPointsForObject(JSContext *cx, JSObject *obj);
  86.  
  87. PR_EXTERN(void)
  88. JS_ClearAllWatchPoints(JSContext *cx);
  89.  
  90. /************************************************************************/
  91.  
  92. PR_EXTERN(uintN)
  93. JS_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc);
  94.  
  95. PR_EXTERN(jsbytecode *)
  96. JS_LineNumberToPC(JSContext *cx, JSScript *script, uintN lineno);
  97.  
  98. PR_EXTERN(JSScript *)
  99. JS_GetFunctionScript(JSContext *cx, JSFunction *fun);
  100.  
  101. PR_EXTERN(JSPrincipals *)
  102. JS_GetScriptPrincipals(JSContext *cx, JSScript *script);
  103.  
  104. /*
  105.  * Stack Frame Iterator
  106.  *
  107.  * Used to iterate through the JS stack frames to extract
  108.  * information from the frames.
  109.  */
  110.  
  111. PR_EXTERN(JSStackFrame *)
  112. JS_FrameIterator(JSContext *cx, JSStackFrame **iteratorp);
  113.  
  114. PR_EXTERN(JSScript *)
  115. JS_GetFrameScript(JSContext *cx, JSStackFrame *fp);
  116.  
  117. PR_EXTERN(jsbytecode *)
  118. JS_GetFramePC(JSContext *cx, JSStackFrame *fp);
  119.  
  120. PR_EXTERN(JSBool)
  121. JS_IsNativeFrame(JSContext *cx, JSStackFrame *fp);
  122.  
  123. PR_EXTERN(void *)
  124. JS_GetFrameAnnotation(JSContext *cx, JSStackFrame *fp);
  125.  
  126. PR_EXTERN(void)
  127. JS_SetFrameAnnotation(JSContext *cx, JSStackFrame *fp, void *annotation);
  128.  
  129. PR_EXTERN(void *)
  130. JS_GetFramePrincipalArray(JSContext *cx, JSStackFrame *fp);
  131.  
  132. PR_EXTERN(JSObject *)
  133. JS_GetFrameObject(JSContext *cx, JSStackFrame *fp);
  134.  
  135. PR_EXTERN(JSObject *)
  136. JS_GetFrameThis(JSContext *cx, JSStackFrame *fp);
  137.  
  138. PR_EXTERN(JSFunction *)
  139. JS_GetFrameFunction(JSContext *cx, JSStackFrame *fp);
  140.  
  141. /************************************************************************/
  142.  
  143. PR_EXTERN(const char *)
  144. JS_GetScriptFilename(JSContext *cx, JSScript *script);
  145.  
  146. PR_EXTERN(uintN)
  147. JS_GetScriptBaseLineNumber(JSContext *cx, JSScript *script);
  148.  
  149. PR_EXTERN(uintN)
  150. JS_GetScriptLineExtent(JSContext *cx, JSScript *script);
  151.  
  152. /************************************************************************/
  153.  
  154. /* called just after script creation */
  155. typedef void
  156. (*JSNewScriptHookProc)(
  157.         JSContext   *cx,
  158.         const char  *filename,      /* URL this script loads from */
  159.         uintN       lineno,         /* line where this script starts */
  160.         JSScript    *script,
  161.         JSFunction  *fun,
  162.         void        *callerdata );
  163.  
  164. /* called just before script destruction */
  165. typedef void
  166. (*JSDestroyScriptHookProc)(
  167.         JSContext   *cx,
  168.         JSScript    *script,
  169.         void        *callerdata );
  170.  
  171. PR_EXTERN(void)
  172. JS_SetNewScriptHookProc(JSRuntime *rt, JSNewScriptHookProc hookproc,
  173.             void *callerdata);
  174.  
  175. PR_EXTERN(void)
  176. JS_SetDestroyScriptHookProc(JSRuntime *rt, JSDestroyScriptHookProc hookproc,
  177.                 void *callerdata);
  178.  
  179. /************************************************************************/
  180.  
  181. PR_EXTERN(JSBool)
  182. JS_EvaluateInStackFrame(JSContext *cx, JSStackFrame *fp,
  183.             const char *bytes, uintN length,
  184.             const char *filename, uintN lineno,
  185.             jsval *rval);
  186.  
  187. /************************************************************************/
  188.  
  189. typedef struct JSPropertyDesc {
  190.     jsval           id;         /* primary id, a string or int */
  191.     jsval           value;      /* property value */
  192.     uint8           flags;      /* flags, see below */
  193.     uint8           spare;      /* unused */
  194.     uint16          slot;       /* argument/variable slot */
  195.     jsval           alias;      /* alias id if JSPD_ALIAS flag */
  196. } JSPropertyDesc;
  197.  
  198. #define JSPD_ENUMERATE  0x01    /* visible to for/in loop */
  199. #define JSPD_READONLY   0x02    /* assignment is error */
  200. #define JSPD_PERMANENT  0x04    /* property cannot be deleted */
  201. #define JSPD_ALIAS      0x08    /* property has an alias id */
  202. #define JSPD_ARGUMENT   0x10    /* argument to function */
  203. #define JSPD_VARIABLE   0x20    /* local variable in function */
  204.  
  205. typedef struct JSPropertyDescArray {
  206.     uint32          length;     /* number of elements in array */
  207.     JSPropertyDesc  *array;     /* alloc'd by Get, freed by Put */
  208. } JSPropertyDescArray;
  209.  
  210. PR_EXTERN(JSProperty *)
  211. JS_PropertyIterator(JSObject *obj, JSProperty **iteratorp);
  212.  
  213. PR_EXTERN(JSBool)
  214. JS_GetPropertyDesc(JSContext *cx, JSProperty *prop, JSPropertyDesc *pd);
  215.  
  216. PR_EXTERN(JSBool)
  217. JS_GetPropertyDescArray(JSContext *cx, JSObject *obj, JSPropertyDescArray *pda);
  218.  
  219. PR_EXTERN(void)
  220. JS_PutPropertyDescArray(JSContext *cx, JSPropertyDescArray *pda);
  221.  
  222. PR_END_EXTERN_C
  223.  
  224. #endif /* jsdbgapi_h___ */
  225.