2001-04-17 12:50:41 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
2004-04-19 02:01:16 +04:00
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
2001-04-17 12:50:41 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
2004-04-19 02:01:16 +04:00
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
2001-04-17 12:50:41 +04:00
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
2004-04-19 02:01:16 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2001-04-17 12:50:41 +04:00
|
|
|
*
|
|
|
|
* Contributor(s):
|
2001-04-20 07:57:28 +04:00
|
|
|
* Robert Ginda, <rginda@netscape.com>
|
2001-04-17 12:50:41 +04:00
|
|
|
*
|
2004-04-19 02:01:16 +04:00
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-04-17 12:50:41 +04:00
|
|
|
|
|
|
|
#ifndef JSDSERVICE_H___
|
|
|
|
#define JSDSERVICE_H___
|
|
|
|
|
|
|
|
#include "jsdIDebuggerService.h"
|
|
|
|
#include "jsdebug.h"
|
2001-06-28 11:47:04 +04:00
|
|
|
#include "nsString.h"
|
2001-04-17 12:50:41 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2001-07-04 02:21:56 +04:00
|
|
|
#include "nspr.h"
|
2001-04-17 12:50:41 +04:00
|
|
|
|
2002-01-31 03:37:28 +03:00
|
|
|
// #if defined(DEBUG_rginda_l)
|
|
|
|
// # define DEBUG_verbose
|
|
|
|
// #endif
|
2001-05-02 01:35:06 +04:00
|
|
|
|
2001-07-04 02:21:56 +04:00
|
|
|
struct LiveEphemeral {
|
|
|
|
/* link in a chain of live values list */
|
2002-01-29 11:32:23 +03:00
|
|
|
PRCList links;
|
|
|
|
jsdIEphemeral *value;
|
|
|
|
void *key;
|
2001-07-04 02:21:56 +04:00
|
|
|
};
|
2001-05-02 01:35:06 +04:00
|
|
|
|
2002-01-12 03:56:35 +03:00
|
|
|
struct PCMapEntry {
|
|
|
|
PRUint32 pc, line;
|
|
|
|
};
|
|
|
|
|
2001-04-17 12:50:41 +04:00
|
|
|
/*******************************************************************************
|
|
|
|
* reflected jsd data structures
|
|
|
|
*******************************************************************************/
|
|
|
|
|
2001-04-20 07:57:28 +04:00
|
|
|
class jsdObject : public jsdIObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
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)
|
2001-07-04 02:21:56 +04:00
|
|
|
return nsnull;
|
2001-04-20 07:57:28 +04:00
|
|
|
|
|
|
|
jsdIObject *rv = new jsdObject (aCx, aObject);
|
2001-04-17 12:50:41 +04:00
|
|
|
NS_IF_ADDREF(rv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2001-04-20 07:57:28 +04:00
|
|
|
jsdObject(); /* no implementation */
|
|
|
|
jsdObject(const jsdObject&); /* no implementation */
|
|
|
|
|
2001-04-25 22:22:49 +04:00
|
|
|
JSDContext *mCx;
|
|
|
|
JSDObject *mObject;
|
2001-04-17 12:50:41 +04:00
|
|
|
};
|
|
|
|
|
2001-04-25 22:22:49 +04:00
|
|
|
|
2001-04-20 07:57:28 +04:00
|
|
|
class jsdProperty : public jsdIProperty
|
2001-04-17 12:50:41 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
2001-04-20 07:57:28 +04:00
|
|
|
NS_DECL_JSDIPROPERTY
|
2001-07-04 02:21:56 +04:00
|
|
|
NS_DECL_JSDIEPHEMERAL
|
|
|
|
|
|
|
|
jsdProperty (JSDContext *aCx, JSDProperty *aProperty);
|
|
|
|
virtual ~jsdProperty ();
|
|
|
|
|
2001-04-20 07:57:28 +04:00
|
|
|
static jsdIProperty *FromPtr (JSDContext *aCx,
|
|
|
|
JSDProperty *aProperty)
|
2001-04-17 12:50:41 +04:00
|
|
|
{
|
2001-04-20 07:57:28 +04:00
|
|
|
if (!aProperty)
|
2001-07-04 02:21:56 +04:00
|
|
|
return nsnull;
|
2001-04-20 07:57:28 +04:00
|
|
|
|
|
|
|
jsdIProperty *rv = new jsdProperty (aCx, aProperty);
|
2001-04-17 12:50:41 +04:00
|
|
|
NS_IF_ADDREF(rv);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2001-07-04 02:21:56 +04:00
|
|
|
static void InvalidateAll();
|
|
|
|
|
2001-04-20 07:57:28 +04:00
|
|
|
private:
|
|
|
|
jsdProperty(); /* no implementation */
|
|
|
|
jsdProperty(const jsdProperty&); /* no implementation */
|
|
|
|
|
2001-07-04 02:21:56 +04:00
|
|
|
PRBool mValid;
|
|
|
|
LiveEphemeral mLiveListEntry;
|
|
|
|
JSDContext *mCx;
|
|
|
|
JSDProperty *mProperty;
|
2001-04-17 12:50:41 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
class jsdScript : public jsdIScript
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_JSDISCRIPT
|
2001-07-04 02:21:56 +04:00
|
|
|
NS_DECL_JSDIEPHEMERAL
|
2001-04-17 12:50:41 +04:00
|
|
|
|
|
|
|
/* you'll normally use use FromPtr() instead of directly constructing one */
|
2001-07-04 02:21:56 +04:00
|
|
|
jsdScript (JSDContext *aCx, JSDScript *aScript);
|
|
|
|
virtual ~jsdScript();
|
|
|
|
|
2001-04-17 12:50:41 +04:00
|
|
|
static jsdIScript *FromPtr (JSDContext *aCx, JSDScript *aScript)
|
|
|
|
{
|
2001-04-20 07:57:28 +04:00
|
|
|
if (!aScript)
|
2001-07-04 02:21:56 +04:00
|
|
|
return nsnull;
|
2001-04-20 07:57:28 +04:00
|
|
|
|
|
|
|
void *data = JSD_GetScriptPrivate (aScript);
|
|
|
|
jsdIScript *rv;
|
|
|
|
|
|
|
|
if (data) {
|
2007-07-08 11:08:04 +04:00
|
|
|
rv = static_cast<jsdIScript *>(data);
|
2001-04-20 07:57:28 +04:00
|
|
|
} else {
|
|
|
|
rv = new jsdScript (aCx, aScript);
|
2001-05-02 01:35:06 +04:00
|
|
|
NS_IF_ADDREF(rv); /* addref for the SetScriptPrivate, released in
|
|
|
|
* Invalidate() */
|
2007-07-08 11:08:04 +04:00
|
|
|
JSD_SetScriptPrivate (aScript, static_cast<void *>(rv));
|
2001-04-20 07:57:28 +04:00
|
|
|
}
|
|
|
|
|
2001-05-02 01:35:06 +04:00
|
|
|
NS_IF_ADDREF(rv); /* addref for return value */
|
2001-04-17 12:50:41 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2002-01-12 03:56:35 +03:00
|
|
|
static void InvalidateAll();
|
|
|
|
|
2001-04-17 12:50:41 +04:00
|
|
|
private:
|
2002-01-12 03:56:35 +03:00
|
|
|
static PRUint32 LastTag;
|
|
|
|
|
2001-04-17 12:50:41 +04:00
|
|
|
jsdScript(); /* no implementation */
|
|
|
|
jsdScript (const jsdScript&); /* no implementation */
|
2002-01-12 03:56:35 +03:00
|
|
|
PCMapEntry* CreatePPLineMap();
|
|
|
|
PRUint32 PPPcToLine(PRUint32 aPC);
|
|
|
|
PRUint32 PPLineToPc(PRUint32 aLine);
|
2001-04-17 12:50:41 +04:00
|
|
|
|
2001-05-02 01:35:06 +04:00
|
|
|
PRBool mValid;
|
2002-01-12 03:56:35 +03:00
|
|
|
PRUint32 mTag;
|
2001-04-17 12:50:41 +04:00
|
|
|
JSDContext *mCx;
|
|
|
|
JSDScript *mScript;
|
2001-06-28 11:47:04 +04:00
|
|
|
nsCString *mFileName;
|
|
|
|
nsCString *mFunctionName;
|
|
|
|
PRUint32 mBaseLineNumber, mLineExtent;
|
2002-01-12 03:56:35 +03:00
|
|
|
PCMapEntry *mPPLineMap;
|
|
|
|
PRUint32 mPCMapSize;
|
|
|
|
jsuword mFirstPC;
|
2001-04-17 12:50:41 +04:00
|
|
|
};
|
|
|
|
|
2002-01-12 03:56:35 +03:00
|
|
|
PRUint32 jsdScript::LastTag = 0;
|
|
|
|
|
2002-01-29 11:32:23 +03:00
|
|
|
class jsdContext : public jsdIContext
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
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:
|
|
|
|
static PRUint32 LastTag;
|
|
|
|
|
|
|
|
jsdContext (); /* no implementation */
|
|
|
|
jsdContext (const jsdContext&); /* no implementation */
|
|
|
|
|
|
|
|
PRBool mValid;
|
|
|
|
LiveEphemeral mLiveListEntry;
|
|
|
|
PRUint32 mTag;
|
|
|
|
JSDContext *mJSDCx;
|
|
|
|
JSContext *mJSCx;
|
|
|
|
nsCOMPtr<nsISupports> mISCx;
|
|
|
|
};
|
|
|
|
|
|
|
|
PRUint32 jsdContext::LastTag = 0;
|
|
|
|
|
2001-04-20 07:57:28 +04:00
|
|
|
class jsdStackFrame : public jsdIStackFrame
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_JSDISTACKFRAME
|
2001-07-04 02:21:56 +04:00
|
|
|
NS_DECL_JSDIEPHEMERAL
|
2001-04-20 07:57:28 +04: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-20 01:56:23 +04:00
|
|
|
JSDStackFrameInfo *aStackFrameInfo);
|
|
|
|
virtual ~jsdStackFrame();
|
2001-04-20 07:57:28 +04: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-20 01:56:23 +04:00
|
|
|
static void InvalidateAll();
|
|
|
|
static jsdIStackFrame* FromPtr (JSDContext *aCx,
|
2001-04-20 07:57:28 +04: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-20 01:56:23 +04:00
|
|
|
JSDStackFrameInfo *aStackFrameInfo);
|
2001-04-20 07:57:28 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
jsdStackFrame(); /* no implementation */
|
|
|
|
jsdStackFrame(const jsdStackFrame&); /* no implementation */
|
|
|
|
|
2001-07-04 02:21:56 +04:00
|
|
|
PRBool 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-20 01:56:23 +04:00
|
|
|
LiveEphemeral mLiveListEntry;
|
2001-05-05 02:14:37 +04:00
|
|
|
JSDContext *mCx;
|
|
|
|
JSDThreadState *mThreadState;
|
2001-04-20 07:57:28 +04:00
|
|
|
JSDStackFrameInfo *mStackFrameInfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
class jsdValue : public jsdIValue
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_JSDIVALUE
|
2001-07-04 02:21:56 +04:00
|
|
|
NS_DECL_JSDIEPHEMERAL
|
2001-04-20 07:57:28 +04:00
|
|
|
|
|
|
|
/* you'll normally use use FromPtr() instead of directly constructing one */
|
2001-07-04 02:21:56 +04:00
|
|
|
jsdValue (JSDContext *aCx, JSDValue *aValue);
|
|
|
|
virtual ~jsdValue();
|
2001-04-20 07:57:28 +04:00
|
|
|
|
2002-01-29 11:32:23 +03:00
|
|
|
static jsdIValue *FromPtr (JSDContext *aCx, JSDValue *aValue);
|
2001-07-04 02:21:56 +04:00
|
|
|
static void InvalidateAll();
|
2001-04-20 07:57:28 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
jsdValue(); /* no implementation */
|
|
|
|
jsdValue (const jsdScript&); /* no implementation */
|
|
|
|
|
2001-07-04 02:21:56 +04:00
|
|
|
PRBool mValid;
|
|
|
|
LiveEphemeral mLiveListEntry;
|
|
|
|
JSDContext *mCx;
|
|
|
|
JSDValue *mValue;
|
2001-04-20 07:57:28 +04:00
|
|
|
};
|
|
|
|
|
2001-04-17 12:50:41 +04:00
|
|
|
/******************************************************************************
|
|
|
|
* debugger service
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
class jsdService : public jsdIDebuggerService
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_JSDIDEBUGGERSERVICE
|
|
|
|
|
2001-10-30 16:41:32 +03:00
|
|
|
jsdService() : mInitAtStartup(triUnknown), mOn(PR_FALSE), mPauseLevel(0),
|
2002-01-29 08:56:02 +03:00
|
|
|
mNestedLoopLevel(0), mCx(0), mRuntime(0), mErrorHook(0),
|
|
|
|
mBreakpointHook(0), mDebugHook(0), mDebuggerHook(0),
|
|
|
|
mInterruptHook(0), mScriptHook(0), mThrowHook(0),
|
|
|
|
mTopLevelHook(0), mFunctionHook(0)
|
2001-06-28 11:47:04 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-11-06 15:59:21 +03:00
|
|
|
virtual ~jsdService();
|
2001-04-17 12:50:41 +04:00
|
|
|
|
2001-04-26 01:55:20 +04:00
|
|
|
static jsdService *GetService ();
|
|
|
|
|
2001-04-17 12:50:41 +04:00
|
|
|
private:
|
2001-10-30 16:41:32 +03:00
|
|
|
enum Tristate {
|
|
|
|
triUnknown = 0U,
|
|
|
|
triYes = 1U,
|
|
|
|
triNo = 2U
|
|
|
|
};
|
|
|
|
|
|
|
|
Tristate mInitAtStartup;
|
2001-04-25 22:22:49 +04:00
|
|
|
PRBool mOn;
|
2001-10-30 16:41:32 +03:00
|
|
|
PRUint32 mPauseLevel;
|
2001-04-20 07:57:28 +04:00
|
|
|
PRUint32 mNestedLoopLevel;
|
2001-04-25 22:22:49 +04:00
|
|
|
JSDContext *mCx;
|
2001-06-28 11:47:04 +04:00
|
|
|
JSRuntime *mRuntime;
|
2002-01-29 08:56:02 +03:00
|
|
|
|
|
|
|
nsCOMPtr<jsdIErrorHook> mErrorHook;
|
2001-04-25 22:22:49 +04:00
|
|
|
nsCOMPtr<jsdIExecutionHook> mBreakpointHook;
|
2002-01-29 08:56:02 +03:00
|
|
|
nsCOMPtr<jsdIExecutionHook> mDebugHook;
|
2001-04-17 12:50:41 +04:00
|
|
|
nsCOMPtr<jsdIExecutionHook> mDebuggerHook;
|
|
|
|
nsCOMPtr<jsdIExecutionHook> mInterruptHook;
|
2001-04-20 07:57:28 +04:00
|
|
|
nsCOMPtr<jsdIScriptHook> mScriptHook;
|
2001-05-05 02:14:37 +04:00
|
|
|
nsCOMPtr<jsdIExecutionHook> mThrowHook;
|
2001-09-01 22:03:53 +04:00
|
|
|
nsCOMPtr<jsdICallHook> mTopLevelHook;
|
|
|
|
nsCOMPtr<jsdICallHook> mFunctionHook;
|
|
|
|
|
2001-04-17 12:50:41 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* JSDSERVICE_H___ */
|
|
|
|
|
2001-05-05 02:14:37 +04:00
|
|
|
|
|
|
|
/* graveyard */
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
class jsdContext : public jsdIContext
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
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)
|
2001-07-04 02:21:56 +04:00
|
|
|
return nsnull;
|
2001-05-05 02:14:37 +04:00
|
|
|
|
|
|
|
void *data = JSD_GetContextPrivate (aCx);
|
|
|
|
jsdIContext *rv;
|
|
|
|
|
|
|
|
if (data) {
|
2007-07-08 11:08:04 +04:00
|
|
|
rv = static_cast<jsdIContext *>(data);
|
2001-05-05 02:14:37 +04:00
|
|
|
} else {
|
|
|
|
rv = new jsdContext (aCx);
|
|
|
|
NS_IF_ADDREF(rv); // addref for the SetContextPrivate
|
2007-07-08 11:08:04 +04:00
|
|
|
JSD_SetContextPrivate (aCx, static_cast<void *>(rv));
|
2001-05-05 02:14:37 +04: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:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
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)
|
2001-07-04 02:21:56 +04:00
|
|
|
return nsnull;
|
2001-05-05 02:14:37 +04: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
|