⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 running.html

📁 jdbc书
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<P>
To start <CODE>jdb</CODE> in remote 
debug mode, supply a host name, which can be either the machine where the remote 
program was started or <CODE>localhost</CODE> if you are debugging on the 
same machine as the remote program, and the agent password.

</FONT>

<PRE>
jdb -host localhost -password 4gk5hm
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">

<H4>Listing Threads</H4>

Once inside the <CODE>jdb</CODE> session, you can list the currently active 
threads with the <CODE>threads</CODE> command, and use the 
<CODE>thread &lt;threadnumber&gt;</CODE> command, for example, <CODE>thread 7</CODE>
to select the thread to analyze. Once the thread is selected,
use the <CODE>where</CODE> command to see which methods have been 
called for this thread. 
</FONT>

<PRE>
<FONT SIZE="-1">
$ jdb -host arsenal -password 5ufhic
Initializing jdb...
&gt; threads
Group system:
1. (java.lang.Thread)0x9        Signal dispatcher  
			       cond. waiting
2. (java.lang.ref.Reference     0xb Reference Handler
      $ReferenceHandler)       cond. waiting
3. (java.lang.ref.              Finalizer
      Finalizer                cond. waiting
      $FinalizerThread)0xd            
						
4. (java.lang.Thread)0xe       Debugger agent     
		              running    
5. (sun.tools.agent.           Breakpoint handler
      Handler)0x10            cond. waiting
6. (sun.tools.agent.           Step handler
      StepHandler)0x12        cond. waiting
Group main:
7. (java.awt.                  AWT-EventQueue-0 
       EventDispatchThread)   cond. waiting 
       0x19 					         
8. (sun.awt.                    PostEventQueue-0 
      PostEventQueue)0x1b      cond. waiting          
9. (java.lang.Thread)0x1c       AWT-Motif        
			       running                
10. (java.lang.Thread)0x1d      TimerQueue       
			       cond. waiting          
11. (sun.awt.                   Screen Updater
       ScreenUpdater)0x1f      cond. waiting          
12. (java.lang.Thread)0x20      Thread-0         
			       cond. waiting          
&gt; thread 7
AWT-EventQueue-0[1] where
  [1] java.lang.Object.wait (native method)
  [2] java.lang.Object.wait (Object:424)
  [3] java.awt.EventQueue.getNextEvent 
                            (EventQueue:179)
  [4] java.awt.EventDispatchThread.run 
	         (EventDispatchThread:67)
</FONT>
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">
<P>
<H4>Listing Source</H4>
<P>

To list the source, the thread needs to be suspended using the 
<CODE>suspend</CODE> command. To let this thread continue
use the <CODE>resume</CODE> command. The example uses
<CODE>resume 7.</CODE> 

</FONT>

<PRE>
<FONT SIZE="-1">
AWT-EventQueue-0[1] suspend 7
AWT-EventQueue-0[1] list
Current method is native
AWT-EventQueue-0[1] where
  [1] java.lang.Object.wait (native method)
  [2] java.lang.Object.wait (Object:424)
  [3] java.awt.EventQueue.getNextEvent 
                            (EventQueue:179)
  [4] java.awt.EventDispatchThread.run 
		 (EventDispatchThread:67)
AWT-EventQueue-0[1] resume 7
</FONT>
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">

<P>
<H4>Ending the Session</H4>
<P>

When you finish debugging this program remotely,
clear any remaining breakpoints before quitting the debug
session. To get a list of remaining breakpoints use the <CODE>clear</CODE>
command, and to remove them enter <CODE>clear class:linenumber</CODE> as
follows:
</FONT>

<PRE>
main[1] clear
Current breakpoints set:
SimpleJdbTest:10

main[1] clear SimpleJdbTest:10
main[1] quit
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">

<A NAME="auto"></A>
<H3>Using Auto-Pilot</H3>

One little known trick with <CODE>jdb</CODE> is the <CODE>jdb</CODE> startup 
file. <CODE>jdb</CODE> automatically looks for a file called <CODE>jdb.ini</CODE> 
in the <CODE>user.home</CODE> directory. If you have multiple projects, it
is a good idea to set a different <CODE>user.home</CODE> property for each
project when you start <CODE>jdb</CODE>. To start <CODE>jdb</CODE> with a 
<CODE>jdb.ini</CODE> file in the current directory, type the following:

<P>
</FONT>

<PRE>
jdb -J-Duser.home=.
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">

<P>
The <CODE>jdb.ini</CODE> file lets you set up <CODE>jdb</CODE> configuration 
commands, such as <CODE>use</CODE>, without having to enter the details each 
time <CODE>jdb</CODE> runs. The following example <CODE>jdb.ini</CODE> file
starts a <CODE>jdb</CODE> session for the <CODE>FacTest</CODE> class.
It includes the Java platform sources on the source path list and passes
the parameter 6 to the program. It then runs and stops at line 13,
displays the free memory, and waits for further input.

</FONT>

<PRE>
load FacTest
stop at FacTest:13
use /home/calvin/java:/home/calvin/jdk/src/
run FacTest 6
memory
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">

Here is the output from the <CODE>jdb.ini</CODE> file execution:

</FONT>

<PRE>
$ jdb -J-Duser.home=/home/calvin/java
Initializing jdb...
0xad:class(FacTest)
Breakpoint set at FacTest:13
running ...
Free: 662384, total: 1048568
main[1]
Breakpoint hit: FacTest.compute (FacTest:13)
main[1]
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">

You might wonder if <CODE>jdb.ini</CODE> files can be used to control 
an entire <CODE>jdb</CODE> session. Unfortunately, commands in a
<CODE>jdb.ini</CODE> startup file are executed synchronously, and 
<CODE>jdb</CODE> does not wait until a breakpoint is reached
before executing the next command. This makes printing variables
awkward.  You can add artificial delays with repeated <CODE>help</CODE>
commands, but there is still no guarantee the thread will be suspended when 
you need it to be.

<A NAME="session"></A>
<H3>Creating a Session Log</H3>

You can use a little-known <CODE>jdb</CODE> feature to obtain a record of your
debug session. The output is similar to what you see when you run 
<CODE>jdb -dbgtrace</CODE>.

<P>
To enable <CODE>jdb</CODE> logging, create a file called <CODE>.agentLog</CODE> 
in the directory where you are running <CODE>jdb</CODE> 
or <CODE>java -debug</CODE>. 
In the <CODE>.agentLog</CODE> file, put the file name that you want the session 
information to be written to on the first line. For example, an
<CODE>.agentLog</CODE> file would have these contents:

</FONT>

<PRE>
jdblog
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">

<P>
When you next run <CODE>jdb</CODE> or <CODE>java -debug</CODE>,
you will see <CODE>jdb</CODE> session information as shown below.
You can use this information to retrieve the breakpoint hits and
the commands entered if you need to reproduce this debug session.

</FONT>

<PRE>
<FONT SIZE="-1">
---- debug agent message log ----
[debug agent: adding Debugger agent to 
system thread list]
[debug agent: adding Breakpoint handler 
to system thread list]
[debug agent: adding Step handler to 
system thread list]
[debug agent: adding Finalizer to 
system thread list]
[debug agent: adding Reference Handler to 
system thread list]
[debug agent: adding Signal dispatcher to 
system thread list]
[debug agent: Awaiting new step request]
[debug agent: cmd socket: 
Socket[addr=localhost/127.0.0.1,
port=38986,localport=3 8985]]
[debug agent: connection accepted]
[debug agent: dumpClasses()]
[debug agent: no such class: HelloWorldApp.main]
[debug agent: Adding breakpoint bkpt:main(0)]
[debug agent: no last suspended to resume]
[debug agent: Getting threads for HelloWorldApp.main]
</FONT>
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">


<P ALIGN="RIGHT">
<FONT SIZE="-1">[<A HREF="#top">TOP</A>]</FONT>

</FONT>
</TD>
</TR>
</TABLE>




<!-- ================ -->
<!-- End Main Content -->
<!-- ================ -->

</TD>
</TR>
</TABLE>

<!-- Copyright Insert -->

<BR CLEAR="ALL">

<FORM ACTION="/cgi-bin/search.cgi" METHOD="POST">
<TABLE WIDTH="100%" CELLPADDING="0" BORDER="0" CELLSPACING="5">   
  <TR>
    <TD VALIGN="TOP">
	
    <P ALIGN=CENTER>
    <FONT SIZE="-1" COLOR="#999999" FACE="Verdana, Arial, Helvetica, sans-serif">
    [ This page was updated: <!-- new date --> 13-Oct-99 ]</font></P>
    </TD>
  </TR>
  
  <TR>
    <TD BGCOLOR="#CCCCCC">
    <IMG SRC="/images/pixel.gif" HEIGHT="1" WIDTH="1" ALT=""></TD>
  </TR>
  
  <TR>
    <TD>
    <CENTER>
    <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
    <A HREF="http://java.sun.com/products/">Products &amp; APIs</A> | 
    <A HREF="/developer/index.html">Developer Connection</A> | 
    <A HREF="/developer/infodocs/index.shtml">Docs &amp; Training</A> | 
    <A HREF="/developer/support/index.html">Online Support</A><BR>
    <A HREF="/developer/community/index.html">Community Discussion</A> |
    <A HREF="http://java.sun.com/industry/">Industry News</A> | 
    <A HREF="http://java.sun.com/solutions">Solutions Marketplace</A> | 
    <A HREF="http://java.sun.com/casestudies">Case Studies</A>
    </FONT>
    </CENTER>
    </TD>
  </TR>
  
  <TR>
    <TD BGCOLOR="#CCCCCC">
    <IMG SRC="/images/pixel.gif" HEIGHT="1" WIDTH="1" ALT=""></TD>
  </TR>

  <TR>
    <TD ALIGN="CENTER">
    <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
    <A HREF="http://java.sun.com/docs/glossary.html">Glossary</A> - 
    <A HREF="http://java.sun.com/applets/">Applets</A> - 
    <A HREF="http://java.sun.com/docs/books/tutorial/">Tutorial</A> - 
    <A HREF="http://java.sun.com/jobs/">Employment</A> - 
    <A HREF="http://java.sun.com/nav/business/">Business &amp; Licensing</A> - 
    <A HREF="http://java.sun.com/javastore/">Java Store</A> -
    <A HREF="http://java.sun.com/casestudies/">Java in the Real World</A>
    </FONT>
    </TD>
  </TR>

  <TR>
    <TD>
    <CENTER>
    <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
    <a href="/siteinfo/faq.html">FAQ</a> |
    <a href="/feedback/index.html">Feedback</a> | 
    <a href="http://www.dynamicdiagrams.net/mapa/cgi-bin/help.tcl?db=javasoft&dest=http://java.sun.com/">Map</a> | 
    <A HREF="http://java.sun.com/a-z/index.html">A-Z Index</A>
    </FONT>
    </CENTER>

    </TD>
  </TR>
  
  <TR>
    <TD>

    <TABLE WIDTH="100%" CELLPADDING="0" BORDER="0" CELLSPACING="0">
      <TR>
        <TD WIDTH="50%">
        <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
        For more information on Java technology<BR>
        and other software from Sun Microsystems, call:<BR>
        </FONT>
        <FONT SIZE="-1" FACE="Verdana, Arial, Helvetica, sans-serif">
        (800) 786-7638<BR></FONT>
        <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
        Outside the U.S. and Canada, dial your country's 
        <A HREF="http://www.att.com/business_traveler/attdirecttollfree/">AT&amp;T&nbsp;Direct&nbsp;Access&nbsp;Number</A> first.<BR>
        </FONT>
        </TD>

        <TD ALIGN="RIGHT" WIDTH="50%">
        <A HREF="http://www.sun.com"><IMG SRC="/images/lgsun.gif" width="64" height="30" border="0" ALT="Sun Microsystems, Inc."></A><BR>
        <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
        Copyright &copy; 1995-99
        <A HREF="http://www.sun.com">Sun Microsystems, Inc.</A><BR>
        All Rights Reserved. 
        <a href="http://www.sun.com/share/text/SMICopyright.html">Legal Terms</a>. 
        <A HREF="http://www.sun.com/privacy/">Privacy&nbsp;Policy</A>.
        </FONT>
        </TD>
      </TR>
    </TABLE>
	
    </TD>
  </TR> 
</TABLE>
</FORM>

<!-- End Copyright Insert -->


</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -