Site Search :
Standard Enterprise XML Methodology Pattern Setting Tunning Other
Article Contributors
GuestBook
Javapattern Maven
XSourceGen Dev
JetSpeed Test
JLook Image
jLook Family Site


Using java debugger
 
º»°ÝÀûÀÎ ÀÚ¹Ù ÇÁ·Î±×·¥¿¡ ¾Õ¼­ ¹Ì¸® ÀÍÇô¾ß ÇÒ »çÇ×Àº µð¹ö±ë ¹æ¹ýÀÌ´Ù. µð¹ö±ë¾ø´Â ÇÁ·Î±×·¥Àº ÇѸ¶µð·Î ¹«±â¾øÀÌ ÀüÀïÅÍ¿¡ ³ª°¡´Â °Í°ú °°´Ù. ( 2003/02/28 ) 188
Written by ienvyou - ÃÖÁö¿õ
1 of 1
 

ÀÚ¹Ù µð¹ö±ë ¹æ¹ý

º»°ÝÀûÀÎ ÀÚ¹Ù ÇÁ·Î±×·¥¿¡ ¾Õ¼­ ¹Ì¸® ÀÍÇô¾ß ÇÒ »çÇ×Àº µð¹ö±ë ¹æ¹ýÀÌ´Ù.
 µð¹ö±ë¾ø´Â ÇÁ·Î±×·¥Àº ÇѸ¶µð·Î ¹«±â¾øÀÌ ÀüÀïÅÍ¿¡ ³ª°¡´Â °Í°ú °°´Ù. 
 ƯÈ÷ ÀÚ¹Ù¸¦ ¼Ò°³ÇÏ´Â ´ëºÎºÐÀÇ Áö¸é¿¡¼­ µð¹ö°Å »ç¿ë¿¡ ¼ÒȦÇÑ °Í °°´Ù. 
 µû¶ó¼­ À̹ø ±âȸ¿¡ È®½ÇÈ÷ ÀÚ¹Ù µð¹ö±ë ¹æ¹ýÀ» ÀÍÈ÷µµ·Ï ÇÑ´Ù. 

µð¹ö°Å ÄÄÆÄÀÏ ¿É¼Ç
¸ÕÀú ÀÚ¹Ù µð¹ö±ëÀ» À§ÇØ »ç¿ëÀÚ´Â -g ¿É¼ÇÀ» ÁÖ¾î ÄÄÆÄÀÏÇØ¾ß ÇÑ´Ù. 

% javac -g HelloWorld.java [ À¯´Ð½º ]

c:\> javac -g HelloWorld.java [ PC ]

¾ÖÇø´ºä¾î µð¹ö°Å ¿É¼Ç
HelloWorld.html ÆÄÀÏÀÇ ÀÚ¹Ù ¾ÖÇø´¿¡ ´ëÇØ µð¹ö°Å¸¦ »ç¿ëÇϱâ À§ÇØ 
´ÙÀ½°ú °°ÀÌ ¾ÖÇø´ ºä¾î¸¦ ½ÇÇà½ÃŲ´Ù.

% appletviewer -debug HelloWorld.html


ÀÚ¹Ù µð¹ö°Å ¸í·É¾î ÀÌÇØ
´ÙÀ½Àº ½ÇÁ¦ HelloWorld.html À̶ó´Â ¾ÖÇø´À» µð¹ö±ëÇϸ鼭 
ÀÚ¹Ù µð¹ö±ë½Ã ÇÊ¿äÇÑ ¸í·É¾î¸¦ ÀÍÇôº»´Ù. 

- µð¹ö°Å¸¦ ±¸µ¿ÇÑ´Ù.

% appletviewer -debug HelloWorld.html

Initializing jdb...
0xee311280:class(sun.applet.AppletViewer)

¡¡

- µð¹ö°Å¿¡¼­ Á¦°øÇÏ´Â ¸í·É¾î¿¡ ¹«¾ùÀÌ ÀÖ´ÂÁö Á¶È¸Çϱâ À§ÇØ help¸¦ ÀÔ·ÂÇغ»´Ù. 
´ÙÀ½°ú °°ÀÌ ¸í·É¾î¿Í ÇØ´ç ¸í·É¾îÀÇ ¼³¸íÀÌ Ãâ·ÂµÈ´Ù.
> help
** command list **

threads [threadgroup] -- list threads
thread  -- set default thread
suspend [thread id(s)] -- suspend threads (default: all)
resume [thread id(s)] -- resume threads (default: all)
where [thread id] | all -- dump a thread's stack
threadgroups -- list threadgroups
threadgroup  -- set current threadgroup

print  [id(s)] -- print object or field
dump  [id(s)] -- print all object information
locals -- print all local variables in current stack frame classes -- list currently known classes

methods  -- list a class's methods
stop in . -- set a breakpoint in a method
stop at : -- set a breakpoint at a line
up [n frames] -- move up a thread's stack
down [n frames] -- move down a thread's stack
clear : -- clear a breakpoint
step -- execute current line
cont -- continue execution from breakpoint

catch  -- break for the specified exception
ignore  -- ignore when the specified exception
list [line number] -- print source code
use [source file path] -- display or change the source path
memory -- report memory usage
gc -- free unused objects
load classname -- load Java class to be debugged

run  [args] -- start execution of a loaded Java class
!! -- repeat last command
help (or ?) -- list commands
exit (or quit) -- exit debugger

ÀÌ ¸í·É¾îÁß ÀÚÁÖ »ç¿ëÇÏ´Â Áß¿äÇÑ °ÍÀº ´ÙÀ½°ú °°´Ù.
- threadgroups , ÇöÀç ¼öÇàÁßÀÎ ¶ß·¹µå ±×·ìÀÇ ¸ñ·ÏÀ» º¸¿©ÁØ´Ù.
> threadgroups
1. (java.lang.ThreadGroup)0xee3000b8 system
2. (java.lang.ThreadGroup)0xee300aa8 main

threads, ¼öÇàÁßÀÎ ¸ðµç ½º·¹µåÀÇ ¸ñ·ÏÀ» º¸¿©ÁØ´Ù. 
> threads

Group system:
1. (java.lang.Thread)0xee3001f8 clock handler cond.
2. (java.lang.Thread)0xee3002a0 Idle thread runni
3. (java.lang.Thread)0xee300318 Async Garbage Collector cond.
4. (java.lang.Thread)0xee300370 Finalizer thread cond.
5. (java.lang.Thread)0xee300a18 Debugger agent runni
6. (sun.tools.debug.BreakpointHandler)0xee30f708 Breakpoint handler cond.
Group main:
7. (java.lang.Thread)0xee3000a0 main suspended 

>
run , ¾ÖÇø´ºä¾î¸¦ ¼öÇà½ÃÄÑÁØ´Ù. 
> run
run sun.applet.AppletViewer HelloWorld.html 
running ...

main[1] threads
Group sun.applet.AppletViewer.main:

1. (sun.awt.motif.InputThread)0xee313090 AWT-Input running 

2. (java.lang.Thread)0xee3130b8 AWT-Motif cond. waiting 

3. (sun.awt.ScreenUpdater)0xee300858 Screen Updater cond. waiting 

Group group applet-HelloWorld.class:

4. (java.lang.Thread)0xee312f40 class cond. waiting 

main[1] exit

pid 1247 status 0

Received sigchild for 1247 exit=0

% exit

stop , breakpoing ÁöÁ¤
% appletviewer -debug HelloWorld.html

Initializing jdb...
0xee311280:class(sun.applet.AppletViewer)
stop in HelloWorld.paint
Breakpoint set in HelloWorld.paint

run
run sun.applet.AppletViewer HelloWorld.html 
running ...
main[1] 

Breakpoint hit: HelloWorld.paint (HelloWorld:10)

list , ÇöÀç ¼öÇàÁßÀÎ ¼Ò½ºÄÚµåÀÇ breakpoing¸¦ º¸¿©ÁØ´Ù. 
AWT-Motif[1] 

AWT-Motif[1] list

6 int i;
7 
8 public void paint(Graphics g)
9 {
10 => i = 10;
11 g.drawString("Hellow world!" , 25 , 25);
12 }
13 }
14 

where , ÇöÀç ½ÇÇà ½ºÅÃÀ» º¸¿©ÁØ´Ù.
AWT-Motif[1] where

[1] HelloWorld.paint (HelloWorld:10)
[2] sun.awt.motif.MComponentPeer.paint (MComponentPeer:122)
sun.awt.motif.MComponentPeer.handleExpose (MComponentPeer:246)
¡¡
use , ÀÚ¹Ù°¡ ¼Ò½ºÆÄÀÏÀ» ã±âÀ§ÇÑ °æ·Î¸¦ º¸¿©ÁØ´Ù. ±âº»ÀûÀ¸·Î CLASSPATH°¡ »ç¿ëµÈ´Ù.
AWT-Motif[1] use
.:/usr/local/httpd/java/lib/classes.zip:/usr/local/httpd/java/bin
/../classes:/usr/local/httpd/java/bin/../lib/classes.zip:/usr/local/httpd/java/bin/../bin/
../classes:/usr/local/httpd/java/bin/../bin/../lib/classes.zip

dump , °´Ã¼¿¡ ´ëÇÑ Á¤º¸¸¦ ¾òÀ» ¶§ »ç¿ëµÈ´Ù.
AWT-Motif[1] dump g

g = (sun.awt.motif.X11Graphics)0xee310d58 {
int pData = 1476744
Color foreground = (java.awt.Color)0xee300300
Font font = (java.awt.Font)0xee300268
int originX = 0
int originY = 0
Image image = null
}

step , ÇöÀç ¼Ò½ºÄÚµåÁß ÇÑ ¶óÀθ¸À» ¼öÇàÇÑ´Ù.
AWT-Motif[1] step
AWT-Motif[1] 
Breakpoint hit: HelloWorld.paint (HelloWorld:11)

AWT-Motif[1] list
7 
8 public void paint(Graphics g)
9 {
10 i = 10;
11 => g.drawString("Hellow world!" , 25 , 25);
12 }
13 }
14 

¡¡

load Ŭ·¡½ºÀ̸§ , ÇØ´ç Ŭ·¡½º¸¦ ·ÎµåÇØÁØ´Ù.
> load HelloWorld
0xee310ea8:class(HelloWorld)
memory , »ç¿ëÁßÀÎ ¸Þ¸ð¸®ÀÇ »óȲÀ» º¸¿©ÁØ´Ù.
main[1] memory
Free: 577856, total: 1048568

gc , »ç¿ëÇÏÁö ¾ÊÀº °´Ã¼¸¦ ÇÁ¸®ÇØÁØ´Ù.
main[1] gc
main[1] memory
Free: 578904, total: 1048568


2001-06-20
 
1
References
 
java documentation
Copyright ¨Ï 2003 www.javapattern.info & www.jlook.com, an jLOOK co.,LTD