1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
* License, v. 2.0. If a copy of the MPL was not distributed with this
4
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7
* Header for JavaScript Debugging support - Internal ONLY declarations
14
* NOTE: This is a *private* header file and should only be included by
15
* the sources in js/jsd. Defining EXPORT_JSD_API in an outside module
16
* using jsd would be bad.
18
#define EXPORT_JSD_API 1 /* if used, must be set before include of jsdebug.h */
21
* These can be controled by the makefile, but this allows a place to set
22
* the values always used in the mozilla client, but perhaps done differently
23
* in other embeddings.
26
#define JSD_THREADSAFE 1
27
/* define JSD_HAS_DANGEROUS_THREAD 1 */
28
#define JSD_USE_NSPR_LOCKS 1
29
#endif /* MOZILLA_CLIENT */
32
/* Get jstypes.h included first. After that we can use PR macros for doing
33
* this extern "C" stuff!
46
#include "jsutil.h" /* Added by JSIFY */
47
#include "jshash.h" /* Added by JSIFY */
59
#include <base/pblock.h>
60
#include <base/session.h>
61
#include <frame/log.h>
62
#include <frame/req.h>
68
#define JSD_MAJOR_VERSION 1
69
#define JSD_MINOR_VERSION 1
71
/***************************************************************************/
74
#define CHECK_BIT_FLAG(f,b) ((f)&(b))
76
#define SET_BIT_FLAG(f,b) ((f)|=(b))
78
#define CLEAR_BIT_FLAG(f,b) ((f)&=(~(b)))
80
#define JSD_IS_DEBUG_ENABLED(jsdc,jsdscript) \
81
(!(((jsdc->flags & JSD_DEBUG_WHEN_SET) ? 1 : 0) ^ \
82
((jsdscript->flags & JSD_SCRIPT_DEBUG_BIT) ? 1 : 0)))
83
#define JSD_IS_PROFILE_ENABLED(jsdc,jsdscript) \
84
((jsdc->flags & JSD_COLLECT_PROFILE_DATA) && \
85
(!(((jsdc->flags & JSD_PROFILE_WHEN_SET) ? 1 : 0) ^ \
86
((jsdscript->flags & JSD_SCRIPT_PROFILE_BIT) ? 1 : 0))))
89
/***************************************************************************/
90
/* These are not exposed in jsdebug.h - typedef here for consistency */
92
typedef struct JSDExecHook JSDExecHook;
93
typedef struct JSDAtom JSDAtom;
94
typedef struct JSDProfileData JSDProfileData;
95
/***************************************************************************/
99
* XXX What I'm calling a JSDContext is really more of a JSDTaskState.
104
JSCList links; /* we are part of a JSCList */
108
JSD_ScriptHookProc scriptHook;
109
void* scriptHookData;
110
JSD_ExecutionHookProc interruptHook;
111
void* interruptHookData;
113
JSD_ErrorReporter errorReporter;
114
void* errorReporterData;
115
JSCList threadsStates;
116
JSD_ExecutionHookProc debugBreakHook;
117
void* debugBreakHookData;
118
JSD_ExecutionHookProc debuggerHook;
119
void* debuggerHookData;
120
JSD_ExecutionHookProc throwHook;
122
JSD_CallHookProc functionHook;
123
void* functionHookData;
124
JSD_CallHookProc toplevelHook;
125
void* toplevelHookData;
126
JSContext* dumbContext;
128
JSD_UserCallbacks userCallbacks;
131
JSHashTable* scriptsTable;
133
JSCList removedSources;
134
unsigned sourceAlterCount;
137
JSHashTable* objectsTable;
138
JSDProfileData* callingFunctionPData;
139
int64_t lastReturnTime;
140
#ifdef JSD_THREADSAFE
142
void* sourceTextLock;
145
void* threadStatesLock;
146
#endif /* JSD_THREADSAFE */
147
#ifdef JSD_HAS_DANGEROUS_THREAD
148
void* dangerousThread;
149
#endif /* JSD_HAS_DANGEROUS_THREAD */
155
JSCList links; /* we are part of a JSCList */
156
JSDContext* jsdc; /* JSDContext for this jsdscript */
157
JSScript* script; /* script we are wrapping */
158
unsigned lineBase; /* we cache this */
159
unsigned lineExtent; /* we cache this */
160
JSCList hooks; /* JSCList of JSDExecHooks for this script */
165
JSDProfileData *profileData;
169
LWDBGScript* lwscript;
173
struct JSDProfileData
175
JSDProfileData* caller;
176
int64_t lastCallStart;
179
unsigned recurseDepth;
180
unsigned maxRecurseDepth;
181
double minExecutionTime;
182
double maxExecutionTime;
183
double totalExecutionTime;
184
double minOwnExecutionTime;
185
double maxOwnExecutionTime;
186
double totalOwnExecutionTime;
191
JSCList links; /* we are part of a JSCList */
197
JSDSourceStatus status;
204
JSCList links; /* we are part of a JSCList */
205
JSDScript* jsdscript;
207
JSD_ExecutionHookProc hook;
211
#define TS_HAS_DISABLED_FRAME 0x01
213
struct JSDThreadState
215
JSCList links; /* we are part of a JSCList */
223
struct JSDStackFrameInfo
225
JSCList links; /* we are part of a JSCList */
226
JSDThreadState* jsdthreadstate;
227
JSDScript* jsdscript;
232
#define GOT_PROTO ((short) (1 << 0))
233
#define GOT_PROPS ((short) (1 << 1))
234
#define GOT_PARENT ((short) (1 << 2))
235
#define GOT_CTOR ((short) (1 << 3))
244
const char* className;
253
JSCList links; /* we are part of a JSCList */
263
char* str; /* must be first element in struct for compare */
269
JSCList links; /* we are part of a JSCList */
278
/***************************************************************************/
279
/* Code validation support */
282
extern void JSD_ASSERT_VALID_CONTEXT(JSDContext* jsdc);
283
extern void JSD_ASSERT_VALID_SCRIPT(JSDScript* jsdscript);
284
extern void JSD_ASSERT_VALID_SOURCE_TEXT(JSDSourceText* jsdsrc);
285
extern void JSD_ASSERT_VALID_THREAD_STATE(JSDThreadState* jsdthreadstate);
286
extern void JSD_ASSERT_VALID_STACK_FRAME(JSDStackFrameInfo* jsdframe);
287
extern void JSD_ASSERT_VALID_EXEC_HOOK(JSDExecHook* jsdhook);
288
extern void JSD_ASSERT_VALID_VALUE(JSDValue* jsdval);
289
extern void JSD_ASSERT_VALID_PROPERTY(JSDProperty* jsdprop);
290
extern void JSD_ASSERT_VALID_OBJECT(JSDObject* jsdobj);
292
#define JSD_ASSERT_VALID_CONTEXT(x) ((void)0)
293
#define JSD_ASSERT_VALID_SCRIPT(x) ((void)0)
294
#define JSD_ASSERT_VALID_SOURCE_TEXT(x) ((void)0)
295
#define JSD_ASSERT_VALID_THREAD_STATE(x)((void)0)
296
#define JSD_ASSERT_VALID_STACK_FRAME(x) ((void)0)
297
#define JSD_ASSERT_VALID_EXEC_HOOK(x) ((void)0)
298
#define JSD_ASSERT_VALID_VALUE(x) ((void)0)
299
#define JSD_ASSERT_VALID_PROPERTY(x) ((void)0)
300
#define JSD_ASSERT_VALID_OBJECT(x) ((void)0)
303
/***************************************************************************/
304
/* higher level functions */
307
jsd_DebuggerOnForUser(JSRuntime* jsrt,
308
JSD_UserCallbacks* callbacks,
313
jsd_DebuggerOn(void);
316
jsd_DebuggerOff(JSDContext* jsdc);
319
jsd_DebuggerPause(JSDContext* jsdc, JSBool forceAllHooksOff);
322
jsd_DebuggerUnpause(JSDContext* jsdc);
325
jsd_SetUserCallbacks(JSRuntime* jsrt, JSD_UserCallbacks* callbacks, void* user);
328
jsd_JSDContextForJSContext(JSContext* context);
331
jsd_SetContextPrivate(JSDContext* jsdc, void *data);
334
jsd_GetContextPrivate(JSDContext* jsdc);
337
jsd_ClearAllProfileData(JSDContext* jsdc);
340
jsd_SetErrorReporter(JSDContext* jsdc,
341
JSD_ErrorReporter reporter,
345
jsd_GetErrorReporter(JSDContext* jsdc,
346
JSD_ErrorReporter* reporter,
349
/***************************************************************************/
350
/* Script functions */
353
jsd_InitScriptManager(JSDContext *jsdc);
356
jsd_DestroyScriptManager(JSDContext* jsdc);
359
jsd_FindJSDScript(JSDContext* jsdc,
363
jsd_FindOrCreateJSDScript(JSDContext *jsdc,
368
extern JSDProfileData*
369
jsd_GetScriptProfileData(JSDContext* jsdc, JSDScript *script);
372
jsd_GetScriptFlags(JSDContext *jsdc, JSDScript *script);
375
jsd_SetScriptFlags(JSDContext *jsdc, JSDScript *script, uint32_t flags);
378
jsd_GetScriptCallCount(JSDContext* jsdc, JSDScript *script);
381
jsd_GetScriptMaxRecurseDepth(JSDContext* jsdc, JSDScript *script);
384
jsd_GetScriptMinExecutionTime(JSDContext* jsdc, JSDScript *script);
387
jsd_GetScriptMaxExecutionTime(JSDContext* jsdc, JSDScript *script);
390
jsd_GetScriptTotalExecutionTime(JSDContext* jsdc, JSDScript *script);
393
jsd_GetScriptMinOwnExecutionTime(JSDContext* jsdc, JSDScript *script);
396
jsd_GetScriptMaxOwnExecutionTime(JSDContext* jsdc, JSDScript *script);
399
jsd_GetScriptTotalOwnExecutionTime(JSDContext* jsdc, JSDScript *script);
402
jsd_ClearScriptProfileData(JSDContext* jsdc, JSDScript *script);
405
jsd_GetJSScript (JSDContext *jsdc, JSDScript *script);
408
jsd_GetJSFunction (JSDContext *jsdc, JSDScript *script);
411
jsd_IterateScripts(JSDContext* jsdc, JSDScript **iterp);
414
jsd_SetScriptPrivate (JSDScript *jsdscript, void *data);
417
jsd_GetScriptPrivate (JSDScript *jsdscript);
420
jsd_IsActiveScript(JSDContext* jsdc, JSDScript *jsdscript);
423
jsd_GetScriptFilename(JSDContext* jsdc, JSDScript *jsdscript);
426
jsd_GetScriptFunctionId(JSDContext* jsdc, JSDScript *jsdscript);
429
jsd_GetScriptBaseLineNumber(JSDContext* jsdc, JSDScript *jsdscript);
432
jsd_GetScriptLineExtent(JSDContext* jsdc, JSDScript *jsdscript);
435
jsd_SetScriptHook(JSDContext* jsdc, JSD_ScriptHookProc hook, void* callerdata);
438
jsd_GetScriptHook(JSDContext* jsdc, JSD_ScriptHookProc* hook, void** callerdata);
441
jsd_GetClosestPC(JSDContext* jsdc, JSDScript* jsdscript, unsigned line);
444
jsd_GetClosestLine(JSDContext* jsdc, JSDScript* jsdscript, uintptr_t pc);
447
jsd_GetLinePCs(JSDContext* jsdc, JSDScript* jsdscript,
448
unsigned startLine, unsigned maxLines,
449
unsigned* count, unsigned** lines, uintptr_t** pcs);
452
jsd_NewScriptHookProc(
454
const char *filename, /* URL this script loads from */
455
unsigned lineno, /* line where this script starts */
461
jsd_DestroyScriptHookProc(
466
/* Script execution hook functions */
469
jsd_SetExecutionHook(JSDContext* jsdc,
470
JSDScript* jsdscript,
472
JSD_ExecutionHookProc hook,
476
jsd_ClearExecutionHook(JSDContext* jsdc,
477
JSDScript* jsdscript,
481
jsd_ClearAllExecutionHooksForScript(JSDContext* jsdc, JSDScript* jsdscript);
484
jsd_ClearAllExecutionHooks(JSDContext* jsdc);
487
jsd_ScriptCreated(JSDContext* jsdc,
489
const char *filename, /* URL this script loads from */
490
unsigned lineno, /* line where this script starts */
495
jsd_ScriptDestroyed(JSDContext* jsdc,
499
/***************************************************************************/
500
/* Source Text functions */
502
extern JSDSourceText*
503
jsd_IterateSources(JSDContext* jsdc, JSDSourceText **iterp);
505
extern JSDSourceText*
506
jsd_FindSourceForURL(JSDContext* jsdc, const char* url);
509
jsd_GetSourceURL(JSDContext* jsdc, JSDSourceText* jsdsrc);
512
jsd_GetSourceText(JSDContext* jsdc, JSDSourceText* jsdsrc,
513
const char** ppBuf, int* pLen);
516
jsd_ClearSourceText(JSDContext* jsdc, JSDSourceText* jsdsrc);
518
extern JSDSourceStatus
519
jsd_GetSourceStatus(JSDContext* jsdc, JSDSourceText* jsdsrc);
522
jsd_IsSourceDirty(JSDContext* jsdc, JSDSourceText* jsdsrc);
525
jsd_SetSourceDirty(JSDContext* jsdc, JSDSourceText* jsdsrc, JSBool dirty);
528
jsd_GetSourceAlterCount(JSDContext* jsdc, JSDSourceText* jsdsrc);
531
jsd_IncrementSourceAlterCount(JSDContext* jsdc, JSDSourceText* jsdsrc);
533
extern JSDSourceText*
534
jsd_NewSourceText(JSDContext* jsdc, const char* url);
536
extern JSDSourceText*
537
jsd_AppendSourceText(JSDContext* jsdc,
538
JSDSourceText* jsdsrc,
539
const char* text, /* *not* zero terminated */
541
JSDSourceStatus status);
543
extern JSDSourceText*
544
jsd_AppendUCSourceText(JSDContext* jsdc,
545
JSDSourceText* jsdsrc,
546
const jschar* text, /* *not* zero terminated */
548
JSDSourceStatus status);
550
/* convienence function for adding complete source of url in one call */
552
jsd_AddFullSourceText(JSDContext* jsdc,
553
const char* text, /* *not* zero terminated */
558
jsd_DestroyAllSources(JSDContext* jsdc);
561
jsd_BuildNormalizedURL(const char* url_string);
564
jsd_StartingEvalUsingFilename(JSDContext* jsdc, const char* url);
567
jsd_FinishedEvalUsingFilename(JSDContext* jsdc, const char* url);
569
/***************************************************************************/
570
/* Interrupt Hook functions */
573
jsd_SetInterruptHook(JSDContext* jsdc,
574
JSD_ExecutionHookProc hook,
578
jsd_ClearInterruptHook(JSDContext* jsdc);
581
jsd_EnableSingleStepInterrupts(JSDContext* jsdc,
582
JSDScript* jsdscript,
586
jsd_SetDebugBreakHook(JSDContext* jsdc,
587
JSD_ExecutionHookProc hook,
591
jsd_ClearDebugBreakHook(JSDContext* jsdc);
594
jsd_SetDebuggerHook(JSDContext* jsdc,
595
JSD_ExecutionHookProc hook,
599
jsd_ClearDebuggerHook(JSDContext* jsdc);
602
jsd_CallExecutionHook(JSDContext* jsdc,
605
JSD_ExecutionHookProc hook,
610
jsd_CallCallHook (JSDContext* jsdc,
613
JSD_CallHookProc hook,
617
jsd_SetThrowHook(JSDContext* jsdc,
618
JSD_ExecutionHookProc hook,
621
jsd_ClearThrowHook(JSDContext* jsdc);
624
jsd_DebuggerHandler(JSContext *cx, JSScript *script, jsbytecode *pc,
625
jsval *rval, void *closure);
628
jsd_ThrowHandler(JSContext *cx, JSScript *script, jsbytecode *pc,
629
jsval *rval, void *closure);
632
jsd_SetFunctionHook(JSDContext* jsdc,
633
JSD_CallHookProc hook,
637
jsd_ClearFunctionHook(JSDContext* jsdc);
640
jsd_SetTopLevelHook(JSDContext* jsdc,
641
JSD_CallHookProc hook,
645
jsd_ClearTopLevelHook(JSDContext* jsdc);
647
/***************************************************************************/
648
/* Stack Frame functions */
651
jsd_GetCountOfStackFrames(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
653
extern JSDStackFrameInfo*
654
jsd_GetStackFrame(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
657
jsd_GetJSContext(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
659
extern JSDStackFrameInfo*
660
jsd_GetCallingStackFrame(JSDContext* jsdc,
661
JSDThreadState* jsdthreadstate,
662
JSDStackFrameInfo* jsdframe);
665
jsd_GetScriptForStackFrame(JSDContext* jsdc,
666
JSDThreadState* jsdthreadstate,
667
JSDStackFrameInfo* jsdframe);
670
jsd_GetPCForStackFrame(JSDContext* jsdc,
671
JSDThreadState* jsdthreadstate,
672
JSDStackFrameInfo* jsdframe);
675
jsd_GetCallObjectForStackFrame(JSDContext* jsdc,
676
JSDThreadState* jsdthreadstate,
677
JSDStackFrameInfo* jsdframe);
680
jsd_GetScopeChainForStackFrame(JSDContext* jsdc,
681
JSDThreadState* jsdthreadstate,
682
JSDStackFrameInfo* jsdframe);
685
jsd_IsStackFrameDebugger(JSDContext* jsdc,
686
JSDThreadState* jsdthreadstate,
687
JSDStackFrameInfo* jsdframe);
690
jsd_IsStackFrameConstructing(JSDContext* jsdc,
691
JSDThreadState* jsdthreadstate,
692
JSDStackFrameInfo* jsdframe);
695
jsd_GetThisForStackFrame(JSDContext* jsdc,
696
JSDThreadState* jsdthreadstate,
697
JSDStackFrameInfo* jsdframe);
700
jsd_GetIdForStackFrame(JSDContext* jsdc,
701
JSDThreadState* jsdthreadstate,
702
JSDStackFrameInfo* jsdframe);
704
extern JSDThreadState*
705
jsd_NewThreadState(JSDContext* jsdc, JSContext *cx);
708
jsd_DestroyThreadState(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
711
jsd_EvaluateUCScriptInStackFrame(JSDContext* jsdc,
712
JSDThreadState* jsdthreadstate,
713
JSDStackFrameInfo* jsdframe,
714
const jschar *bytes, unsigned length,
715
const char *filename, unsigned lineno,
716
JSBool eatExceptions, jsval *rval);
719
jsd_EvaluateScriptInStackFrame(JSDContext* jsdc,
720
JSDThreadState* jsdthreadstate,
721
JSDStackFrameInfo* jsdframe,
722
const char *bytes, unsigned length,
723
const char *filename, unsigned lineno,
724
JSBool eatExceptions, jsval *rval);
727
jsd_ValToStringInStackFrame(JSDContext* jsdc,
728
JSDThreadState* jsdthreadstate,
729
JSDStackFrameInfo* jsdframe,
733
jsd_IsValidThreadState(JSDContext* jsdc,
734
JSDThreadState* jsdthreadstate);
737
jsd_IsValidFrameInThreadState(JSDContext* jsdc,
738
JSDThreadState* jsdthreadstate,
739
JSDStackFrameInfo* jsdframe);
742
jsd_GetException(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
745
jsd_SetException(JSDContext* jsdc, JSDThreadState* jsdthreadstate,
748
/***************************************************************************/
749
/* Locking support */
751
/* protos are in js_lock.h for:
759
#ifdef JSD_THREADSAFE
761
/* the system-wide lock */
762
extern void* _jsd_global_lock;
765
if(!_jsd_global_lock) \
766
_jsd_global_lock = jsd_CreateLock(); \
767
JS_ASSERT(_jsd_global_lock); \
768
jsd_Lock(_jsd_global_lock); \
771
#define JSD_UNLOCK() \
773
JS_ASSERT(_jsd_global_lock); \
774
jsd_Unlock(_jsd_global_lock); \
777
/* locks for the subsystems of a given context */
778
#define JSD_INIT_LOCKS(jsdc) \
779
( (NULL != (jsdc->scriptsLock = jsd_CreateLock())) && \
780
(NULL != (jsdc->sourceTextLock = jsd_CreateLock())) && \
781
(NULL != (jsdc->atomsLock = jsd_CreateLock())) && \
782
(NULL != (jsdc->objectsLock = jsd_CreateLock())) && \
783
(NULL != (jsdc->threadStatesLock = jsd_CreateLock())) )
785
#define JSD_LOCK_SCRIPTS(jsdc) jsd_Lock(jsdc->scriptsLock)
786
#define JSD_UNLOCK_SCRIPTS(jsdc) jsd_Unlock(jsdc->scriptsLock)
788
#define JSD_LOCK_SOURCE_TEXT(jsdc) jsd_Lock(jsdc->sourceTextLock)
789
#define JSD_UNLOCK_SOURCE_TEXT(jsdc) jsd_Unlock(jsdc->sourceTextLock)
791
#define JSD_LOCK_ATOMS(jsdc) jsd_Lock(jsdc->atomsLock)
792
#define JSD_UNLOCK_ATOMS(jsdc) jsd_Unlock(jsdc->atomsLock)
794
#define JSD_LOCK_OBJECTS(jsdc) jsd_Lock(jsdc->objectsLock)
795
#define JSD_UNLOCK_OBJECTS(jsdc) jsd_Unlock(jsdc->objectsLock)
797
#define JSD_LOCK_THREADSTATES(jsdc) jsd_Lock(jsdc->threadStatesLock)
798
#define JSD_UNLOCK_THREADSTATES(jsdc) jsd_Unlock(jsdc->threadStatesLock)
800
#else /* !JSD_THREADSAFE */
802
#define JSD_LOCK() ((void)0)
803
#define JSD_UNLOCK() ((void)0)
805
#define JSD_INIT_LOCKS(jsdc) 1
807
#define JSD_LOCK_SCRIPTS(jsdc) ((void)0)
808
#define JSD_UNLOCK_SCRIPTS(jsdc) ((void)0)
810
#define JSD_LOCK_SOURCE_TEXT(jsdc) ((void)0)
811
#define JSD_UNLOCK_SOURCE_TEXT(jsdc) ((void)0)
813
#define JSD_LOCK_ATOMS(jsdc) ((void)0)
814
#define JSD_UNLOCK_ATOMS(jsdc) ((void)0)
816
#define JSD_LOCK_OBJECTS(jsdc) ((void)0)
817
#define JSD_UNLOCK_OBJECTS(jsdc) ((void)0)
819
#define JSD_LOCK_THREADSTATES(jsdc) ((void)0)
820
#define JSD_UNLOCK_THREADSTATES(jsdc) ((void)0)
822
#endif /* JSD_THREADSAFE */
824
/* NOTE: These are intended for ASSERTs. Thus we supply checks for both
825
* LOCKED and UNLOCKED (rather that just LOCKED and !LOCKED) so that in
826
* the DEBUG non-Threadsafe case we can have an ASSERT that always succeeds
827
* without having to special case things in the code.
829
#if defined(JSD_THREADSAFE) && defined(DEBUG)
830
#define JSD_SCRIPTS_LOCKED(jsdc) (jsd_IsLocked(jsdc->scriptsLock))
831
#define JSD_SOURCE_TEXT_LOCKED(jsdc) (jsd_IsLocked(jsdc->sourceTextLock))
832
#define JSD_ATOMS_LOCKED(jsdc) (jsd_IsLocked(jsdc->atomsLock))
833
#define JSD_OBJECTS_LOCKED(jsdc) (jsd_IsLocked(jsdc->objectsLock))
834
#define JSD_THREADSTATES_LOCKED(jsdc) (jsd_IsLocked(jsdc->threadStatesLock))
835
#define JSD_SCRIPTS_UNLOCKED(jsdc) (!jsd_IsLocked(jsdc->scriptsLock))
836
#define JSD_SOURCE_TEXT_UNLOCKED(jsdc) (!jsd_IsLocked(jsdc->sourceTextLock))
837
#define JSD_ATOMS_UNLOCKED(jsdc) (!jsd_IsLocked(jsdc->atomsLock))
838
#define JSD_OBJECTS_UNLOCKED(jsdc) (!jsd_IsLocked(jsdc->objectsLock))
839
#define JSD_THREADSTATES_UNLOCKED(jsdc) (!jsd_IsLocked(jsdc->threadStatesLock))
841
#define JSD_SCRIPTS_LOCKED(jsdc) 1
842
#define JSD_SOURCE_TEXT_LOCKED(jsdc) 1
843
#define JSD_ATOMS_LOCKED(jsdc) 1
844
#define JSD_OBJECTS_LOCKED(jsdc) 1
845
#define JSD_THREADSTATES_LOCKED(jsdc) 1
846
#define JSD_SCRIPTS_UNLOCKED(jsdc) 1
847
#define JSD_SOURCE_TEXT_UNLOCKED(jsdc) 1
848
#define JSD_ATOMS_UNLOCKED(jsdc) 1
849
#define JSD_OBJECTS_UNLOCKED(jsdc) 1
850
#define JSD_THREADSTATES_UNLOCKED(jsdc) 1
851
#endif /* defined(JSD_THREADSAFE) && defined(DEBUG) */
853
/***************************************************************************/
854
/* Threading support */
856
#ifdef JSD_THREADSAFE
858
#define JSD_CURRENT_THREAD() jsd_CurrentThread()
860
#else /* !JSD_THREADSAFE */
862
#define JSD_CURRENT_THREAD() ((void*)0)
864
#endif /* JSD_THREADSAFE */
866
/***************************************************************************/
867
/* Dangerous thread support */
869
#ifdef JSD_HAS_DANGEROUS_THREAD
871
#define JSD_IS_DANGEROUS_THREAD(jsdc) \
872
(JSD_CURRENT_THREAD() == jsdc->dangerousThread)
874
#else /* !JSD_HAS_DANGEROUS_THREAD */
876
#define JSD_IS_DANGEROUS_THREAD(jsdc) 0
878
#endif /* JSD_HAS_DANGEROUS_THREAD */
880
/***************************************************************************/
881
/* Value and Property Functions */
884
jsd_NewValue(JSDContext* jsdc, jsval val);
887
jsd_DropValue(JSDContext* jsdc, JSDValue* jsdval);
890
jsd_GetValueWrappedJSVal(JSDContext* jsdc, JSDValue* jsdval);
893
jsd_RefreshValue(JSDContext* jsdc, JSDValue* jsdval);
895
/**************************************************/
898
jsd_IsValueObject(JSDContext* jsdc, JSDValue* jsdval);
901
jsd_IsValueNumber(JSDContext* jsdc, JSDValue* jsdval);
904
jsd_IsValueInt(JSDContext* jsdc, JSDValue* jsdval);
907
jsd_IsValueDouble(JSDContext* jsdc, JSDValue* jsdval);
910
jsd_IsValueString(JSDContext* jsdc, JSDValue* jsdval);
913
jsd_IsValueBoolean(JSDContext* jsdc, JSDValue* jsdval);
916
jsd_IsValueNull(JSDContext* jsdc, JSDValue* jsdval);
919
jsd_IsValueVoid(JSDContext* jsdc, JSDValue* jsdval);
922
jsd_IsValuePrimitive(JSDContext* jsdc, JSDValue* jsdval);
925
jsd_IsValueFunction(JSDContext* jsdc, JSDValue* jsdval);
928
jsd_IsValueNative(JSDContext* jsdc, JSDValue* jsdval);
930
/**************************************************/
933
jsd_GetValueBoolean(JSDContext* jsdc, JSDValue* jsdval);
936
jsd_GetValueInt(JSDContext* jsdc, JSDValue* jsdval);
939
jsd_GetValueDouble(JSDContext* jsdc, JSDValue* jsdval);
942
jsd_GetValueString(JSDContext* jsdc, JSDValue* jsdval);
945
jsd_GetValueFunctionId(JSDContext* jsdc, JSDValue* jsdval);
948
jsd_GetValueFunction(JSDContext* jsdc, JSDValue* jsdval);
950
/**************************************************/
953
jsd_GetCountOfProperties(JSDContext* jsdc, JSDValue* jsdval);
956
jsd_IterateProperties(JSDContext* jsdc, JSDValue* jsdval, JSDProperty **iterp);
959
jsd_GetValueProperty(JSDContext* jsdc, JSDValue* jsdval, JSString* name);
962
jsd_GetValuePrototype(JSDContext* jsdc, JSDValue* jsdval);
965
jsd_GetValueParent(JSDContext* jsdc, JSDValue* jsdval);
968
jsd_GetValueConstructor(JSDContext* jsdc, JSDValue* jsdval);
971
jsd_GetValueClassName(JSDContext* jsdc, JSDValue* jsdval);
974
jsd_GetScriptForValue(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);
993
/**************************************************/
994
/* Stepping Functions */
997
jsd_FunctionCallHook(JSContext *cx, JSStackFrame *fp, JSBool before,
998
JSBool *ok, void *closure);
1001
jsd_TopLevelCallHook(JSContext *cx, JSStackFrame *fp, JSBool before,
1002
JSBool *ok, void *closure);
1004
/**************************************************/
1005
/* Object Functions */
1008
jsd_InitObjectManager(JSDContext* jsdc);
1011
jsd_DestroyObjectManager(JSDContext* jsdc);
1014
jsd_DestroyObjects(JSDContext* jsdc);
1017
jsd_Constructing(JSDContext* jsdc, JSContext *cx, JSObject *obj,
1021
jsd_IterateObjects(JSDContext* jsdc, JSDObject** iterp);
1024
jsd_GetWrappedObject(JSDContext* jsdc, JSDObject* jsdobj);
1027
jsd_GetObjectNewURL(JSDContext* jsdc, JSDObject* jsdobj);
1030
jsd_GetObjectNewLineNumber(JSDContext* jsdc, JSDObject* jsdobj);
1033
jsd_GetObjectConstructorURL(JSDContext* jsdc, JSDObject* jsdobj);
1036
jsd_GetObjectConstructorLineNumber(JSDContext* jsdc, JSDObject* jsdobj);
1039
jsd_GetObjectConstructorName(JSDContext* jsdc, JSDObject* jsdobj);
1042
jsd_GetJSDObjectForJSObject(JSDContext* jsdc, JSObject* jsobj);
1045
jsd_GetObjectForValue(JSDContext* jsdc, JSDValue* jsdval);
1048
* returns new refcounted JSDValue
1051
jsd_GetValueForObject(JSDContext* jsdc, JSDObject* jsdobj);
1053
/**************************************************/
1054
/* Atom Functions */
1057
jsd_CreateAtomTable(JSDContext* jsdc);
1060
jsd_DestroyAtomTable(JSDContext* jsdc);
1063
jsd_AddAtom(JSDContext* jsdc, const char* str);
1066
jsd_CloneAtom(JSDContext* jsdc, JSDAtom* atom);
1069
jsd_DropAtom(JSDContext* jsdc, JSDAtom* atom);
1071
#define JSD_ATOM_TO_STRING(a) ((const char*)((a)->str))
1073
/***************************************************************************/
1074
/* Livewire specific API */
1078
jsdlw_GetLWScript(JSDContext* jsdc, JSDScript* jsdscript);
1081
jsdlw_BuildAppRelativeFilename(LWDBGApp* app, const char* filename);
1083
extern JSDSourceText*
1084
jsdlw_PreLoadSource(JSDContext* jsdc, LWDBGApp* app,
1085
const char* filename, JSBool clear);
1087
extern JSDSourceText*
1088
jsdlw_ForceLoadSource(JSDContext* jsdc, JSDSourceText* jsdsrc);
1091
jsdlw_UserCodeAtPC(JSDContext* jsdc, JSDScript* jsdscript, uintptr_t pc);
1094
jsdlw_RawToProcessedLineNumber(JSDContext* jsdc, JSDScript* jsdscript,
1095
unsigned lineIn, unsigned* lineOut);
1098
jsdlw_ProcessedToRawLineNumber(JSDContext* jsdc, JSDScript* jsdscript,
1099
unsigned lineIn, unsigned* lineOut);
1103
/* our hook proc for LiveWire app start/stop */
1105
jsdlw_AppHookProc(LWDBGApp* app,
1112
/***************************************************************************/
1116
#endif /* jsd_h___ */