1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is mozilla.org code.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 1998
20
* the Initial Developer. All Rights Reserved.
24
* Alternatively, the contents of this file may be used under the terms of
25
* either the GNU General Public License Version 2 or later (the "GPL"), or
26
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
* in which case the provisions of the GPL or the LGPL are applicable instead
28
* of those above. If you wish to allow use of your version of this file only
29
* under the terms of either the GPL or the LGPL, and not to allow others to
30
* use your version of this file under the terms of the NPL, indicate your
31
* decision by deleting the provisions above and replace them with the notice
32
* and other provisions required by the GPL or the LGPL. If you do not delete
33
* the provisions above, a recipient may use your version of this file under
34
* the terms of any one of the NPL, the GPL or the LGPL.
36
* ***** END LICENSE BLOCK ***** */
39
* Header for JavaScript Debugging support - Internal ONLY declarations
46
* NOTE: This is a *private* header file and should only be included by
47
* the sources in js/jsd. Defining EXPORT_JSD_API in an outside module
48
* using jsd would be bad.
50
#define EXPORT_JSD_API 1 /* if used, must be set before include of jsdebug.h */
53
* These can be controled by the makefile, but this allows a place to set
54
* the values always used in the mozilla client, but perhaps done differnetly
55
* in other embeddings.
58
#define JSD_THREADSAFE 1
59
/* define JSD_HAS_DANGEROUS_THREAD 1 */
60
#define JSD_USE_NSPR_LOCKS 1
61
#endif /* MOZILLA_CLIENT */
64
/* Get jstypes.h included first. After that we can use PR macros for doing
65
* this extern "C" stuff!
78
#include "jsutil.h" /* Added by JSIFY */
79
#include "jshash.h" /* Added by JSIFY */
94
#include <base/pblock.h>
95
#include <base/session.h>
96
#include <frame/log.h>
97
#include <frame/req.h>
103
#define JSD_MAJOR_VERSION 1
104
#define JSD_MINOR_VERSION 1
106
/***************************************************************************/
108
#undef CHECK_BIT_FLAG
109
#define CHECK_BIT_FLAG(f,b) ((f)&(b))
111
#define SET_BIT_FLAG(f,b) ((f)|=(b))
112
#undef CLEAR_BIT_FLAG
113
#define CLEAR_BIT_FLAG(f,b) ((f)&=(~(b)))
115
#define JSD_IS_DEBUG_ENABLED(jsdc,jsdscript) \
116
(!(((jsdc->flags & JSD_DEBUG_WHEN_SET) ? 1 : 0) ^ \
117
((jsdscript->flags & JSD_SCRIPT_DEBUG_BIT) ? 1 : 0)))
118
#define JSD_IS_PROFILE_ENABLED(jsdc,jsdscript) \
119
((jsdc->flags & JSD_COLLECT_PROFILE_DATA) && \
120
(!(((jsdc->flags & JSD_PROFILE_WHEN_SET) ? 1 : 0) ^ \
121
((jsdscript->flags & JSD_SCRIPT_PROFILE_BIT) ? 1 : 0))))
124
/***************************************************************************/
125
/* These are not exposed in jsdebug.h - typedef here for consistency */
127
typedef struct JSDExecHook JSDExecHook;
128
typedef struct JSDAtom JSDAtom;
129
typedef struct JSDProfileData JSDProfileData;
130
/***************************************************************************/
134
* XXX What I'm calling a JSDContext is really more of a JSDTaskState.
139
JSCList links; /* we are part of a JSCList */
143
JSD_ScriptHookProc scriptHook;
144
void* scriptHookData;
145
JSD_ExecutionHookProc interruptHook;
146
void* interruptHookData;
148
JSD_ErrorReporter errorReporter;
149
void* errorReporterData;
150
JSCList threadsStates;
151
JSD_ExecutionHookProc debugBreakHook;
152
void* debugBreakHookData;
153
JSD_ExecutionHookProc debuggerHook;
154
void* debuggerHookData;
155
JSD_ExecutionHookProc throwHook;
157
JSD_CallHookProc functionHook;
158
void* functionHookData;
159
JSD_CallHookProc toplevelHook;
160
void* toplevelHookData;
161
JSContext* dumbContext;
163
JSD_UserCallbacks userCallbacks;
166
JSHashTable* scriptsTable;
168
JSCList removedSources;
169
uintN sourceAlterCount;
172
JSHashTable* objectsTable;
173
#ifdef JSD_THREADSAFE
175
void* sourceTextLock;
178
void* threadStatesLock;
179
#endif /* JSD_THREADSAFE */
180
#ifdef JSD_HAS_DANGEROUS_THREAD
181
void* dangerousThread;
182
#endif /* JSD_HAS_DANGEROUS_THREAD */
188
JSCList links; /* we are part of a JSCList */
189
JSDContext* jsdc; /* JSDContext for this jsdscript */
190
JSScript* script; /* script we are wrapping */
191
JSFunction* function; /* back pointer to owning function (can be NULL) */
192
uintN lineBase; /* we cache this */
193
uintN lineExtent; /* we cache this */
194
JSCList hooks; /* JSCList of JSDExecHooks for this script */
199
JSDProfileData *profileData;
203
LWDBGScript* lwscript;
207
struct JSDProfileData
212
uintN maxRecurseDepth;
213
jsdouble minExecutionTime;
214
jsdouble maxExecutionTime;
215
jsdouble totalExecutionTime;
220
JSCList links; /* we are part of a JSCList */
226
JSDSourceStatus status;
233
JSCList links; /* we are part of a JSCList */
234
JSDScript* jsdscript;
236
JSD_ExecutionHookProc hook;
240
#define TS_HAS_DISABLED_FRAME 0x01
242
struct JSDThreadState
244
JSCList links; /* we are part of a JSCList */
252
struct JSDStackFrameInfo
254
JSCList links; /* we are part of a JSCList */
255
JSDThreadState* jsdthreadstate;
256
JSDScript* jsdscript;
261
#define GOT_PROTO ((short) (1 << 0))
262
#define GOT_PROPS ((short) (1 << 1))
263
#define GOT_PARENT ((short) (1 << 2))
264
#define GOT_CTOR ((short) (1 << 3))
273
const char* className;
282
JSCList links; /* we are part of a JSCList */
293
char* str; /* must be first element in stuct for compare */
299
JSCList links; /* we are part of a JSCList */
308
/***************************************************************************/
309
/* Code validation support */
312
extern void JSD_ASSERT_VALID_CONTEXT(JSDContext* jsdc);
313
extern void JSD_ASSERT_VALID_SCRIPT(JSDScript* jsdscript);
314
extern void JSD_ASSERT_VALID_SOURCE_TEXT(JSDSourceText* jsdsrc);
315
extern void JSD_ASSERT_VALID_THREAD_STATE(JSDThreadState* jsdthreadstate);
316
extern void JSD_ASSERT_VALID_STACK_FRAME(JSDStackFrameInfo* jsdframe);
317
extern void JSD_ASSERT_VALID_EXEC_HOOK(JSDExecHook* jsdhook);
318
extern void JSD_ASSERT_VALID_VALUE(JSDValue* jsdval);
319
extern void JSD_ASSERT_VALID_PROPERTY(JSDProperty* jsdprop);
320
extern void JSD_ASSERT_VALID_OBJECT(JSDObject* jsdobj);
322
#define JSD_ASSERT_VALID_CONTEXT(x) ((void)0)
323
#define JSD_ASSERT_VALID_SCRIPT(x) ((void)0)
324
#define JSD_ASSERT_VALID_SOURCE_TEXT(x) ((void)0)
325
#define JSD_ASSERT_VALID_THREAD_STATE(x)((void)0)
326
#define JSD_ASSERT_VALID_STACK_FRAME(x) ((void)0)
327
#define JSD_ASSERT_VALID_EXEC_HOOK(x) ((void)0)
328
#define JSD_ASSERT_VALID_VALUE(x) ((void)0)
329
#define JSD_ASSERT_VALID_PROPERTY(x) ((void)0)
330
#define JSD_ASSERT_VALID_OBJECT(x) ((void)0)
333
/***************************************************************************/
334
/* higher level functions */
337
jsd_DebuggerOnForUser(JSRuntime* jsrt,
338
JSD_UserCallbacks* callbacks,
341
jsd_DebuggerOn(void);
344
jsd_DebuggerOff(JSDContext* jsdc);
347
jsd_SetUserCallbacks(JSRuntime* jsrt, JSD_UserCallbacks* callbacks, void* user);
350
jsd_JSDContextForJSContext(JSContext* context);
353
jsd_SetContextPrivate(JSDContext* jsdc, void *data);
356
jsd_GetContextPrivate(JSDContext* jsdc);
359
jsd_ClearAllProfileData(JSDContext* jsdc);
362
jsd_SetErrorReporter(JSDContext* jsdc,
363
JSD_ErrorReporter reporter,
367
jsd_GetErrorReporter(JSDContext* jsdc,
368
JSD_ErrorReporter* reporter,
371
JS_STATIC_DLL_CALLBACK(JSBool)
372
jsd_DebugErrorHook(JSContext *cx, const char *message,
373
JSErrorReport *report, void *closure);
375
/***************************************************************************/
376
/* Script functions */
379
jsd_InitScriptManager(JSDContext *jsdc);
382
jsd_DestroyScriptManager(JSDContext* jsdc);
385
jsd_FindJSDScript(JSDContext* jsdc,
388
extern JSDProfileData*
389
jsd_GetScriptProfileData(JSDContext* jsdc, JSDScript *script);
392
jsd_GetScriptFlags(JSDContext *jsdc, JSDScript *script);
395
jsd_SetScriptFlags(JSDContext *jsdc, JSDScript *script, uint32 flags);
398
jsd_GetScriptCallCount(JSDContext* jsdc, JSDScript *script);
401
jsd_GetScriptMaxRecurseDepth(JSDContext* jsdc, JSDScript *script);
404
jsd_GetScriptMinExecutionTime(JSDContext* jsdc, JSDScript *script);
407
jsd_GetScriptMaxExecutionTime(JSDContext* jsdc, JSDScript *script);
410
jsd_GetScriptTotalExecutionTime(JSDContext* jsdc, JSDScript *script);
413
jsd_ClearScriptProfileData(JSDContext* jsdc, JSDScript *script);
416
jsd_GetJSScript (JSDContext *jsdc, JSDScript *script);
419
jsd_GetJSFunction (JSDContext *jsdc, JSDScript *script);
422
jsd_IterateScripts(JSDContext* jsdc, JSDScript **iterp);
425
jsd_SetScriptPrivate (JSDScript *jsdscript, void *data);
428
jsd_GetScriptPrivate (JSDScript *jsdscript);
431
jsd_IsActiveScript(JSDContext* jsdc, JSDScript *jsdscript);
434
jsd_GetScriptFilename(JSDContext* jsdc, JSDScript *jsdscript);
437
jsd_GetScriptFunctionName(JSDContext* jsdc, JSDScript *jsdscript);
440
jsd_GetScriptBaseLineNumber(JSDContext* jsdc, JSDScript *jsdscript);
443
jsd_GetScriptLineExtent(JSDContext* jsdc, JSDScript *jsdscript);
446
jsd_SetScriptHook(JSDContext* jsdc, JSD_ScriptHookProc hook, void* callerdata);
449
jsd_GetScriptHook(JSDContext* jsdc, JSD_ScriptHookProc* hook, void** callerdata);
452
jsd_GetClosestPC(JSDContext* jsdc, JSDScript* jsdscript, uintN line);
455
jsd_GetClosestLine(JSDContext* jsdc, JSDScript* jsdscript, jsuword pc);
457
extern void JS_DLL_CALLBACK
458
jsd_NewScriptHookProc(
460
const char *filename, /* URL this script loads from */
461
uintN lineno, /* line where this script starts */
466
extern void JS_DLL_CALLBACK
467
jsd_DestroyScriptHookProc(
472
/* Script execution hook functions */
475
jsd_SetExecutionHook(JSDContext* jsdc,
476
JSDScript* jsdscript,
478
JSD_ExecutionHookProc hook,
482
jsd_ClearExecutionHook(JSDContext* jsdc,
483
JSDScript* jsdscript,
487
jsd_ClearAllExecutionHooksForScript(JSDContext* jsdc, JSDScript* jsdscript);
490
jsd_ClearAllExecutionHooks(JSDContext* jsdc);
493
jsd_ScriptCreated(JSDContext* jsdc,
495
const char *filename, /* URL this script loads from */
496
uintN lineno, /* line where this script starts */
501
jsd_ScriptDestroyed(JSDContext* jsdc,
505
/***************************************************************************/
506
/* Source Text functions */
508
extern JSDSourceText*
509
jsd_IterateSources(JSDContext* jsdc, JSDSourceText **iterp);
511
extern JSDSourceText*
512
jsd_FindSourceForURL(JSDContext* jsdc, const char* url);
515
jsd_GetSourceURL(JSDContext* jsdc, JSDSourceText* jsdsrc);
518
jsd_GetSourceText(JSDContext* jsdc, JSDSourceText* jsdsrc,
519
const char** ppBuf, intN* pLen);
522
jsd_ClearSourceText(JSDContext* jsdc, JSDSourceText* jsdsrc);
524
extern JSDSourceStatus
525
jsd_GetSourceStatus(JSDContext* jsdc, JSDSourceText* jsdsrc);
528
jsd_IsSourceDirty(JSDContext* jsdc, JSDSourceText* jsdsrc);
531
jsd_SetSourceDirty(JSDContext* jsdc, JSDSourceText* jsdsrc, JSBool dirty);
534
jsd_GetSourceAlterCount(JSDContext* jsdc, JSDSourceText* jsdsrc);
537
jsd_IncrementSourceAlterCount(JSDContext* jsdc, JSDSourceText* jsdsrc);
539
extern JSDSourceText*
540
jsd_NewSourceText(JSDContext* jsdc, const char* url);
542
extern JSDSourceText*
543
jsd_AppendSourceText(JSDContext* jsdc,
544
JSDSourceText* jsdsrc,
545
const char* text, /* *not* zero terminated */
547
JSDSourceStatus status);
549
extern JSDSourceText*
550
jsd_AppendUCSourceText(JSDContext* jsdc,
551
JSDSourceText* jsdsrc,
552
const jschar* text, /* *not* zero terminated */
554
JSDSourceStatus status);
556
/* convienence function for adding complete source of url in one call */
558
jsd_AddFullSourceText(JSDContext* jsdc,
559
const char* text, /* *not* zero terminated */
564
jsd_DestroyAllSources(JSDContext* jsdc);
567
jsd_BuildNormalizedURL(const char* url_string);
570
jsd_StartingEvalUsingFilename(JSDContext* jsdc, const char* url);
573
jsd_FinishedEvalUsingFilename(JSDContext* jsdc, const char* url);
575
/***************************************************************************/
576
/* Interrupt Hook functions */
579
jsd_SetInterruptHook(JSDContext* jsdc,
580
JSD_ExecutionHookProc hook,
584
jsd_ClearInterruptHook(JSDContext* jsdc);
587
jsd_SetDebugBreakHook(JSDContext* jsdc,
588
JSD_ExecutionHookProc hook,
592
jsd_ClearDebugBreakHook(JSDContext* jsdc);
595
jsd_SetDebuggerHook(JSDContext* jsdc,
596
JSD_ExecutionHookProc hook,
600
jsd_ClearDebuggerHook(JSDContext* jsdc);
603
jsd_CallExecutionHook(JSDContext* jsdc,
606
JSD_ExecutionHookProc hook,
611
jsd_CallCallHook (JSDContext* jsdc,
614
JSD_CallHookProc hook,
618
jsd_SetThrowHook(JSDContext* jsdc,
619
JSD_ExecutionHookProc hook,
622
jsd_ClearThrowHook(JSDContext* jsdc);
624
extern JSTrapStatus JS_DLL_CALLBACK
625
jsd_DebuggerHandler(JSContext *cx, JSScript *script, jsbytecode *pc,
626
jsval *rval, void *closure);
628
extern JSTrapStatus JS_DLL_CALLBACK
629
jsd_ThrowHandler(JSContext *cx, JSScript *script, jsbytecode *pc,
630
jsval *rval, void *closure);
633
jsd_SetFunctionHook(JSDContext* jsdc,
634
JSD_CallHookProc hook,
638
jsd_ClearFunctionHook(JSDContext* jsdc);
641
jsd_SetTopLevelHook(JSDContext* jsdc,
642
JSD_CallHookProc hook,
646
jsd_ClearTopLevelHook(JSDContext* jsdc);
648
/***************************************************************************/
649
/* Stack Frame functions */
652
jsd_GetCountOfStackFrames(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
654
extern JSDStackFrameInfo*
655
jsd_GetStackFrame(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
658
jsd_GetJSContext(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
660
extern JSDStackFrameInfo*
661
jsd_GetCallingStackFrame(JSDContext* jsdc,
662
JSDThreadState* jsdthreadstate,
663
JSDStackFrameInfo* jsdframe);
666
jsd_GetScriptForStackFrame(JSDContext* jsdc,
667
JSDThreadState* jsdthreadstate,
668
JSDStackFrameInfo* jsdframe);
671
jsd_GetPCForStackFrame(JSDContext* jsdc,
672
JSDThreadState* jsdthreadstate,
673
JSDStackFrameInfo* jsdframe);
676
jsd_GetCallObjectForStackFrame(JSDContext* jsdc,
677
JSDThreadState* jsdthreadstate,
678
JSDStackFrameInfo* jsdframe);
681
jsd_GetScopeChainForStackFrame(JSDContext* jsdc,
682
JSDThreadState* jsdthreadstate,
683
JSDStackFrameInfo* jsdframe);
686
jsd_IsStackFrameNative(JSDContext* jsdc,
687
JSDThreadState* jsdthreadstate,
688
JSDStackFrameInfo* jsdframe);
691
jsd_IsStackFrameDebugger(JSDContext* jsdc,
692
JSDThreadState* jsdthreadstate,
693
JSDStackFrameInfo* jsdframe);
696
jsd_IsStackFrameConstructing(JSDContext* jsdc,
697
JSDThreadState* jsdthreadstate,
698
JSDStackFrameInfo* jsdframe);
701
jsd_GetThisForStackFrame(JSDContext* jsdc,
702
JSDThreadState* jsdthreadstate,
703
JSDStackFrameInfo* jsdframe);
706
jsd_GetNameForStackFrame(JSDContext* jsdc,
707
JSDThreadState* jsdthreadstate,
708
JSDStackFrameInfo* jsdframe);
710
extern JSDThreadState*
711
jsd_NewThreadState(JSDContext* jsdc, JSContext *cx);
714
jsd_DestroyThreadState(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
717
jsd_EvaluateUCScriptInStackFrame(JSDContext* jsdc,
718
JSDThreadState* jsdthreadstate,
719
JSDStackFrameInfo* jsdframe,
720
const jschar *bytes, uintN length,
721
const char *filename, uintN lineno,
722
JSBool eatExceptions, jsval *rval);
725
jsd_EvaluateScriptInStackFrame(JSDContext* jsdc,
726
JSDThreadState* jsdthreadstate,
727
JSDStackFrameInfo* jsdframe,
728
const char *bytes, uintN length,
729
const char *filename, uintN lineno,
730
JSBool eatExceptions, jsval *rval);
733
jsd_ValToStringInStackFrame(JSDContext* jsdc,
734
JSDThreadState* jsdthreadstate,
735
JSDStackFrameInfo* jsdframe,
739
jsd_IsValidThreadState(JSDContext* jsdc,
740
JSDThreadState* jsdthreadstate);
743
jsd_IsValidFrameInThreadState(JSDContext* jsdc,
744
JSDThreadState* jsdthreadstate,
745
JSDStackFrameInfo* jsdframe);
748
jsd_GetException(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
751
jsd_SetException(JSDContext* jsdc, JSDThreadState* jsdthreadstate,
754
/***************************************************************************/
755
/* Locking support */
757
/* protos are in js_lock.h for:
765
#ifdef JSD_THREADSAFE
767
/* the system-wide lock */
768
extern void* _jsd_global_lock;
771
if(!_jsd_global_lock) \
772
_jsd_global_lock = jsd_CreateLock(); \
773
JS_ASSERT(_jsd_global_lock); \
774
jsd_Lock(_jsd_global_lock); \
777
#define JSD_UNLOCK() \
779
JS_ASSERT(_jsd_global_lock); \
780
jsd_Unlock(_jsd_global_lock); \
783
/* locks for the subsystems of a given context */
784
#define JSD_INIT_LOCKS(jsdc) \
785
( (NULL != (jsdc->scriptsLock = jsd_CreateLock())) && \
786
(NULL != (jsdc->sourceTextLock = jsd_CreateLock())) && \
787
(NULL != (jsdc->atomsLock = jsd_CreateLock())) && \
788
(NULL != (jsdc->objectsLock = jsd_CreateLock())) && \
789
(NULL != (jsdc->threadStatesLock = jsd_CreateLock())) )
791
#define JSD_LOCK_SCRIPTS(jsdc) jsd_Lock(jsdc->scriptsLock)
792
#define JSD_UNLOCK_SCRIPTS(jsdc) jsd_Unlock(jsdc->scriptsLock)
794
#define JSD_LOCK_SOURCE_TEXT(jsdc) jsd_Lock(jsdc->sourceTextLock)
795
#define JSD_UNLOCK_SOURCE_TEXT(jsdc) jsd_Unlock(jsdc->sourceTextLock)
797
#define JSD_LOCK_ATOMS(jsdc) jsd_Lock(jsdc->atomsLock)
798
#define JSD_UNLOCK_ATOMS(jsdc) jsd_Unlock(jsdc->atomsLock)
800
#define JSD_LOCK_OBJECTS(jsdc) jsd_Lock(jsdc->objectsLock)
801
#define JSD_UNLOCK_OBJECTS(jsdc) jsd_Unlock(jsdc->objectsLock)
803
#define JSD_LOCK_THREADSTATES(jsdc) jsd_Lock(jsdc->threadStatesLock)
804
#define JSD_UNLOCK_THREADSTATES(jsdc) jsd_Unlock(jsdc->threadStatesLock)
806
#else /* !JSD_THREADSAFE */
808
#define JSD_LOCK() ((void)0)
809
#define JSD_UNLOCK() ((void)0)
811
#define JSD_INIT_LOCKS(jsdc) 1
813
#define JSD_LOCK_SCRIPTS(jsdc) ((void)0)
814
#define JSD_UNLOCK_SCRIPTS(jsdc) ((void)0)
816
#define JSD_LOCK_SOURCE_TEXT(jsdc) ((void)0)
817
#define JSD_UNLOCK_SOURCE_TEXT(jsdc) ((void)0)
819
#define JSD_LOCK_ATOMS(jsdc) ((void)0)
820
#define JSD_UNLOCK_ATOMS(jsdc) ((void)0)
822
#define JSD_LOCK_OBJECTS(jsdc) ((void)0)
823
#define JSD_UNLOCK_OBJECTS(jsdc) ((void)0)
825
#define JSD_LOCK_THREADSTATES(jsdc) ((void)0)
826
#define JSD_UNLOCK_THREADSTATES(jsdc) ((void)0)
828
#endif /* JSD_THREADSAFE */
830
/* NOTE: These are intended for ASSERTs. Thus we supply checks for both
831
* LOCKED and UNLOCKED (rather that just LOCKED and !LOCKED) so that in
832
* the DEBUG non-Threadsafe case we can have an ASSERT that always succeeds
833
* without having to special case things in the code.
835
#if defined(JSD_THREADSAFE) && defined(DEBUG)
836
#define JSD_SCRIPTS_LOCKED(jsdc) (jsd_IsLocked(jsdc->scriptsLock))
837
#define JSD_SOURCE_TEXT_LOCKED(jsdc) (jsd_IsLocked(jsdc->sourceTextLock))
838
#define JSD_ATOMS_LOCKED(jsdc) (jsd_IsLocked(jsdc->atomsLock))
839
#define JSD_OBJECTS_LOCKED(jsdc) (jsd_IsLocked(jsdc->objectsLock))
840
#define JSD_THREADSTATES_LOCKED(jsdc) (jsd_IsLocked(jsdc->threadStatesLock))
841
#define JSD_SCRIPTS_UNLOCKED(jsdc) (!jsd_IsLocked(jsdc->scriptsLock))
842
#define JSD_SOURCE_TEXT_UNLOCKED(jsdc) (!jsd_IsLocked(jsdc->sourceTextLock))
843
#define JSD_ATOMS_UNLOCKED(jsdc) (!jsd_IsLocked(jsdc->atomsLock))
844
#define JSD_OBJECTS_UNLOCKED(jsdc) (!jsd_IsLocked(jsdc->objectsLock))
845
#define JSD_THREADSTATES_UNLOCKED(jsdc) (!jsd_IsLocked(jsdc->threadStatesLock))
847
#define JSD_SCRIPTS_LOCKED(jsdc) 1
848
#define JSD_SOURCE_TEXT_LOCKED(jsdc) 1
849
#define JSD_ATOMS_LOCKED(jsdc) 1
850
#define JSD_OBJECTS_LOCKED(jsdc) 1
851
#define JSD_THREADSTATES_LOCKED(jsdc) 1
852
#define JSD_SCRIPTS_UNLOCKED(jsdc) 1
853
#define JSD_SOURCE_TEXT_UNLOCKED(jsdc) 1
854
#define JSD_ATOMS_UNLOCKED(jsdc) 1
855
#define JSD_OBJECTS_UNLOCKED(jsdc) 1
856
#define JSD_THREADSTATES_UNLOCKED(jsdc) 1
857
#endif /* defined(JSD_THREADSAFE) && defined(DEBUG) */
859
/***************************************************************************/
860
/* Threading support */
862
#ifdef JSD_THREADSAFE
864
#define JSD_CURRENT_THREAD() jsd_CurrentThread()
866
#else /* !JSD_THREADSAFE */
868
#define JSD_CURRENT_THREAD() ((void*)0)
870
#endif /* JSD_THREADSAFE */
872
/***************************************************************************/
873
/* Dangerous thread support */
875
#ifdef JSD_HAS_DANGEROUS_THREAD
877
#define JSD_IS_DANGEROUS_THREAD(jsdc) \
878
(JSD_CURRENT_THREAD() == jsdc->dangerousThread)
880
#else /* !JSD_HAS_DANGEROUS_THREAD */
882
#define JSD_IS_DANGEROUS_THREAD(jsdc) 0
884
#endif /* JSD_HAS_DANGEROUS_THREAD */
886
/***************************************************************************/
887
/* Value and Property Functions */
890
jsd_NewValue(JSDContext* jsdc, jsval val);
893
jsd_DropValue(JSDContext* jsdc, JSDValue* jsdval);
896
jsd_GetValueWrappedJSVal(JSDContext* jsdc, JSDValue* jsdval);
899
jsd_RefreshValue(JSDContext* jsdc, JSDValue* jsdval);
901
/**************************************************/
904
jsd_IsValueObject(JSDContext* jsdc, JSDValue* jsdval);
907
jsd_IsValueNumber(JSDContext* jsdc, JSDValue* jsdval);
910
jsd_IsValueInt(JSDContext* jsdc, JSDValue* jsdval);
913
jsd_IsValueDouble(JSDContext* jsdc, JSDValue* jsdval);
916
jsd_IsValueString(JSDContext* jsdc, JSDValue* jsdval);
919
jsd_IsValueBoolean(JSDContext* jsdc, JSDValue* jsdval);
922
jsd_IsValueNull(JSDContext* jsdc, JSDValue* jsdval);
925
jsd_IsValueVoid(JSDContext* jsdc, JSDValue* jsdval);
928
jsd_IsValuePrimitive(JSDContext* jsdc, JSDValue* jsdval);
931
jsd_IsValueFunction(JSDContext* jsdc, JSDValue* jsdval);
934
jsd_IsValueNative(JSDContext* jsdc, JSDValue* jsdval);
936
/**************************************************/
939
jsd_GetValueBoolean(JSDContext* jsdc, JSDValue* jsdval);
942
jsd_GetValueInt(JSDContext* jsdc, JSDValue* jsdval);
945
jsd_GetValueDouble(JSDContext* jsdc, JSDValue* jsdval);
948
jsd_GetValueString(JSDContext* jsdc, JSDValue* jsdval);
951
jsd_GetValueFunctionName(JSDContext* jsdc, JSDValue* jsdval);
953
/**************************************************/
956
jsd_GetCountOfProperties(JSDContext* jsdc, JSDValue* jsdval);
959
jsd_IterateProperties(JSDContext* jsdc, JSDValue* jsdval, JSDProperty **iterp);
962
jsd_GetValueProperty(JSDContext* jsdc, JSDValue* jsdval, JSString* name);
965
jsd_GetValuePrototype(JSDContext* jsdc, JSDValue* jsdval);
968
jsd_GetValueParent(JSDContext* jsdc, JSDValue* jsdval);
971
jsd_GetValueConstructor(JSDContext* jsdc, JSDValue* jsdval);
974
jsd_GetValueClassName(JSDContext* jsdc, JSDValue* jsdval);
976
/**************************************************/
979
jsd_DropProperty(JSDContext* jsdc, JSDProperty* jsdprop);
982
jsd_GetPropertyName(JSDContext* jsdc, JSDProperty* jsdprop);
985
jsd_GetPropertyValue(JSDContext* jsdc, JSDProperty* jsdprop);
988
jsd_GetPropertyAlias(JSDContext* jsdc, JSDProperty* jsdprop);
991
jsd_GetPropertyFlags(JSDContext* jsdc, JSDProperty* jsdprop);
994
jsd_GetPropertyVarArgSlot(JSDContext* jsdc, JSDProperty* jsdprop);
996
/**************************************************/
997
/* Stepping Functions */
999
extern void * JS_DLL_CALLBACK
1000
jsd_FunctionCallHook(JSContext *cx, JSStackFrame *fp, JSBool before,
1001
JSBool *ok, void *closure);
1003
extern void * JS_DLL_CALLBACK
1004
jsd_TopLevelCallHook(JSContext *cx, JSStackFrame *fp, JSBool before,
1005
JSBool *ok, void *closure);
1007
/**************************************************/
1008
/* Object Functions */
1011
jsd_InitObjectManager(JSDContext* jsdc);
1014
jsd_DestroyObjectManager(JSDContext* jsdc);
1016
extern void JS_DLL_CALLBACK
1017
jsd_ObjectHook(JSContext *cx, JSObject *obj, JSBool isNew, void *closure);
1020
jsd_Constructing(JSDContext* jsdc, JSContext *cx, JSObject *obj,
1024
jsd_IterateObjects(JSDContext* jsdc, JSDObject** iterp);
1027
jsd_GetWrappedObject(JSDContext* jsdc, JSDObject* jsdobj);
1030
jsd_GetObjectNewURL(JSDContext* jsdc, JSDObject* jsdobj);
1033
jsd_GetObjectNewLineNumber(JSDContext* jsdc, JSDObject* jsdobj);
1036
jsd_GetObjectConstructorURL(JSDContext* jsdc, JSDObject* jsdobj);
1039
jsd_GetObjectConstructorLineNumber(JSDContext* jsdc, JSDObject* jsdobj);
1042
jsd_GetObjectConstructorName(JSDContext* jsdc, JSDObject* jsdobj);
1045
jsd_GetJSDObjectForJSObject(JSDContext* jsdc, JSObject* jsobj);
1048
jsd_GetObjectForValue(JSDContext* jsdc, JSDValue* jsdval);
1051
* returns new refcounted JSDValue
1054
jsd_GetValueForObject(JSDContext* jsdc, JSDObject* jsdobj);
1056
/**************************************************/
1057
/* Atom Functions */
1060
jsd_CreateAtomTable(JSDContext* jsdc);
1063
jsd_DestroyAtomTable(JSDContext* jsdc);
1066
jsd_AddAtom(JSDContext* jsdc, const char* str);
1069
jsd_CloneAtom(JSDContext* jsdc, JSDAtom* atom);
1072
jsd_DropAtom(JSDContext* jsdc, JSDAtom* atom);
1074
#define JSD_ATOM_TO_STRING(a) ((const char*)((a)->str))
1076
/***************************************************************************/
1077
/* Livewire specific API */
1081
jsdlw_GetLWScript(JSDContext* jsdc, JSDScript* jsdscript);
1084
jsdlw_BuildAppRelativeFilename(LWDBGApp* app, const char* filename);
1086
extern JSDSourceText*
1087
jsdlw_PreLoadSource(JSDContext* jsdc, LWDBGApp* app,
1088
const char* filename, JSBool clear);
1090
extern JSDSourceText*
1091
jsdlw_ForceLoadSource(JSDContext* jsdc, JSDSourceText* jsdsrc);
1094
jsdlw_UserCodeAtPC(JSDContext* jsdc, JSDScript* jsdscript, jsuword pc);
1097
jsdlw_RawToProcessedLineNumber(JSDContext* jsdc, JSDScript* jsdscript,
1098
uintN lineIn, uintN* lineOut);
1101
jsdlw_ProcessedToRawLineNumber(JSDContext* jsdc, JSDScript* jsdscript,
1102
uintN lineIn, uintN* lineOut);
1106
/* our hook proc for LiveWire app start/stop */
1107
extern void JS_DLL_CALLBACK
1108
jsdlw_AppHookProc(LWDBGApp* app,
1115
/***************************************************************************/
1119
#endif /* jsd_h___ */