(not part of client build) initial checkin of mozilla/js/jsdj (migrated from ns/js/jsdj)

This commit is contained in:
jband%netscape.com 1998-09-16 02:07:50 +00:00
parent ddab882f04
commit 74b712789c
437 changed files with 41046 additions and 0 deletions

1
js/jsdj/.cvsignore Normal file
View File

@ -0,0 +1 @@
dist

30
js/jsdj/README Normal file
View File

@ -0,0 +1,30 @@
/* jband - 09/14/98 - */
js/jsdj contains virtually all of the Java code for JavaScript Debugging
(native parts of the code for JavaScript can be found in js/jsd).
This includes the full source to Netscape JavaScript Debugger, adapter parts,
jslogger, a simple console debugger, a test system, and some build tools.
The notable subdirs are:
build - stuff to build the code
classes - trees of source files
dist - generated output dir
ifcui - auxilary pieces of the JavaScript Debugger
jslogger - auxilary pieces of a smaple JavaScript logging app
stub_classes - stubbed out mozilla classes to allow standalone debugging
test - a place for subsystem tests
The source to the debugger lives in:
jsdj/classes/com/netscape/jsdebugging/ifcui
All building is done in:
jsdj/build
***************************************************************************
*** 09/15/98
*** NOTE: some of this relates to code in js/jsd that is not yet checked in.
*** New stuff in js/jsd will go in when new js/src lands (later this week).
*** I decided to check this in anyway...
***************************************************************************

33
js/jsdj/build/README Normal file
View File

@ -0,0 +1,33 @@
/* jband - 09/14/98 - */
The build system here currently supports only Microsoft nmake (I use the one
from MSDEV 4.2). It assumes that Symantec Visual Cafe is installed (i.e. it uses
sj.exe), and also uses awk. I mostly use the 4NT shell, but I think that
everything still works with the default NT shell.
This system can build all the Java code here. It can also do jar packaging (with
dependency checks to assure that you have the right stuff) and produce javadocs.
Netscape's JavaScript in Java engine (known as Rhino) is not currently available
to the public. The flag 'NO_RHINO=1' is necessary for many of the makefile
targets when used outside of Netscape.
There is code here to also build a Corba/iiop connection for remote debugging to
a Netscape Internal version of Enterprise Server 3.51. This is not fully
functional on the server side. You should normally use the NO_CORBA=1 build
flag. If you want to play with this stuff then you need an install of ES3.51 and
you need to set the ES3_ROOT environment variable to point to that install.
(e.g. mine is 'set ES3_ROOT=E:\Netscape\SuiteSpot'. NOTE: the code in
com.netscape.jsdebugging.remote.corba is *generated* in an 'interesting' build
system in js/jsd/corba/src -- it would not be a good idea to modify this
generated code.
'nmake -f jsdj.mak help' will display a list of possible targets (might not be
up to date :).
'nmake -f jsdj.mak all NO_RHINO=1 NO_CORBA=1' will build everything.
There are a few .bat files for convenience to build the targets I often build.

View File

@ -0,0 +1,31 @@
#
# This requires -vpackage_name=whatever.the.name.of.the.package.is
#
BEGIN{
print
print "// generated automatically by gen_date.awk"
print
print "package "package_name";"
print
print "class BuildDate"
print "{"
print strftime(" // %A, %B %d, %Y at %I:%M %p");
print
print " public static final long buildDate = " systime() "000L;"
print
print " public static final java.util.Date date()"
print " {"
print " return new java.util.Date(buildDate);"
print " }"
print
print " public static final String display()"
print " {"
print " return date().toString();"
print " }"
print "}"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 925 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 886 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 896 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 925 B

517
js/jsdj/build/jsdj.mak Normal file
View File

@ -0,0 +1,517 @@
# jband - 09/14/98
BUILD_DIR = .
DIST = $(BUILD_DIR)\..\dist
DIST_CLASSES = $(BUILD_DIR)\..\dist\classes
CLASS_SRC = $(BUILD_DIR)\..\classes
JSDEBUGGING_DIR = $(BUILD_DIR)\..\classes\com\netscape\jsdebugging
PALOMAR_DIR = $(JSDEBUGGING_DIR)\ifcui\palomar
IFC_DIST_FILE = $(DIST_CLASSES)\ifc11.jar
!IF "$(NO_RHINO)" == ""
RHINO_CLASSES = $(BUILD_DIR)\..\..\..\..\ns\js\rhino
!ENDIF
#these are used for CD
FROM_BUILD_TO_DIST_CLASSES = ..\dist\classes
FROM_DIST_CLASSES_TO_BUILD = ..\..\build
JSLOGGER_JARFILE = jslogger.jar
JSLOGGER_MAIN_DIR = $(BUILD_DIR)\..\jslogger
NETSCAPE_JSDEBUG_JARFILE = jsd11.jar
IFCUI_JARFILE = jsdeb12.jar
IFCUI_RUN_DIR = $(BUILD_DIR)\..\ifcui\run
OUR_CLASSPATH = $(DIST_CLASSES);$(IFC_DIST_FILE);$(RHINO_CLASSES);$(CLASSPATH)
STD_JAVA_FLAGS = -d $(DIST_CLASSES) -classpath $(OUR_CLASSPATH)
CORBA_CLASSPATH = $(OUR_CLASSPATH);$(ES3_ROOT)\wai\java\nisb.zip;$(ES3_ROOT)\wai\java\WAI.zip;$(ES3_ROOT)\plugins\Java\classes\serv3_0.zip
CORBA_JAVA_FLAGS = -d $(DIST_CLASSES) -classpath $(CORBA_CLASSPATH)
!IF "$(NO_CORBA)" == ""
JAVADOC_CLASSPATH = $(CORBA_CLASSPATH)
!ELSE
JAVADOC_CLASSPATH = $(OUR_CLASSPATH)
!ENDIF
!IF "$(BUILD_OPT)" != ""
JAVAFLAGS = $(STD_JAVA_FLAGS) -O
!ELSE
JAVAFLAGS = $(STD_JAVA_FLAGS) -g
!ENDIF
all: core jsdb ifcui ifcui_lanchers jslogger apitests tools \
dependency_checks jars netscape_applet javadoc_all
all_clean : clean all
help :
@echo targets:
@echo --------
@echo all
@echo all_clean
@echo help
@echo clean
@echo core
@echo jsdb
@echo apitests
@echo ifcui
@echo ifcui_fast
@echo ifcui_lanchers
@echo jslogger
@echo jslogger_fast
@echo depend_tool
@echo tools
@echo dependency_checks
@echo jars
@echo netscape_security
@echo netscape_jsdebug
@echo netscape_javascript
@echo netscape_applet
@echo com_netscape_nativejsengine
@echo com_netscape_jsdebugging_api
@echo com_netscape_jsdebugging_engine
@echo com_netscape_jsdebugging_api_local
@echo com_netscape_jsdebugging_engine_local
@echo com_netscape_jsdebugging_api_rhino
@echo com_netscape_jsdebugging_engine_rhino
@echo com_netscape_jsdebugging_jsdb
@echo com_netscape_jsdebugging_ifcui_palomar
@echo com_netscape_jsdebugging_ifcui
@echo com_netscape_jsdebugging_ifcui_launcher_local
@echo com_netscape_jsdebugging_ifcui_launcher_rhino
@echo com_netscape_jsdebugging_apitests
@echo com_netscape_jsdebugging_jslogger
@echo com_netscape_jsdebugging_tools_depend
@echo check_depend_jslogger
@echo jslogger_jar
@echo check_depend_netscape_jsdebug
@echo netscape_jsdebug_jar
core: initial_state \
netscape_security \
netscape_jsdebug \
com_netscape_jsdebugging_api \
com_netscape_jsdebugging_engine \
com_netscape_jsdebugging_api_local \
com_netscape_jsdebugging_engine_local \
!IF "$(NO_RHINO)" == ""
com_netscape_jsdebugging_api_rhino \
com_netscape_jsdebugging_engine_rhino \
!ENDIF
!IF "$(NO_CORBA)" == ""
com_netscape_jsdebugging_remote_corba \
com_netscape_jsdebugging_api_corba \
!ENDIF
jsdb : com_netscape_jsdebugging_jsdb
apitests : com_netscape_jsdebugging_apitests
ifcui : initial_state \
netscape_security \
netscape_javascript \
netscape_jsdebug \
com_netscape_jsdebugging_api \
com_netscape_jsdebugging_ifcui_palomar \
com_netscape_jsdebugging_ifcui \
CP_DIST_CLASSES_RESOURCES
ifcui_fast : com_netscape_jsdebugging_ifcui
ifcui_lanchers : com_netscape_jsdebugging_ifcui_launcher_local \
!IF "$(NO_RHINO)" == ""
com_netscape_jsdebugging_ifcui_launcher_rhino
!ENDIF
jslogger : ifcui com_netscape_jsdebugging_jslogger
jslogger_fast : com_netscape_jsdebugging_jslogger
depend_tool : initial_state com_netscape_jsdebugging_tools_depend
tools : depend_tool
dependency_checks : check_depend_jslogger \
check_depend_netscape_jsdebug
jars : jslogger_jar \
netscape_jsdebug_jar
netscape_security : initial_state
@echo building stubbed netscape.security classes
@sj $(JAVAFLAGS) $(BUILD_DIR)\..\stub_classes\netscape\security\*.java
netscape_applet : initial_state
@echo building stubbed netscape.applet classes
@sj $(JAVAFLAGS) $(BUILD_DIR)\..\stub_classes\netscape\applet\*.java
netscape_jsdebug : netscape_security
@echo building netscape.jsdebug
@sj $(JAVAFLAGS) $(BUILD_DIR)\..\classes\netscape\jsdebug\*.java
netscape_javascript: netscape_security
@echo building netscape.javascript
@sj $(JAVAFLAGS) $(BUILD_DIR)\..\stub_classes\netscape\javascript\*.java
com_netscape_jsdebugging_api : netscape_security
@echo building com.netscape.jsdebugging.api
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\api\*.java
com_netscape_jsdebugging_engine : com_netscape_jsdebugging_api
@echo building com.netscape.jsdebugging.engine
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\engine\*.java
com_netscape_jsdebugging_api_local : com_netscape_jsdebugging_api netscape_jsdebug
@echo building com.netscape.jsdebugging.api.local
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\api\local\*.java
com_netscape_jsdebugging_engine_local : com_netscape_nativejsengine com_netscape_jsdebugging_engine netscape_jsdebug
@echo building com.netscape.jsdebugging.engine.local
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\engine\local\*.java
com_netscape_nativejsengine :
@echo building com.netscape.nativejsengine
@sj $(JAVAFLAGS) $(CLASS_SRC)\com\netscape\nativejsengine\*.java
com_netscape_jsdebugging_api_rhino : com_netscape_jsdebugging_api
@echo building com.netscape.jsdebugging.api.rhino
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\api\rhino\*.java
com_netscape_jsdebugging_engine_rhino : com_netscape_jsdebugging_engine
@echo building com.netscape.jsdebugging.engine.rhino
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\engine\rhino\*.java
com_netscape_jsdebugging_jsdb : core
@echo building com.netscape.jsdebugging.jsdb
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\jsdb\*.java
com_netscape_jsdebugging_ifcui_palomar : initial_state
@echo building com.netscape.jsdebugging.ifcui.palomar etc...
@sj $(JAVAFLAGS)\
$(PALOMAR_DIR)\util\*.java\
$(PALOMAR_DIR)\widget\*.java\
$(PALOMAR_DIR)\widget\layout\*.java\
$(PALOMAR_DIR)\widget\layout\math\*.java\
$(PALOMAR_DIR)\widget\toolbar\*.java\
$(PALOMAR_DIR)\widget\toolTip\*.java
com_netscape_jsdebugging_ifcui :
@echo generating com.netscape.jsdebugging.ifcui.BuildDate
@gawk -f $(BUILD_DIR)\gen_date.awk -vpackage_name=com.netscape.jsdebugging.ifcui > $(JSDEBUGGING_DIR)\ifcui\BuildDate.java
@echo building com.netscape.jsdebugging.ifcui
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\ifcui\*.java
com_netscape_jsdebugging_ifcui_launcher_local : ifcui
@echo building com.netscape.jsdebugging.ifcui.launcher.local
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\ifcui\launcher\local\*.java
com_netscape_jsdebugging_ifcui_launcher_rhino : com_netscape_jsdebugging_api_rhino ifcui
@echo building com.netscape.jsdebugging.ifcui.launcher.rhino
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\ifcui\launcher\rhino\*.java
com_netscape_jsdebugging_apitests : core
@echo building com.netscape.jsdebugging.apitests etc...
@sj $(JAVAFLAGS)\
$(JSDEBUGGING_DIR)\apitests\*.java\
$(JSDEBUGGING_DIR)\apitests\xml\*.java\
$(JSDEBUGGING_DIR)\apitests\testing\*.java\
$(JSDEBUGGING_DIR)\apitests\testing\desc\*.java\
$(JSDEBUGGING_DIR)\apitests\testing\tests\*.java\
$(JSDEBUGGING_DIR)\apitests\analyzing\*.java\
$(JSDEBUGGING_DIR)\apitests\analyzing\analyzers\*.java\
$(JSDEBUGGING_DIR)\apitests\analyzing\data\*.java\
$(JSDEBUGGING_DIR)\apitests\analyzing\tree\*.java
com_netscape_jsdebugging_jslogger :
@echo building com.netscape.jsdebugging.jslogger
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\jslogger\*.java
com_netscape_jsdebugging_tools_depend :
@echo building com.netscape.jsdebugging.tools.depend
@sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\tools\depend\*.java
com_netscape_jsdebugging_remote_corba : initial_state
@echo building com.netscape.jsdebugging.remote.corba
@if "$(ES3_ROOT)" == "" @echo !!! ES3_ROOT is not set !!!
@if not exist $(ES3_ROOT)\NUL @echo !!! $(ES3_ROOT) does not exist !!!
@sj $(CORBA_JAVA_FLAGS) \
$(JSDEBUGGING_DIR)\remote\corba\*.java \
$(JSDEBUGGING_DIR)\remote\corba\ISourceTextProviderPackage\*.java \
$(JSDEBUGGING_DIR)\remote\corba\TestInterfacePackage\*.java \
com_netscape_jsdebugging_api_corba : com_netscape_jsdebugging_api com_netscape_jsdebugging_remote_corba ifcui
@echo building com.netscape.jsdebugging.api.corba
@sj $(CORBA_JAVA_FLAGS) $(JSDEBUGGING_DIR)\api\corba\*.java
api_corba_fast :
@echo building com.netscape.jsdebugging.api.corba
@sj $(CORBA_JAVA_FLAGS) $(JSDEBUGGING_DIR)\api\corba\*.java
########## packaging #################
JSLOGGER_CLASS_FILES = \
com\netscape\jsdebugging\jslogger\*.class \
com\netscape\jsdebugging\ifcui\Log.class \
com\netscape\jsdebugging\ifcui\Env.class \
com\netscape\jsdebugging\ifcui\palomar\util\*.class
JSLOGGER_EXPECTED_DEPENDENCIES = \
-i java \
-i netscape/application \
-i netscape/util \
-i netscape/jsdebug \
-i netscape/security
check_depend_jslogger :
@echo checking for unexpected dependencies in jslogger
@cd $(FROM_BUILD_TO_DIST_CLASSES)
@jre -cp . com.netscape.jsdebugging.tools.depend.Main \
$(JSLOGGER_CLASS_FILES) $(JSLOGGER_EXPECTED_DEPENDENCIES)
@cd $(FROM_DIST_CLASSES_TO_BUILD)
jslogger_jar :
@echo building $(JSLOGGER_JARFILE)
@cd $(FROM_BUILD_TO_DIST_CLASSES)
@if exist $(JSLOGGER_JARFILE) @del $(JSLOGGER_JARFILE) >NUL
@zip -q -r $(JSLOGGER_JARFILE) $(JSLOGGER_CLASS_FILES)
@cd $(FROM_DIST_CLASSES_TO_BUILD)
@echo copying $(JSLOGGER_JARFILE) to $(JSLOGGER_MAIN_DIR)
@copy $(DIST_CLASSES)\$(JSLOGGER_JARFILE) $(JSLOGGER_MAIN_DIR) >NUL
##########
NETSCAPE_JSDEBUG_CLASS_FILES = netscape\jsdebug\*.class
NETSCAPE_JSDEBUG_EXPECTED_DEPENDENCIES = \
-i java \
-i netscape/security \
-i netscape/util \
check_depend_netscape_jsdebug :
@echo checking for unexpected dependencies in netscape.jsdebug
@cd $(FROM_BUILD_TO_DIST_CLASSES)
@jre -cp . com.netscape.jsdebugging.tools.depend.Main \
$(NETSCAPE_JSDEBUG_CLASS_FILES) $(NETSCAPE_JSDEBUG_EXPECTED_DEPENDENCIES)
@cd $(FROM_DIST_CLASSES_TO_BUILD)
netscape_jsdebug_jar :
@echo building $(NETSCAPE_JSDEBUG_JARFILE)
@cd $(FROM_BUILD_TO_DIST_CLASSES)
@if exist $(NETSCAPE_JSDEBUG_JARFILE) @del $(NETSCAPE_JSDEBUG_JARFILE) >NUL
@zip -q -r $(NETSCAPE_JSDEBUG_JARFILE) $(NETSCAPE_JSDEBUG_CLASS_FILES)
@cd $(FROM_DIST_CLASSES_TO_BUILD)
# @echo copying $(JSLOGGER_JARFILE) to $(JSLOGGER_MAIN_DIR)
# @copy $(DIST_CLASSES)\$(JSLOGGER_JARFILE) $(JSLOGGER_MAIN_DIR) >NUL
##########
IFCUI_CLASS_FILES = \
com\netscape\jsdebugging\ifcui\*.class \
com\netscape\jsdebugging\ifcui\palomar\util\*.class \
com\netscape\jsdebugging\ifcui\palomar\widget\*.class \
com\netscape\jsdebugging\ifcui\palomar\widget\layout\*.class \
com\netscape\jsdebugging\ifcui\palomar\widget\layout\math\*.class \
com\netscape\jsdebugging\ifcui\palomar\widget\toolbar\*.class \
com\netscape\jsdebugging\ifcui\palomar\widget\toolTip\*.class \
com\netscape\jsdebugging\api\*.class \
!IF "$(INCLUDE_SECURITY)" != ""
netscape\security\*.class \
!ENDIF
!IF "$(INCLUDE_LOCAL_ADAPTER)" != ""
com\netscape\jsdebugging\api\local\*.class \
!ENDIF
!IF "$(INCLUDE_RHINO_ADAPTER)" != ""
com\netscape\jsdebugging\api\rhino\*.class \
!ENDIF
!IF "$(INCLUDE_CORBA_ADAPTER)" != ""
com\netscape\jsdebugging\api\corba\*.class \
!ENDIF
!IF "$(INCLUDE_LOCAL_LAUNCHER)" != ""
com\netscape\jsdebugging\ifcui\launcher\local\*.class \
!ENDIF
!IF "$(INCLUDE_RHINO_LAUNCHER)" != ""
com\netscape\jsdebugging\ifcui\launcher\rhino\*.class \
!ENDIF
IFCUI_OTHER_FILES = \
!IF "$(INCLUDE_IMAGES)" != ""
images\*.gif \
!ENDIF
!IF "$(INCLUDE_SOUNDS)" != ""
sounds\*.au \
!ENDIF
IFCUI_EXPECTED_DEPENDENCIES = \
-i java \
-i netscape/security \
-i netscape/util \
-i netscape/application \
-i netscape/javascript \
!IF "$(INCLUDE_LOCAL_ADAPTER)" != ""
-i netscape/jsdebug \
!ENDIF
!IF "$(INCLUDE_RHINO_ADAPTER)" != ""
-i com/netscape/javascript \
!ENDIF
check_depend_ifcui :
@echo checking for unexpected dependencies for ifcui
@cd $(FROM_BUILD_TO_DIST_CLASSES)
@jre -cp . com.netscape.jsdebugging.tools.depend.Main \
$(IFCUI_CLASS_FILES) $(IFCUI_EXPECTED_DEPENDENCIES)
@cd $(FROM_DIST_CLASSES_TO_BUILD)
ifcui_jar :
@echo building $(IFCUI_JARFILE)
@cd $(FROM_BUILD_TO_DIST_CLASSES)
@if exist $(IFCUI_JARFILE) @del $(IFCUI_JARFILE) >NUL
@zip -q -r $(IFCUI_JARFILE) $(IFCUI_CLASS_FILES) $(IFCUI_OTHER_FILES)
@cd $(FROM_DIST_CLASSES_TO_BUILD)
@echo copying $(IFCUI_JARFILE) to $(IFCUI_RUN_DIR)
@copy $(DIST_CLASSES)\$(IFCUI_JARFILE) $(IFCUI_RUN_DIR) >NUL
########## javadoc stuff #################
ALL_PACKAGES = \
netscape.security \
netscape.jsdebug \
netscape.javascript \
netscape.applet \
com.netscape.jsdebugging.api \
com.netscape.jsdebugging.api.local \
com.netscape.jsdebugging.engine \
com.netscape.jsdebugging.engine.local \
com.netscape.jsdebugging.jsdb \
com.netscape.jsdebugging.ifcui \
com.netscape.jsdebugging.ifcui.palomar.util \
com.netscape.jsdebugging.ifcui.palomar.widget \
com.netscape.jsdebugging.ifcui.palomar.widget.layout \
com.netscape.jsdebugging.ifcui.palomar.widget.layout.math \
com.netscape.jsdebugging.ifcui.palomar.widget.toolbar \
com.netscape.jsdebugging.ifcui.palomar.widget.toolTip \
com.netscape.jsdebugging.ifcui.launcher.local \
com.netscape.jsdebugging.apitests \
com.netscape.jsdebugging.apitests.xml \
com.netscape.jsdebugging.apitests.testing \
com.netscape.jsdebugging.apitests.testing.desc \
com.netscape.jsdebugging.apitests.testing.tests \
com.netscape.jsdebugging.apitests.analyzing.analyzers \
com.netscape.jsdebugging.apitests.analyzing.data \
com.netscape.jsdebugging.apitests.analyzing.tree \
com.netscape.jsdebugging.jslogger \
com.netscape.jsdebugging.tools.depend \
com.netscape.nativejsengine \
!IF "$(NO_RHINO)" == ""
com.netscape.jsdebugging.api.rhino \
com.netscape.jsdebugging.engine.rhino \
com.netscape.jsdebugging.ifcui.launcher.rhino \
!ENDIF
!IF "$(NO_CORBA)" == ""
com.netscape.jsdebugging.api.corba \
com.netscape.jsdebugging.remote.corba \
com.netscape.jsdebugging.remote.corba.ISourceTextProviderPackage \
com.netscape.jsdebugging.remote.corba.TestInterfacePackage \
!ENDIF
javadoc_all : initial_state
@echo cleaning up old stuff in javadoc directory
@if exist $(DIST)\javadocs\*.html @del $(DIST)\javadocs\*.html > NUL
@echo copying javadoc images to the dist dir
@copy $(BUILD_DIR)\images\*.gif $(DIST)\javadocs\images > NUL
@echo building javadoc for EVERYTHING
@javadoc -sourcepath $(JAVADOC_CLASSPATH);$(CLASS_SRC);$(BUILD_DIR)\..\stub_classes -d $(DIST)\javadocs $(ALL_PACKAGES)
########## before anything can happen... #################
initial_state : MK_DIST_CLASSES_DIRS $(IFC_DIST_FILE)
$(IFC_DIST_FILE) :
@echo getting ifc11.jar -- if this fails you need to copy it to dist/classes yourself
copy ..\..\..\nav-java\stubs\classes\ifc11.jar $(DIST_CLASSES) > NUL
########## directory stuff #################
#
# This list got too long so I split it in two. If you need to add more items
# then add them to the second list...
#
DIST_CLASSES_DIRS_0 = \
$(DIST) \
$(DIST_CLASSES) \
$(DIST_CLASSES)\images \
$(DIST_CLASSES)\sounds \
$(DIST_CLASSES)\netscape \
$(DIST_CLASSES)\netscape\security \
$(DIST_CLASSES)\netscape\jsdebug \
$(DIST_CLASSES)\netscape\javascript \
$(DIST_CLASSES)\netscape\applet \
$(DIST_CLASSES)\com \
$(DIST_CLASSES)\com\netscape \
$(DIST_CLASSES)\com\netscape\jsdebugging \
$(DIST_CLASSES)\com\netscape\jsdebugging\api \
$(DIST_CLASSES)\com\netscape\jsdebugging\api\local \
$(DIST_CLASSES)\com\netscape\jsdebugging\api\rhino \
$(DIST_CLASSES)\com\netscape\jsdebugging\api\corba \
$(DIST_CLASSES)\com\netscape\jsdebugging\engine \
$(DIST_CLASSES)\com\netscape\jsdebugging\engine\local \
$(DIST_CLASSES)\com\netscape\jsdebugging\engine\rhino \
$(DIST_CLASSES)\com\netscape\jsdebugging\jsdb \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\util \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\widget \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\widget\layout \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\widget\layout\math \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\widget\toolbar \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\widget\toolTip \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\launcher \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\launcher\local \
$(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\launcher\rhino \
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests \
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\xml \
DIST_CLASSES_DIRS_1 = \
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\testing \
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\testing\desc \
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\testing\tests \
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\analyzing \
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\analyzing\analyzers \
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\analyzing\data \
$(DIST_CLASSES)\com\netscape\jsdebugging\apitests\analyzing\tree \
$(DIST_CLASSES)\com\netscape\jsdebugging\jslogger \
$(DIST_CLASSES)\com\netscape\jsdebugging\tools \
$(DIST_CLASSES)\com\netscape\jsdebugging\tools\depend \
$(DIST_CLASSES)\com\netscape\nativejsengine \
$(DIST)\javadocs \
$(DIST)\javadocs\images \
$(DIST_CLASSES)\com\netscape\jsdebugging\remote \
$(DIST_CLASSES)\com\netscape\jsdebugging\remote\corba \
$(DIST_CLASSES)\com\netscape\jsdebugging\remote\corba\ISourceTextProviderPackage \
$(DIST_CLASSES)\com\netscape\jsdebugging\remote\corba\TestInterfacePackage \
MK_DIST_CLASSES_DIRS :
@echo making any non existent classfile output directories
@for %i in ($(DIST_CLASSES_DIRS_0)) do @if not exist %i\NUL mkdir %i > NUL
@for %i in ($(DIST_CLASSES_DIRS_1)) do @if not exist %i\NUL mkdir %i > NUL
CP_DIST_CLASSES_RESOURCES : initial_state
@echo copying images and sounds to dist directory
@xcopy $(BUILD_DIR)\..\ifcui\run\images\*.* $(DIST_CLASSES)\images > NUL
@xcopy $(BUILD_DIR)\..\ifcui\run\sounds\*.* $(DIST_CLASSES)\sounds > NUL
clean:
@echo deleting built classes
@for %i in ($(DIST_CLASSES_DIRS_0)) do @if exist %i\*.class @del %i\*.class > NUL
@for %i in ($(DIST_CLASSES_DIRS_1)) do @if exist %i\*.class @del %i\*.class > NUL
@echo deleting ifcui image and sound resources
@if exist $(DIST_CLASSES)\images\*.gif @del $(DIST_CLASSES)\images\*.gif > NUL
@if exist $(DIST_CLASSES)\sounds\*.au @del $(DIST_CLASSES)\sounds\*.au > NUL

1
js/jsdj/build/mk.bat Executable file
View File

@ -0,0 +1 @@
nmake -f jsdj.mak %1 %2 %3 %4 %5 %6 %7 %8 %9

2
js/jsdj/build/mk_ifcui_std.bat Executable file
View File

@ -0,0 +1,2 @@
nmake -f jsdj.mak INCLUDE_SECURITY=1 INCLUDE_LOCAL_ADAPTER=1 INCLUDE_LOCAL_LAUNCHER=1 INCLUDE_IMAGES=1 INCLUDE_SOUNDS=1 %1 %2 %3 %4 %5 %6 %7 %8 %9

View File

@ -0,0 +1 @@
call mk_ifcui_std.bat ifcui_fast ifcui_jar

7
js/jsdj/classes/README Normal file
View File

@ -0,0 +1,7 @@
/* jband - 09/14/98 - */
The 'classes' directory is the root of the JavaScript debugging pacakage space.
Older pacakages begin with 'netscape' (e.g. netscape.jsdebug which shipped - in
eariler form - with Navigator 4.x). Newer packages all start with
'com.netscape'.

View File

@ -0,0 +1,29 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
import netscape.security.ForbiddenTargetException;
public interface AdapterLoader
{
public void setHost(String host);
public boolean isDebuggingSupported() throws ForbiddenTargetException;
public DebugController getDebugController() throws ForbiddenTargetException;
public SourceTextProvider getSourceTextProvider();
}

View File

@ -0,0 +1,35 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
/**
* DebugBreakHook must be subclassed to respond to hooks
* at a particular program instruction.
*/
public class DebugBreakHook extends Hook {
/**
* Override this method to respond just before a thread
* reaches a particular instruction.
*/
/* jband - 03/31/97 - I made this public to allow chaining */
public void aboutToExecute(ThreadStateBase debug, PC pc) {
// defaults to no action
}
}

View File

@ -0,0 +1,138 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
import netscape.security.ForbiddenTargetException;
/**
* This is the master control panel for observing events in the VM.
* Each method setXHook() must be passed an object that extends
* the interface XHook. When an event of the specified type
* occurs, a well-known method on XHook will be called (see the
* various XHook interfacees for details). The method call takes place
* on the same thread that triggered the event in the first place,
* so that any monitors held by the thread which triggered the hook
* will still be owned in the hook method.
*/
public interface DebugController
{
public static final long SUPPORTS_EXEC_TO_VALUE = 1L << 0;
public static final long SUPPORTS_CATCH_EXEC_ERRORS = 1L << 1;
public static final long SUPPORTS_FRAME_CALL_SCOPE_THIS = 1L << 2;
/**
* Return flags which indicate what 'extended' capabilities are supported
* by the implementing api
*
* NOTE: this function is only available for version 1.1 and above
* i.e. if(getMajorVersion() > 1 || getMinorVersion() >= 1)
*
*/
public long getSupportsFlags();
/**
* Request notification of Script loading events. Whenever a Script
* is loaded into or unloaded from the VM the appropriate method of
* the ScriptHook argument will be called.
* returns the previous hook object.
*/
public ScriptHook setScriptHook(ScriptHook h)
throws ForbiddenTargetException;
/**
* Find the current observer of Script events, or return null if there
* is none.
*/
public ScriptHook getScriptHook()
throws ForbiddenTargetException;
/**
* Set a hook at the given program counter value. When
* a thread reaches that instruction, a ThreadState object will be
* created and the appropriate method of the hook object
* will be called.
* returns the previous hook object.
*/
public InstructionHook setInstructionHook(
PC pc,
InstructionHook h)
throws ForbiddenTargetException;
/**
* Get the hook at the given program counter value, or return
* null if there is none.
*/
public InstructionHook getInstructionHook(PC pc)
throws ForbiddenTargetException;
public InterruptHook setInterruptHook( InterruptHook h )
throws ForbiddenTargetException;
public InterruptHook getInterruptHook()
throws ForbiddenTargetException;
public void sendInterrupt()
throws ForbiddenTargetException;
public void sendInterruptStepInto(ThreadStateBase debug)
throws ForbiddenTargetException;
public void sendInterruptStepOver(ThreadStateBase debug)
throws ForbiddenTargetException;
public void sendInterruptStepOut(ThreadStateBase debug)
throws ForbiddenTargetException;
public void reinstateStepper(ThreadStateBase debug)
throws ForbiddenTargetException;
public DebugBreakHook setDebugBreakHook( DebugBreakHook h )
throws ForbiddenTargetException;
public DebugBreakHook getDebugBreakHook()
throws ForbiddenTargetException;
public ExecResult executeScriptInStackFrame( JSStackFrameInfo frame,
String text,
String filename,
int lineno )
throws ForbiddenTargetException;
public ExecResult executeScriptInStackFrameValue( JSStackFrameInfo frame,
String text,
String filename,
int lineno )
throws ForbiddenTargetException;
public JSErrorReporter getErrorReporter()
throws ForbiddenTargetException;
public JSErrorReporter setErrorReporter(JSErrorReporter er)
throws ForbiddenTargetException;
public void iterateScripts(ScriptHook h)
throws ForbiddenTargetException;
public int getMajorVersion();
public int getMinorVersion();
}

View File

@ -0,0 +1,33 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
public interface ExecResult
{
public String getResult();
public boolean getErrorOccured();
public String getErrorMessage();
public String getErrorFilename();
public int getErrorLineNumber();
public String getErrorLineBuffer();
public int getErrorTokenOffset();
public Value getResultValue();
}

View File

@ -0,0 +1,27 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
/**
* An instance of this class is returned for each hook set by
* the debugger as a handle for removing the hook later.
*/
public abstract class Hook {
}

View File

@ -0,0 +1,50 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
/**
* InstructionHook must be subclassed to respond to hooks
* at a particular program instruction.
*/
public class InstructionHook extends Hook {
private PC pc;
/**
* Create an InstructionHook at the given PC value.
*/
public InstructionHook(PC pc) {
this.pc = pc;
}
/**
* Get the instruction that the hook is set at.
*/
public PC getPC() {
return pc;
}
/**
* Override this method to respond just before a thread
* reaches a particular instruction.
*/
/* jband - 03/31/97 - I made this public to allow chaining */
public void aboutToExecute(ThreadStateBase debug) {
// defaults to no action
}
}

View File

@ -0,0 +1,36 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
/**
* InterruptHook must be subclassed to respond to hooks
* at a particular program instruction.
*/
public class InterruptHook extends Hook {
/**
* Override this method to respond just before a thread
* reaches a particular instruction.
*/
/* jband - 03/31/97 - I made this public to allow chaining */
public void aboutToExecute(ThreadStateBase debug, PC pc) {
// System.out.println( "called the wrong hook..." );
// defaults to no action
}
}

View File

@ -0,0 +1,39 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
public class InvalidInfoException extends Exception
{
/**
* Constructs a InvalidInfoException without a detail message.
* A detail message is a String that describes this particular exception.
*/
public InvalidInfoException() {
super();
}
/**
* Constructs a InvalidInfoException with a detail message.
* A detail message is a String that describes this particular exception.
* @param s the detail message
*/
public InvalidInfoException(String s) {
super(s);
}
}

View File

@ -0,0 +1,33 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
public interface JSErrorReporter
{
/* keep these in sync with the numbers in jsdebug.h */
public int PASS_ALONG = 0;
public int RETURN = 1;
public int DEBUG = 2;
public int reportError( String msg,
String filename,
int lineno,
String linebuf,
int tokenOffset );
}

View File

@ -0,0 +1,41 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
/**
* This subinterface of PC provides JavaScript-specific information.
*/
public interface JSPC extends PC
{
public Script getScript();
public int getPC();
public boolean isValid();
/**
* Get the SourceLocation associated with this PC value.
* returns null if the source location is unavailable.
*/
public SourceLocation getSourceLocation();
// XXX need to implement these...
public boolean equals(Object obj);
public int hashCode();
public String toString();
}

View File

@ -0,0 +1,43 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
public interface JSSourceLocation extends SourceLocation
{
/**
* Gets the first line number associated with this SourceLocation.
* This is the lowest common denominator information that will be
* available: some implementations may choose to include more
* specific location information in a subinterface of SourceLocation.
*/
public int getLine();
public String getURL();
/**
* Get the first PC associated with a given SourceLocation.
* This is the place to set a breakpoint at that location.
* returns null if there is no code corresponding to that source
* location.
*/
public PC getPC();
// XXX
public String toString();
}

View File

@ -0,0 +1,45 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
/**
* This interface provides access to the execution stack of a thread.
* It has several subinterfacees to distinguish between different kinds of
* stack frames: these currently include activations of Java methods
* or JavaScript functions.
* It is possible that synchronize blocks and try blocks deserve their own
* stack frames - to allow for later extensions a debugger should skip over
* stack frames it doesn't understand.
* Note that this appears very Java-specific. However, multiple threads and
* exceptions are relevant to JavaScript as well because of its
* interoperation with Java.
*/
public interface JSStackFrameInfo extends StackFrameInfo
{
public Value getCallObject()
throws InvalidInfoException;
public Value getScopeChain()
throws InvalidInfoException;
public Value getThis()
throws InvalidInfoException;
}

View File

@ -0,0 +1,23 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
public interface JSThreadState extends ThreadStateBase
{
}

View File

@ -0,0 +1,37 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
/**
* The PC interface is an opaque representation of a program counter. It
* may have different implementations for interpreted Java methods,
* methods compiled by the JIT, JavaScript methods, etc.
*/
public interface PC {
/**
* Get the SourceLocation associated with this PC value.
* returns null if the source location is unavailable.
*/
public SourceLocation getSourceLocation();
/**
* Ask whether two program counter values are equal.
*/
public boolean equals(Object obj);
}

View File

@ -0,0 +1,53 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
public interface Property
{
// these must stay the same as the flags in netscape.jsdebug.Property.java
public static int ENUMERATE = 0x01; /* visible to for/in loop */
public static int READONLY = 0x02; /* assignment is error */
public static int PERMANENT = 0x04; /* property cannot be deleted */
public static int ALIAS = 0x08; /* property has an alias id */
public static int ARGUMENT = 0x10; /* argument to function */
public static int VARIABLE = 0x20; /* local variable in function */
public static int HINTED = 0x800; /* found via explicit lookup */
public boolean isNameString();
public boolean isAliasString();
public String getNameString();
public int getNameInt();
public String getAliasString();
public int getAliasInt();
public Value getValue();
public int getVarArgSlot();
public int getFlags();
public boolean canEnumerate();
public boolean isReadOnly();
public boolean isPermanent();
public boolean hasAlias();
public boolean isArgument();
public boolean isVariable();
public boolean isHinted();
}

View File

@ -0,0 +1,9 @@
/* jband - 09/14/98 - */
com.netscape.jsdebugging.api is the package which defines the interface used by
debugger(s) to access the debugging support in the JavaScript engine. It exists
to allow the very same debugger to be used with either the C based engine, the
Java based engine (Rhino), of with a remote engine accessed via Corba/iiop
(additional 'adapter' implementations might be added in the future). This
package presents the generic JS debug interface against which the debugger
compiles and runs.

View File

@ -0,0 +1,35 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
public interface Script
{
public String getURL();
public String getFunction();
public int getBaseLineNumber();
public int getLineExtent();
public boolean isValid();
public JSPC getClosestPC(int line);
public ScriptSection[] getSections();
// XXX
public String toString();
public int hashCode();
public boolean equals(Object obj);
}

View File

@ -0,0 +1,49 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
/**
* ScriptHook must be subclassed to respond to significant events
* in the virtual machine.
*/
public class ScriptHook extends Hook
{
/**
* Create a ScriptHook for current the current VM.
*/
public ScriptHook() {}
/**
* Override this method to respond when a new script is
* loaded into the VM.
*/
/* jband - 03/31/97 - I made this public to allow chaining */
public void justLoadedScript(Script script) {
// defaults to no action
}
/**
* Override this method to respond when a class is
* about to be unloaded from the VM.
*/
/* jband - 03/31/97 - I made this public to allow chaining */
public void aboutToUnloadScript(Script script) {
// defaults to no action
}
}

View File

@ -0,0 +1,26 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
public interface ScriptSection
{
public int getBaseLineNumber();
public int getLineExtent();
}

View File

@ -0,0 +1,45 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
/**
* An implementation of the SourceLocation interface is used to represent
* a location in a source file. Java interfacefiles only make source locations
* available at the line-by-line granularity, but other languages may
* include finer-grain information. At this time only line number
* information is included.
* XXX must source locations be contiguous?
*/
public interface SourceLocation {
/**
* Gets the first line number associated with this SourceLocation.
* This is the lowest common denominator information that will be
* available: some implementations may choose to include more
* specific location information in a subinterface of SourceLocation.
*/
public int getLine();
/**
* Get the first PC associated with a given SourceLocation.
* This is the place to set a breakpoint at that location.
* returns null if there is no code corresponding to that source
* location.
*/
public PC getPC();
}

View File

@ -0,0 +1,39 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
public interface SourceTextItem
{
/* these coorespond to jsdebug.h values - change in both places if anywhere */
public static final int INITED = 0;
public static final int FULL = 1;
public static final int PARTIAL = 2;
public static final int ABORTED = 3;
public static final int FAILED = 4;
public static final int CLEARED = 5;
public String getURL();
public String getText();
public int getStatus();
public int getAlterCount();
// these are not supported in Livewire version (simulated locally)
public boolean getDirty();
public void setDirty(boolean b);
}

View File

@ -0,0 +1,27 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
public interface SourceTextProvider
{
public SourceTextItem[] getItems();
public void refreshAll();
public SourceTextItem findItem(String url);
public SourceTextItem loadItem(String url);
}

View File

@ -0,0 +1,42 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
/**
* This interface provides access to the execution stack of a thread.
* It has several subinterfacees to distinguish between different kinds of
* stack frames: these currently include activations of Java methods
* or JavaScript functions.
* It is possible that synchronize blocks and try blocks deserve their own
* stack frames - to allow for later extensions a debugger should skip over
* stack frames it doesn't understand.
* Note that this appears very Java-specific. However, multiple threads and
* exceptions are relevant to JavaScript as well because of its
* interoperation with Java.
*/
public interface StackFrameInfo
{
public boolean isValid();
// public StackFrameInfo getCaller() throws InvalidInfoException;
// public Thread getThread();
public ThreadStateBase getThreadState();
public PC getPC() throws InvalidInfoException;
}

View File

@ -0,0 +1,134 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
/**
* When a hook is hit, the debugger records the state of the
* thread before the hook in a ThreadState object. This object
* is then passed to any hook methods that are called, and can
* be used to change the state of the thread when it resumes from the
* hook.
*/
public interface ThreadStateBase
{
/**
* Return true if the Thread hasn't been resumed since this ThreadState
* was made.
*/
public boolean isValid();
/**
* partial list of thread states from sun.debug.ThreadInfo.
* XXX some of these don't apply.
*/
public int THR_STATUS_UNKNOWN = 0x01;
public int THR_STATUS_ZOMBIE = 0x02;
public int THR_STATUS_RUNNING = 0x03;
public int THR_STATUS_SLEEPING = 0x04;
public int THR_STATUS_MONWAIT = 0x05;
public int THR_STATUS_CONDWAIT = 0x06;
public int THR_STATUS_SUSPENDED = 0x07;
public int THR_STATUS_BREAK = 0x08;
/**
* Get the state of the thread at the time it entered debug mode.
* This can't be modified directly.
*/
public int getStatus();
public int countStackFrames()
throws InvalidInfoException;
public StackFrameInfo getCurrentFrame()
throws InvalidInfoException;
/**
* Get the thread's stack as an array. stack[stack.length-1] is the
* current frame, and stack[0] is the beginning of the stack.
*/
public StackFrameInfo[] getStack()
throws InvalidInfoException;
/**
* Return true if the thread is currently running a hook
* for this ThreadState
*/
public boolean isRunningHook();
/**
* Return true if the hook on this thread has already completed
* and we are waiting for a call to resume()
*/
public boolean isWaitingForResume();
/**
* Leave the thread in a suspended state when the hook method(s)
* finish. This can be undone by calling resume().
*/
public void leaveSuspended();
/**
* Resume the thread.
* Two cases:
* 1) Hook is still running, this will undo the leaveSuspended
* and the thread will still be waiting for the hook to
* return.
* 2) Hook has already returned and we are in an event loop
* waiting to contine the suspended thread, this will
* force completion of events pending on the suspended
* thread and resume it.
*/
public void resume();
/**
* if the continueState is DEAD, the thread cannot
* be restarted.
*/
public int DEBUG_STATE_DEAD = 0x01;
/**
* if the continueState is RUN, the thread will
* proceed to the next program counter value when it resumes.
*/
public int DEBUG_STATE_RUN = 0x02;
/**
* if the continueState is RETURN, the thread will
* return from the current method with the value in getReturnValue()
* when it resumes.
*/
public int DEBUG_STATE_RETURN = 0x03;
/**
* if the continueState is THROW, the thread will
* throw an exception (accessible with getException()) when it
* resumes.
*/
public int DEBUG_STATE_THROW = 0x04;
/**
* This gets the current continue state of the debug frame, which
* will be one of the DEBUG_STATE_* values above.
*/
public int getContinueState();
public int setContinueState(int state);
}

View File

@ -0,0 +1,56 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api;
public interface Value
{
public boolean isObject();
public boolean isNumber();
public boolean isInt();
public boolean isDouble();
public boolean isString();
public boolean isBoolean();
public boolean isNull();
public boolean isVoid();
public boolean isPrimitive();
public boolean isFunction();
public boolean isNative();
public boolean getBoolean();
public int getInt();
public double getDouble();
/**
* does a JavaScript toString conversion if value is not already a string
*/
public String getString();
public String getFunctionName();
public String getClassName();
public Value getPrototype();
public Value getParent();
public Value getConstructor();
public Property[] getProperties();
public Property getProperty(String name);
public String[] getPropertyHints();
public void setPropertyHints(String[] hints);
public void refresh();
}

View File

@ -0,0 +1,54 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.corba;
import netscape.security.ForbiddenTargetException;
import com.netscape.jsdebugging.api.DebugController;
import com.netscape.jsdebugging.api.SourceTextProvider;
public class AdapterLoaderCorba
implements com.netscape.jsdebugging.api.AdapterLoader
{
public void setHost(String host) {_host = host;}
public boolean isDebuggingSupported() throws ForbiddenTargetException
{
return null != getDebugController();
}
public com.netscape.jsdebugging.api.DebugController getDebugController() throws ForbiddenTargetException
{
if(null == _controller)
_controller = DebugControllerCorba.getDebugController(_host);
return _controller;
}
public com.netscape.jsdebugging.api.SourceTextProvider getSourceTextProvider()
{
try {
DebugControllerCorba controller =
(DebugControllerCorba) getDebugController();
return SourceTextProviderCorba.getSourceTextProvider(controller);
}
catch(ForbiddenTargetException e) {
// eat it
}
return null;
}
private DebugControllerCorba _controller;
private String _host;
}

View File

@ -0,0 +1,60 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.corba;
import com.netscape.jsdebugging.api.*;
/**
* DebugBreakHook must be subclassed to respond to hooks
* at a particular program instruction.
*/
public class DebugBreakHookCorba
extends com.netscape.jsdebugging.remote.corba._sk_IJSExecutionHook
{
private static int _objectCounter = 0;
public DebugBreakHookCorba(DebugControllerCorba controller,
DebugBreakHook hook)
{
super( "DebugBreakHookCorba_"+_objectCounter++);
_controller = controller;
_hook = hook;
}
public void aboutToExecute(com.netscape.jsdebugging.remote.corba.IJSThreadState debug,
com.netscape.jsdebugging.remote.corba.IJSPC pc)
{
try
{
JSThreadStateCorba ts = new JSThreadStateCorba(_controller, debug);
JSPCCorba jspc = (JSPCCorba) ts.getCurrentFrame().getPC();
_hook.aboutToExecute( ts, jspc );
}
catch( Exception e )
{
e.printStackTrace();
// eat it.
}
}
public DebugBreakHook getWrappedHook() {return _hook;}
private DebugControllerCorba _controller;
private DebugBreakHook _hook;
}

View File

@ -0,0 +1,559 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.corba;
import com.netscape.jsdebugging.api.*;
import netscape.security.PrivilegeManager;
import netscape.security.ForbiddenTargetException;
import com.netscape.jsdebugging.ifcui.Log;
import com.netscape.jsdebugging.ifcui.palomar.util.ER;
/**
* This is the master control panel for observing events in the VM.
* Each method setXHook() must be passed an object that extends
* the interface XHook. When an event of the specified type
* occurs, a well-known method on XHook will be called (see the
* various XHook interfacees for details). The method call takes place
* on the same thread that triggered the event in the first place,
* so that any monitors held by the thread which triggered the hook
* will still be owned in the hook method.
*/
public class DebugControllerCorba implements DebugController
{
public long getSupportsFlags()
{
return 0;
}
public static synchronized DebugControllerCorba getDebugController(String host)
throws ForbiddenTargetException
{
if( null == _controllerCorba )
_controllerCorba = new DebugControllerCorba(host);
if( null == _controllerCorba || null == _controllerCorba._remoteController )
{
_controllerCorba = null;
throw new ForbiddenTargetException();
}
return _controllerCorba;
}
private DebugControllerCorba(String host)
{
_host = host;
try
{
_orb = org.omg.CORBA.ORB.init();
_boa = _orb.BOA_init();
PrivilegeManager.enablePrivilege("UniversalConnect");
// String name = _host+"/NameService/"+wai_name;
// org.omg.CORBA.Object o = netscape.WAI.Naming.resolve(name);
org.omg.CORBA.Object o = MyNaming.resolve(_host, wai_name);
// if(ASS)System.err.println("o = " + o );
if( null == o )
{
// eat it;
System.err.println("DebugControllerCorba.ctor (null returned by resolve)");
return;
}
_remoteController = com.netscape.jsdebugging.remote.corba.IDebugControllerHelper.narrow(o);
// if(ASS)System.err.println("_remoteController = " + _remoteController );
if( null == _remoteController )
{
// eat it;
System.err.println("DebugControllerCorba.ctor (null returned by narrow)");
return;
}
}
catch( Exception e )
{
// eat it
_printException(e, "ctor");
_remoteController = null;
return;
}
// Do a real call to the remote controller. If communication
// is not going to work, then we want to know it now.
try
{
_remoteController.getMajorVersion();
}
catch( Exception e )
{
// eat it
System.err.println("/************************************************************");
System.err.println("* JSD connected to server, but failed when making remote call");
System.err.println("* Server has probably been stopped or restarted");
System.err.println("* You should verify server is running and restart Navigator");
System.err.println("************************************************************/");
_printException(e, "ctor");
_remoteController = null;
return;
}
}
public String getHostName() {return _host;}
public com.netscape.jsdebugging.remote.corba.IDebugController getRemoteController()
{return _remoteController;}
public org.omg.CORBA.ORB getORB() {return _orb;}
public org.omg.CORBA.BOA getBOA() {return _boa;}
/**
* Request notification of Script loading events. Whenever a Script
* is loaded into or unloaded from the VM the appropriate method of
* the ScriptHook argument will be called.
* returns the previous hook object.
*/
public ScriptHook setScriptHook(ScriptHook h)
{
try
{
ScriptHookCorba newWrapper = null;
if( null != h )
{
PrivilegeManager.enablePrivilege("UniversalConnect");
newWrapper = new ScriptHookCorba(this, h);
_boa.obj_is_ready(newWrapper);
}
com.netscape.jsdebugging.remote.corba.IScriptHook oldHook =
_remoteController.setScriptHook(newWrapper);
if( null != oldHook && oldHook instanceof ScriptHookCorba )
return ((ScriptHookCorba)oldHook).getWrappedHook();
}
catch( Exception e )
{
// eat it
_printException(e, "setScriptHook");
}
return null;
}
/**
* Find the current observer of Script events, or return null if there
* is none.
*/
public ScriptHook getScriptHook()
{
try
{
com.netscape.jsdebugging.remote.corba.IScriptHook oldHook =
_remoteController.getScriptHook();
if( null != oldHook && oldHook instanceof ScriptHookCorba )
return ((ScriptHookCorba)oldHook).getWrappedHook();
}
catch( Exception e )
{
// eat it
_printException(e, "getScriptHook");
}
return null;
}
/**
* Set a hook at the given program counter value. When
* a thread reaches that instruction, a ThreadState object will be
* created and the appropriate method of the hook object
* will be called.
* returns the previous hook object.
*/
public InstructionHook setInstructionHook(
PC pc,
InstructionHook h)
{
try
{
com.netscape.jsdebugging.remote.corba.IJSPC newWrappedPC = null;
if( null != pc )
newWrappedPC = ((JSPCCorba)pc).getWrappedJSPC();
InstructionHookCorba newWrapper = null;
if( null != h )
{
PrivilegeManager.enablePrivilege("UniversalConnect");
newWrapper = new InstructionHookCorba(this, h);
_boa.obj_is_ready(newWrapper);
}
com.netscape.jsdebugging.remote.corba.IJSExecutionHook oldHook =
_remoteController.setInstructionHook(newWrapper, newWrappedPC);
if( null != oldHook && oldHook instanceof InstructionHookCorba )
return ((InstructionHookCorba)oldHook).getWrappedHook();
}
catch( Exception e )
{
// eat it
_printException(e, "setInstructionHook");
}
return null;
}
/**
* Get the hook at the given program counter value, or return
* null if there is none.
*/
public InstructionHook getInstructionHook(PC pc)
{
if( null == pc )
return null;
try
{
com.netscape.jsdebugging.remote.corba.IJSPC newWrappedPC = ((JSPCCorba)pc).getWrappedJSPC();
com.netscape.jsdebugging.remote.corba.IJSExecutionHook oldHook =
_remoteController.getInstructionHook(newWrappedPC);
if( null != oldHook && oldHook instanceof InstructionHookCorba )
return ((InstructionHookCorba)oldHook).getWrappedHook();
}
catch( Exception e )
{
// eat it
_printException(e, "getInstructionHook");
}
return null;
}
public InterruptHook setInterruptHook( InterruptHook h )
{
try
{
InterruptHookCorba newWrapper = null;
if( null != h )
{
PrivilegeManager.enablePrivilege("UniversalConnect");
newWrapper = new InterruptHookCorba(this, h);
_boa.obj_is_ready(newWrapper);
}
com.netscape.jsdebugging.remote.corba.IJSExecutionHook oldHook =
_remoteController.setInterruptHook(newWrapper);
if( null != oldHook && oldHook instanceof InterruptHookCorba )
return ((InterruptHookCorba)oldHook).getWrappedHook();
}
catch( Exception e )
{
// eat it
_printException(e, "setInterruptHook");
}
return null;
}
public InterruptHook getInterruptHook()
{
try
{
com.netscape.jsdebugging.remote.corba.IJSExecutionHook oldHook =
_remoteController.getInterruptHook();
if( null != oldHook && oldHook instanceof InterruptHookCorba )
return ((InterruptHookCorba)oldHook).getWrappedHook();
}
catch( Exception e )
{
// eat it
_printException(e, "getInterruptHook");
}
return null;
}
public void sendInterrupt()
{
try
{
if(ASS)Log.trace("_remoteController.sendInterrupt()", "+++");
_remoteController.sendInterrupt();
if(ASS)Log.trace("_remoteController.sendInterrupt()", "---");
}
catch( Exception e )
{
// eat it
_printException(e, "sendInterrupt");
}
}
public void sendInterruptStepInto(ThreadStateBase debug)
{
try
{
_remoteController.sendInterruptStepInto(
((JSThreadStateCorba)debug).getWrappedThreadState().id);
}
catch( Exception e )
{
// eat it
_printException(e, "sendInterruptStepInto");
}
}
public void sendInterruptStepOver(ThreadStateBase debug)
{
try
{
_remoteController.sendInterruptStepOver(
((JSThreadStateCorba)debug).getWrappedThreadState().id);
}
catch( Exception e )
{
// eat it
_printException(e, "sendInterruptStepOver");
}
}
public void sendInterruptStepOut(ThreadStateBase debug)
{
try
{
_remoteController.sendInterruptStepOut(
((JSThreadStateCorba)debug).getWrappedThreadState().id);
}
catch( Exception e )
{
// eat it
_printException(e, "sendInterruptStepOut");
}
}
public void reinstateStepper(ThreadStateBase debug)
{
try
{
_remoteController.reinstateStepper(
((JSThreadStateCorba)debug).getWrappedThreadState().id);
}
catch( Exception e )
{
// eat it
_printException(e, "reinstateStepper");
}
}
public DebugBreakHook setDebugBreakHook( DebugBreakHook h )
{
try
{
DebugBreakHookCorba newWrapper = null;
if( null != h )
{
PrivilegeManager.enablePrivilege("UniversalConnect");
newWrapper = new DebugBreakHookCorba(this, h);
_boa.obj_is_ready(newWrapper);
}
com.netscape.jsdebugging.remote.corba.IJSExecutionHook oldHook =
_remoteController.setDebugBreakHook(newWrapper);
if( null != oldHook && oldHook instanceof DebugBreakHookCorba )
return ((DebugBreakHookCorba)oldHook).getWrappedHook();
}
catch( Exception e )
{
// eat it
_printException(e, "setDebugBreakHook");
}
return null;
}
public DebugBreakHook getDebugBreakHook()
{
try
{
com.netscape.jsdebugging.remote.corba.IJSExecutionHook oldHook =
_remoteController.getDebugBreakHook();
if( null != oldHook && oldHook instanceof DebugBreakHookCorba )
return ((DebugBreakHookCorba)oldHook).getWrappedHook();
}
catch( Exception e )
{
// eat it
_printException(e, "getDebugBreakHook");
}
return null;
}
public ExecResult executeScriptInStackFrame( JSStackFrameInfo frame,
String text,
String filename,
int lineno )
{
JSStackFrameInfoCorba framec = (JSStackFrameInfoCorba) frame;
JSThreadStateCorba ts = (JSThreadStateCorba) framec.getThreadState();
int id = ts.getWrappedThreadState().id;
try
{
return new ExecResultCorba(_remoteController.executeScriptInStackFrame(
id, framec.getWrappedInfo(),
text, filename, lineno));
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("exeception while calling remote controler to do exec");
return null;
}
}
public ExecResult executeScriptInStackFrameValue( JSStackFrameInfo frame,
String text,
String filename,
int lineno )
throws ForbiddenTargetException
{
return null; // XXX implement this...
}
public JSErrorReporter setErrorReporter(JSErrorReporter h)
{
try
{
JSErrorReporterCorba newWrapper = null;
if( null != h )
{
PrivilegeManager.enablePrivilege("UniversalConnect");
newWrapper = new JSErrorReporterCorba(h);
_boa.obj_is_ready(newWrapper);
}
com.netscape.jsdebugging.remote.corba.IJSErrorReporter oldHook =
_remoteController.setErrorReporter(newWrapper);
if( null != oldHook && oldHook instanceof JSErrorReporterCorba )
return ((JSErrorReporterCorba)oldHook).getWrappedHook();
}
catch( Exception e )
{
// eat it
_printException(e, "setErrorReporter");
}
return null;
}
public JSErrorReporter getErrorReporter()
{
try
{
com.netscape.jsdebugging.remote.corba.IJSErrorReporter oldHook =
_remoteController.getErrorReporter();
if( null != oldHook && oldHook instanceof JSErrorReporterCorba )
return ((JSErrorReporterCorba)oldHook).getWrappedHook();
}
catch( Exception e )
{
// eat it
_printException(e, "getErrorReporter");
}
return null;
}
public void iterateScripts(ScriptHook h)
{
try
{
PrivilegeManager.enablePrivilege("UniversalConnect");
ScriptHookCorba newWrapper = new ScriptHookCorba(this, h);
_boa.obj_is_ready(newWrapper);
_remoteController.iterateScripts(newWrapper);
}
catch( Exception e )
{
// eat it
_printException(e, "iterateScripts");
}
}
public int getMajorVersion()
{
try
{
return _remoteController.getMajorVersion();
}
catch( Exception e )
{
// eat it
_printException(e, "getMajorVersion");
}
return 0;
}
public int getMinorVersion()
{
try
{
return _remoteController.getMinorVersion();
}
catch( Exception e )
{
// eat it
_printException(e, "getMinorVersion");
}
return 0;
}
private void _printException(Exception e, String funname)
{
e.printStackTrace();
System.out.println("error in DebugControllerCorba." + funname );
}
// private int _callsToRemote = 0;
// private int _callbacksFromRemote = 0;
//
// private boolean _callsToRemoteAllowed = true;
//
// public synchronized void beginCallbackFromRemote()
// {
// _callbacksFromRemote++ ;
// }
// public synchronized void endCallbackFromRemote()
// {
// _callbacksFromRemote-- ;
// }
//
// public synchronized void beginCallToRemote()
// {
// if(ASS)ER.T(_callsToRemoteAllowed,"beginCallToRemote() when ! _callsToRemoteAllowed",this);
// _callsToRemote++ ;
// if(ASS)ER.T(_callsToRemote >= 0,"_callsToRemote >= 0 failed in beginCallToRemote()",this);
// }
//
// public synchronized void endCallToRemote()
// {
// if(ASS)ER.T(_callsToRemoteAllowed,"endCallToRemote() when ! _callsToRemoteAllowed",this);
// _callsToRemote-- ;
// if(ASS)ER.T(_callsToRemote >= 0,"_callsToRemote >= 0 failed in endCallToRemote()",this);
// }
//
// public synchronized void setCallsToRemoteAllowed(boolean b)
// {
// if(ASS)ER.T(_callsToRemoteAllowed != b,"setNoCallToRemoteAllowed() called with bad arg",this);
// _callsToRemoteAllowed = b;
// }
// data...
private com.netscape.jsdebugging.remote.corba.IDebugController _remoteController = null;
private org.omg.CORBA.ORB _orb;
private org.omg.CORBA.BOA _boa;
private String _host;
private static DebugControllerCorba _controllerCorba = null;
private static final String wai_name = "JSDebugController";
private static final boolean ASS = true; // enable ASSERT support?
}

View File

@ -0,0 +1,43 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.corba;
public class ExecResultCorba
implements com.netscape.jsdebugging.api.ExecResult
{
ExecResultCorba( com.netscape.jsdebugging.remote.corba.IExecResult result )
{
_result = result;
}
public String getResult() {return _result.result;}
public boolean getErrorOccured() {return _result.errorOccured;}
public String getErrorMessage() {return _result.errorMessage;}
public String getErrorFilename() {return _result.errorFilename;}
public int getErrorLineNumber() {return _result.errorLineNumber;}
public String getErrorLineBuffer() {return _result.errorLineBuffer;}
public int getErrorTokenOffset() {return _result.errorTokenOffset;}
public com.netscape.jsdebugging.api.Value getResultValue()
{return null;} // XXX implement this
private com.netscape.jsdebugging.remote.corba.IExecResult _result;
}

View File

@ -0,0 +1,50 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.corba;
import com.netscape.jsdebugging.api.*;
/**
* InstructionHook must be subinterfaceed to respond to hooks
* at a particular program instruction.
*/
public class InstructionHookCorba
extends com.netscape.jsdebugging.remote.corba._sk_IJSExecutionHook
{
private static int _objectCounter = 0;
InstructionHookCorba(DebugControllerCorba controller,
InstructionHook hook)
{
super( "InstructionHookCorba_"+_objectCounter++);
_controller = controller;
_hook = hook;
}
public void aboutToExecute(com.netscape.jsdebugging.remote.corba.IJSThreadState debug,
com.netscape.jsdebugging.remote.corba.IJSPC pc)
{
_hook.aboutToExecute( new JSThreadStateCorba(_controller, debug) );
}
public InstructionHook getWrappedHook() {return _hook;}
private DebugControllerCorba _controller;
private InstructionHook _hook;
}

View File

@ -0,0 +1,66 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.corba;
import com.netscape.jsdebugging.api.*;
import com.netscape.jsdebugging.ifcui.Log;
import com.netscape.jsdebugging.ifcui.palomar.util.ER;
/**
* InterruptHook must be subinterfaceed to respond to hooks
* at a particular program instruction.
*/
public class InterruptHookCorba
extends com.netscape.jsdebugging.remote.corba._sk_IJSExecutionHook
{
private static int _objectCounter = 0;
public InterruptHookCorba(DebugControllerCorba controller,
InterruptHook hook)
{
super( "InterruptHookCorba_"+_objectCounter++);
_controller = controller;
_hook = hook;
}
public void aboutToExecute(com.netscape.jsdebugging.remote.corba.IJSThreadState debug,
com.netscape.jsdebugging.remote.corba.IJSPC pc)
{
if(ASS)Log.trace("com.netscape.jsdebugging.api.corba.InterruptHookCorba.aboutToExecute", "in -> , JSThreadID: "+debug.id);
// System.out.println( "InterruptHookCorba called..." );
try
{
JSThreadStateCorba ts = new JSThreadStateCorba(_controller,debug);
JSPCCorba jspc = (JSPCCorba) ts.getCurrentFrame().getPC();
_hook.aboutToExecute( ts, jspc );
}
catch( Exception e )
{
e.printStackTrace();
// eat it.
}
if(ASS)Log.trace("com.netscape.jsdebugging.api.corba.InterruptHookCorba.aboutToExecute", "out <- , JSThreadID: "+debug.id);
}
public InterruptHook getWrappedHook() {return _hook;}
private DebugControllerCorba _controller;
private InterruptHook _hook;
private static final boolean ASS = true; // enable ASSERT support?
}

View File

@ -0,0 +1,46 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.corba;
import com.netscape.jsdebugging.api.*;
public class JSErrorReporterCorba
extends com.netscape.jsdebugging.remote.corba._sk_IJSErrorReporter
{
private static int _objectCounter = 0;
public JSErrorReporterCorba(JSErrorReporter er)
{
super( "JSErrorReporterCorba_"+_objectCounter++);
_er = er;
}
public int reportError( String msg,
String filename,
int lineno,
String linebuf,
int tokenOffset )
{
return _er.reportError(msg, filename, lineno, linebuf, tokenOffset);
}
public JSErrorReporter getWrappedHook() {return _er;}
private JSErrorReporter _er;
}

View File

@ -0,0 +1,91 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.corba;
import com.netscape.jsdebugging.api.*;
/**
* This subinterface of PC provides JavaScript-specific information.
*/
public class JSPCCorba implements JSPC
{
public JSPCCorba(DebugControllerCorba controller,
com.netscape.jsdebugging.remote.corba.IJSPC pc)
{
this( controller, pc, new ScriptCorba(controller, pc.script) );
}
public JSPCCorba(DebugControllerCorba controller,
com.netscape.jsdebugging.remote.corba.IJSPC pc,
ScriptCorba script)
{
_controller = controller;
_pc = pc;
_script = script;
_sourceLocation = null;
}
public Script getScript() {return _script;}
public int getPC() {return _pc.offset;}
// XXX currently no way to track invalidity!!!
public boolean isValid() {return true;}
public SourceLocation getSourceLocation()
{
if( null == _sourceLocation )
{
try
{
_sourceLocation = new JSSourceLocationCorba(this,
_controller.getRemoteController().getSourceLocation(_pc));
}
catch (Exception e)
{
// eat it;
e.printStackTrace();
System.err.println("error in JSPCCorba.getSourceLocation()");
}
}
return _sourceLocation;
}
public boolean equals(Object obj)
{
try
{
JSPCCorba other = (JSPCCorba) obj;
return other._script.equals(_script) &&
other._pc.offset == _pc.offset;
}
catch( ClassCastException e )
{
return false;
}
}
public int hashCode() {return _script.hashCode()+_pc.offset*7;}
public String toString() {return _pc.toString();}
public com.netscape.jsdebugging.remote.corba.IJSPC getWrappedJSPC() {return _pc;}
private DebugControllerCorba _controller;
private com.netscape.jsdebugging.remote.corba.IJSPC _pc;
private ScriptCorba _script;
private JSSourceLocationCorba _sourceLocation;
}

View File

@ -0,0 +1,56 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.corba;
import com.netscape.jsdebugging.api.*;
public class JSSourceLocationCorba implements JSSourceLocation
{
public JSSourceLocationCorba( JSPCCorba pc,
com.netscape.jsdebugging.remote.corba.IJSSourceLocation sl )
{
_pc = pc;
_sl = sl;
}
public int getLine() {return _sl.line;}
public String getURL() {return _pc.getScript().getURL();}
public PC getPC() {return _pc;}
public String toString()
{
return "<JSSourceLocationCorba at "+getURL()+" line "+getLine()+">";
}
public boolean equals(Object obj)
{
try
{
JSSourceLocationCorba other = (JSSourceLocationCorba) obj;
return getLine() == other.getLine() &&
getURL().equals(other.getURL());
}
catch( ClassCastException e )
{
return false;
}
}
public int hashCode() {return getURL().hashCode() + 17*getLine();}
private JSPCCorba _pc;
private com.netscape.jsdebugging.remote.corba.IJSSourceLocation _sl;
}

View File

@ -0,0 +1,77 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.corba;
import com.netscape.jsdebugging.api.*;
/**
* This interface provides access to the execution stack of a thread.
* It has several subinterfacees to distinguish between different kinds of
* stack frames: these currently include activations of Java methods
* or JavaScript functions.
* It is possible that synchronize blocks and try blocks deserve their own
* stack frames - to allow for later extensions a debugger should skip over
* stack frames it doesn't understand.
* Note that this appears very Java-specific. However, multiple threads and
* exceptions are relevant to JavaScript as well because of its
* interoperation with Java.
*/
public class JSStackFrameInfoCorba implements JSStackFrameInfo
{
public JSStackFrameInfoCorba( DebugControllerCorba controller,
com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo info,
JSThreadStateCorba ts )
{
_info = info;
_ts = ts;
_pc = new JSPCCorba(controller, info.pc);
}
// XXX currently no way to track invalidity!!!
public boolean isValid() {return true;}
public ThreadStateBase getThreadState() {return _ts;}
public PC getPC() throws InvalidInfoException
{
if( null == _pc )
throw new InvalidInfoException();
return _pc;
}
public Value getCallObject() throws InvalidInfoException
{
throw new InvalidInfoException("not implemented");
}
public Value getScopeChain() throws InvalidInfoException
{
throw new InvalidInfoException("not implemented");
}
public Value getThis() throws InvalidInfoException
{
throw new InvalidInfoException("not implemented");
}
public com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo getWrappedInfo() {return _info;}
private com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo _info;
private JSThreadStateCorba _ts;
private JSPCCorba _pc;
}

View File

@ -0,0 +1,179 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.corba;
import com.netscape.jsdebugging.api.*;
public class JSThreadStateCorba implements JSThreadState
{
public JSThreadStateCorba(DebugControllerCorba controller,
com.netscape.jsdebugging.remote.corba.IJSThreadState ts)
{
_controller = controller;
_ts = ts;
if( null != _ts.stack && 0 != _ts.stack.length )
{
_stack = new JSStackFrameInfoCorba[_ts.stack.length];
for( int i = 0; i < _ts.stack.length; i++ )
_stack[i] = new JSStackFrameInfoCorba(_controller, _ts.stack[i], this);
}
}
// XXX currently no way to track invalidity!!!
public boolean isValid() {return true;}
public int getStatus() {return _ts.status;}
public int countStackFrames()
throws InvalidInfoException
{
if( null == _stack )
throw new InvalidInfoException();
return _stack.length;
}
public StackFrameInfo getCurrentFrame()
throws InvalidInfoException
{
if( null == _stack )
throw new InvalidInfoException();
return _stack[_stack.length-1];
}
/**
* Get the thread's stack as an array. stack[stack.length-1] is the
* current frame, and stack[0] is the beginning of the stack.
*/
public StackFrameInfo[] getStack()
throws InvalidInfoException
{
if( null == _stack )
throw new InvalidInfoException();
return _stack;
}
/**
* Return true if the thread is currently running a hook
* for this ThreadState
*/
public boolean isRunningHook()
{
try
{
return _controller.getRemoteController().isRunningHook(_ts.id);
}
catch (Exception e)
{
// eat it;
e.printStackTrace();
System.err.println("error in JSThreadStateCorba.isRunningHook");
return false;
}
}
/**
* Return true if the hook on this thread has already completed
* and we are waiting for a call to resume()
*/
public boolean isWaitingForResume()
{
try
{
return _controller.getRemoteController().isWaitingForResume(_ts.id);
}
catch (Exception e)
{
// eat it;
e.printStackTrace();
System.err.println("error in JSThreadStateCorba.isWaitingForResume");
return false;
}
}
/**
* Leave the thread in a suspended state when the hook method(s)
* finish. This can be undone by calling resume().
*/
public synchronized void leaveSuspended()
{
try
{
_controller.getRemoteController().leaveThreadSuspended(_ts.id);
}
catch (Exception e)
{
// eat it;
e.printStackTrace();
System.err.println("error in JSThreadStateCorba.isWaitingForResume");
}
}
/**
* Resume the thread.
* Two cases:
* 1) Hook is still running, this will undo the leaveSuspended
* and the thread will still be waiting for the hook to
* return.
* 2) Hook has already returned and we are in an event loop
* waiting to contine the suspended thread, this will
* force completion of events pending on the suspended
* thread and resume it.
*/
public synchronized void resume()
{
try
{
_controller.getRemoteController().resumeThread(_ts.id);
}
catch (Exception e)
{
// eat it;
e.printStackTrace();
System.err.println("error in JSThreadStateCorba.resume");
}
}
/**
* This gets the current continue state of the debug frame, which
* will be one of the DEBUG_STATE_* values above.
*/
public int getContinueState() {return _ts.continueState;}
public synchronized int setContinueState(int state)
{
int old = _ts.continueState;
try
{
_controller.getRemoteController().setThreadContinueState(_ts.id, state);
_ts.continueState = state;
}
catch (Exception e)
{
// eat it;
e.printStackTrace();
System.err.println("error in JSThreadStateCorba.setContinueState");
}
return old;
}
public com.netscape.jsdebugging.remote.corba.IJSThreadState getWrappedThreadState() {return _ts;}
private DebugControllerCorba _controller;
private com.netscape.jsdebugging.remote.corba.IJSThreadState _ts;
private JSStackFrameInfoCorba[] _stack;
}

View File

@ -0,0 +1,71 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.corba;
import java.net.URL;
import java.net.Socket;
import java.io.DataInputStream;
import java.io.DataOutputStream;
public class MyNaming
{
/*
* host is in the form: http://server[:port] e.g. http://warp
* name is just the name of the object (without "/NameService/")
*/
public static String resolveToIOR(String host, String name)
{
try
{
URL url = new URL(host);
int port = url.getPort();
if( port == -1 )
port = 80;
Socket socket = new Socket(url.getHost(), port);
DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
dos.writeBytes("GET "+"/NameService/"+name+" HTTP/1.0\n\n");
DataInputStream dis = new DataInputStream(socket.getInputStream());
String line;
while(null != (line = dis.readLine()))
{
// System.out.println("line: "+ line);
if( line.startsWith("IOR:") )
return line;
}
}
catch(Exception e)
{
// eat it...
}
return null;
}
public static org.omg.CORBA.Object resolve(String host, String name)
{
String IOR = resolveToIOR(host, name);
if( null == IOR )
return null;
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init();
if( null == orb )
return null;
return orb.string_to_object(IOR);
}
}

View File

@ -0,0 +1,91 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.corba;
import com.netscape.jsdebugging.api.*;
public class ScriptCorba implements Script
{
ScriptCorba(DebugControllerCorba controller,
com.netscape.jsdebugging.remote.corba.IScript script)
{
_controller = controller;
_script = script;
int count = _script.sections.length;
if( 0 != count )
{
_sections = new ScriptSectionCorba[count];
for( int i = 0; i < count; i++ )
_sections[i] = new ScriptSectionCorba(_script.sections[i].base,
_script.sections[i].extent);
}
else
{
// make one big section
_sections = new ScriptSectionCorba[1];
_sections[0] = new ScriptSectionCorba(_script.base, _script.extent);
}
}
public String getURL() {return _script.url;}
public String getFunction() {return _script.funname;}
public int getBaseLineNumber() {return _script.base;}
public int getLineExtent() {return _script.extent;}
// XXX right now we have no scheme for tracking destruction of scripts
public boolean isValid() {return true;}
public JSPC getClosestPC(int line)
{
try
{
return new
JSPCCorba(_controller,
_controller.getRemoteController().getClosestPC(_script, line));
}
catch (Exception e)
{
// eat it;
e.printStackTrace();
System.err.println("error in ScriptCorba.getClosestPC");
return null;
}
}
public ScriptSection[] getSections() {return _sections;}
public String toString() {return _script.toString();}
public int hashCode() {return _script.jsdscript;}
public boolean equals(Object obj)
{
try
{
return ((ScriptCorba)obj)._script.jsdscript == _script.jsdscript;
}
catch( ClassCastException e )
{
return false;
}
}
public com.netscape.jsdebugging.remote.corba.IScript getRealScript() {return _script;}
private ScriptSectionCorba[] _sections;
private DebugControllerCorba _controller;
private com.netscape.jsdebugging.remote.corba.IScript _script;
}

View File

@ -0,0 +1,54 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.corba;
import com.netscape.jsdebugging.api.*;
/**
* ScriptHook must be subinterfaceed to respond to significant events
* in the virtual machine.
*/
public class ScriptHookCorba
extends com.netscape.jsdebugging.remote.corba._sk_IScriptHook
{
private static int _objectCounter = 0;
public ScriptHookCorba(DebugControllerCorba controller,
ScriptHook hook)
{
super( "ScriptHookCorba_"+_objectCounter++);
_controller = controller;
_hook = hook;
}
public void justLoadedScript(com.netscape.jsdebugging.remote.corba.IScript script)
{
_hook.justLoadedScript( new ScriptCorba(_controller, script) );
}
public void aboutToUnloadScript(com.netscape.jsdebugging.remote.corba.IScript script)
{
_hook.aboutToUnloadScript( new ScriptCorba(_controller, script) );
}
public ScriptHook getWrappedHook() {return _hook;}
private DebugControllerCorba _controller;
private ScriptHook _hook;
}

View File

@ -0,0 +1,37 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.corba;
import com.netscape.jsdebugging.api.*;
public class ScriptSectionCorba implements ScriptSection
{
public ScriptSectionCorba( int base, int extent )
{
_base = base;
_extent = extent;
}
public int getBaseLineNumber() {return _base;}
public int getLineExtent() {return _extent;}
private int _base;
private int _extent;
}

View File

@ -0,0 +1,114 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.corba;
import com.netscape.jsdebugging.api.*;
public class SourceTextItemCorba
implements SourceTextItem
{
/*
* The 'array' param is an ugly hack. iiop doesn't really refcount the
* items, but rather the whole array. As long as this item lives, a
* ref to the array it camme from must be held. So, we hold it...
*/
public SourceTextItemCorba(com.netscape.jsdebugging.remote.corba.ISourceTextProvider pro,
String url )
{
_pro = pro;
_url = url;
}
// implements SourceTextItem
public String getURL() {return _url;}
public String getText()
{
try
{
return _pro.getPageText(_url);
}
catch( Exception e )
{
// eat it;
_printException(e, "getText");
return null;
}
}
public int getStatus()
{
try
{
return _pro.getPageStatus(_url);
}
catch( Exception e )
{
// eat it;
_printException(e, "getPageStatus");
return INITED;
}
}
public int getAlterCount()
{
try
{
return _pro.getPageAlterCount(_url);
}
catch( Exception e )
{
// eat it;
_printException(e, "getAlterCount");
return 0;
}
}
public boolean getDirty() {return _lastAlterCount < getAlterCount();}
public void setDirty(boolean b)
{
if(b)
_lastAlterCount-- ;
else
_lastAlterCount = getAlterCount();
}
private void _printException(Exception e, String funname)
{
e.printStackTrace();
System.out.println("error occured in SourceTextItemCorba." + funname );
}
public int hashCode() {return _url.hashCode();}
public boolean equals(Object obj)
{
try
{
return ((SourceTextItemCorba)obj)._url.equals(_url);
}
catch( ClassCastException e )
{
return false;
}
}
// data
private com.netscape.jsdebugging.remote.corba.ISourceTextProvider _pro;
private String _url;
private int _lastAlterCount = 0;
}

View File

@ -0,0 +1,171 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.corba;
import com.netscape.jsdebugging.api.*;
import netscape.security.PrivilegeManager;
import netscape.security.ForbiddenTargetException;
public class SourceTextProviderCorba
implements SourceTextProvider
{
// allow for possible singleton-ness enforcement
public static synchronized SourceTextProvider
getSourceTextProvider(DebugControllerCorba controller)
{
return new SourceTextProviderCorba(controller);
}
private SourceTextProviderCorba(DebugControllerCorba controller)
{
_controller = controller;
try
{
PrivilegeManager.enablePrivilege("UniversalConnect");
// String name = _controller.getHostName()+"/NameService/"+wai_name;
// org.omg.CORBA.Object o = netscape.WAI.Naming.resolve(name);
org.omg.CORBA.Object o = MyNaming.resolve(_controller.getHostName(),wai_name);
if( null == o )
{
// eat it;
System.err.println("SourceTextProviderCorba.ctor (null returned by resolve)");
return;
}
_pro = com.netscape.jsdebugging.remote.corba.ISourceTextProviderHelper.narrow(o);
if( null == _pro )
{
// eat it;
System.err.println("SourceTextProviderCorba.ctor (null returned by narrow)");
return;
}
}
catch (Exception e)
{
// eat it;
_printException(e, "ctor");
return;
}
}
// implement com.netscape.jsdebugging.ifcui.SourceTextProvider
public SourceTextItem[] getItems()
{
if( null == _pro )
return null;
if( null == _items )
_rebuildItemsArray();
return _items;
}
public void refreshAll()
{
if( null == _pro )
return;
try
{
_pro.refreshAllPages();
}
catch( Exception e )
{
// eat it;
_printException(e, "refreshAll");
}
_rebuildItemsArray();
}
public SourceTextItem findItem(String url)
{
if( null == _pro )
return null;
if( null == _items )
_rebuildItemsArray();
if( null == _items )
return null;
for( int i = 0; i < _items.length; i++ )
{
if( url.equals(_items[i].getURL()) )
return _items[i];
}
return null;
}
public SourceTextItem loadItem(String url)
{
// XXX not implemented...
return null;
}
private synchronized void _rebuildItemsArray()
{
SourceTextItemCorba[] olditems = _items;
_items = null;
if( null == _pro )
return;
try
{
String[] urls = _pro.getAllPages();
if( null == urls || 0 == urls.length )
return;
SourceTextItemCorba[] newitems = new SourceTextItemCorba[urls.length];
next_item: for( int i = 0; i < urls.length; i++ )
{
String url = urls[i];
if( null != olditems && 0 != olditems.length )
{
for( int k = 0; k < olditems.length; k++ )
{
SourceTextItemCorba item = olditems[k];
if( item.getURL().equals(url) )
{
// System.out.println( "reusing " + url );
newitems[i] = item;
continue next_item;
}
}
}
// System.out.println( "+++ new item generated for " + url );
newitems[i] = new SourceTextItemCorba(_pro,url);
}
_items = newitems;
}
catch( Exception e )
{
// eat it;
_printException(e, "_rebuildItemsArray");
}
}
private void _printException(Exception e, String funname)
{
e.printStackTrace();
System.out.println("error occured in SourceTextProviderCorba." + funname );
}
// data
private com.netscape.jsdebugging.remote.corba.ISourceTextProvider _pro = null;
private SourceTextItemCorba[] _items = null;
private DebugControllerCorba _controller;
private static final String wai_name = "JSSourceTextProvider";
}

View File

@ -0,0 +1,41 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.local;
import netscape.security.ForbiddenTargetException;
import com.netscape.jsdebugging.api.DebugController;
import com.netscape.jsdebugging.api.SourceTextProvider;
public class AdapterLoaderLocal
implements com.netscape.jsdebugging.api.AdapterLoader
{
public void setHost(String host) {} // ignored
public boolean isDebuggingSupported() throws ForbiddenTargetException
{
return null != DebugControllerLocal.getDebugController();
}
public DebugController getDebugController() throws ForbiddenTargetException
{
return DebugControllerLocal.getDebugController();
}
public SourceTextProvider getSourceTextProvider()
{
return SourceTextProviderLocal.getSourceTextProvider();
}
}

View File

@ -0,0 +1,24 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.local;
public interface Callback
{
public void call();
}

View File

@ -0,0 +1,55 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.local;
import com.netscape.jsdebugging.api.*;
/**
* DebugBreakHook must be subclassed to respond to hooks
* at a particular program instruction.
*/
public class DebugBreakHookLocal extends netscape.jsdebug.DebugBreakHook
{
public DebugBreakHookLocal( DebugBreakHook hook )
{
_hook = hook;
}
public void aboutToExecute(netscape.jsdebug.ThreadStateBase debug,
netscape.jsdebug.PC pc)
{
try
{
JSThreadStateLocal ts = new JSThreadStateLocal(debug);
JSPCLocal jspc = (JSPCLocal) ts.getCurrentFrame().getPC();
ts.aboutToCallHook();
_hook.aboutToExecute(ts, jspc);
ts.returnedFromCallHook();
}
catch( Exception e )
{
e.printStackTrace();
// eat it.
}
}
public DebugBreakHook getWrappedHook() {return _hook;}
private DebugBreakHook _hook;
}

View File

@ -0,0 +1,449 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.local;
import com.netscape.jsdebugging.api.*;
import netscape.security.ForbiddenTargetException;
import netscape.security.PrivilegeManager;
/**
* This is the master control panel for observing events in the VM.
* Each method setXHook() must be passed an object that extends
* the interface XHook. When an event of the specified type
* occurs, a well-known method on XHook will be called (see the
* various XHook interfacees for details). The method call takes place
* on the same thread that triggered the event in the first place,
* so that any monitors held by the thread which triggered the hook
* will still be owned in the hook method.
*/
public class DebugControllerLocal implements DebugController
{
public long getSupportsFlags()
{
return SUPPORTS_EXEC_TO_VALUE |
SUPPORTS_CATCH_EXEC_ERRORS |
SUPPORTS_FRAME_CALL_SCOPE_THIS ;
}
public static DebugControllerLocal getDebugController()
throws ForbiddenTargetException
{
if( null == _controllerLocal )
_controllerLocal = new DebugControllerLocal();
if( null == _controllerLocal || null == _controllerLocal._controller )
throw new ForbiddenTargetException();
return _controllerLocal;
}
private DebugControllerLocal()
{
try
{
PrivilegeManager.enablePrivilege("Debugger");
_controller = netscape.jsdebug.DebugController.getDebugController();
if( null != _controller && 0 == _controller.getNativeContext() )
{
_controller = null;
System.err.println("Unable to load natives");
}
}
catch( ForbiddenTargetException e )
{
System.out.println(e);
_controller = null;
}
}
/**
* Request notification of Script loading events. Whenever a Script
* is loaded into or unloaded from the VM the appropriate method of
* the ScriptHook argument will be called.
* returns the previous hook object.
*/
public ScriptHook setScriptHook(ScriptHook h)
throws ForbiddenTargetException
{
ScriptHookLocal newWrapper = null;
if( null != h )
newWrapper = new ScriptHookLocal(h);
netscape.jsdebug.ScriptHook oldWrapper =
_controller.setScriptHook(newWrapper);
if( null != oldWrapper && oldWrapper instanceof ScriptHookLocal )
return ((ScriptHookLocal)oldWrapper).getWrappedHook();
return null;
}
/**
* Find the current observer of Script events, or return null if there
* is none.
*/
public ScriptHook getScriptHook()
{
netscape.jsdebug.ScriptHook oldWrapper =
_controller.getScriptHook();
if( null != oldWrapper && oldWrapper instanceof ScriptHookLocal )
return ((ScriptHookLocal)oldWrapper).getWrappedHook();
return null;
}
/**
* Set a hook at the given program counter value. When
* a thread reaches that instruction, a ThreadState object will be
* created and the appropriate method of the hook object
* will be called.
* returns the previous hook object.
*/
public InstructionHook setInstructionHook(
PC pc,
InstructionHook h)
throws ForbiddenTargetException
{
// XXX this is hack to deal with fact that the native v1.0 JSD
// for Navigator can't handle a null instruction hook.
if( null == h )
return null;
netscape.jsdebug.JSPC newWrappedPC = null;
if( null != pc )
newWrappedPC = ((JSPCLocal)pc).getWrappedJSPC();
InstructionHookLocal newWrapper = null;
if( null != h )
newWrapper = new InstructionHookLocal(h, newWrappedPC);
netscape.jsdebug.InstructionHook oldWrapper =
_controller.setInstructionHook(newWrappedPC, newWrapper);
if( null != oldWrapper && oldWrapper instanceof InstructionHookLocal )
return ((InstructionHookLocal)oldWrapper).getWrappedHook();
return null;
}
/**
* Get the hook at the given program counter value, or return
* null if there is none.
*/
public InstructionHook getInstructionHook(PC pc)
throws ForbiddenTargetException
{
if( null == pc )
return null;
netscape.jsdebug.JSPC newWrappedPC = ((JSPCLocal)pc).getWrappedJSPC();
netscape.jsdebug.InstructionHook oldWrapper =
_controller.getInstructionHook(newWrappedPC);
if( null != oldWrapper && oldWrapper instanceof InstructionHookLocal )
return ((InstructionHookLocal)oldWrapper).getWrappedHook();
return null;
}
public InterruptHook setInterruptHook( InterruptHook h )
throws ForbiddenTargetException
{
InterruptHookLocal newWrapper = null;
if( null != h )
newWrapper = new InterruptHookLocal(h);
netscape.jsdebug.InterruptHook oldWrapper =
_controller.setInterruptHook(newWrapper);
if( null != oldWrapper && oldWrapper instanceof InterruptHookLocal )
return ((InterruptHookLocal)oldWrapper).getWrappedHook();
return null;
}
public InterruptHook getInterruptHook()
throws ForbiddenTargetException
{
netscape.jsdebug.InterruptHook oldWrapper =
_controller.getInterruptHook();
if( null != oldWrapper && oldWrapper instanceof InterruptHookLocal )
return ((InterruptHookLocal)oldWrapper).getWrappedHook();
return null;
}
public void sendInterrupt()
throws ForbiddenTargetException
{
_controller.sendInterrupt();
}
public void sendInterruptStepInto(ThreadStateBase debug)
{
System.err.println("call to unimplemented function sendInterruptStepInto() failed");
}
public void sendInterruptStepOver(ThreadStateBase debug)
{
System.err.println("call to unimplemented function sendInterruptStepOver() failed");
}
public void sendInterruptStepOut(ThreadStateBase debug)
{
System.err.println("call to unimplemented function sendInterruptStepOut() failed");
}
public void reinstateStepper(ThreadStateBase debug)
{
System.err.println("call to unimplemented function reinstateStepper() failed");
}
public DebugBreakHook setDebugBreakHook( DebugBreakHook h )
throws ForbiddenTargetException
{
DebugBreakHookLocal newWrapper = null;
if( null != h )
newWrapper = new DebugBreakHookLocal(h);
netscape.jsdebug.DebugBreakHook oldWrapper =
_controller.setDebugBreakHook(newWrapper);
if( null != oldWrapper && oldWrapper instanceof DebugBreakHookLocal )
return ((DebugBreakHookLocal)oldWrapper).getWrappedHook();
return null;
}
public DebugBreakHook getDebugBreakHook()
throws ForbiddenTargetException
{
netscape.jsdebug.DebugBreakHook oldWrapper =
_controller.getDebugBreakHook();
if( null != oldWrapper && oldWrapper instanceof DebugBreakHookLocal )
return ((DebugBreakHookLocal)oldWrapper).getWrappedHook();
return null;
}
public ExecResult executeScriptInStackFrame( JSStackFrameInfo frame,
String text,
String filename,
int lineno )
throws ForbiddenTargetException
{
JSThreadStateLocal ts = (JSThreadStateLocal)frame.getThreadState();
Evaluator e = new Evaluator(this,ts,frame,text,filename,lineno);
return e.eval(Evaluator.TO_STRING);
}
public ExecResult executeScriptInStackFrameValue( JSStackFrameInfo frame,
String text,
String filename,
int lineno )
throws ForbiddenTargetException
{
JSThreadStateLocal ts = (JSThreadStateLocal)frame.getThreadState();
Evaluator e = new Evaluator(this,ts,frame,text,filename,lineno);
return e.eval(Evaluator.TO_VALUE);
}
public JSErrorReporter setErrorReporter(JSErrorReporter h)
throws ForbiddenTargetException
{
JSErrorReporterLocal newWrapper = null;
if( null != h )
newWrapper = new JSErrorReporterLocal(h);
netscape.jsdebug.JSErrorReporter oldWrapper =
_controller.setErrorReporter(newWrapper);
if( null != oldWrapper && oldWrapper instanceof JSErrorReporterLocal)
return ((JSErrorReporterLocal)oldWrapper).getWrappedHook();
return null;
}
public JSErrorReporter getErrorReporter()
throws ForbiddenTargetException
{
netscape.jsdebug.JSErrorReporter oldWrapper =
_controller.getErrorReporter();
if( null != oldWrapper && oldWrapper instanceof JSErrorReporterLocal)
return ((JSErrorReporterLocal)oldWrapper).getWrappedHook();
return null;
}
public void iterateScripts(ScriptHook h)
{
// XXX does nothing at present...
}
public int getMajorVersion()
{
return _controller.getMajorVersion();
}
public int getMinorVersion()
{
return _controller.getMinorVersion();
}
public netscape.jsdebug.DebugController getWrappedController()
{
return _controller;
}
// data...
private netscape.jsdebug.DebugController _controller = null;
private static DebugControllerLocal _controllerLocal = null;
}
class Evaluator
implements Callback, JSErrorReporter
{
static final boolean TO_STRING = false;
static final boolean TO_VALUE = true;
Evaluator(DebugControllerLocal dc,
JSThreadStateLocal ts,
JSStackFrameInfo frame,
String text,
String filename,
int lineno)
{
_dc = dc ;
_ts = ts ;
_frame = frame ;
_text = text ;
_filename = filename;
_lineno = lineno ;
}
ExecResultLocal eval(boolean toValue)
{
_evalToValue = toValue;
if( !_ts.isWaitingForResume() )
{
call(); // just call directly on this thread.
}
else
{
if( ! _completed && _ts.addCallbackEvent(this) )
{
synchronized(this)
{
while( ! _completed )
{
try
{
wait();
}
catch(Exception e)
{
// eat it...
e.printStackTrace();
System.out.println(e);
break;
}
}
}
}
}
return _execResult;
}
// implement Callback
public synchronized void call()
{
JSErrorReporter oldER = null;
boolean setER = false;
try
{
PrivilegeManager.enablePrivilege("Debugger");
oldER = _dc.setErrorReporter(this);
setER = true;
if(_evalToValue)
{
// we break this out as a seperate method because
// netscape.jsdebug 1.0 had no Value class and we need to
// avoid any unnecessary references to netscape.jsdebug.Value.
_doEvalToValue();
}
else
{
String result =
_dc.getWrappedController().executeScriptInStackFrame(
((JSStackFrameInfoLocal)_frame).getWrappedInfo(),
_text,
_filename,
_lineno);
if(null == _execResult)
_execResult = new ExecResultLocal(result);
}
}
catch(Exception e)
{
// eat it...
e.printStackTrace();
System.out.println(e);
}
if(setER)
_dc.setErrorReporter(oldER);
_completed = true;
notify();
}
private void _doEvalToValue() throws Exception
{
netscape.jsdebug.Value result =
_dc.getWrappedController().executeScriptInStackFrameValue(
((JSStackFrameInfoLocal)_frame).getWrappedInfo(),
_text,
_filename,
_lineno);
if(null == _execResult)
_execResult = new ExecResultLocal(new ValueLocal(result));
}
// implements JSErrorReporter
public int reportError( String msg,
String filename,
int lineno,
String linebuf,
int tokenOffset )
{
_execResult = new ExecResultLocal(msg, filename, lineno,
linebuf, tokenOffset);
return netscape.jsdebug.JSErrorReporter.RETURN;
}
private DebugControllerLocal _dc;
private JSThreadStateLocal _ts;
private JSStackFrameInfo _frame;
private String _text;
private String _filename;
private int _lineno;
private boolean _completed;
private boolean _evalToValue;
private ExecResultLocal _execResult;
}

View File

@ -0,0 +1,62 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.local;
public class ExecResultLocal
implements com.netscape.jsdebugging.api.ExecResult
{
ExecResultLocal(String str) {_str = str;}
ExecResultLocal(ValueLocal val) {_val = val;}
ExecResultLocal(String errorMessage,
String errorFilename,
int errorLineNumber,
String errorLineBuffer,
int errorTokenOffset)
{
_errorOccured = true;
_errorMessage = errorMessage;
_errorFilename = errorFilename;
_errorLineNumber = errorLineNumber;
_errorLineBuffer = errorLineBuffer;
_errorTokenOffset= errorTokenOffset;
}
public String getResult() {return _str;}
public boolean getErrorOccured() {return _errorOccured;}
public String getErrorMessage() {return _errorMessage;}
public String getErrorFilename() {return _errorFilename;}
public int getErrorLineNumber() {return _errorLineNumber;}
public String getErrorLineBuffer() {return _errorLineBuffer;}
public int getErrorTokenOffset() {return _errorTokenOffset;}
public com.netscape.jsdebugging.api.Value getResultValue() {return _val;}
private String _str;
private ValueLocal _val;
private boolean _errorOccured;
private String _errorMessage;
private String _errorFilename;
private int _errorLineNumber;
private String _errorLineBuffer;
private int _errorTokenOffset;
}

View File

@ -0,0 +1,47 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.local;
import com.netscape.jsdebugging.api.*;
/**
* InstructionHook must be subinterfaceed to respond to hooks
* at a particular program instruction.
*/
public class InstructionHookLocal extends netscape.jsdebug.InstructionHook
{
InstructionHookLocal( InstructionHook hook,
netscape.jsdebug.JSPC pc )
{
super(pc);
_hook = hook;
}
public void aboutToExecute(netscape.jsdebug.ThreadStateBase debug)
{
JSThreadStateLocal ts = new JSThreadStateLocal(debug);
ts.aboutToCallHook();
_hook.aboutToExecute(ts);
ts.returnedFromCallHook();
}
public InstructionHook getWrappedHook() {return _hook;}
private InstructionHook _hook;
}

View File

@ -0,0 +1,56 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.local;
import com.netscape.jsdebugging.api.*;
/**
* InterruptHook must be subinterfaceed to respond to hooks
* at a particular program instruction.
*/
public class InterruptHookLocal extends netscape.jsdebug.InterruptHook
{
public InterruptHookLocal( InterruptHook hook )
{
_hook = hook;
}
public void aboutToExecute(netscape.jsdebug.ThreadStateBase debug,
netscape.jsdebug.PC pc)
{
// System.out.println( "InterruptHookLocal called..." );
try
{
JSThreadStateLocal ts = new JSThreadStateLocal(debug);
JSPCLocal jspc = (JSPCLocal) ts.getCurrentFrame().getPC();
ts.aboutToCallHook();
_hook.aboutToExecute(ts, jspc);
ts.returnedFromCallHook();
}
catch( Exception e )
{
e.printStackTrace();
// eat it.
}
}
public InterruptHook getWrappedHook() {return _hook;}
private InterruptHook _hook;
}

View File

@ -0,0 +1,42 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.local;
import com.netscape.jsdebugging.api.*;
public class JSErrorReporterLocal implements netscape.jsdebug.JSErrorReporter
{
public JSErrorReporterLocal(JSErrorReporter er)
{
_er = er;
}
public int reportError( String msg,
String filename,
int lineno,
String linebuf,
int tokenOffset )
{
return _er.reportError(msg, filename, lineno, linebuf, tokenOffset);
}
public JSErrorReporter getWrappedHook() {return _er;}
private JSErrorReporter _er;
}

View File

@ -0,0 +1,68 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.local;
import com.netscape.jsdebugging.api.*;
/**
* This subinterface of PC provides JavaScript-specific information.
*/
public class JSPCLocal implements JSPC
{
public JSPCLocal(netscape.jsdebug.JSPC pc)
{
this( pc, new ScriptLocal(pc.getScript()) );
}
public JSPCLocal(netscape.jsdebug.JSPC pc, ScriptLocal script)
{
_pc = pc;
_script = script;
_sourceLocation =
new JSSourceLocationLocal(this,
(netscape.jsdebug.JSSourceLocation)_pc.getSourceLocation());
}
public Script getScript() {return _script;}
public int getPC() {return _pc.getPC();}
public boolean isValid() {return _pc.isValid();}
public SourceLocation getSourceLocation() {return _sourceLocation;}
public boolean equals(Object obj)
{
try
{
JSPCLocal other = (JSPCLocal) obj;
return other._pc.getScript() == _pc.getScript() &&
other._pc.getPC() == _pc.getPC();
}
catch( ClassCastException e )
{
return false;
}
}
public int hashCode() {return _pc.hashCode();}
public String toString() {return _pc.toString();}
public netscape.jsdebug.JSPC getWrappedJSPC() {return _pc;}
private netscape.jsdebug.JSPC _pc;
private ScriptLocal _script;
private JSSourceLocationLocal _sourceLocation;
}

View File

@ -0,0 +1,53 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.local;
import com.netscape.jsdebugging.api.*;
public class JSSourceLocationLocal implements JSSourceLocation
{
public JSSourceLocationLocal( JSPCLocal pc,
netscape.jsdebug.JSSourceLocation sl )
{
_pc = pc;
_sl = sl;
}
public int getLine() {return _sl.getLine();}
public String getURL() {return _sl.getURL();}
public PC getPC() {return _pc;}
public String toString() {return _sl.toString();}
public boolean equals(Object obj)
{
try
{
JSSourceLocationLocal other = (JSSourceLocationLocal) obj;
return getLine() == other.getLine() &&
getURL().equals(other.getURL());
}
catch( ClassCastException e )
{
return false;
}
}
public int hashCode() {return getURL().hashCode() + 17*getLine();}
private JSPCLocal _pc;
private netscape.jsdebug.JSSourceLocation _sl;
}

View File

@ -0,0 +1,110 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.local;
import com.netscape.jsdebugging.api.*;
/**
* This interface provides access to the execution stack of a thread.
* It has several subinterfacees to distinguish between different kinds of
* stack frames: these currently include activations of Java methods
* or JavaScript functions.
* It is possible that synchronize blocks and try blocks deserve their own
* stack frames - to allow for later extensions a debugger should skip over
* stack frames it doesn't understand.
* Note that this appears very Java-specific. However, multiple threads and
* exceptions are relevant to JavaScript as well because of its
* interoperation with Java.
*/
public class JSStackFrameInfoLocal implements JSStackFrameInfo
{
public JSStackFrameInfoLocal( netscape.jsdebug.JSStackFrameInfo info,
JSThreadStateLocal ts )
{
_info = info;
_ts = ts;
try
{
_pc = new JSPCLocal((netscape.jsdebug.JSPC)_info.getPC());
}
catch( netscape.jsdebug.InvalidInfoException e )
{
_pc = null;
}
}
public boolean isValid() {return _info.isValid();}
public ThreadStateBase getThreadState() {return _ts;}
public PC getPC() throws InvalidInfoException
{
if( null == _pc )
throw new InvalidInfoException();
return _pc;
}
public Value getCallObject() throws InvalidInfoException
{
if( ! _info.isValid() )
throw new InvalidInfoException();
try
{
return new ValueLocal(_info.getCallObject());
}
catch(netscape.jsdebug.InvalidInfoException e)
{
throw new InvalidInfoException();
}
}
public Value getScopeChain() throws InvalidInfoException
{
if( ! _info.isValid() )
throw new InvalidInfoException();
try
{
return new ValueLocal(_info.getScopeChain());
}
catch(netscape.jsdebug.InvalidInfoException e)
{
throw new InvalidInfoException();
}
}
public Value getThis() throws InvalidInfoException
{
if( ! _info.isValid() )
throw new InvalidInfoException();
try
{
return new ValueLocal(_info.getThis());
}
catch(netscape.jsdebug.InvalidInfoException e)
{
throw new InvalidInfoException();
}
}
public netscape.jsdebug.JSStackFrameInfo getWrappedInfo() {return _info;}
private netscape.jsdebug.JSStackFrameInfo _info;
private JSThreadStateLocal _ts;
private JSPCLocal _pc;
}

View File

@ -0,0 +1,226 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.local;
import com.netscape.jsdebugging.api.*;
public class JSThreadStateLocal implements JSThreadState
{
public JSThreadStateLocal( netscape.jsdebug.ThreadStateBase ts )
{
_ts = ts;
try
{
netscape.jsdebug.StackFrameInfo[] stack = _ts.getStack();
if( null != stack && 0 != stack.length )
{
_stack = new JSStackFrameInfoLocal[stack.length];
for( int i = 0; i < stack.length; i++ )
_stack[i] = new JSStackFrameInfoLocal(
(netscape.jsdebug.JSStackFrameInfo)stack[i],
this);
}
}
catch( netscape.jsdebug.InvalidInfoException e )
{
_stack = null;
}
}
public boolean isValid() {return null != _stack && _ts.isValid();}
public int getStatus() {return _ts.getStatus();}
public int countStackFrames()
throws InvalidInfoException
{
if( null == _stack )
throw new InvalidInfoException();
return _stack.length;
}
public StackFrameInfo getCurrentFrame()
throws InvalidInfoException
{
if( null == _stack )
throw new InvalidInfoException();
return _stack[_stack.length-1];
}
/**
* Get the thread's stack as an array. stack[stack.length-1] is the
* current frame, and stack[0] is the beginning of the stack.
*/
public StackFrameInfo[] getStack()
throws InvalidInfoException
{
if( null == _stack )
throw new InvalidInfoException();
return _stack;
}
/**
* Return true if the thread is currently running a hook
* for this ThreadState
*/
public boolean isRunningHook()
{
return _runningHook;
}
/**
* Return true if the hook on this thread has already completed
* and we are waiting for a call to resume()
*/
public boolean isWaitingForResume()
{
return _runningEventQueue;
}
/**
* Leave the thread in a suspended state when the hook method(s)
* finish. This can be undone by calling resume().
*/
public synchronized void leaveSuspended()
{
if( _runningHook && ! _runningEventQueue )
_leaveSuspended = true;
}
/**
* Resume the thread.
* Two cases:
* 1) Hook is still running, this will undo the leaveSuspended
* and the thread will still be waiting for the hook to
* return.
* 2) Hook has already returned and we are in an event loop
* waiting to contine the suspended thread, this will
* force completion of events pending on the suspended
* thread and resume it.
*/
public synchronized void resume()
{
if( ! _runningHook )
return;
_leaveSuspended = false;
// signal stopped thread
if( _runningEventQueue )
notifyAll();
}
/**
* This gets the current continue state of the debug frame, which
* will be one of the DEBUG_STATE_* values above.
*/
public int getContinueState() {return _ts.getContinueState();}
public int setContinueState(int state) {return _ts.setContinueState(state);}
public synchronized void aboutToCallHook()
{
_runningHook = true;
}
public synchronized void returnedFromCallHook()
{
if(_leaveSuspended)
{
_runningEventQueue = true;
while( _leaveSuspended )
{
try
{
wait();
}
catch(Exception e)
{
e.printStackTrace();
System.out.println(e);
_leaveSuspended = false;
}
processAllEvents();
}
_runningEventQueue = false;
}
_runningHook = false;
}
public synchronized boolean addCallbackEvent(Callback cb)
{
if( _runningEventQueue )
{
addEvent(cb);
notify();
return true;
}
return false;
}
private synchronized void addEvent(Callback cb)
{
Event e = new Event();
e.cb = cb;
if( null != _lastEvent )
_lastEvent.next = e;
_lastEvent = e;
if( null == _firstEvent )
_firstEvent = e;
}
private synchronized Event getEvent()
{
Event e = _firstEvent;
if( null != e )
{
_firstEvent = e.next;
if( _lastEvent == e )
_lastEvent = null;
e.next = null;
}
return e;
}
private synchronized void processAllEvents()
{
Event e;
while( null != (e = getEvent()) )
{
if( null != e.cb )
e.cb.call();
}
}
private netscape.jsdebug.ThreadStateBase _ts;
private JSStackFrameInfoLocal[] _stack;
private boolean _runningHook = false;
private boolean _leaveSuspended = false;
private boolean _runningEventQueue = false;
private Event _firstEvent = null;
private Event _lastEvent = null;
}
class Event
{
public Event next = null;
public Callback cb = null;
}

View File

@ -0,0 +1,58 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.local;
public class PropertyLocal
implements com.netscape.jsdebugging.api.Property
{
PropertyLocal(netscape.jsdebug.Property prop) {_prop = prop;}
public boolean isNameString() {return _prop.isNameString();}
public boolean isAliasString() {return _prop.isAliasString();}
public String getNameString() {return _prop.getNameString();}
public int getNameInt() {return _prop.getNameInt();}
public String getAliasString() {return _prop.getAliasString();}
public int getAliasInt() {return _prop.getAliasInt();}
public com.netscape.jsdebugging.api.Value getValue()
{
if(null == _val)
_val = new ValueLocal(_prop.getValue());
return _val;
}
public int getVarArgSlot() {return _prop.getVarArgSlot();}
public int getFlags() {return _prop.getFlags();}
public boolean canEnumerate() {return _prop.canEnumerate();}
public boolean isReadOnly() {return _prop.isReadOnly();}
public boolean isPermanent() {return _prop.isPermanent();}
public boolean hasAlias() {return _prop.hasAlias();}
public boolean isArgument() {return _prop.isArgument();}
public boolean isVariable() {return _prop.isVariable();}
public boolean isHinted() {return _prop.isHinted();}
// override Object
public String toString() {return _prop.toString();}
private netscape.jsdebug.Property _prop;
private com.netscape.jsdebugging.api.Value _val;
}

View File

@ -0,0 +1,5 @@
/* jband - 09/14/98 - */
com.netscape.jsdebugging.api.local implements the interfaces defined in
com.netscape.jsdebugging.api. It supports adapting the debugger(s) to the
netscape.jsdebug api used in mozilla (and the stand-alone C based JS engine).

View File

@ -0,0 +1,47 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.local;
import com.netscape.jsdebugging.api.*;
/**
* ScriptHook must be subinterfaceed to respond to significant events
* in the virtual machine.
*/
public class ScriptHookLocal extends netscape.jsdebug.ScriptHook
{
public ScriptHookLocal( ScriptHook hook )
{
_hook = hook;
}
public void justLoadedScript(netscape.jsdebug.Script script)
{
_hook.justLoadedScript( new ScriptLocal(script) );
}
public void aboutToUnloadScript(netscape.jsdebug.Script script)
{
_hook.aboutToUnloadScript( new ScriptLocal(script) );
}
public ScriptHook getWrappedHook() {return _hook;}
private ScriptHook _hook;
}

View File

@ -0,0 +1,63 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.local;
import com.netscape.jsdebugging.api.*;
public class ScriptLocal implements Script
{
ScriptLocal(netscape.jsdebug.Script script)
{
_script = script;
_sections = new ScriptSectionLocal[1];
_sections[0] = new ScriptSectionLocal(_script.getBaseLineNumber(),
_script.getLineExtent());
}
public String getURL() {return _script.getURL();}
public String getFunction() {return _script.getFunction();}
public int getBaseLineNumber() {return _script.getBaseLineNumber();}
public int getLineExtent() {return _script.getLineExtent();}
public boolean isValid() {return _script.isValid();}
public JSPC getClosestPC(int line)
{
return new JSPCLocal(_script.getClosestPC(line), this);
}
public ScriptSection[] getSections() {return _sections;}
public String toString() {return _script.toString();}
public int hashCode() {return _script.hashCode();}
public boolean equals(Object obj)
{
try
{
return ((ScriptLocal)obj)._script == _script;
}
catch( ClassCastException e )
{
return false;
}
}
public netscape.jsdebug.Script getRealScript() {return _script;}
private ScriptSectionLocal[] _sections;
private netscape.jsdebug.Script _script;
}

View File

@ -0,0 +1,37 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.local;
import com.netscape.jsdebugging.api.*;
public class ScriptSectionLocal implements ScriptSection
{
public ScriptSectionLocal( int base, int extent )
{
_base = base;
_extent = extent;
}
public int getBaseLineNumber() {return _base;}
public int getLineExtent() {return _extent;}
private int _base;
private int _extent;
}

View File

@ -0,0 +1,80 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.local;
import com.netscape.jsdebugging.api.*;
public class SourceTextItemLocal
implements SourceTextItem
{
public SourceTextItemLocal(netscape.jsdebug.SourceTextItem sti)
{
_sti = sti;
//
// XXX Hack to deal with the fact that JSScript 'filenames' for
// urls containing query parts are truncated at '?', while sources
// contain the full URL. (do the same for '#')
int index;
String url = _sti.getURL();
if( -1 != (index = url.indexOf('?')) ||
-1 != (index = url.indexOf('#')) )
_url = url.substring(0,index);
else
_url = url;
}
// implements SourceTextItem
public String getURL() {return _url;}
public String getText() {return _sti.getText();}
public int getStatus() {return _sti.getStatus();}
public int getAlterCount()
{
if( _sti.getDirty() )
{
_sti.setDirty(false);
_lastAlterCount++;
}
return _lastAlterCount;
}
public boolean getDirty() {return _sti.getDirty();}
public void setDirty(boolean b) {_sti.setDirty(b);}
public int hashCode() {return _sti.getURL().hashCode();}
public boolean equals(Object obj)
{
try
{
return ((SourceTextItemLocal)obj)._sti == _sti;
}
catch( ClassCastException e )
{
return false;
}
}
public netscape.jsdebug.SourceTextItem getWrappedItem() {return _sti;}
// data
private String _url;
private netscape.jsdebug.SourceTextItem _sti = null;
private int _lastAlterCount = 0;
}

View File

@ -0,0 +1,138 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.local;
import com.netscape.jsdebugging.api.*;
import netscape.util.Vector;
import netscape.security.PrivilegeManager;
import netscape.security.ForbiddenTargetException;
public class SourceTextProviderLocal
implements SourceTextProvider
{
// allow for possible singleton-ness enforcement
public static SourceTextProvider getSourceTextProvider()
{
return new SourceTextProviderLocal();
}
private SourceTextProviderLocal()
{
try
{
PrivilegeManager.enablePrivilege("Debugger");
_pro = (netscape.jsdebug.JSSourceTextProvider)
netscape.jsdebug.JSSourceTextProvider.getSourceTextProvider();
}
catch( ForbiddenTargetException e )
{
// eat it;
}
}
// implement netscape.jsdebugger.SourceTextProvider
public SourceTextItem[] getItems()
{
if( null == _pro )
return null;
if( null == _items )
_rebuildItemsArray();
return _items;
}
public void refreshAll()
{
if( null == _pro )
return;
_pro.refreshSourceTextVector();
_rebuildItemsArray();
}
public SourceTextItem findItem(String url)
{
if( null == _pro )
return null;
if( null == _items )
_rebuildItemsArray();
if( null == _items )
return null;
for( int i = 0; i < _items.length; i++ )
{
if( url.equals(_items[i].getURL()) )
return _items[i];
}
return null;
}
public SourceTextItem loadItem(String url)
{
// XXX not implemented...
return null;
}
// this goes through some gyrations to try to reuse existing item wrappers
private void _rebuildItemsArray()
{
SourceTextItemLocal[] olditems = _items;
_items = null;
if( null == _pro )
return;
try
{
int count;
PrivilegeManager.enablePrivilege("Debugger");
Vector v = _pro.getSourceTextVector();
if( null == v || 0 == (count = v.size()) )
return;
SourceTextItemLocal[] newitems = new SourceTextItemLocal[count];
next_item: for( int i = 0; i < count; i++ )
{
netscape.jsdebug.SourceTextItem rawItem =
(netscape.jsdebug.SourceTextItem) v.elementAt(i);
if( null != olditems && 0 != olditems.length )
{
for( int k = 0; k < olditems.length; k++ )
{
SourceTextItemLocal item = olditems[k];
if( item.getWrappedItem() == rawItem )
{
newitems[i] = item;
continue next_item;
}
}
}
newitems[i] = new SourceTextItemLocal(rawItem);
}
_items = newitems;
}
catch( ForbiddenTargetException e )
{
// eat it;
}
}
// data
private netscape.jsdebug.JSSourceTextProvider _pro = null;
private SourceTextItemLocal[] _items = null;
}

View File

@ -0,0 +1,160 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.local;
public class ValueLocal
implements com.netscape.jsdebugging.api.Value
{
ValueLocal(netscape.jsdebug.Value val) {_val = val;}
public boolean isObject() {return _val.isObject();}
public boolean isNumber() {return _val.isNumber();}
public boolean isInt() {return _val.isInt();}
public boolean isDouble() {return _val.isDouble();}
public boolean isString() {return _val.isString();}
public boolean isBoolean() {return _val.isBoolean();}
public boolean isNull() {return _val.isNull();}
public boolean isVoid() {return _val.isVoid();}
public boolean isPrimitive() {return _val.isPrimitive();}
public boolean isFunction() {return _val.isFunction();}
public boolean isNative() {return _val.isNative();}
public boolean getBoolean() {return _val.getBoolean();}
public int getInt() {return _val.getInt();}
public double getDouble() {return _val.getDouble();}
public String getString() {return _val.getString();}
public String getFunctionName() {return _val.getFunctionName();}
public String getClassName() {return _val.getClassName();}
public com.netscape.jsdebugging.api.Value getPrototype()
{
if(null == _proto && !_getFlag(GOT_PROTO))
{
netscape.jsdebug.Value p = _val.getPrototype();
if(null != p)
_proto = new ValueLocal(p);
_setFlag(GOT_PROTO);
}
return _proto;
}
public com.netscape.jsdebugging.api.Value getParent()
{
if(null == _parent && !_getFlag(GOT_PARENT))
{
netscape.jsdebug.Value p = _val.getParent();
if(null != p)
_parent = new ValueLocal(p);
_setFlag(GOT_PARENT);
}
return _parent;
}
public com.netscape.jsdebugging.api.Value getConstructor()
{
if(null == _ctor && !_getFlag(GOT_CTOR))
{
netscape.jsdebug.Value c = _val.getConstructor();
if(null != c)
_ctor = new ValueLocal(c);
_setFlag(GOT_CTOR);
}
return _ctor;
}
public com.netscape.jsdebugging.api.Property[] getProperties()
{
if(null == _props && !_getFlag(GOT_PROPS))
{
netscape.jsdebug.Property[] p = _val.getProperties();
if(null != p && 0 != p.length)
{
_props = new PropertyLocal[p.length];
for( int i = 0; i < p.length; i++)
_props[i] = new PropertyLocal(p[i]);
}
_setFlag(GOT_PROPS);
}
return _props;
}
public com.netscape.jsdebugging.api.Property getProperty(String name)
{
if(null == name)
return null;
com.netscape.jsdebugging.api.Property[] props = getProperties();
if(null == props)
return null;
for(int i = 0; i < props.length; i++)
if(name.equals(props[i].getNameString()))
return props[i];
netscape.jsdebug.Property wprop = _val.getProperty(name);
if(null == wprop)
return null;
com.netscape.jsdebugging.api.Property prop = new PropertyLocal(wprop);
if(null != prop) {
com.netscape.jsdebugging.api.Property[] newProps =
new com.netscape.jsdebugging.api.Property[props.length+1];
System.arraycopy(props, 0, newProps, 0, props.length);
newProps[props.length] = prop;
_props = newProps;
}
return prop;
}
public String[] getPropertyHints() {return _val.getPropertyHints();}
public void setPropertyHints(String[] hints) {_val.setPropertyHints(hints);}
public void refresh() {
_val.refresh();
_flags = 0;
_props = null;
_proto = null;
_parent = null;
_ctor = null;
}
public netscape.jsdebug.Value getWrappedValue() {return _val;}
// override Object
public String toString() {return _val.toString();}
public int hashCode() {return _val.hashCode();}
// private flagage...
private static final short GOT_PROTO = (short) (1 << 0);
private static final short GOT_PROPS = (short) (1 << 1);
private static final short GOT_PARENT = (short) (1 << 2);
private static final short GOT_CTOR = (short) (1 << 3);
private final boolean _getFlag(short b) {return 0 != (_flags & b);}
private final void _setFlag(short b) {_flags |= b;}
private final void _clearFlag(short b) {_flags &= ~b;}
private short _flags;
// private data...
private netscape.jsdebug.Value _val;
private com.netscape.jsdebugging.api.Property[] _props;
private com.netscape.jsdebugging.api.Value _proto;
private com.netscape.jsdebugging.api.Value _parent;
private com.netscape.jsdebugging.api.Value _ctor;
}

View File

@ -0,0 +1,41 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.rhino;
import netscape.security.ForbiddenTargetException;
import com.netscape.jsdebugging.api.DebugController;
import com.netscape.jsdebugging.api.SourceTextProvider;
public class AdapterLoaderRhino
implements com.netscape.jsdebugging.api.AdapterLoader
{
public void setHost(String host) {} // ignored
public boolean isDebuggingSupported() throws ForbiddenTargetException
{
return null != DebugControllerRhino.getDebugController();
}
public DebugController getDebugController() throws ForbiddenTargetException
{
return DebugControllerRhino.getDebugController();
}
public SourceTextProvider getSourceTextProvider()
{
return SourceTextProviderRhino.getSourceTextProvider();
}
}

View File

@ -0,0 +1,24 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.rhino;
public interface Callback
{
public void call();
}

View File

@ -0,0 +1,55 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.rhino;
import com.netscape.jsdebugging.api.*;
/**
* DebugBreakHook must be subclassed to respond to hooks
* at a particular program instruction.
*/
public class DebugBreakHookRhino implements com.netscape.javascript.debug.IDebugBreakHook
{
public DebugBreakHookRhino( DebugBreakHook hook )
{
_hook = hook;
}
public void aboutToExecute(com.netscape.javascript.debug.IThreadState debug,
com.netscape.javascript.debug.IPC pc)
{
try
{
JSThreadStateRhino ts = new JSThreadStateRhino(debug);
JSPCRhino jspc = (JSPCRhino) ts.getCurrentFrame().getPC();
ts.aboutToCallHook();
_hook.aboutToExecute(ts, jspc);
ts.returnedFromCallHook();
}
catch( Exception e )
{
e.printStackTrace();
// eat it.
}
}
public DebugBreakHook getWrappedHook() {return _hook;}
private DebugBreakHook _hook;
}

View File

@ -0,0 +1,396 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.rhino;
import com.netscape.jsdebugging.api.*;
import netscape.security.ForbiddenTargetException;
import netscape.security.PrivilegeManager;
/**
* This is the master control panel for observing events in the VM.
* Each method setXHook() must be passed an object that extends
* the interface XHook. When an event of the specified type
* occurs, a well-known method on XHook will be called (see the
* various XHook interfacees for details). The method call takes place
* on the same thread that triggered the event in the first place,
* so that any monitors held by the thread which triggered the hook
* will still be owned in the hook method.
*/
public class DebugControllerRhino implements DebugController
{
public long getSupportsFlags()
{
return 0;
}
public static boolean setGlobalDebugManager(com.netscape.javascript.debug.IDebugManager manager)
{
if(null != _controller)
return false;
_controller = manager;
return true;
}
public static DebugControllerRhino getDebugController()
throws ForbiddenTargetException
{
if( null == _controllerRhino )
_controllerRhino = new DebugControllerRhino();
if( null == _controllerRhino )
throw new ForbiddenTargetException();
if( null == _controllerRhino._controller )
{
_controllerRhino = null;
throw new ForbiddenTargetException();
}
return _controllerRhino;
}
private DebugControllerRhino()
{
}
/**
* Request notification of Script loading events. Whenever a Script
* is loaded into or unloaded from the VM the appropriate method of
* the ScriptHook argument will be called.
* returns the previous hook object.
*/
public ScriptHook setScriptHook(ScriptHook h)
throws ForbiddenTargetException
{
ScriptHookRhino newWrapper = null;
if( null != h )
newWrapper = new ScriptHookRhino(h);
com.netscape.javascript.debug.IScriptHook oldWrapper =
_controller.setScriptHook(newWrapper);
if( null != oldWrapper && oldWrapper instanceof ScriptHookRhino )
return ((ScriptHookRhino)oldWrapper).getWrappedHook();
return null;
}
/**
* Find the current observer of Script events, or return null if there
* is none.
*/
public ScriptHook getScriptHook()
{
com.netscape.javascript.debug.IScriptHook oldWrapper =
_controller.getScriptHook();
if( null != oldWrapper && oldWrapper instanceof ScriptHookRhino )
return ((ScriptHookRhino)oldWrapper).getWrappedHook();
return null;
}
/**
* Set a hook at the given program counter value. When
* a thread reaches that instruction, a ThreadState object will be
* created and the appropriate method of the hook object
* will be called.
* returns the previous hook object.
*/
public InstructionHook setInstructionHook(
PC pc,
InstructionHook h)
throws ForbiddenTargetException
{
// XXX this is hack to deal with fact that the native v1.0 JSD
// for Navigator can't handle a null instruction hook.
if( null == h )
return null;
com.netscape.javascript.debug.IPC newWrappedPC = null;
if( null != pc )
newWrappedPC = ((JSPCRhino)pc).getWrappedJSPC();
InstructionHookRhino newWrapper = null;
if( null != h )
newWrapper = new InstructionHookRhino(h, newWrappedPC);
com.netscape.javascript.debug.IInstructionHook oldWrapper =
_controller.setInstructionHook(newWrappedPC, newWrapper);
if( null != oldWrapper && oldWrapper instanceof InstructionHookRhino )
return ((InstructionHookRhino)oldWrapper).getWrappedHook();
return null;
}
/**
* Get the hook at the given program counter value, or return
* null if there is none.
*/
public InstructionHook getInstructionHook(PC pc)
throws ForbiddenTargetException
{
if( null == pc )
return null;
com.netscape.javascript.debug.IPC newWrappedPC = ((JSPCRhino)pc).getWrappedJSPC();
com.netscape.javascript.debug.IInstructionHook oldWrapper =
_controller.getInstructionHook(newWrappedPC);
if( null != oldWrapper && oldWrapper instanceof InstructionHookRhino )
return ((InstructionHookRhino)oldWrapper).getWrappedHook();
return null;
}
public InterruptHook setInterruptHook( InterruptHook h )
throws ForbiddenTargetException
{
InterruptHookRhino newWrapper = null;
if( null != h )
newWrapper = new InterruptHookRhino(h);
com.netscape.javascript.debug.IInterruptHook oldWrapper =
_controller.setInterruptHook(newWrapper);
if( null != oldWrapper && oldWrapper instanceof InterruptHookRhino )
return ((InterruptHookRhino)oldWrapper).getWrappedHook();
return null;
}
public InterruptHook getInterruptHook()
throws ForbiddenTargetException
{
com.netscape.javascript.debug.IInterruptHook oldWrapper =
_controller.getInterruptHook();
if( null != oldWrapper && oldWrapper instanceof InterruptHookRhino )
return ((InterruptHookRhino)oldWrapper).getWrappedHook();
return null;
}
public void sendInterrupt()
throws ForbiddenTargetException
{
_controller.sendInterrupt();
}
public void sendInterruptStepInto(ThreadStateBase debug)
{
System.err.println("call to unimplemented function sendInterruptStepInto() failed");
}
public void sendInterruptStepOver(ThreadStateBase debug)
{
System.err.println("call to unimplemented function sendInterruptStepOver() failed");
}
public void sendInterruptStepOut(ThreadStateBase debug)
{
System.err.println("call to unimplemented function sendInterruptStepOut() failed");
}
public void reinstateStepper(ThreadStateBase debug)
{
System.err.println("call to unimplemented function reinstateStepper() failed");
}
public DebugBreakHook setDebugBreakHook( DebugBreakHook h )
throws ForbiddenTargetException
{
DebugBreakHookRhino newWrapper = null;
if( null != h )
newWrapper = new DebugBreakHookRhino(h);
com.netscape.javascript.debug.IDebugBreakHook oldWrapper =
_controller.setDebugBreakHook(newWrapper);
if( null != oldWrapper && oldWrapper instanceof DebugBreakHookRhino )
return ((DebugBreakHookRhino)oldWrapper).getWrappedHook();
return null;
}
public DebugBreakHook getDebugBreakHook()
throws ForbiddenTargetException
{
com.netscape.javascript.debug.IDebugBreakHook oldWrapper =
_controller.getDebugBreakHook();
if( null != oldWrapper && oldWrapper instanceof DebugBreakHookRhino )
return ((DebugBreakHookRhino)oldWrapper).getWrappedHook();
return null;
}
public ExecResult executeScriptInStackFrame( JSStackFrameInfo frame,
String text,
String filename,
int lineno )
throws ForbiddenTargetException
{
JSThreadStateRhino ts = (JSThreadStateRhino)frame.getThreadState();
if( ts.isWaitingForResume() )
{
Evaluator e = new Evaluator(this,ts,frame,text,filename,lineno);
return new ExecResultRhino( e.eval() );
}
else
{
return new ExecResultRhino(
_controller.executeScriptInStackFrame(
((JSStackFrameInfoRhino)frame).getWrappedInfo(),
text,
filename,
lineno) );
}
}
public ExecResult executeScriptInStackFrameValue( JSStackFrameInfo frame,
String text,
String filename,
int lineno )
throws ForbiddenTargetException
{
return null; // XXX implement this...
}
public JSErrorReporter setErrorReporter(JSErrorReporter h)
throws ForbiddenTargetException
{
JSErrorReporterRhino newWrapper = null;
if( null != h )
newWrapper = new JSErrorReporterRhino(h);
com.netscape.javascript.debug.IErrorReporter oldWrapper =
_controller.setErrorReporter(newWrapper);
if( null != oldWrapper && oldWrapper instanceof JSErrorReporterRhino)
return ((JSErrorReporterRhino)oldWrapper).getWrappedHook();
return null;
}
public JSErrorReporter getErrorReporter()
throws ForbiddenTargetException
{
com.netscape.javascript.debug.IErrorReporter oldWrapper =
_controller.getErrorReporter();
if( null != oldWrapper && oldWrapper instanceof JSErrorReporterRhino)
return ((JSErrorReporterRhino)oldWrapper).getWrappedHook();
return null;
}
public void iterateScripts(ScriptHook h)
{
// XXX does nothing at present...
}
public int getMajorVersion()
{
return _controller.getMajorVersion();
}
public int getMinorVersion()
{
return _controller.getMinorVersion();
}
public com.netscape.javascript.debug.IDebugManager getWrappedController()
{
return _controller;
}
// data...
private static com.netscape.javascript.debug.IDebugManager _controller = null;
private static DebugControllerRhino _controllerRhino = null;
}
class Evaluator implements Callback
{
public Evaluator(DebugControllerRhino dc,
JSThreadStateRhino ts,
JSStackFrameInfo frame,
String text,
String filename,
int lineno)
{
_dc = dc ;
_ts = ts ;
_frame = frame ;
_text = text ;
_filename = filename;
_lineno = lineno ;
_completed = false;
_result = null;
}
public String eval()
{
if( ! _completed && _ts.addCallbackEvent(this) )
{
synchronized(this)
{
while( ! _completed )
{
try
{
wait();
}
catch(Exception e)
{
// eat it...
e.printStackTrace();
System.out.println(e);
break;
}
}
}
}
return _result;
}
// implement Callback
public synchronized void call()
{
try
{
PrivilegeManager.enablePrivilege("Debugger");
_result =
_dc.getWrappedController().executeScriptInStackFrame(
((JSStackFrameInfoRhino)_frame).getWrappedInfo(),
_text,
_filename,
_lineno);
}
catch(Exception e)
{
// eat it...
e.printStackTrace();
System.out.println(e);
}
_completed = true;
notify();
}
private DebugControllerRhino _dc;
private JSThreadStateRhino _ts;
private JSStackFrameInfo _frame;
private String _text;
private String _filename;
private int _lineno;
private boolean _completed;
private String _result;
}

View File

@ -0,0 +1,43 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.rhino;
public class ExecResultRhino
implements com.netscape.jsdebugging.api.ExecResult
{
ExecResultRhino( String str )
{
_str = str;
}
public String getResult() {return _str;}
public boolean getErrorOccured() {return false;}
public String getErrorMessage() {return null;}
public String getErrorFilename() {return null;}
public int getErrorLineNumber() {return 0;}
public String getErrorLineBuffer() {return null;}
public int getErrorTokenOffset() {return 0;}
public com.netscape.jsdebugging.api.Value getResultValue()
{return null;} // XXX implement this
private String _str;
}

View File

@ -0,0 +1,47 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.rhino;
import com.netscape.jsdebugging.api.*;
/**
* InstructionHook must be subinterfaceed to respond to hooks
* at a particular program instruction.
*/
public class InstructionHookRhino implements com.netscape.javascript.debug.IInstructionHook
{
InstructionHookRhino( InstructionHook hook,
com.netscape.javascript.debug.IPC pc )
{
// super(pc);
_hook = hook;
}
public void aboutToExecute(com.netscape.javascript.debug.IThreadState debug)
{
JSThreadStateRhino ts = new JSThreadStateRhino(debug);
ts.aboutToCallHook();
_hook.aboutToExecute(ts);
ts.returnedFromCallHook();
}
public InstructionHook getWrappedHook() {return _hook;}
private InstructionHook _hook;
}

View File

@ -0,0 +1,56 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.rhino;
import com.netscape.jsdebugging.api.*;
/**
* InterruptHook must be subinterfaceed to respond to hooks
* at a particular program instruction.
*/
public class InterruptHookRhino implements com.netscape.javascript.debug.IInterruptHook
{
public InterruptHookRhino( InterruptHook hook )
{
_hook = hook;
}
public void aboutToExecute(com.netscape.javascript.debug.IThreadState debug,
com.netscape.javascript.debug.IPC pc)
{
// System.out.println( "InterruptHookRhino called..." );
try
{
JSThreadStateRhino ts = new JSThreadStateRhino(debug);
JSPCRhino jspc = (JSPCRhino) ts.getCurrentFrame().getPC();
ts.aboutToCallHook();
_hook.aboutToExecute(ts, jspc);
ts.returnedFromCallHook();
}
catch( Exception e )
{
e.printStackTrace();
// eat it.
}
}
public InterruptHook getWrappedHook() {return _hook;}
private InterruptHook _hook;
}

View File

@ -0,0 +1,42 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.rhino;
import com.netscape.jsdebugging.api.*;
public class JSErrorReporterRhino implements com.netscape.javascript.debug.IErrorReporter
{
public JSErrorReporterRhino(JSErrorReporter er)
{
_er = er;
}
public int reportError( String msg,
String filename,
int lineno,
String linebuf,
int tokenOffset )
{
return _er.reportError(msg, filename, lineno, linebuf, tokenOffset);
}
public JSErrorReporter getWrappedHook() {return _er;}
private JSErrorReporter _er;
}

View File

@ -0,0 +1,68 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
package com.netscape.jsdebugging.api.rhino;
import com.netscape.jsdebugging.api.*;
/**
* This subinterface of PC provides JavaScript-specific information.
*/
public class JSPCRhino implements JSPC
{
public JSPCRhino(com.netscape.javascript.debug.IPC pc)
{
this( pc, new ScriptRhino(pc.getScript()) );
}
public JSPCRhino(com.netscape.javascript.debug.IPC pc, ScriptRhino script)
{
_pc = pc;
_script = script;
_sourceLocation =
new JSSourceLocationRhino(this,
(com.netscape.javascript.debug.ISourceLocation)_pc.getSourceLocation());
}
public Script getScript() {return _script;}
public int getPC() {return _pc.getPC();}
public boolean isValid() {return _pc.isValid();}
public SourceLocation getSourceLocation() {return _sourceLocation;}
public boolean equals(Object obj)
{
try
{
JSPCRhino other = (JSPCRhino) obj;
return other._pc.getScript() == _pc.getScript() &&
other._pc.getPC() == _pc.getPC();
}
catch( ClassCastException e )
{
return false;
}
}
public int hashCode() {return _pc.hashCode();}
public String toString() {return _pc.toString();}
public com.netscape.javascript.debug.IPC getWrappedJSPC() {return _pc;}
private com.netscape.javascript.debug.IPC _pc;
private ScriptRhino _script;
private JSSourceLocationRhino _sourceLocation;
}

Some files were not shown because too many files have changed in this diff Show More