Initial Commit
[packages] / xemacs-packages / jde / doc / src / jdb-ug / jdb-ug.xml
1 <?xml version="1.0" encoding="utf-8"?>
2
3 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBk XML V4.4CR2//EN" 
4  "file:///c:/home/xae-dev/xae/doctypes/docbook/docbookx.dtd" []>
5
6
7 <?xml-stylesheet href="file:///c:/home/jde-dev/jde/doc/src/styles/html/jdebook.xsl" type="text/xsl"  ?>
8
9 <book>
10
11   <title>Debugging with jdb</title>
12
13
14   <bookinfo>
15
16     <releaseinfo>
17       <remark>
18         Revised for JDEE <productnumber>2.3.3</productnumber>
19       </remark>
20     </releaseinfo>
21
22     <copyright>
23       <year>1997</year>
24       <year>1998</year>
25       <year>1999</year>
26       <year>2000</year>
27       <year>2001</year>
28       <year>2002</year>
29       <year>2003</year>
30       <holder>Paul Kinnucan</holder>
31     </copyright>
32   </bookinfo>
33
34   <chapter>
35
36     <title><anchor id="Intro"/>Debugger Setup</title>
37
38     <para>You should perform the following steps before attempting to use jdb.</para>
39
40     <itemizedlist>
41
42       <listitem>
43         <para>Set the configuration variable
44           <varname>jde-debugger</varname> to <option>jdb</option> if
45           you are using version 1.3 (or later) of the Windows or
46           Solaris versions of the JDK or version 1.2.2 (or later) of
47           the Linux version of the JDK. Set
48           <varname>jde-debugger</varname> to <option>oldjdb</option>
49           if you are using older versions of the JDK.</para>
50         </listitem>
51
52
53       <listitem>
54           <para>
55             Use <varname>jde-sourcepath</varname> to specify the paths
56             of any source code that you expect to visit while
57             debugging your application (see <ulink
58               url="#SettingSourcePath"> 
59               Setting the Source Path</ulink>). If you suspect that a
60             problem is occurring in the Java API, you should include
61             the API source files in your source path.
62           </para>      
63         </listitem>
64
65
66     <listitem>
67           <para>        
68             Set <varname>jde-compile-option-debug</varname> on 
69             (see 
70             <ulink url="../jde-ug/jde-ug-content.html#CompilingJavaPrograms">Compiling 
71               Java Programs</ulink>). This causes the compiler to insert
72             information needed by the debugger into your
73             application's class files.
74           </para>      
75         </listitem>
76
77       <listitem>
78           <para>Specify the app's main class either by setting the
79             <varname>jde-run-application-class</varname> variable  or by starting the
80             debugger from the buffer that contains the source file for
81             the main class.
82           </para>      
83         </listitem>
84     </itemizedlist>
85
86   </chapter>
87
88   <chapter>
89
90     <title><anchor id="RunningDebugger"/>Running the Debugger</title>
91
92     <sect3>
93
94       <title><anchor id="StartingDebugger"/>Starting the Debugger</title>
95
96       <para>To debug a program with <filename>jdb</filename>,
97         first select a buffer containing the source of the program you
98         want to debug (or a source buffer containing the program's
99         main class if you have not set
100         <varname>jde-run-application-class</varname>). Then execute
101         the JDEE's <command>jde-debug</command> command. You can execute
102         this command by:
103       </para>
104
105       <itemizedlist>
106         <listitem>
107           <para>Selecting 
108             <menuchoice>
109               <guimenu>JDE</guimenu>
110               <guimenuitem>Debug App</guimenuitem></menuchoice> 
111           </para>
112         </listitem>
113
114         <listitem>
115           <para>
116             Entering the key combination 
117             <keycombo>
118               <keycap>C</keycap>
119               <keycap>c</keycap>
120             </keycombo> <keycombo>
121               <keycap>C</keycap>
122               <keycap>v</keycap></keycombo> <keycombo>
123               <keycap>C</keycap>
124               <keycap>d</keycap></keycombo>
125           </para>
126         </listitem>
127
128         <listitem>
129           <para>Entering <keycombo>
130               <keycap>M</keycap>
131               <keycap>x</keycap></keycombo> <command>jde-debug</command></para>
132         </listitem>
133   
134       </itemizedlist>
135
136       <para>The JDEE launches jdb, passing to it the name of the main
137         class of the program in the current source buffer and any
138         debug options that you have specified via the JDEE's debugger
139         option variables (see <ulink
140           url="#SettingDebugOptions">Setting Debug Options</ulink>.
141         jdb in turn launches a virtual machine to run the debuggee
142         program and stops the virtual machine before the main method
143         of the program's main class. Meanwhile the JDEE splits the
144         source window into two windows.
145       </para>
146
147       <screenshot>
148         <mediaobject>
149           <imageobject>
150             <imagedata fileref="images/debug1.gif"/>
151           </imageobject>
152         </mediaobject>
153       </screenshot>
154
155       <para> 
156         The upper window shows the source buffer.  The menu bar
157         of the source buffer displays a menu (<guimenu>Jdb</guimenu>)
158         of debug commands. The lower window shows the debugger
159         interaction buffer.
160       </para>
161
162       <para>At this point, you can set breakpoints, run to a breakpoint that
163       you set before you started the debugger, or step into the main method
164       of your program.</para>
165
166
167       <sect4>
168
169         <title><anchor id="SettingDebugOptions"/>Setting Debug Options</title>
170
171         <para>The <command>jde-jdb</command> command (selected by
172         <menuchoice>
173             <guimenu>JDE</guimenu>
174             <guimenuitem>Debug App</guimenuitem></menuchoice> when jdb
175           is the debugger for the current project) can optionally pass
176           command-line arguments that specify various debug options to
177           jdb when starting jdb. The JDEE provides two ways to specify
178           these options: via customization variables or in the
179           minibuffer when you run the <command>jde-jdb</command>
180           command.</para>
181       
182         <para>The <command>jde-jdb</command> command passes any
183           options that you specify via customization variables to jdb.
184           In addition, if you set the customization variable
185           <varname>jde-db-read-vm-args</varname> to a non-nil value,
186           the <command>jde-jdb</command> command prompts you to enter
187           debugger options in the minibuffer. It appends the options
188           that you enter to the options specified via customization
189           variables. The JDEE saves the arguments that you enter in a
190           minibuffer history list. You can recall previously entered
191           options by pressing the up or down arrows on your keyboard.
192         </para>
193
194       </sect4>
195
196       <sect4>
197
198         <title><anchor id="SettingAppArguments"/>Setting App Arguments</title>
199
200         <para>You can use the customization variable
201           <varname>jde-db-option-application-args</varname> to specify
202           arguments to be passed to the application launched by jdb.
203           The <command>jde-jdb</command> command inserts the specified
204           arguments on the command-line that it constructs to run
205           jdb.</para>
206
207         <para>In addition, if you set the customization variable
208           <varname>jde-db-read-app-args</varname> to a
209           non-<option>nil</option> value, the
210           <command>jde-jdb</command> command prompts you to enter the
211           application arguments in the minibuffer. It appends the
212           options that you enter to the arguments specified via
213           <varname>jde-db-option-application-args</varname>. The JDEE
214           saves the arguments that you enter in a minibuffer history
215           list. You can recall previously entered options by pressing
216           the up or down arrows on your keyboard. </para>
217
218     </sect4>
219
220     </sect3>
221
222
223     <sect3>
224
225       <title><anchor id="EnteringCommands"/>Entering Debug Commands</title>
226
227         <para>The JDE lets you enter commands from either the current source
228           buffer or from the debugger command-line interaction buffer.
229           You can enter all debugger commands from the debugger
230           buffer. You can enter only a subset of debugger commands
231           from the current source buffer. </para>
232
233         <para> To enter a debugger command
234           from the current source buffer, select the command from the
235           jdb menu or type the shortcut key for the command. The <guimenu>Jdb</guimenu>
236           menu lists the shortcut keys
237           for debugger commands. </para>
238
239  
240         <para>To enter a command in the debugger interaction window, type the
241           command at the debugger prompt and press the <keycap>Enter</keycap>
242           key. To see a list of debugger commands, enter the command
243           <command>help</command>.
244         </para>
245
246     </sect3>
247
248     <sect3>
249
250       <title><anchor id="SteppingProgram"/>Stepping Through a Program</title>
251
252       <para>
253         Jdb provides a set of command-line commands that advance a
254         program to the next line or the next breakpoint. The JDEE's
255         jdb interface provides Emacs commands that invoke the jdb's
256         step commands from a source buffer and move a debug cursor to
257         the next line to be executed in the source buffer.  If you
258         prefer, you can enter jdb's step commands directly in the jdb
259         buffer. 
260       </para>
261
262       <sect4>
263
264         <title><anchor id="StepCommands"/>Step Commands</title>
265
266         <para> The following table lists the jdb step commands
267           supported by the JDEE.
268         </para>
269
270         <table>
271           <title>Step Commands</title>
272           <tgroup cols="4">
273             <thead>
274               <row>
275                 <entry>Jdb Menu Item</entry>
276                 <entry>Emacs Command</entry>
277                 <entry>jdb Command</entry>
278                 <entry>Description</entry>
279               </row>
280             </thead>
281             <tbody>
282               <row>
283                 <entry>Step Over</entry>
284                 <entry>jde-bug-step-over</entry>
285                 <entry>next</entry>
286                 <entry><para>Advance to the next line in the current
287                     method, stepping over any lines that invoke other
288                     methods.</para></entry>
289               </row>
290               <row>
291                 <entry>Step Into</entry>
292                 <entry>jde-debug-step-into</entry>
293                 <entry>step</entry>
294                 <entry><para>Advance to the next line in the
295                     program.</para></entry>
296               </row>
297               <row>
298                 <entry>Step Out</entry>
299                 <entry>jde-debug-step-out</entry>
300                 <entry>step up</entry>
301                 <entry><para>Advance to the next line in the method
302                     that invoked the current method.</para></entry>
303               </row>
304               <row>
305                 <entry>Continue</entry>
306                 <entry>jde-debug-cont</entry>
307                 <entry>cont</entry>
308                 <entry><para>Advance to the next breakpoint or to the
309                     end of the program, whichever comes
310                     first.</para></entry>
311               </row>
312             </tbody>
313         </tgroup>
314         </table>
315
316       </sect4>
317
318       <sect4>
319
320         <title><anchor id="DebugCursor"/>Debug Cursor</title>
321
322         <para>The JDEE uses an arrow, called the debug cursor, to
323           indicate the next line to be executed as the result of a
324           step or continue command. The debug cursor appears in the
325           left gutter of the source window containing the next line to
326           be executed.</para>
327
328         <screenshot>
329           <mediaobject>
330             <imageobject>
331               <imagedata fileref="images/debug_cursor.gif"/>
332           </imageobject>
333           </mediaobject>
334         </screenshot>
335
336           <para>If the step or continue command advances the
337           program to a line that is not displayed in the current
338           source window, the JDEE opens the source file containing the
339           line, if necessary, and displays the source buffer in the
340           current source window, with the window scrolled to show the
341           line at which the program has halted.</para>
342
343         <note>
344           <para>A blank source buffer indicates that the debugger
345             cannot find the source file into which you have stepped.
346             You should check your source path setting (see <ulink
347               url="#SettingSourcePath">Setting the Source
348               Path</ulink>) to ensure that it includes all source
349             files in the execution path of your program. 
350           </para>
351         </note>
352       </sect4>
353
354     </sect3>
355
356   </chapter>
357
358
359   <chapter>
360
361     <title><anchor id="SettingBreakpoints"/>Setting Breakpoints</title>
362
363  
364     <para>To set a breakpoint on any executable line in the current
365       source buffer, click on the line and select <menuchoice>
366         <guimenu>Jdb</guimenu>
367         <guimenuitem>Set Breakpoint</guimenuitem></menuchoice>
368       (<keycombo>
369         <keycap>C</keycap>
370         <keycap>c</keycap></keycombo><keycombo>
371         <keycap>C</keycap>
372         <keycap>a</keycap></keycombo>
373         <keycombo>
374         <keycap>C</keycap>
375         <keycap>b</keycap></keycombo>).  The JDEE highlights the
376       current line to indicate that a breakpoint is to be set at that
377       line. </para>
378
379     <screenshot>
380         <mediaobject>
381           <imageobject>
382             <imagedata fileref="images/breakpoint.gif"/>
383           </imageobject>
384         </mediaobject>
385     </screenshot>
386
387
388     <para>
389       If the debugger is
390       running, the JDEE issues a command to the debugger to set a
391       breakpoint at the highlighted line. If not, the JDEE issues the
392       breakpoint command as soon as you start the debugger. If the
393       class in which the breakpoint is to be set is currently in memory
394       and the breakpoint is valid, the debugger sets the breakpoint.
395       If the class in which the breakpoint is set is not in memory,
396       the debugger puts it on a list of pending breakpoints. If the
397       class is subsequently loades, the debugger sets the breakpoint
398       in the class.
399     </para>
400
401
402     <sect3>
403       <title><anchor id="BreakpointColors"/>Breakpoint Colors</title>
404       
405  
406       <para>    
407         The color of a breakpoint highlight indicates the status of the breakpoint
408         as follows.
409       </para>
410
411       <table>
412         <title>Breakpoint Colors</title>
413         <tgroup cols="2">
414           <thead>
415             <row>
416               <entry>Color</entry>
417               <entry>Description</entry>
418             </row>
419           </thead>
420           <tbody>
421             <row>
422               <entry>Green</entry>
423               <entry>The JDEE has not yet issued a command to the
424                 debugger to set the breakpoint.</entry>
425             </row>
426             <row>
427               <entry>Yellow</entry>
428               <entry>The breakpoint is pending loading of the class in which it
429               is to be set.</entry>
430             </row>
431             <row>
432               <entry>Red</entry>
433               <entry>The breakpoint has been set.</entry>
434             </row>
435
436           </tbody>
437         </tgroup>
438       </table>
439
440     </sect3>
441
442     <sect3>
443       <title><anchor id="ClearingBreakpoints"/>Clearing
444         Breakpoints</title>
445       <para>
446       To clear a breakpoint from a line in the current buffer, click
447         on the line and select <menuchoice>
448           <guimenu>Jdb</guimenu>
449           <guimenuitem>Toggle Breakpoint</guimenuitem></menuchoice>
450         (<keycombo>
451           <keycap>C</keycap>
452           <keycap>c</keycap></keycombo>
453           <keycombo>
454           <keycap>C</keycap>
455           <keycap>a</keycap></keycombo>
456         <keycombo>
457           <keycap>C</keycap>
458           <keycap>b</keycap></keycombo>).
459       </para>
460
461       <para>To clear all breakpoints set in the current session,
462         select <menuchoice><guimenu>Jdb</guimenu> <guimenuitem>Clear
463             Breakpoints</guimenuitem></menuchoice>.
464       </para>
465  
466       <note>
467         <para>You can also set and clear breakpoints by entering jdb
468           breakpoint commands in the jdb interaction buffer. See the
469           jdb documentation for information on using the jdb
470           breakpoint commands.</para>
471       </note>
472
473     </sect3>
474     
475   </chapter>
476
477   <chapter>
478
479     <title><anchor id="SettingSourcePath"/>Setting the Source Path</title>
480
481     <para>The <varname>jde-sourcepath</varname> variable specifies the
482         directories the JDEE should search for source for classes
483         visited by the debugger as you step through your program.
484     </para>
485
486
487     <para>To set this variable, enter <command>M-x customize-variable jde-sourcepath</command>.
488       The customization buffer for jde-sourcepath appears. The buffer shows the current
489       source path as a list of paths.</para>
490
491       <screenshot>
492         <mediaobject>
493           <imageobject>
494             <imagedata fileref="images/debug2.gif"/>
495           </imageobject>
496         </mediaobject>
497       </screenshot>
498
499       <para>To add a path, click the <guibutton>INS</guibutton> button
500       corresponding to the position in the list and enter the path in
501       the resulting edit field. To delete a path, click the <guibutton>DEL</guibutton> button
502       corresponding to the path. You can use environment variables in paths and
503       use dot notation to specify paths relative to the project file for the
504       project to which this sourcepath applies. When you are done editing the buffer,
505       press the <guibutton>State</guibutton> button to set the
506       variable.</para>
507
508       <para>To avoid having to specify the sourcepath every time you
509       start a session, save the setting of
510       <varname>jde-db-sourcepath</varname> in your
511       <filename>prj.el</filename> file (see <ulink
512         url="../jde-ug/jde-ug-content.html#SavingProjSettings">Saving
513         Project Settings</ulink>)  To save the setting in your project
514       file, select 
515         <menuchoice>
516         <guimenu>JDE</guimenu>
517         <guimenuitem>Project</guimenuitem><guimenuitem>Project File</guimenuitem>
518         <guimenuitem>Save</guimenuitem></menuchoice> (<keycombo>
519         <keycap>C</keycap>
520         <keycap>c</keycap>
521       </keycombo>
522       <keycombo>
523         <keycap>C</keycap>
524         <keycap>v</keycap>
525       </keycombo>
526       <keycombo>
527         <keycap>C</keycap>
528         <keycap>p</keycap>
529       </keycombo>
530       ). </para>
531
532
533       <para>
534       You must specify the paths of the top-level directories of any
535       source code that you might visit while debugging your
536       application. The source code directory structure must mirror
537       your application's package structure. For example, suppose that your
538       application includes a set of classes packaged in the
539       <filename>myapp</filename> directory. Then, the source for those classes
540       must be reside in a directory named <filename>myapp</filename> and you must
541       specify the path of <filename>myapp</filename>'s parent directory.
542       </para>
543
544       <para>If you want to step through the JDK source code,
545         select the source code install option when you install the JDK
546         and set the <varname>jde-sourcepath</varname> variable
547         to the top-level directory containing the source code.
548         The JDE will use the JDK's package structure to find the
549         source code in the subdirectories. </para>
550
551
552   </chapter>
553
554
555   <chapter>
556
557     <title><anchor id="DisplayingVariables"/>Displaying Variables</title>
558
559     <para>This section shows you how to display the values of variables
560     (or expressions).</para>
561
562     <sect3>
563
564       <title><anchor id="DisplayingExpressions"/>Displaying
565         Expressions</title>
566
567       <para>When the debuggee program is stopped, the debugger lets
568         you display the value of any valid Java expression composed of
569         variables currently in scope.  For example, to display the
570         value of a local, in-scope variable whose source is displayed
571         in a Java source buffer, put the point on the variable and
572         select
573       <menuchoice>
574           <guimenu>Jdb</guimenu>
575           <guimenuitem>Display</guimenuitem>
576           <guimenuitem>Expression</guimenuitem>
577       </menuchoice>. The JDEE prompts you to enter an expression to be
578         evaluated and displayed in the minibuffer.</para>
579
580       <screenshot>
581         <mediaobject>
582           <imageobject>
583             <imagedata fileref="images/display_var1.gif"/>
584           </imageobject>
585         </mediaobject>
586       </screenshot>
587
588
589       <para> The default expression is the variable at point in the
590         source buffer. Edit the displayed expression and press
591         <keycap>Enter</keycap>. The JDEE issues a command to the
592         debugger to display the variable in the jdb buffer.</para>
593
594       <screenshot>
595         <mediaobject>
596           <imageobject>
597             <imagedata fileref="images/display_var2.gif"/>
598           </imageobject>
599         </mediaobject>
600       </screenshot>
601
602     </sect3>
603
604     <sect3>
605       <title><anchor id="DisplayingObjects"/>Displaying
606         Objects</title>
607       <para>To display the values of the fields of an object
608         referenced by an in-scope variable in the current source
609         buffer, and select
610       <menuchoice>
611           <guimenu>Jdb</guimenu>
612           <guimenuitem>Display</guimenuitem>
613           <guimenuitem>Object</guimenuitem>
614       </menuchoice>. The JDEE prompts you to enter the name of the
615         variable in the minibuffer. The default is the variable at
616         point in the source buffer. Press <keycap>Enter</keycap>. The
617         JDEE issues a <command>dump</command> command to the debugger
618         to display the field values of the object referenced by the
619         variable you entered.</para>
620
621       <screenshot>
622         <mediaobject>
623           <imageobject>
624             <imagedata fileref="images/display_obj.gif"/>
625           </imageobject>
626         </mediaobject>
627       </screenshot>
628     </sect3>
629
630
631
632     <sect3>
633       <title><anchor id="DisplayingLocals"/>Displaying Locals
634       </title>
635       <para>To display the values of all in-scope local variables,
636         including the values of the arguments of the method in which
637         the program is halted, select
638       <menuchoice>
639           <guimenu>Jdb</guimenu>
640           <guimenuitem>Display</guimenuitem>
641           <guimenuitem>Locals</guimenuitem>
642       </menuchoice>. The JDEE issues a <command>locals</command>
643         command to the debugger to display the local variable
644         values.</para>
645
646       <screenshot>
647         <mediaobject>
648           <imageobject>
649             <imagedata fileref="images/display_locals.gif"/>
650           </imageobject>
651         </mediaobject>
652       </screenshot>
653     </sect3>
654   </chapter>
655
656   <chapter>
657     <title><anchor id="SettingVariables"/>Setting Variables</title>
658     
659     <para>Jdb allows you to change the values of variables that are 
660     in scope. To change the value of a variable via the JDEE's jdb
661     interface:</para>
662
663     <orderedlist>
664
665       <listitem>
666         <para>Position point on the variable you want to change.</para>
667       </listitem>
668
669       <listitem>
670         <para>Select <menuchoice>
671             <guimenu>Jdb</guimenu>
672             <guimenuitem>Set Variable</guimenuitem>
673           </menuchoice>.
674         </para>
675         <para>The JDEE prompts you to enter a left expression that
676           represents the variable whose value you want to change. The
677           default is the variable at point in the source buffer.
678         </para>
679
680         <screenshot>
681           <mediaobject>
682             <imageobject>
683               <imagedata fileref="images/set_var1.gif"/>
684             </imageobject>
685           </mediaobject>
686         </screenshot>
687
688         <note>
689           <para>Edit the expression if necessary. For example, to set
690             the value of an array element at point, edit the
691             expression to include the index of the element.</para>
692         </note>
693
694       </listitem>
695
696       <listitem>
697         <para>Press <keycap>Enter</keycap>.</para>
698         <para>The JDEE prompts you to enter the new value of the
699           variable.</para>
700
701         <screenshot>
702           <mediaobject>
703             <imageobject>
704               <imagedata fileref="images/set_var2.gif"/>
705             </imageobject>
706           </mediaobject>
707         </screenshot>
708       </listitem>
709
710       <listitem>
711         <para>Enter the new value at the prompt in the minibuffer.</para>
712
713         <screenshot>
714           <mediaobject>
715             <imageobject>
716               <imagedata fileref="images/set_var3.gif"/>
717             </imageobject>
718           </mediaobject>
719         </screenshot>
720       </listitem>
721         
722
723       <listitem>
724         <para>Press <keycap>Enter</keycap>.</para>
725         <para>The JDEE issues a <command>set</command> command to the
726           debugger to set the specified variable to the new
727           value.</para>
728
729         <screenshot>
730           <mediaobject>
731             <imageobject>
732               <imagedata fileref="images/set_var4.gif"/>
733             </imageobject>
734           </mediaobject>
735         </screenshot>
736
737       </listitem>
738
739     </orderedlist>
740
741   </chapter>
742
743   <chapter>
744
745     <title><anchor id="DebugExternalProcesses"/>Debugging External Processes</title>
746
747     <para>Normally jdb launches the application that it debugs.
748       However, you can use jdb to debug processes that are not
749       launched by jdb itself. This is useful, for example, if you need
750       to debug a process running on a remote computer or a Java
751       process launched by a nonJava process.</para>
752     
753     <para>Jdb provides two
754       modes for debugging external processes: attach mode and listen
755       mode. When started in attach mode, jdb connects itself to the
756       external process. When started in listen mode, jdb waits for an
757       external process to connect itself to jdb. Each mode has
758       advantages. Attach mode allows you to debug an external process
759       anytime after it has started. Listen mode allows you to debug
760       the startup of a Java process launched by a nonJava process.</para>
761
762     <para>
763       The following sections explain how to use the JDEE's jdb
764       interface to run jdb in attach and listen mode.</para>
765
766     <sect3>
767       <title><anchor id="AttachingProcesses"/>Attaching Processes</title>
768       
769       <para>To attach jdb to an external process, you must ensure that the 
770       external process is started in debug server mode. You must then
771       start jdb in attach mode.</para>
772
773       <sect4>
774         <title><anchor id="DebugServerMode"/>Starting the External
775           Process in Debug Server Mode</title>
776
777         <para>To start an external process in debug server mode, you
778           must start the vm that runs the process with the following
779           command-line options:</para>
780
781         <itemizedlist>
782           <listitem>
783             <para><literal>-Xdebug</literal></para>
784           </listitem>
785
786           <listitem>
787             <para>
788               <literal>-Xrunjdwp:transport=<keycap>TRANSPORT</keycap>,address=<keycap>ADDRESS</keycap>,server=y,suspend=<keycap>SUSPEND</keycap></literal>
789             </para>
790             <para>where</para> 
791               <itemizedlist>
792                 <listitem>
793                 <para><literal><keycap>TRANSPORT</keycap></literal> is
794                   the type of communications channel between jdb and
795                   the debuggee process, either
796                   <literal>dt_socket</literal> (socket) or
797                   <literal>dt_shmem</literal> (shared memory, valid
798                   only for Windows systems)</para>
799                 </listitem>
800               
801               <listitem>
802                 <para><literal><keycap>ADDRESS</keycap></literal> is
803                   the address of the socket port or shared memory area
804                   used by the debuggee process to listen for a jdb
805                   connection.</para>
806               </listitem>
807
808               <listitem>
809                 <para><literal><keycap>SUSPEND</keycap></literal> is
810                   either <literal>y</literal> (suspend the debuggee
811                   process at startup, i.e., to wait for jdb to start,
812                   a useful option when you need to debug an
813                   application's startup code) or <literal>n</literal>
814                   (do not suspend the debuggee process)</para>
815               </listitem>
816             </itemizedlist>           
817           
818           </listitem>
819         </itemizedlist>
820
821         <example>
822           <title>Specifying Socket Transport</title>
823           <para><literal>-Xdebug
824               -Xrunjdwp:transport=dt_socket,address=4444,server=y,suspend=n</literal></para>
825         </example>
826
827         <example>
828           <title>Specifying Shared Memory Transport (MS Windows only)</title>
829           <para><literal>-Xdebug
830               -Xrunjdwp:transport=dt_shmem,address=javadebug,server=y,suspend=n</literal></para>
831         </example>
832
833
834         <para>The JDEE customization variable, <varname>jde-run-option-debug</varname>, causes
835         the JDEE to generate these arguments automatically when launching a vm to run a  Java
836         application. Thus, if you plan to launch the debuggee process from the JDEE, you
837         should set this variable to the desired options.</para>
838       </sect4>
839
840       <sect4>
841         <title><anchor id="AttachMode"/>Starting jdb in Attach
842           Mode</title>
843
844         <para>To attach jdb to an existing process via a socket, 
845           select <menuchoice>
846             <guimenu>Jdb</guimenu>
847             <guimenuitem>External Process</guimenuitem>
848             <guimenuitem>Attach Via Socket</guimenuitem>
849           </menuchoice> from the Emacs menu bar. By default, 
850           the JDEE uses the socket address specified by 
851           the customization variable <varname>jde-db-option-connect-socket</varname>. 
852           If you set this variable to Prompt (nil), the JDEE 
853           prompts you to enter a socket address in the minibuffer. 
854         </para>
855
856         <note>
857           <para>The default socket address specified by
858             <varname>jde-db-option-connect-socket</varname>
859           is the same as the default socket address specified
860           by <varname>jde-run-option-debug</varname>. Thus, if you
861           want to attach jdb to a process started by the JDEE, the
862           only variable you have to set is 
863             <varname>jde-run-option-debug</varname> (to run 
864           the debuggee process in socket attach mode).</para>
865         </note>
866
867
868         <para>To attach jdb to an existing process via a shared memory
869           connection (Windows platforms only), 
870           select <menuchoice>
871             <guimenu>Jdb</guimenu>
872             <guimenuitem>External Process</guimenuitem>
873             <guimenuitem>Attach Via Shared Memory</guimenuitem>
874           </menuchoice> from the Emacs menu bar. By default, 
875           the JDEE uses the shared memory transport name specified by 
876           the customization variable 
877           <varname>jde-db-option-connect-shared-memory-name</varname>. 
878           If you set this variable to Prompt (nil), the JDEE 
879           prompts you to enter a shared-memory name in the minibuffer. 
880         </para>
881
882         <note>
883           <para>The default shared memory name specified by
884             <varname>jde-db-option-connect-shared-memory-name</varname>
885           is the same as the default shared memory name specified
886           by <varname>jde-run-option-debug</varname>. Thus, if you
887           want to attach jdb to a process started by the JDEE, the
888           only variable you have to set is 
889             <varname>jde-run-option-debug</varname> (to run 
890           the debuggee process in shared memory attach mode).</para>
891         </note>
892
893       </sect4>
894
895     </sect3>
896
897     <sect3>
898       <title><anchor id="ListeningForProcesses"/>Listening for Processes</title>
899
900       <para>To connect an external process to a jdb instance running in listener
901       mode:</para>
902
903       <orderedlist>
904         <listitem>
905           <para>Start jdb in listener mode (see <ulink url="#ListenMode">Starting
906             jdb in Listen Mode</ulink>)</para>
907         </listitem>
908         <listitem>
909           <para>Start the debuggee process in debug client 
910             mode(see <ulink url="#DebugClientMode">Starting
911             the External Process in Debug Client Mode</ulink>)</para>
912         </listitem>
913       </orderedlist>
914
915       <sect4>
916         <title><anchor id="ListenMode"/>Starting jdb in Listen Mode</title>
917         <para>To start jdb in listen mode, select <menuchoice>
918             <guimenu>Jdb</guimenu>
919             <guimenuitem>External Process</guimenuitem>
920             <guimenuitem>Listen For</guimenuitem>
921           </menuchoice> from the Emacs menu bar. By default, the 
922           JDEE prompts you to enter the address of the process to
923           be debugged in the minibuffer. The JDEE customization variable
924           jde-db-option-listen-address allows you to specify a default
925           debuggee address. If you set this variable, the JDEE does not
926           prompt you to enter an address.
927         </para>
928
929         <para>To start jdb listening for  existing process via a socket, 
930           select <menuchoice>
931             <guimenu>Jdb</guimenu>
932             <guimenuitem>External Process</guimenuitem>
933             <guimenuitem>Listen Via Socket</guimenuitem>
934           </menuchoice> from the Emacs menu bar. By default, 
935           the JDEE uses the socket address specified by 
936           the customization variable <varname>jde-db-option-connect-socket</varname>. 
937           If you set this variable to Prompt (nil), the JDEE 
938           prompts you to enter a socket address in the minibuffer. 
939         </para>
940
941         <note>
942           <para>The default socket address specified by
943             <varname>jde-db-option-connect-socket</varname>
944           is the same as the default socket address specified
945           by <varname>jde-run-option-debug</varname>. Thus, if you
946           want jdb to listen for a process started by the JDEE, the
947           only variable you have to set is 
948             <varname>jde-run-option-debug</varname>, i.e., to run 
949           the debuggee process in socket listen (client) mode.</para>
950         </note>
951
952
953         <para>To start jdb listening for a process via a shared memory
954           connection (Windows platforms only), 
955           select <menuchoice>
956             <guimenu>Jdb</guimenu>
957             <guimenuitem>External Process</guimenuitem>
958             <guimenuitem>Listen Via Shared Memory</guimenuitem>
959           </menuchoice> from the Emacs menu bar. By default, 
960           the JDEE uses the shared memory transport name specified by 
961           the customization variable 
962           <varname>jde-db-option-connect-shared-memory-name</varname>. 
963           If you set this variable to Prompt (nil), the JDEE 
964           prompts you to enter a shared-memory name in the minibuffer. 
965         </para>
966
967         <note>
968           <para>The default shared memory name specified by
969             <varname>jde-db-option-connect-shared-memory-name</varname>
970           is the same as the default shared memory name specified
971           by <varname>jde-run-option-debug</varname>. Thus, if you
972           want  jdb to listen for a process started by the JDEE, the
973           only variable you have to set is 
974             <varname>jde-run-option-debug</varname>, i.e., to run 
975           the debuggee process in shared memory listen (client) mode.</para>
976         </note>
977     
978       </sect4>
979
980
981       <sect4>
982         <title><anchor id="DebugClientMode"/>Starting the External
983           Process in Debug Client Mode</title>
984
985         <para>To start an external process in debug client mode, you
986           must start the vm that runs the process with the following
987           command-line options:</para>
988
989         <itemizedlist>
990           <listitem>
991             <para><literal>-Xdebug</literal></para>
992           </listitem>
993
994           <listitem>
995             <para>
996               <literal>-Xrunjdwp:transport=<keycap>TRANSPORT</keycap>,address=<keycap>ADDRESS</keycap>,server=n,suspend=<keycap>SUSPEND</keycap></literal>
997             </para>
998             <para>where</para> 
999               <itemizedlist>
1000                 <listitem>
1001                 <para><literal><keycap>TRANSPORT</keycap></literal> is
1002                   the type of communications channel between jdb and
1003                   the debuggee process, either
1004                   <literal>dt_socket</literal> (socket) or
1005                   <literal>dt_shmem</literal> (shared memory, valid
1006                   only for Windows systems)</para>
1007                 </listitem>
1008               
1009               <listitem>
1010                 <para><literal><keycap>ADDRESS</keycap></literal> is
1011                   the address of the socket port or shared memory area
1012                   used by jdb to listen for a debuggee process
1013                   connection.</para>
1014               </listitem>
1015
1016               <listitem>
1017                 <para><literal><keycap>SUSPEND</keycap></literal> is
1018                   either <literal>y</literal> (suspend the debuggee
1019                   process when the connection occurs,
1020                   a useful option when you need to debug an
1021                   application's startup code) or <literal>n</literal>
1022                   (do not suspend the debuggee process)</para>
1023               </listitem>
1024             </itemizedlist>           
1025           
1026           </listitem>
1027         </itemizedlist>
1028
1029         <example>
1030           <title>Specifying Socket Transport</title>
1031           <para><literal>-Xdebug
1032               -Xrunjdwp:transport=dt_socket,address=4444,server=n,suspend=n</literal></para>
1033         </example>
1034
1035         <example>
1036           <title>Specifying Shared Memory Transport (MS Windows only)</title>
1037           <para><literal>-Xdebug
1038               -Xrunjdwp:transport=dt_shmem,address=javadebug,server=n,suspend=n</literal></para>
1039         </example>
1040
1041
1042         <para>The JDEE customization variable, <varname>jde-run-option-debug</varname>, causes
1043         the JDEE to generate these arguments automatically when launching a vm to run a  Java
1044         application. Thus, if you plan to launch the debuggee process from the JDEE, you
1045         should set this variable to the desired options.</para>
1046
1047       </sect4>
1048
1049     </sect3>
1050
1051   </chapter>
1052
1053   <chapter>
1054
1055     <title><anchor id="DebugOptions"/>Debug Options</title>
1056
1057     <para>The JDEE allows you to specify debug options by setting JDEE
1058       configuration variables. You can use the Emacs customization
1059       feature to set debug variables interactively. To use the
1060       customization feature, select <menuchoice>
1061         <guimenu>Project</guimenu>
1062         <guimenuitem>Options</guimenuitem>
1063         <guimenuitem>Debug</guimenuitem></menuchoice> from the
1064       <guimenu>JDE</guimenu> menu. (See <ulink
1065         url="../jde-ug/jde-ug-content.html#ConfiguringJDE">Configuring
1066         the JDEE</ulink> for more information on using the
1067       customization feature). To save the compilation settings in the
1068       project file (see <ulink
1069         url="../jde-ug/jde-ug-content.html#UsingProjectFiles">Using
1070         Project Files</ulink> for the current source buffer, select
1071       <menuchoice>
1072         <guimenu>Project</guimenu>
1073         <guimenuitem>Project File</guimenuitem>
1074         <guimenuitem>Save</guimenuitem></menuchoice> from the
1075       <guimenu>JDE</guimenu> menu.</para>
1076
1077     <para>The following table lists the jdb customization variables.</para>
1078
1079
1080     <table>
1081
1082       <title>Jdb Customization  Variables</title>
1083
1084       <tgroup cols="3">
1085
1086         <thead>
1087           <row>
1088             <entry>Variable</entry>
1089             <entry>Group</entry>
1090             <entry>Usage</entry>
1091           </row>
1092         </thead>
1093
1094         <tbody>
1095     <row>
1096         <entry valign="top"><varname>jde-debugger</varname></entry>
1097         <entry valign="top">Project</entry>
1098         <entry valign="top">Specify which debugger to use to debug the current project.</entry>
1099     </row>
1100     <row>
1101         <entry valign="top"><varname>jde-sourcepath</varname></entry>
1102         <entry valign="top">Project</entry>
1103         <entry valign="top">Specify location(s) of source files that
1104         can be visited while stepping through a program.</entry>
1105     </row>
1106     <row>
1107         <entry valign="top"><varname>jde-db-mode-hook</varname></entry>
1108         <entry valign="top">Project</entry>
1109         <entry valign="top">Customization hook for jde-db inferior
1110         mode.</entry>
1111     </row>
1112     <row>
1113         <entry valign="top"><varname>jde-global-classpath</varname></entry>
1114         <entry valign="top">Project</entry>
1115         <entry valign="top">Specify class paths for compile, run,
1116         and debug commands.</entry>
1117     </row>
1118     <row>
1119         <entry valign="top"><varname>jde-db-read-vm-args</varname></entry>
1120         <entry valign="top">Project</entry>
1121         <entry>Specifies whether to read debugger VM arguments from
1122         the minibuffer.</entry>
1123     </row>
1124     <row>
1125         <entry valign="top"><varname>jde-db-read-app-args</varname></entry>
1126         <entry valign="top">Project</entry>
1127         <entry>Specifies whether to read command-line application
1128         arguments from the minibuffer.</entry>
1129     </row>
1130     <row>
1131         <entry valign="top"><varname>jde-db-option-classpath</varname></entry>
1132         <entry valign="top">Debug</entry>
1133         <entry valign="top">Specifies the classpath for the
1134         Java interpreter. This option overrides the
1135         jde-global-classpath option.</entry>
1136     </row>
1137     <row>
1138         <entry valign="top"><varname>jde-db-option-verbose</varname></entry>
1139         <entry valign="top">Debug</entry>
1140         <entry valign="top">Print messages about the running
1141         process.</entry>
1142     </row>
1143     <row>
1144         <entry valign="top"><varname>jde-db-option-properties</varname></entry>
1145         <entry valign="top">Debug</entry>
1146         <entry valign="top">Specify property values.</entry>
1147     </row>
1148     <row>
1149         <entry valign="top"><varname>jde-db-option-heap-size</varname></entry>
1150         <entry valign="top">Debug</entry>
1151         <entry valign="top">Specify the initial and maximum size of
1152         the interpreter heap.</entry>
1153     </row>
1154     <row>
1155         <entry valign="top"><varname>jde-db-option-stack-size</varname></entry>
1156         <entry valign="top">Debug</entry>
1157         <entry valign="top">Specify size of the C and Java stacks.</entry>
1158     </row>
1159     <row>
1160         <entry valign="top"><varname>jde-db-option-garbage-</varname>
1161         <varname>collection</varname></entry>
1162         <entry valign="top">Debug</entry>
1163         <entry valign="top">Specify garbage collection
1164         options.</entry>
1165     </row>
1166     <row>
1167         <entry valign="top"><varname>jde-db-option-java-profile</varname></entry>
1168         <entry valign="top">Debug</entry>
1169         <entry valign="top">Enable Java profiling.</entry>
1170     </row>
1171     <row>
1172         <entry valign="top"><varname>jde-db-option-heap-profile</varname></entry>
1173         <entry valign="top">Debug</entry>
1174         <entry valign="top">Output heap profiling data.</entry>
1175     </row>
1176     <row>
1177         <entry valign="top"><varname>jde-db-option-verify</varname></entry>
1178         <entry valign="top">Debug</entry>
1179         <entry valign="top">Verify classes.</entry>
1180     </row>
1181     <row>
1182         <entry valign="top"><varname>jde-db-option-vm-args</varname></entry>
1183         <entry valign="top">Debug</entry>
1184         <entry valign="top">Specify command-line arguments to be
1185         passed to the Java VM.</entry>
1186     </row>
1187           <row>
1188             <entry valign="top"><varname>jde-db-option-application-args</varname></entry>
1189             <entry valign="top">Debug</entry>
1190             <entry valign="top">Specify command-line arguments to pass
1191               to the application.</entry>
1192           </row>
1193           <row>
1194             <entry valign="top"><varname>jde-db-option-connect-socket</varname></entry>
1195             <entry valign="top">Debug</entry>
1196             <entry valign="top">Specify socket address of a running process
1197               to which you want to connect the debugger, using a
1198               debugger attach or listen command.</entry>
1199           </row>
1200           <row>
1201             <entry valign="top"><varname>jde-db-option-connect-shared-memory-name</varname></entry>
1202             <entry valign="top">Debug</entry>
1203             <entry valign="top">Specify shared memory name used by the debugger
1204               to attach or listen for debuggee processes to debug.</entry>
1205           </row>
1206           <row>
1207             <entry valign="top"><varname>jde-db-option-host</varname></entry>
1208             <entry valign="top">Debug</entry>
1209             <entry valign="top">Host of a remote process to which you
1210               wish to attach the debugger. This option is invalid for JDK verions
1211               greater than JDK 1.1.x.</entry>
1212           </row>
1213         </tbody>      
1214       </tgroup>
1215     </table>
1216   </chapter>
1217
1218 </book>
1219
1220 <!-- 
1221 Local Variables: 
1222 mode: xae
1223 sgml-indent-step: 2
1224 sgml-indent-data: t
1225 sgml-set-face: t
1226 sgml-insert-missing-element-comment: nil
1227 End:
1228  -->