1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is mozilla.org code.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
24 * Robert Ginda, <rginda@netscape.com>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #include
"nsISupports.idl"
44 #include
"nsAString.h"
47 [ptr] native JSDContext
(JSDContext
);
48 [ptr] native JSDObject
(JSDObject
);
49 [ptr] native JSDProperty
(JSDProperty
);
50 [ptr] native JSDScript
(JSDScript
);
51 [ptr] native JSDStackFrameInfo
(JSDStackFrameInfo
);
52 [ptr] native JSDThreadState
(JSDThreadState
);
53 [ptr] native JSDValue
(JSDValue
);
54 [ptr] native JSRuntime
(JSRuntime
);
55 [ptr] native JSContext
(JSContext
);
57 /* interfaces we declare in this file */
58 interface jsdIDebuggerService
;
60 interface jsdINestCallback
;
61 interface jsdIFilterEnumerator
;
62 interface jsdIContextEnumerator
;
63 interface jsdIScriptEnumerator
;
64 interface jsdIScriptHook
;
65 interface jsdIErrorHook
;
66 interface jsdIExecutionHook
;
67 interface jsdICallHook
;
68 interface jsdIEphemeral
;
69 interface jsdIContext
;
70 interface jsdIStackFrame
;
74 interface jsdIProperty
;
77 * Debugger service. It's not a good idea to have more than one active client of
78 * the debugger service.
80 [scriptable
, uuid(9dd9006a
-4e5e
-4a80
-ac3d
-007fb7335ca4
)]
81 interface jsdIDebuggerService
: nsISupports
83 /** Internal use only. */
84 [noscript
] readonly attribute JSDContext JSDContext
;
87 * Called when an error or warning occurs.
89 attribute jsdIErrorHook errorHook
;
91 * Called when a jsdIScript is created or destroyed.
93 attribute jsdIScriptHook scriptHook
;
95 * Called when the engine encounters a breakpoint.
97 attribute jsdIExecutionHook breakpointHook
;
99 * Called when the engine encounters the debugger keyword.
101 attribute jsdIExecutionHook debuggerHook
;
103 * Called when the errorHook returns false.
105 attribute jsdIExecutionHook debugHook
;
107 * Called before the next PC is executed.
109 attribute jsdIExecutionHook interruptHook
;
111 * Called when an exception is thrown (even if it will be caught.)
113 attribute jsdIExecutionHook throwHook
;
115 * Called before and after a toplevel script is evaluated.
117 attribute jsdICallHook topLevelHook
;
119 * Called before and after a function is called.
121 attribute jsdICallHook functionHook
;
125 * VERSION_* values must be kept in sync with the JSVersion enumeration in
130 * Possible values for jsdIScript::version and jsdIContext::version.
132 const long VERSION_1_0
= 100;
133 const long VERSION_1_1
= 110;
134 const long VERSION_1_2
= 120;
135 const long VERSION_1_3
= 130;
136 const long VERSION_1_4
= 140;
137 const long VERSION_1_5
= 150;
138 const long VERSION_DEFAULT
= 0;
139 const long VERSION_UNKNOWN
= -1;
142 * These flags need to be kept in sync with the context flags defined in
147 * Link native frames in call stacks.
149 const unsigned long ENABLE_NATIVE_FRAMES
= 0x01;
151 * Normally, if a script has a 0 in JSD_SCRIPT_PROFILE_BIT it is included in
152 * profile data, otherwise it is not profiled. Setting the
153 * PROFILE_WHEN_SET flag reverses this convention.
155 const unsigned long PROFILE_WHEN_SET
= 0x02;
157 * Normally, when the script in the top frame of a thread state has a 1 in
158 * JSD_SCRIPT_DEBUG_BIT, the execution hook is ignored. Setting the
159 * DEBUG_WHEN_SET flag reverses this convention.
161 const unsigned long DEBUG_WHEN_SET
= 0x04;
163 * When this flag is set the internal call hook will collect profile data.
165 const unsigned long COLLECT_PROFILE_DATA
= 0x08;
167 * When this flag is set, stack frames that are disabled for debugging
168 * will not appear in the call stack chain.
170 const unsigned long HIDE_DISABLED_FRAMES
= 0x10;
172 * When this flag is set, the debugger will only check the
173 * JSD_SCRIPT_DEBUG_BIT on the top (most recent) stack frame. This
174 * makes it possible to stop in an enabled frame which was called from
175 * a stack that contains a disabled frame.
177 * When this flag is *not* set, any stack that contains a disabled frame
178 * will not be debugged (the execution hook will not be invoked.)
180 * This only applies when the reason for calling the hook would have
181 * been TYPE_INTERRUPTED or TYPE_THROW. TYPE_BREAKPOINT,
182 * TYPE_DEBUG_REQUESTED, and TYPE_DEBUGGER_KEYWORD always stop, regardless
183 * of this setting, as long as the top frame is not disabled.
185 * If HIDE_DISABLED_FRAMES is set, this is effectively set as well.
187 const unsigned long MASK_TOP_FRAME_ONLY
= 0x20;
189 * When this flag is set, object creation will not be tracked. This will
190 * reduce the performance price you pay by enabling the debugger.
192 const unsigned long DISABLE_OBJECT_TRACE
= 0x40;
195 * Debugger service flags.
197 attribute
unsigned long flags
;
200 * Major version number of implementation.
202 readonly attribute
unsigned long implementationMajor
;
204 * Minor version number of implementation.
206 readonly attribute
unsigned long implementationMinor
;
208 * Free form string identifier for implementation.
210 readonly attribute
string implementationString
;
213 * |true| if the debugger should register an app-start observer in order
214 * to begin collecting debug information when mozilla is launched.
216 attribute
boolean initAtStartup
;
219 * |true| if the debugger service has been turned on. This does not
220 * necessarily mean another app is actively using the service, as the
221 * autostart pref may have turned the service on.
223 readonly attribute
boolean isOn
;
226 * Turn on the debugger. This function should only be called from JavaScript
227 * code. The debugger will be enabled on the runtime the call is made on,
228 * as determined by nsIXPCNativeCallContext.
232 * Turn on the debugger for a given runtime.
234 * @param rt The runtime you want to debug. You cannot turn the debugger
235 * on for multiple runtimes.
237 [noscript
] void onForRuntime
(in JSRuntime rt
);
239 * Turn the debugger off. This will invalidate all of your jsdIEphemeral
240 * derived objects, and clear all of your breakpoints. In theory you
241 * should be able to turn the debugger back on at some later time without
247 * Peek at the current pause depth of the debugger.
249 * @return depth Number of pause() calls still waiting to be unPause()d.
251 readonly attribute
unsigned long pauseDepth
;
253 * Temporarily disable the debugger. Hooks will not be called while the
254 * debugger is paused. Multiple calls to pause will increase the "pause
255 * depth", and equal number of unPause calles must be made to resume
258 * @return depth Number of times pause has been called since the debugger
261 unsigned long pause
();
265 * @return depth The number of remaining pending pause calls.
267 unsigned long unPause
();
270 * Force the engine to perform garbage collection.
275 * Output dump of JS heap.
277 * @param fileName Filename to dump the heap into.
279 void DumpHeap
(in string fileName
);
282 * Clear profile data for all scripts.
284 void clearProfileData
();
287 * Adds an execution hook filter. These filters are consulted each time one
288 * of the jsdIExecutionHooks is about to be called. Filters are matched in
289 * a first in, first compared fashion. The first filter to match determines
290 * whether or not the hook is called. Use swapFilter to reorder existing
291 * filters, and removeFilter to remove them.
293 * If |filter| is already present this method throws NS_ERROR_INVALID_ARG.
295 * @param filter Object representing the filter to add.
296 * @param after Insert |filter| after this one. Pass null to insert at
299 void insertFilter
(in jsdIFilter filter
, in jsdIFilter after
);
301 * Same as insertFilter, except always add to the end of the list.
303 void appendFilter
(in jsdIFilter filter
);
307 * If |filter| is not present this method throws NS_ERROR_INVALID_ARG.
309 * @param filter Object representing the filter to remove. Must be the exact
310 * object passed to addFilter, not just a new object with the same
313 void removeFilter
(in jsdIFilter filter
);
315 * Swap position of two filters.
317 * If |filter_a| is not present, this method throws NS_ERROR_INVALID_ARG.
318 * If |filter_b| is not present, filter_a is replaced by filter_b.
319 * If |filter_a| == |filter_b|, then filter is refreshed.
321 void swapFilters
(in jsdIFilter filter_a
, in jsdIFilter filter_b
);
323 * Enumerate registered filters. This routine refreshes each filter before
324 * passing them on to the enumeration function. Calling this with a null
325 * |enumerator| is equivalent to jsdIService::refreshFilters.
327 * @param enumerator jsdIFilterEnumerator instance to be called back for the
330 void enumerateFilters
(in jsdIFilterEnumerator enumerator
);
332 * Force the debugger to resync its internal filter cache with the
333 * actual values in the jsdIFilter objects. To refresh a single filter
334 * use jsdIService::swapFilters. This method is equivalent to
335 * jsdIService::enumerateFilters with a null enumerator.
337 void refreshFilters
();
339 * Clear the list of filters.
344 * Enumerate all known contexts.
346 void enumerateContexts
(in jsdIContextEnumerator enumerator
);
349 * Enumerate all scripts the debugger knows about. Any scripts created
350 * before you turned the debugger on, or after turning the debugger off
351 * will not be available unless the autostart perf is set.
353 * @param enumerator jsdIScriptEnumerator instance to be called back for
356 void enumerateScripts
(in jsdIScriptEnumerator enumerator
);
358 * Clear all breakpoints in all scripts.
360 void clearAllBreakpoints
();
363 * When called from JavaScript, this method returns the jsdIValue wrapper
364 * for the given value. If a wrapper does not exist one will be created.
365 * When called from another language this method returns an xpconnect
366 * defined error code.
368 jsdIValue wrapValue
(/*in jsvalue value*/);
370 /* XXX these two routines are candidates for refactoring. The only problem
371 * is that it is not clear where and how they should land.
375 * Push a new network queue, and enter a new UI event loop.
376 * @param callback jsdINestCallback instance to be called back after the
377 * network queue has been pushed, but before the
379 * @return depth returns the current number of times the event loop has been
380 * nested. your code can use it for sanity checks.
382 unsigned long enterNestedEventLoop
(in jsdINestCallback
callback);
384 * Exit the current nested event loop after the current iteration completes,
385 * and pop the network event queue.
387 * @return depth returns the current number of times the event loop has been
388 * nested. your code can use it for sanity checks.
390 unsigned long exitNestedEventLoop
();
393 /* callback interfaces */
396 * Object representing a pattern of global object and/or url the debugger should
397 * ignore. The debugger service itself will not modify properties of these
400 [scriptable
, uuid(05593438-1b83
-4517-864f
-3cea3d37a266
)]
401 interface jsdIFilter
: nsISupports
404 * These two bytes of the flags attribute are reserved for interpretation
405 * by the jsdService implementation. You can do what you like with the
408 const unsigned long FLAG_RESERVED_MASK
= 0xFF;
410 * Filters without this flag set are ignored.
412 const unsigned long FLAG_ENABLED
= 0x01;
414 * Filters with this flag set are "pass" filters, they allow matching hooks
415 * to continue. Filters without this flag block matching hooks.
417 const unsigned long FLAG_PASS
= 0x02;
420 * FLAG_* values from above, OR'd together.
422 attribute
unsigned long flags
;
425 * An nsISupports version of the global object to be filtered. A null glob
426 * matches all hooks. This attribute must be QI'able to the
427 * (non-scriptable) nsIScriptGlobalObject interface.
429 * The jsdIService caches this value internally, so if it changes you must
430 * swap the filter with itself using jsdIService::swapFilters.
432 attribute nsISupports globalObject
;
435 * String representing the url pattern to be filtered. Supports limited
436 * glob matching, at the beginning and end of the pattern only. For example,
437 * "chrome://venkman*" filters all urls that start with chrome/venkman,
438 * "*.cgi" filters all cgi's, and "http://myserver/utils.js" filters only
439 * the utils.js file on "myserver". A null urlPattern matches all urls.
441 * The jsdIService caches this value internally, to if it changes you must
442 * swap the filter with itself using jsdIService::swapFilters.
444 attribute
string urlPattern
;
447 * Line number for the start of this filter. Line numbers are one based.
448 * Assigning a 0 to this attribute will tell the debugger to ignore the
451 attribute
unsigned long startLine
;
454 * Line number for the end of this filter. Line numbers are one based.
455 * Assigning a 0 to this attribute will tell the debugger to ignore from
456 * |startLine| to the end of the file.
458 attribute
unsigned long endLine
;
462 * Pass an instance of one of these to jsdIDebuggerService::enterNestedEventLoop.
464 [scriptable
, uuid(88bea60f
-9b5d
-4b39
-b08b
-1c3a278782c6
)]
465 interface jsdINestCallback
: nsISupports
468 * This method will be called after pre-nesting work has completed, such
469 * as pushing the js context and network event queue, but before the new
476 * Pass an instance of one of these to jsdIDebuggerService::enumerateFilters.
478 [scriptable
, uuid(54382875-ed12
-4f90
-9a63
-1f0498d0a3f2
)]
479 interface jsdIFilterEnumerator
: nsISupports
482 * The enumerateFilter method will be called once for every filter the
483 * debugger knows about.
485 void enumerateFilter
(in jsdIFilter filter
);
489 * Pass an instance of one of these to jsdIDebuggerService::enumerateScripts.
491 [scriptable
, uuid(4c2f706e
-1dd2
-11b2
-9ebc
-85a06e948830
)]
492 interface jsdIScriptEnumerator
: nsISupports
495 * The enumerateScript method will be called once for every script the
496 * debugger knows about.
498 void enumerateScript
(in jsdIScript script
);
502 * Pass an instance of one of these to jsdIDebuggerService::enumerateContexts.
504 [scriptable
, uuid(912e342a
-1dd2
-11b2
-b09f
-cf3af38c15f0
)]
505 interface jsdIContextEnumerator
: nsISupports
508 * The enumerateContext method will be called once for every context
511 void enumerateContext
(in jsdIContext executionContext
);
515 * Set jsdIDebuggerService::scriptHook to an instance of one of these.
517 [scriptable
, uuid(ae89a7e2
-1dd1
-11b2
-8c2f
-af82086291a5
)]
518 interface jsdIScriptHook
: nsISupports
521 * Called when scripts are created.
523 void onScriptCreated
(in jsdIScript script
);
525 * Called when the JavaScript engine destroys a script. The jsdIScript
526 * object passed in will already be invalidated.
528 void onScriptDestroyed
(in jsdIScript script
);
532 * Hook instances of this interface up to the
533 * jsdIDebuggerService::functionHook and toplevelHook properties.
535 [scriptable
, uuid(f102caf6
-1dd1
-11b2
-bd43
-c1dbacb95a98
)]
536 interface jsdICallHook
: nsISupports
539 * TYPE_* values must be kept in sync with the JSD_HOOK_* #defines
544 * Toplevel script is starting.
546 const unsigned long TYPE_TOPLEVEL_START
= 0;
548 * Toplevel script has completed.
550 const unsigned long TYPE_TOPLEVEL_END
= 1;
552 * Function is being called.
554 const unsigned long TYPE_FUNCTION_CALL
= 2;
556 * Function is returning.
558 const unsigned long TYPE_FUNCTION_RETURN
= 3;
561 * Called before the JavaScript engine executes a top level script or calls
564 void onCall
(in jsdIStackFrame frame
, in unsigned long type
);
567 [scriptable
, uuid(b7dd3c1c
-1dd1
-11b2
-83eb
-8a857d199e0f
)]
568 interface jsdIErrorHook
: nsISupports
571 * REPORT_* values must be kept in sync with JSREPORT_* #defines in
576 * Report is an error.
578 const unsigned long REPORT_ERROR
= 0x00;
580 * Report is only a warning.
582 const unsigned long REPORT_WARNING
= 0x01;
584 * Report represents an uncaught exception.
586 const unsigned long REPORT_EXCEPTION
= 0x02;
588 * Report is due to strict mode.
590 const unsigned long REPORT_STRICT
= 0x04;
593 * Called when the JavaScript engine encounters an error. Return |true|
594 * to pass the error along, |false| to invoke the debugHook.
596 boolean onError
(in string message, in string fileName
,
597 in unsigned long line
, in unsigned long pos
,
598 in unsigned long flags
, in unsigned long errnum
,
603 * Hook instances of this interface up to the
604 * jsdIDebuggerService::breakpointHook, debuggerHook, errorHook, interruptHook,
605 * and throwHook properties.
607 [scriptable
, uuid(9a7b6ad0
-1dd1
-11b2
-a789
-fcfae96356a2
)]
608 interface jsdIExecutionHook
: nsISupports
611 * TYPE_* values must be kept in sync with JSD_HOOK_* #defines in jsdebug.h.
615 * Execution stopped because we're in single step mode.
617 const unsigned long TYPE_INTERRUPTED
= 0;
619 * Execution stopped by a trap instruction (i.e. breakoint.)
621 const unsigned long TYPE_BREAKPOINT
= 1;
623 * Error handler returned an "invoke debugger" value.
625 const unsigned long TYPE_DEBUG_REQUESTED
= 2;
627 * Debugger keyword encountered.
629 const unsigned long TYPE_DEBUGGER_KEYWORD
= 3;
631 * Exception was thrown.
633 const unsigned long TYPE_THROW
= 4;
636 * RETURN_* values must be kept in sync with JSD_HOOK_RETURN_* #defines in
641 * Indicates unrecoverable error processing the hook. This will cause
642 * the script being executed to be aborted without raising a JavaScript
645 const unsigned long RETURN_HOOK_ERROR
= 0;
647 * Continue processing normally. This is the "do nothing special" return
648 * value for all hook types *except* TYPE_THROW. Returning RETURN_CONTINUE
649 * from TYPE_THROW cause the exception to be ignored. Return
650 * RETURN_CONTINUE_THROW to continue exception processing from TYPE_THROW
653 const unsigned long RETURN_CONTINUE
= 1;
655 * Same effect as RETURN_HOOK_ERROR.
657 const unsigned long RETURN_ABORT
= 2;
659 * Return the value of the |val| parameter.
661 const unsigned long RETURN_RET_WITH_VAL
= 3;
663 * Throw the value of the |val| parameter.
665 const unsigned long RETURN_THROW_WITH_VAL
= 4;
667 * Continue the current throw.
669 const unsigned long RETURN_CONTINUE_THROW
= 5;
672 * @param frame A jsdIStackFrame object representing the bottom stack frame.
673 * @param type One of the jsdIExecutionHook::TYPE_ constants.
674 * @param val in - Current exception (if any) when this method is called.
675 * out - If you return RETURN_THROW_WITH_VAL, value to be
677 * If you return RETURN_RET_WITH_VAL, value to return.
678 * All other return values, not significant.
679 * @retval One of the jsdIExecutionHook::RETURN_* constants.
681 unsigned long onExecute
(in jsdIStackFrame frame
,
682 in unsigned long type
, inout jsdIValue val
);
686 * Objects which inherit this interface may go away, with (jsdIScript) or
687 * without (all others) notification. These objects are generally wrappers
688 * around JSD structures that go away when you call jsdService::Off().
690 [scriptable
, uuid(46f1e23e
-1dd2
-11b2
-9ceb
-8285f2e95e69
)]
691 interface jsdIEphemeral
: nsISupports
694 * |true| if this object is still valid. If not, many or all of the methods
695 * and/or properties of the inheritor may no longer be callable.
697 readonly attribute
boolean isValid
;
699 * Mark this instance as invalid.
701 [noscript
] void invalidate
();
707 * Context object. Only context's which are also nsISupports objects can be
708 * reflected by this interface.
710 [scriptable
, uuid(a2dd25a4
-1dd1
-11b2
-bda6
-ed525acd4c35
)]
711 interface jsdIContext
: jsdIEphemeral
713 /* Internal use only. */
714 [noscript
] readonly attribute JSContext JSContext
;
717 * OPT_* values must be kept in sync with JSOPTION_* #defines in jsapi.h.
723 const long OPT_STRICT
= 0x01;
725 * Warnings reported as errors.
727 const long OPT_WERR
= 0x02;
729 * Makes eval() use the last object on its 'obj' param's scope chain as the
730 * ECMA 'variables object'.
732 const long OPT_VAROBJFIX
= 0x04;
734 * Private data for this object is an nsISupports object. Attempting to
735 * alter this bit will result in an NS_ERROR_ILLEGAL_VALUE.
737 const long OPT_ISUPPORTS
= 0x08;
739 * OPT_* values above, OR'd together.
741 attribute
unsigned long options
;
744 * Last version set on this context.
745 * Scripts typically select this with the "language" attribute.
746 * See the VERSION_* consts on jsdIDebuggerService.
748 attribute
long version;
751 * Unique tag among all valid jsdIContext objects, useful as a hash key.
753 readonly attribute
unsigned long tag
;
756 * Private data for this context, if it is an nsISupports, |null| otherwise.
758 readonly attribute nsISupports privateData
;
761 * Retrieve the underlying context wrapped by this jsdIContext.
763 readonly attribute nsISupports wrappedContext
;
766 * Top of the scope chain for this context.
768 readonly attribute jsdIValue globalObject
;
771 * |true| if this context should be allowed to run scripts, |false|
772 * otherwise. This attribute is only valid for contexts which implement
773 * nsIScriptContext. Setting or getting this attribute on any other
774 * context will throw a NS_ERROR_NO_INTERFACE exception.
776 attribute
boolean scriptsEnabled
;
780 * Stack frame objects. These are only valid inside the jsdIExecutionHook which
781 * gave it to you. After you return from that handler the bottom frame, and any
782 * frame you found attached through it, are invalidated via the jsdIEphemeral
783 * interface. Once a jsdIStackFrame has been invalidated all method and
784 * property accesses will throw a NS_ERROR_NOT_AVAILABLE exception.
786 [scriptable
, uuid(b6d50784
-1dd1
-11b2
-a932
-882246c6fe45
)]
787 interface jsdIStackFrame
: jsdIEphemeral
789 /** Internal use only. */
790 [noscript
] readonly attribute JSDContext JSDContext
;
791 /** Internal use only. */
792 [noscript
] readonly attribute JSDThreadState JSDThreadState
;
793 /** Internal use only. */
794 [noscript
] readonly attribute JSDStackFrameInfo JSDStackFrameInfo
;
797 * True if stack frame represents a native frame.
799 readonly attribute
boolean isNative
;
801 * True if stack frame represents a frame created as a result of a debugger
804 readonly attribute
boolean isDebugger
;
806 * True if stack frame is constructing a new object.
808 readonly attribute
boolean isConstructing
;
811 * Link to the caller's stack frame.
813 readonly attribute jsdIStackFrame callingFrame
;
817 readonly attribute jsdIContext executionContext
;
819 * Function name executing in this stack frame.
821 readonly attribute
string functionName
;
823 * Script running in this stack frame, null for native frames.
825 readonly attribute jsdIScript script
;
827 * Current program counter in this stack frame.
829 readonly attribute
unsigned long pc
;
831 * Current line number (using the script's pc to line map.)
833 readonly attribute
unsigned long line
;
835 * Function object running in this stack frame.
837 readonly attribute jsdIValue callee
;
839 * Top object in the scope chain.
841 readonly attribute jsdIValue scope
;
843 * |this| object for this stack frame.
845 readonly attribute jsdIValue thisValue
;
847 * Evaluate arbitrary JavaScript in this stack frame.
848 * @param bytes Script to be evaluated.
849 * @param fileName Filename to compile this script under. This is the
850 * filename you'll see in error messages, etc.
851 * @param line Starting line number for this script. One based.
852 * @retval Result of evaluating the script.
854 boolean eval
(in AString bytes
, in string fileName
,
855 in unsigned long line
, out jsdIValue result
);
860 * Script object. In JavaScript engine terms, there's a single script for each
861 * function, and one for the top level script.
863 [scriptable
, uuid(a38f65ca
-1dd1
-11b2
-95d5
-ff2947e9c920
)]
864 interface jsdIScript
: jsdIEphemeral
866 /** Internal use only. */
867 [noscript
] readonly attribute JSDContext JSDContext
;
868 /** Internal use only. */
869 [noscript
] readonly attribute JSDScript JSDScript
;
872 * Last version set on this context.
873 * Scripts typically select this with the "language" attribute.
874 * See the VERSION_* consts on jsdIDebuggerService.
876 readonly attribute
long version;
879 * Tag value guaranteed unique among jsdIScript objects. Useful as a
880 * hash key in script.
882 readonly attribute
unsigned long tag
;
885 * FLAG_* values need to be kept in sync with JSD_SCRIPT_* #defines in
890 * Determines whether or not to collect profile information for this
891 * script. The context flag FLAG_PROFILE_WHEN_SET decides the logic.
893 const unsigned long FLAG_PROFILE
= 0x01;
895 * Determines whether or not to ignore breakpoints, etc. in this script.
896 * The context flag JSD_DEBUG_WHEN_SET decides the logic.
898 const unsigned long FLAG_DEBUG
= 0x02;
901 * FLAG_* attributes from above, OR'd together.
903 attribute
unsigned long flags
;
906 * Filename given for this script when it was compiled.
907 * This data is copied from the underlying structure when the jsdIScript
908 * instance is created and is therefore available even after the script is
911 readonly attribute
string fileName
;
913 * Function name for this script. "anonymous" for unnamed functions (or
914 * a function actually named anonymous), empty for top level scripts.
915 * This data is copied from the underlying structure when the jsdIScript
916 * instance is created and is therefore available even after the script is
919 readonly attribute
string functionName
;
921 * Fetch the function object as a jsdIValue.
923 readonly attribute jsdIValue functionObject
;
925 * Source code for this script, without function declaration.
927 readonly attribute AString functionSource
;
929 * Line number in source file containing the first line of this script.
930 * This data is copied from the underlying structure when the jsdIScript
931 * instance is created and is therefore available even after the script is
934 readonly attribute
unsigned long baseLineNumber
;
936 * Total number of lines in this script.
937 * This data is copied from the underlying structure when the jsdIScript
938 * instance is created and is therefore available even after the script is
941 readonly attribute
unsigned long lineExtent
;
944 * Number of times this script has been called.
946 readonly attribute
unsigned long callCount
;
948 * Number of times this script called itself, directly or indirectly.
950 readonly attribute
unsigned long maxRecurseDepth
;
952 * Shortest execution time recorded, in milliseconds.
954 readonly attribute
double minExecutionTime
;
956 * Longest execution time recorded, in milliseconds.
958 readonly attribute
double maxExecutionTime
;
960 * Total time spent in this function, in milliseconds.
962 readonly attribute
double totalExecutionTime
;
964 * Shortest execution time recorded, in milliseconds, excluding time spent
965 * in other called code.
967 readonly attribute
double minOwnExecutionTime
;
969 * Longest execution time recorded, in milliseconds, excluding time spent
970 * in other called code.
972 readonly attribute
double maxOwnExecutionTime
;
974 * Total time spent in this function, in milliseconds, excluding time spent
975 * in other called code.
977 readonly attribute
double totalOwnExecutionTime
;
980 * Clear profile data for this script.
982 void clearProfileData
();
984 const unsigned long PCMAP_SOURCETEXT
= 1; /* map to actual source text */
985 const unsigned long PCMAP_PRETTYPRINT
= 2; /* map to pretty printed source */
988 * Get the closest line number to a given PC.
989 * The |pcmap| argument specifies which pc to source line map to use.
991 unsigned long pcToLine
(in unsigned long pc
, in unsigned long pcmap
);
993 * Get the first PC associated with a line.
994 * The |pcmap| argument specifies which pc to source line map to use.
996 unsigned long lineToPc
(in unsigned long line
, in unsigned long pcmap
);
998 * Determine is a particular line is executable, like checking that
999 * lineToPc == pcToLine, except in one call.
1000 * The |pcmap| argument specifies which pc to source line map to use.
1002 boolean isLineExecutable
(in unsigned long line
, in unsigned long pcmap
);
1004 * Set a breakpoint at a PC in this script.
1006 void setBreakpoint
(in unsigned long pc
);
1008 * Clear a breakpoint at a PC in this script.
1010 void clearBreakpoint
(in unsigned long pc
);
1012 * Clear all breakpoints set in this script.
1014 void clearAllBreakpoints
();
1018 * Value objects. Represents typeless JavaScript values (jsval in SpiderMonkey
1019 * terminology.) These are valid until the debugger is turned off. Holding a
1020 * jsdIValue adds a root for the underlying JavaScript value, so don't keep it
1021 * if you don't need to.
1023 [scriptable
, uuid(b7964304
-1dd1
-11b2
-ba20
-cf4205772e9d
)]
1024 interface jsdIValue
: jsdIEphemeral
1026 /** Internal use only. */
1027 [noscript
] readonly attribute JSDContext JSDContext
;
1028 /** Internal use only. */
1029 [noscript
] readonly attribute JSDValue JSDValue
;
1032 * |false| unless the value is a function declared in script.
1034 readonly attribute
boolean isNative
;
1036 * |true| if the value represents a number, either double or integer.
1037 * |false| for all other values, including numbers assigned as strings
1040 readonly attribute
boolean isNumber
;
1042 * |true| if the value represents a JavaScript primitive number or string
1044 readonly attribute
boolean isPrimitive
;
1046 /** Value is either |true| or |false|. */
1047 const unsigned long TYPE_BOOLEAN
= 0;
1048 /** Value is a primitive number that is too large to fit in an integer. */
1049 const unsigned long TYPE_DOUBLE
= 1;
1050 /** Value is a primitive number that fits into an integer. */
1051 const unsigned long TYPE_INT
= 2;
1052 /** Value is a function. */
1053 const unsigned long TYPE_FUNCTION
= 3;
1054 /** Value is |null|. */
1055 const unsigned long TYPE_NULL
= 4;
1056 /** Value is an object. */
1057 const unsigned long TYPE_OBJECT
= 5;
1058 /** Value is a primitive string. */
1059 const unsigned long TYPE_STRING
= 6;
1060 /** Value is void. */
1061 const unsigned long TYPE_VOID
= 7;
1064 * One of the TYPE_* values above.
1066 readonly attribute
unsigned long jsType
;
1068 * Prototype value if this value represents an object, null if the value is
1069 * not an object or the object has no prototype.
1071 readonly attribute jsdIValue jsPrototype
;
1073 * Parent value if this value represents an object, null if the value is not
1074 * an object or the object has no parent.
1076 readonly attribute jsdIValue jsParent
;
1078 * Class name if this value represents an object. Empty string if the value
1081 readonly attribute
string jsClassName
;
1083 * Constructor name if this value represents an object. Empty string if the
1084 * value is not an object.
1086 readonly attribute jsdIValue jsConstructor
;
1088 * Function name if this value represents a function. Empty string if the
1089 * value is not a function.
1091 readonly attribute
string jsFunctionName
;
1094 * Value if interpreted as a boolean. Converts if necessary.
1096 readonly attribute
boolean booleanValue
;
1098 * Value if interpreted as a double. Converts if necessary.
1100 readonly attribute
double doubleValue
;
1102 * Value if interpreted as an integer. Converts if necessary.
1104 readonly attribute
long intValue
;
1106 * Value if interpreted as an object.
1108 readonly attribute jsdIObject objectValue
;
1110 * Value if interpreted as a string. Converts if necessary.
1112 readonly attribute
string stringValue
;
1115 * Number of properties. 0 if the value is not an object, or the value is
1116 * an object but has no properties.
1118 readonly attribute
long propertyCount
;
1121 * Retrieves all properties if this value represents an object. If this
1122 * value is not an object a 0 element array is returned.
1123 * @param propArray Array of jsdIProperty values for this value.
1124 * @param length Size of array.
1126 void getProperties
([array
, size_is(length
)] out jsdIProperty propArray
,
1127 out unsigned long length
);
1129 * Retrieves a single property from the value. Only valid if the value
1130 * represents an object.
1131 * @param name Name of the property to retrieve.
1132 * @retval jsdIProperty for the requested property name or null if no
1133 * property exists for the requested name.
1135 jsdIProperty getProperty
(in string name
);
1138 * jsdIValues are wrappers around JavaScript engine structures. Much of the
1139 * data is copied instead of shared. The refresh method is used to resync
1140 * the jsdIValue with the underlying structure.
1145 * When called from JavaScript, this method returns the JavaScript value
1146 * wrapped by this jsdIValue. The calling script is free to use the result
1147 * as it would any other JavaScript value.
1148 * When called from another language this method returns an xpconnect
1149 * defined error code.
1151 void getWrappedValue
();
1155 * Properties specific to values which are also objects.
1156 * XXX We don't add roots for these yet, so make sure you hold on to the
1157 * jsdIValue from whence your jsdIObject instance came for at least as long as
1158 * you hold the jsdIObject.
1159 * XXX Maybe the jsClassName, jsConstructorName, and property related attribute/
1160 * functions from jsdIValue should move to this interface. We could inherit from
1161 * jsdIValue or use interface flattening or something.
1163 [scriptable
, uuid(d500e8b8
-1dd1
-11b2
-89a1
-cdf55d91cbbd
)]
1164 interface jsdIObject
: nsISupports
1166 /** Internal use only. */
1167 [noscript
] readonly attribute JSDContext JSDContext
;
1168 /** Internal use only. */
1169 [noscript
] readonly attribute JSDObject JSDObject
;
1172 * The URL (filename) that contains the script which caused this object
1175 readonly attribute
string creatorURL
;
1177 * Line number in the creatorURL where this object was created.
1179 readonly attribute
unsigned long creatorLine
;
1181 * The URL (filename) that contains the script which defined the constructor
1182 * used to create this object.
1184 readonly attribute
string constructorURL
;
1186 * Line number in the creatorURL where this object was created.
1188 readonly attribute
unsigned long constructorLine
;
1190 * jsdIValue for this object.
1192 readonly attribute jsdIValue value
;
1196 * Representation of a property of an object. When an instance is invalid, all
1197 * method and property access will result in a NS_UNAVAILABLE error.
1199 [scriptable
, uuid(b8816e56
-1dd1
-11b2
-81dc
-8ba99a833d9e
)]
1200 interface jsdIProperty
: jsdIEphemeral
1202 /** Internal use only. */
1203 [noscript
] readonly attribute JSDContext JSDContext
;
1204 /** Internal use only. */
1205 [noscript
] readonly attribute JSDProperty JSDProperty
;
1208 * FLAG_* values must be kept in sync with JSDPD_* #defines in jsdebug.h.
1211 /** visible to for/in loop */
1212 const unsigned long FLAG_ENUMERATE
= 0x01;
1213 /** assignment is error */
1214 const unsigned long FLAG_READONLY
= 0x02;
1215 /** property cannot be deleted */
1216 const unsigned long FLAG_PERMANENT
= 0x04;
1217 /** property has an alias id */
1218 const unsigned long FLAG_ALIAS
= 0x08;
1219 /** argument to function */
1220 const unsigned long FLAG_ARGUMENT
= 0x10;
1221 /** local variable in function */
1222 const unsigned long FLAG_VARIABLE
= 0x20;
1223 /** exception occurred looking up property, value is exception */
1224 const unsigned long FLAG_EXCEPTION
= 0x40;
1225 /** native getter returned JS_FALSE without throwing an exception */
1226 const unsigned long FLAG_ERROR
= 0x80;
1227 /** found via explicit lookup (property defined elsewhere.) */
1228 const unsigned long FLAG_HINTED
= 0x800;
1230 /** FLAG_* values OR'd together, representing the flags for this property. */
1231 readonly attribute
unsigned long flags
;
1232 /** jsdIValue representing the alias for this property. */
1233 readonly attribute jsdIValue alias
;
1234 /** name for this property. */
1235 readonly attribute jsdIValue name
;
1236 /** value of this property. */
1237 readonly attribute jsdIValue value
;
1238 /** slot number if this property is a local variable or parameter. */
1239 readonly attribute
unsigned long varArgSlot
;
1244 [scriptable, uuid(a47adad2-1dd1-11b2-b9e9-8e67a47beca5)]
1245 interface jsdISourceText : nsISupports
1248 [scriptable, uuid(b6d1c006-1dd1-11b2-b9d8-b4d1ccfb74d8)]
1249 interface jsdIThreadState : nsISupports
1251 [noscript] readonly attribute JSDContext JSDContext;
1252 [noscript] readonly attribute JSDThreadState JSDThreadState;
1254 readonly attribute unsigned long frameCount;
1255 readonly attribute jsdIStackFrame topFrame;
1257 attribute jsdIValue pendingException;