gecko-dev/js/rhino/docs/RhinoDebugger.html

162 строки
10 KiB
HTML
Исходник Обычный вид История

<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
<META NAME="Generator" CONTENT="Microsoft Word 97">
<TITLE>1</TITLE>
</HEAD>
<BODY>
<OL>
<B><FONT FACE="Arial" SIZE=5 COLOR="#000080"><LI>Using the Rhino JavaScript Debugger</LI>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The Mozilla Rhino JavaScript engine includes a source-level debugger for debugging JavaScript scripts. The debugger is itself a Java program which you may run as</P>
</FONT><FONT FACE="Arial" SIZE=2><P ALIGN="JUSTIFY">java org.mozilla.javascript.tools.debugger.JSDebugger [options] [filename.js] [script-arguments]</P>
</FONT><FONT SIZE=2><P ALIGN="JUSTIFY">where the options are the same as the shell.</P>
<OL>
<LI><A NAME="_Toc502165108"></FONT><B><FONT FACE="Arial" SIZE=4 COLOR="#000080">Features</A></LI>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The Rhino JavaScript Debugger can debug scripts running in multiple threads and provides facilities to set and clear breakpoints, control execution, view variables, and evaluate arbitrary JavaScript code in the current scope of an executing script.</P>
<OL>
<LI><A NAME="_Toc502165109"></FONT><B><FONT FACE="Arial" COLOR="#000080">Console Window</A></LI>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The debugger redirects the </FONT><FONT FACE="Arial" SIZE=2>System.out</FONT><FONT SIZE=2>, </FONT><FONT FACE="Arial" SIZE=2>System.in</FONT><FONT SIZE=2>, and </FONT><FONT FACE="Arial" SIZE=2>System.err</FONT><FONT SIZE=2> streams to an internal JavaScript console window which provides an editable command line for you to enter JavaScript code and view system output. The console window maintains a history of the commands you have entered. You may move backward and forward through the history list by pressing the Up/Down arrow keys on the keyboard.</P>
<LI><A NAME="_Toc502165110"></FONT><B><FONT FACE="Arial" COLOR="#000080">Opening Scripts</A></LI>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">You may select the <B><I>File-&gt;Open</B></I> menu item on the menu bar to load JavaScript scripts contained in files. This action will display a file-selection dialog box prompting you for the location of a script to load. The selected file will be compiled and displayed in a new window.</P>
</FONT><B><FONT FACE="Arial" COLOR="#000080"><LI>Running Scripts</LI>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">You may select the <B><I>File-&gt;Run</B></I> menu item on the menu bar to execute JavaScript scripts contained in files. This action will display a file-selection dialog box prompting you for the location of a script to execute. The loaded script will be run in a new thread and control will be given to the debugger on its first instruction.</P>
<LI><A NAME="_Toc502165111"></FONT><B><FONT FACE="Arial" COLOR="#000080">Controlling Execution</A></LI>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The debugger provides the following facilities for you to control the execution of scripts you are debugging:</P>
<OL>
</FONT><B><FONT FACE="Arial" COLOR="#000080"><LI>Step Into</LI></OL>
</OL>
</OL>
</OL>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">To single step entering any function calls, you may do any of the following:</P>
<UL>
<P ALIGN="JUSTIFY"><LI>Select the <B><I>Debug-&gt;Step Into </B></I>menu item on the menu bar</LI></P>
<P ALIGN="JUSTIFY"><LI>Press the <B><I>Step Into</B></I> button on the toolbar</LI></P>
<P ALIGN="JUSTIFY"><LI>Press the F11 key on the keyboard</LI></P></UL>
<P ALIGN="JUSTIFY">Execution will resume. If the current line in the script contains a function call control will return to the debugger upon entry into the function. Otherwise control will return to the debugger at the next line in the current function.</P>
<OL>
<OL>
<OL>
<OL>
</FONT><B><FONT FACE="Arial" COLOR="#000080"><LI>Step Over</LI></OL>
</OL>
</OL>
</OL>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">To single step to the next line in the current function, you may do any of the following:</P>
<UL>
<P ALIGN="JUSTIFY"><LI>Select the <B><I>Debug-&gt;Step Over</B></I> menu item on the menu bar</LI></P>
<P ALIGN="JUSTIFY"><LI>Press the <B><I>Step Over</B></I> button on the toolbar</LI></P>
<P ALIGN="JUSTIFY"><LI>Press the F7 key on the keyboard</LI></P></UL>
<P ALIGN="JUSTIFY">Execution will resume but control will return to the debugger at the next line in the current function or top-level script.</P>
<OL>
<OL>
<OL>
<OL>
</FONT><B><FONT FACE="Arial" COLOR="#000080"><LI>Step Out</LI></OL>
</OL>
</OL>
</OL>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">To continue execution until the current function returns you may do any of the following:</P>
<UL>
<P ALIGN="JUSTIFY"><LI>Select the <B><I>Debug-&gt;Step Out</B></I> menu item on the menu bar</LI></P>
<P ALIGN="JUSTIFY"><LI>Press the <B><I>Step Out</B></I> button on the toolbar</LI></P>
<P ALIGN="JUSTIFY"><LI>Press the F8 key on the keyboard</LI></P></UL>
<P ALIGN="JUSTIFY">Execution will resume until the current function returns or a breakpoint is hit.</P>
<OL>
<OL>
<OL>
<OL>
</FONT><B><FONT FACE="Arial" COLOR="#000080"><LI>Go</LI></OL>
</OL>
</OL>
</OL>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">To resume execution of a script you may do any of the following:</P>
<UL>
<P ALIGN="JUSTIFY"><LI>Select the <B><I>Debug-&gt;Go</B></I> menu item on the menu bar</LI></P>
<P ALIGN="JUSTIFY"><LI>Press the <B><I>Go</B></I> button on the toolbar</LI></P>
<P ALIGN="JUSTIFY"><LI>Press the F5 key on the keyboard</LI></P></UL>
<P ALIGN="JUSTIFY">Execution will resume until a breakpoint is hit or the script completes.</P>
<P ALIGN="JUSTIFY">&nbsp;</P>
<OL>
<OL>
<OL>
<OL>
</FONT><B><FONT FACE="Arial" COLOR="#000080"><LI>Break</LI></OL>
</OL>
</OL>
</OL>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">To stop all running scripts and give control to the debugger you may do any of the following:</P>
<UL>
<P ALIGN="JUSTIFY"><LI>Select the <B><I>Debug-&gt;Break</B></I> menu item on the menu bar</LI></P>
<P ALIGN="JUSTIFY"><LI>Press the <B><I>Break</B></I> button on the toolbar</LI></P>
<P ALIGN="JUSTIFY"><LI>Press the Pause/Break key on the keyboard</LI></P></UL>
<OL>
<OL>
<OL>
<LI><A NAME="_Toc502165112"></FONT><B><FONT FACE="Arial" COLOR="#000080">Moving Up and Down the Stack</A></LI>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The lower-left (dockable) pane in the debugger main window contains a combo-box labeled &quot;Context:&quot; which displays the current stack of the executing script. You may move up and down the stack by selecting an entry in the combo-box. When you select a stack frame the variables and watch windows are updated to reflect the names and values of the variables visible at that scope.</P>
<LI><A NAME="_Toc502165113"></FONT><B><FONT FACE="Arial" COLOR="#000080">Setting and Clearing Breakpoints</A></LI></OL>
</OL>
</OL>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The main desktop of the debugger contains file windows which display the contents of each script you are debugging. You may set a breakpoint in a script by doing one of the following:</P>
<UL>
<P ALIGN="JUSTIFY"><LI>Place the cursor on the line at which you want to set a breakpoint and right-click with the mouse. This action will display a pop-up menu. Select the <B><I>Set Breakpoint</B></I> menu item. </LI></P>
<P ALIGN="JUSTIFY"><LI>Simply single-click on the line number of the line at which you want to set a breakpoint.</LI></P></UL>
<P ALIGN="JUSTIFY">If the selected line contains executable code a red dot will appear next to the line number and a breakpoint will be set at that location.</P>
<P ALIGN="JUSTIFY">You may set clear breakpoint in a script by doing one of the following:</P>
<UL>
<P ALIGN="JUSTIFY"><LI>Place the cursor on the line at which you want to clear a breakpoint and right-click with the mouse. This action will display a pop-up menu. Select the <B><I>Clear Breakpoint</B></I> menu item. </LI></P>
<P ALIGN="JUSTIFY"><LI>Simply single-click on the red dot or the line number of the line at which you want to clear a breakpoint.</LI></P></UL>
<P ALIGN="JUSTIFY">The red dot will disappear and the breakpoint at that location will be cleared.</P>
<OL>
<OL>
<OL>
<LI><A NAME="_Toc502165114"></FONT><B><FONT FACE="Arial" COLOR="#000080">Viewing Variables</A></LI>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The lower-left (dockable) pane in the debugger main window contains a tab-pane with two tabs, labeled &quot;this&quot; and &quot;Locals&quot;. Each pane contains a tree-table which displays the properties of the current object and currently visible local variables, respectively. </P>
<OL>
</FONT><B><FONT FACE="Arial" COLOR="#000080"><LI>This</LI></OL>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The properties of the current object are displayed in the <B><I>this</B></I> table. If a property is itself a JavaScript object the property may be expanded to show its sub-properties. The <B><I>this</B></I> table is updated each time control returns to the debugger or when you change the stack location in the <B><I>Context:</B></I> window.</P>
<LI><A NAME="_Toc502165115"></FONT><B><FONT FACE="Arial" COLOR="#000080">Locals</A></LI>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The local variables of the current function are displayed in the <B><I>Locals</B></I> table. If a variable is itself a JavaScript object the variable may be expanded to show its sub-properties. The <B><I>Locals</B></I> table is updated each time control returns to the debugger or when you change the stack location in the <B><I>Context:</B></I> window</P>
<LI><A NAME="_Toc502165116"></FONT><B><FONT FACE="Arial" COLOR="#000080">Watch Window</A></LI>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">You may enter arbitrary JavaScript expressions in the <B><I>Watch:</B></I> table located in the lower-right (dockable) pane in the debugger main window. The expressions you enter are reevaluated in the current scope and their current values displayed each time control returns to the debugger or when you change the stack location in the <B><I>Context:</B></I> window.</P>
<LI><A NAME="_Toc502165117"></FONT><B><FONT FACE="Arial" COLOR="#000080">Evaluation Window</A></LI></OL>
</OL>
</OL>
</B></FONT><FONT SIZE=2><P ALIGN="JUSTIFY">The <B><I>Evaluate</B></I> pane located in the lower-right (dockable) pane in the debugger main window contains an editable command line where you may enter arbitrary JavaScript code. The code is evaluated in the context of the current stack frame. The window maintains a history of the commands you have entered. You may move backward or forward through the history by pressing the Up/Down arrow keys on the keyboard. </P>
</FONT></BODY>
</HTML>