2013-04-16 20:47:10 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
2012-05-21 11:12:37 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-04-17 08:50:41 +00:00
|
|
|
|
|
|
|
#ifndef JSDSERVICE_H___
|
|
|
|
#define JSDSERVICE_H___
|
|
|
|
|
|
|
|
#include "jsdIDebuggerService.h"
|
|
|
|
#include "jsdebug.h"
|
2001-06-28 07:47:04 +00:00
|
|
|
#include "nsString.h"
|
2001-04-17 08:50:41 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2001-07-03 22:21:56 +00:00
|
|
|
#include "nspr.h"
|
2012-04-30 20:58:38 +00:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2012-06-13 03:45:08 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2001-04-17 08:50:41 +00:00
|
|
|
|
2002-01-31 00:37:28 +00:00
|
|
|
// #if defined(DEBUG_rginda_l)
|
|
|
|
// # define DEBUG_verbose
|
|
|
|
// #endif
|
2001-05-01 21:35:06 +00:00
|
|
|
|
2001-07-03 22:21:56 +00:00
|
|
|
struct LiveEphemeral {
|
|
|
|
/* link in a chain of live values list */
|
2002-01-29 08:32:23 +00:00
|
|
|
PRCList links;
|
|
|
|
jsdIEphemeral *value;
|
|
|
|
void *key;
|
2001-07-03 22:21:56 +00:00
|
|
|
};
|
2001-05-01 21:35:06 +00:00
|
|
|
|
2002-01-12 00:56:35 +00:00
|
|
|
struct PCMapEntry {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t pc, line;
|
2002-01-12 00:56:35 +00:00
|
|
|
};
|
|
|
|
|
2001-04-17 08:50:41 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* reflected jsd data structures
|
|
|
|
*******************************************************************************/
|
|
|
|
|
2012-06-13 03:45:08 +00:00
|
|
|
class jsdObject MOZ_FINAL : public jsdIObject
|
2001-04-20 03:57:28 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-07-19 02:23:32 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2001-04-20 03:57:28 +00:00
|
|
|
NS_DECL_JSDIOBJECT
|
|
|
|
|
|
|
|
/* you'll normally use use FromPtr() instead of directly constructing one */
|
|
|
|
jsdObject (JSDContext *aCx, JSDObject *aObject) :
|
|
|
|
mCx(aCx), mObject(aObject)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static jsdIObject *FromPtr (JSDContext *aCx,
|
|
|
|
JSDObject *aObject)
|
|
|
|
{
|
|
|
|
if (!aObject)
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2001-04-20 03:57:28 +00:00
|
|
|
|
|
|
|
jsdIObject *rv = new jsdObject (aCx, aObject);
|
2001-04-17 08:50:41 +00:00
|
|
|
NS_IF_ADDREF(rv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2001-04-20 03:57:28 +00:00
|
|
|
jsdObject(); /* no implementation */
|
|
|
|
jsdObject(const jsdObject&); /* no implementation */
|
|
|
|
|
2001-04-25 18:22:49 +00:00
|
|
|
JSDContext *mCx;
|
|
|
|
JSDObject *mObject;
|
2001-04-17 08:50:41 +00:00
|
|
|
};
|
|
|
|
|
2001-04-25 18:22:49 +00:00
|
|
|
|
2001-04-20 03:57:28 +00:00
|
|
|
class jsdProperty : public jsdIProperty
|
2001-04-17 08:50:41 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-07-19 02:23:32 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2001-04-20 03:57:28 +00:00
|
|
|
NS_DECL_JSDIPROPERTY
|
2001-07-03 22:21:56 +00:00
|
|
|
NS_DECL_JSDIEPHEMERAL
|
|
|
|
|
|
|
|
jsdProperty (JSDContext *aCx, JSDProperty *aProperty);
|
|
|
|
virtual ~jsdProperty ();
|
|
|
|
|
2001-04-20 03:57:28 +00:00
|
|
|
static jsdIProperty *FromPtr (JSDContext *aCx,
|
|
|
|
JSDProperty *aProperty)
|
2001-04-17 08:50:41 +00:00
|
|
|
{
|
2001-04-20 03:57:28 +00:00
|
|
|
if (!aProperty)
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2001-04-20 03:57:28 +00:00
|
|
|
|
|
|
|
jsdIProperty *rv = new jsdProperty (aCx, aProperty);
|
2001-04-17 08:50:41 +00:00
|
|
|
NS_IF_ADDREF(rv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-07-03 22:21:56 +00:00
|
|
|
static void InvalidateAll();
|
|
|
|
|
2001-04-20 03:57:28 +00:00
|
|
|
private:
|
|
|
|
jsdProperty(); /* no implementation */
|
|
|
|
jsdProperty(const jsdProperty&); /* no implementation */
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mValid;
|
2001-07-03 22:21:56 +00:00
|
|
|
LiveEphemeral mLiveListEntry;
|
|
|
|
JSDContext *mCx;
|
|
|
|
JSDProperty *mProperty;
|
2001-04-17 08:50:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class jsdScript : public jsdIScript
|
|
|
|
{
|
|
|
|
public:
|
2013-07-19 02:23:32 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2001-04-17 08:50:41 +00:00
|
|
|
NS_DECL_JSDISCRIPT
|
2001-07-03 22:21:56 +00:00
|
|
|
NS_DECL_JSDIEPHEMERAL
|
2001-04-17 08:50:41 +00:00
|
|
|
|
|
|
|
/* you'll normally use use FromPtr() instead of directly constructing one */
|
2001-07-03 22:21:56 +00:00
|
|
|
jsdScript (JSDContext *aCx, JSDScript *aScript);
|
|
|
|
virtual ~jsdScript();
|
|
|
|
|
2001-04-17 08:50:41 +00:00
|
|
|
static jsdIScript *FromPtr (JSDContext *aCx, JSDScript *aScript)
|
|
|
|
{
|
2001-04-20 03:57:28 +00:00
|
|
|
if (!aScript)
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2001-04-20 03:57:28 +00:00
|
|
|
|
|
|
|
void *data = JSD_GetScriptPrivate (aScript);
|
|
|
|
jsdIScript *rv;
|
|
|
|
|
|
|
|
if (data) {
|
2007-07-08 07:08:04 +00:00
|
|
|
rv = static_cast<jsdIScript *>(data);
|
2001-04-20 03:57:28 +00:00
|
|
|
} else {
|
|
|
|
rv = new jsdScript (aCx, aScript);
|
2001-05-01 21:35:06 +00:00
|
|
|
NS_IF_ADDREF(rv); /* addref for the SetScriptPrivate, released in
|
|
|
|
* Invalidate() */
|
2007-07-08 07:08:04 +00:00
|
|
|
JSD_SetScriptPrivate (aScript, static_cast<void *>(rv));
|
2001-04-20 03:57:28 +00:00
|
|
|
}
|
|
|
|
|
2001-05-01 21:35:06 +00:00
|
|
|
NS_IF_ADDREF(rv); /* addref for return value */
|
2001-04-17 08:50:41 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2002-01-12 00:56:35 +00:00
|
|
|
static void InvalidateAll();
|
|
|
|
|
2001-04-17 08:50:41 +00:00
|
|
|
private:
|
2012-08-22 15:56:38 +00:00
|
|
|
static uint32_t LastTag;
|
2002-01-12 00:56:35 +00:00
|
|
|
|
2001-04-17 08:50:41 +00:00
|
|
|
jsdScript(); /* no implementation */
|
|
|
|
jsdScript (const jsdScript&); /* no implementation */
|
2002-01-12 00:56:35 +00:00
|
|
|
PCMapEntry* CreatePPLineMap();
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t PPPcToLine(uint32_t aPC);
|
|
|
|
uint32_t PPLineToPc(uint32_t aLine);
|
2001-04-17 08:50:41 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mValid;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mTag;
|
2001-04-17 08:50:41 +00:00
|
|
|
JSDContext *mCx;
|
|
|
|
JSDScript *mScript;
|
2001-06-28 07:47:04 +00:00
|
|
|
nsCString *mFileName;
|
|
|
|
nsCString *mFunctionName;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mBaseLineNumber, mLineExtent;
|
2002-01-12 00:56:35 +00:00
|
|
|
PCMapEntry *mPPLineMap;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mPCMapSize;
|
2012-01-11 08:23:05 +00:00
|
|
|
uintptr_t mFirstPC;
|
2001-04-17 08:50:41 +00:00
|
|
|
};
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t jsdScript::LastTag = 0;
|
2002-01-12 00:56:35 +00:00
|
|
|
|
2002-01-29 08:32:23 +00:00
|
|
|
class jsdContext : public jsdIContext
|
|
|
|
{
|
|
|
|
public:
|
2013-07-19 02:23:32 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2002-01-29 08:32:23 +00:00
|
|
|
NS_DECL_JSDICONTEXT
|
|
|
|
NS_DECL_JSDIEPHEMERAL
|
|
|
|
|
|
|
|
jsdContext (JSDContext *aJSDCx, JSContext *aJSCx, nsISupports *aISCx);
|
|
|
|
virtual ~jsdContext();
|
|
|
|
|
|
|
|
static void InvalidateAll();
|
|
|
|
static jsdIContext *FromPtr (JSDContext *aJSDCx, JSContext *aJSCx);
|
|
|
|
private:
|
2012-08-22 15:56:38 +00:00
|
|
|
static uint32_t LastTag;
|
2002-01-29 08:32:23 +00:00
|
|
|
|
|
|
|
jsdContext (); /* no implementation */
|
|
|
|
jsdContext (const jsdContext&); /* no implementation */
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mValid;
|
2013-11-13 00:43:34 +00:00
|
|
|
// The API exposed by JSD here is problematic, because it allows for per-
|
|
|
|
// JSContext script disabling, which no longer exists in the platform.
|
|
|
|
// The only consumer here in practice is Firebug, which makes sure to re-
|
|
|
|
// enable any disabled script before navigation. But if some other consumer
|
|
|
|
// were to disable script, navigate, and try to re-enable it, we'd end up
|
|
|
|
// with an unmatched UnblockScript call, which violates platform invariants.
|
|
|
|
// So we make a half-hearted attempt to detect this by storing the Window ID
|
|
|
|
// of the scope for which we disabled script.
|
|
|
|
uint64_t mScriptDisabledForWindowWithID;
|
|
|
|
bool IsScriptEnabled() { return !mScriptDisabledForWindowWithID; }
|
2002-01-29 08:32:23 +00:00
|
|
|
LiveEphemeral mLiveListEntry;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mTag;
|
2002-01-29 08:32:23 +00:00
|
|
|
JSDContext *mJSDCx;
|
|
|
|
JSContext *mJSCx;
|
|
|
|
nsCOMPtr<nsISupports> mISCx;
|
|
|
|
};
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t jsdContext::LastTag = 0;
|
2002-01-29 08:32:23 +00:00
|
|
|
|
2001-04-20 03:57:28 +00:00
|
|
|
class jsdStackFrame : public jsdIStackFrame
|
|
|
|
{
|
|
|
|
public:
|
2013-07-19 02:23:32 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2001-04-20 03:57:28 +00:00
|
|
|
NS_DECL_JSDISTACKFRAME
|
2001-07-03 22:21:56 +00:00
|
|
|
NS_DECL_JSDIEPHEMERAL
|
2001-04-20 03:57:28 +00:00
|
|
|
|
|
|
|
/* you'll normally use use FromPtr() instead of directly constructing one */
|
|
|
|
jsdStackFrame (JSDContext *aCx, JSDThreadState *aThreadState,
|
Bug 151803, "Debugger is leaking JSDValues", r=peterv, sr=jst
Stop caching jsdIValues, it doesn't seem to be worth the lookup cost. This has the side effect of plugging the leak, as described in the bug.
also...
* Convert a few raw pointers to nsCOMPtrs
* Fix a bug where removing the last filter did not null out the list head,
causing a crash the next time filters were used.
* Track live jsdStackFrames, so we can invalidate them all when execution
continues. Without this, only the top frame is properly invalidated, and any
other frame accessed after a continue will do Bad Things.
* Add some debugging prints to GetInitAtService, which seems to be failing at
random times.
2002-06-19 21:56:23 +00:00
|
|
|
JSDStackFrameInfo *aStackFrameInfo);
|
|
|
|
virtual ~jsdStackFrame();
|
2001-04-20 03:57:28 +00:00
|
|
|
|
Bug 151803, "Debugger is leaking JSDValues", r=peterv, sr=jst
Stop caching jsdIValues, it doesn't seem to be worth the lookup cost. This has the side effect of plugging the leak, as described in the bug.
also...
* Convert a few raw pointers to nsCOMPtrs
* Fix a bug where removing the last filter did not null out the list head,
causing a crash the next time filters were used.
* Track live jsdStackFrames, so we can invalidate them all when execution
continues. Without this, only the top frame is properly invalidated, and any
other frame accessed after a continue will do Bad Things.
* Add some debugging prints to GetInitAtService, which seems to be failing at
random times.
2002-06-19 21:56:23 +00:00
|
|
|
static void InvalidateAll();
|
|
|
|
static jsdIStackFrame* FromPtr (JSDContext *aCx,
|
2001-04-20 03:57:28 +00:00
|
|
|
JSDThreadState *aThreadState,
|
Bug 151803, "Debugger is leaking JSDValues", r=peterv, sr=jst
Stop caching jsdIValues, it doesn't seem to be worth the lookup cost. This has the side effect of plugging the leak, as described in the bug.
also...
* Convert a few raw pointers to nsCOMPtrs
* Fix a bug where removing the last filter did not null out the list head,
causing a crash the next time filters were used.
* Track live jsdStackFrames, so we can invalidate them all when execution
continues. Without this, only the top frame is properly invalidated, and any
other frame accessed after a continue will do Bad Things.
* Add some debugging prints to GetInitAtService, which seems to be failing at
random times.
2002-06-19 21:56:23 +00:00
|
|
|
JSDStackFrameInfo *aStackFrameInfo);
|
2001-04-20 03:57:28 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
jsdStackFrame(); /* no implementation */
|
|
|
|
jsdStackFrame(const jsdStackFrame&); /* no implementation */
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mValid;
|
Bug 151803, "Debugger is leaking JSDValues", r=peterv, sr=jst
Stop caching jsdIValues, it doesn't seem to be worth the lookup cost. This has the side effect of plugging the leak, as described in the bug.
also...
* Convert a few raw pointers to nsCOMPtrs
* Fix a bug where removing the last filter did not null out the list head,
causing a crash the next time filters were used.
* Track live jsdStackFrames, so we can invalidate them all when execution
continues. Without this, only the top frame is properly invalidated, and any
other frame accessed after a continue will do Bad Things.
* Add some debugging prints to GetInitAtService, which seems to be failing at
random times.
2002-06-19 21:56:23 +00:00
|
|
|
LiveEphemeral mLiveListEntry;
|
2001-05-04 22:14:37 +00:00
|
|
|
JSDContext *mCx;
|
|
|
|
JSDThreadState *mThreadState;
|
2001-04-20 03:57:28 +00:00
|
|
|
JSDStackFrameInfo *mStackFrameInfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
class jsdValue : public jsdIValue
|
|
|
|
{
|
|
|
|
public:
|
2013-07-19 02:23:32 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2001-04-20 03:57:28 +00:00
|
|
|
NS_DECL_JSDIVALUE
|
2001-07-03 22:21:56 +00:00
|
|
|
NS_DECL_JSDIEPHEMERAL
|
2001-04-20 03:57:28 +00:00
|
|
|
|
|
|
|
/* you'll normally use use FromPtr() instead of directly constructing one */
|
2001-07-03 22:21:56 +00:00
|
|
|
jsdValue (JSDContext *aCx, JSDValue *aValue);
|
|
|
|
virtual ~jsdValue();
|
2001-04-20 03:57:28 +00:00
|
|
|
|
2002-01-29 08:32:23 +00:00
|
|
|
static jsdIValue *FromPtr (JSDContext *aCx, JSDValue *aValue);
|
2001-07-03 22:21:56 +00:00
|
|
|
static void InvalidateAll();
|
2001-04-20 03:57:28 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
jsdValue(); /* no implementation */
|
|
|
|
jsdValue (const jsdScript&); /* no implementation */
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mValid;
|
2001-07-03 22:21:56 +00:00
|
|
|
LiveEphemeral mLiveListEntry;
|
|
|
|
JSDContext *mCx;
|
|
|
|
JSDValue *mValue;
|
2001-04-20 03:57:28 +00:00
|
|
|
};
|
|
|
|
|
2001-04-17 08:50:41 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* debugger service
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class jsdService : public jsdIDebuggerService
|
|
|
|
{
|
|
|
|
public:
|
2012-04-30 20:58:38 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2001-04-17 08:50:41 +00:00
|
|
|
NS_DECL_JSDIDEBUGGERSERVICE
|
|
|
|
|
2012-04-30 20:58:38 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS(jsdService)
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
jsdService() : mOn(false), mPauseLevel(0),
|
2002-01-29 05:56:02 +00:00
|
|
|
mNestedLoopLevel(0), mCx(0), mRuntime(0), mErrorHook(0),
|
|
|
|
mBreakpointHook(0), mDebugHook(0), mDebuggerHook(0),
|
|
|
|
mInterruptHook(0), mScriptHook(0), mThrowHook(0),
|
2014-03-05 04:09:15 +00:00
|
|
|
mTopLevelHook(0), mFunctionHook(0),
|
|
|
|
mWarnedAboutDeprecation(false),
|
|
|
|
mDeprecationAcknowledged(false)
|
2001-06-28 07:47:04 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-11-06 12:59:21 +00:00
|
|
|
virtual ~jsdService();
|
2001-04-17 08:50:41 +00:00
|
|
|
|
2001-04-25 21:55:20 +00:00
|
|
|
static jsdService *GetService ();
|
2010-11-16 23:18:35 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool CheckInterruptHook() { return !!mInterruptHook; }
|
2001-04-25 21:55:20 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult DoPause(uint32_t *_rval, bool internalCall);
|
|
|
|
nsresult DoUnPause(uint32_t *_rval, bool internalCall);
|
2011-11-09 21:11:39 +00:00
|
|
|
|
2001-04-17 08:50:41 +00:00
|
|
|
private:
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mOn;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mPauseLevel;
|
|
|
|
uint32_t mNestedLoopLevel;
|
2001-04-25 18:22:49 +00:00
|
|
|
JSDContext *mCx;
|
2001-06-28 07:47:04 +00:00
|
|
|
JSRuntime *mRuntime;
|
2002-01-29 05:56:02 +00:00
|
|
|
|
|
|
|
nsCOMPtr<jsdIErrorHook> mErrorHook;
|
2001-04-25 18:22:49 +00:00
|
|
|
nsCOMPtr<jsdIExecutionHook> mBreakpointHook;
|
2002-01-29 05:56:02 +00:00
|
|
|
nsCOMPtr<jsdIExecutionHook> mDebugHook;
|
2001-04-17 08:50:41 +00:00
|
|
|
nsCOMPtr<jsdIExecutionHook> mDebuggerHook;
|
|
|
|
nsCOMPtr<jsdIExecutionHook> mInterruptHook;
|
2001-04-20 03:57:28 +00:00
|
|
|
nsCOMPtr<jsdIScriptHook> mScriptHook;
|
2001-05-04 22:14:37 +00:00
|
|
|
nsCOMPtr<jsdIExecutionHook> mThrowHook;
|
2001-09-01 18:03:53 +00:00
|
|
|
nsCOMPtr<jsdICallHook> mTopLevelHook;
|
|
|
|
nsCOMPtr<jsdICallHook> mFunctionHook;
|
2010-10-30 16:13:02 +00:00
|
|
|
nsCOMPtr<jsdIActivationCallback> mActivationCallback;
|
2014-03-05 04:09:15 +00:00
|
|
|
|
|
|
|
// True if we have ever printed a warning about JSD being deprecated.
|
|
|
|
// We only ever print the warning once.
|
|
|
|
bool mWarnedAboutDeprecation;
|
|
|
|
|
|
|
|
// True if the next call to asyncOn should not produce a warning,
|
|
|
|
// because the consumer called jsdIDebuggerService::acknowledgeDeprecation.
|
|
|
|
bool mDeprecationAcknowledged;
|
2001-04-17 08:50:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* JSDSERVICE_H___ */
|
|
|
|
|
2001-05-04 22:14:37 +00:00
|
|
|
|
|
|
|
/* graveyard */
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
class jsdContext : public jsdIContext
|
|
|
|
{
|
|
|
|
public:
|
2013-07-19 02:23:32 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2001-05-04 22:14:37 +00:00
|
|
|
NS_DECL_JSDICONTEXT
|
|
|
|
|
|
|
|
/* you'll normally use use FromPtr() instead of directly constructing one */
|
|
|
|
jsdContext (JSDContext *aCx) : mCx(aCx)
|
|
|
|
{
|
|
|
|
printf ("++++++ jsdContext\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static jsdIContext *FromPtr (JSDContext *aCx)
|
|
|
|
{
|
|
|
|
if (!aCx)
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2001-05-04 22:14:37 +00:00
|
|
|
|
|
|
|
void *data = JSD_GetContextPrivate (aCx);
|
|
|
|
jsdIContext *rv;
|
|
|
|
|
|
|
|
if (data) {
|
2007-07-08 07:08:04 +00:00
|
|
|
rv = static_cast<jsdIContext *>(data);
|
2001-05-04 22:14:37 +00:00
|
|
|
} else {
|
|
|
|
rv = new jsdContext (aCx);
|
|
|
|
NS_IF_ADDREF(rv); // addref for the SetContextPrivate
|
2007-07-08 07:08:04 +00:00
|
|
|
JSD_SetContextPrivate (aCx, static_cast<void *>(rv));
|
2001-05-04 22:14:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IF_ADDREF(rv); // addref for the return value
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual ~jsdContext() { printf ("------ ~jsdContext\n"); }
|
|
|
|
private:
|
|
|
|
jsdContext(); /* no implementation */
|
|
|
|
jsdContext(const jsdContext&); /* no implementation */
|
|
|
|
|
|
|
|
JSDContext *mCx;
|
|
|
|
};
|
|
|
|
|
|
|
|
class jsdThreadState : public jsdIThreadState
|
|
|
|
{
|
|
|
|
public:
|
2013-07-19 02:23:32 +00:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2001-05-04 22:14:37 +00:00
|
|
|
NS_DECL_JSDITHREADSTATE
|
|
|
|
|
|
|
|
/* you'll normally use use FromPtr() instead of directly constructing one */
|
|
|
|
jsdThreadState (JSDContext *aCx, JSDThreadState *aThreadState) :
|
|
|
|
mCx(aCx), mThreadState(aThreadState)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX These things are only valid for a short period of time, they reflect
|
|
|
|
* state in the js engine that will go away after stepping past wherever
|
|
|
|
* we were stopped at when this was created. We could keep a list of every
|
|
|
|
* instance of this we've created, and "invalidate" them before we let the
|
|
|
|
* engine continue. The next time we need a threadstate, we can search the
|
|
|
|
* list to find an invalidated one, and just reuse it.
|
|
|
|
*/
|
|
|
|
static jsdIThreadState *FromPtr (JSDContext *aCx,
|
|
|
|
JSDThreadState *aThreadState)
|
|
|
|
{
|
|
|
|
if (!aThreadState)
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2001-05-04 22:14:37 +00:00
|
|
|
|
|
|
|
jsdIThreadState *rv = new jsdThreadState (aCx, aThreadState);
|
|
|
|
NS_IF_ADDREF(rv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
jsdThreadState(); /* no implementation */
|
|
|
|
jsdThreadState(const jsdThreadState&); /* no implementation */
|
|
|
|
|
|
|
|
JSDContext *mCx;
|
|
|
|
JSDThreadState *mThreadState;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|