Debuging
Windows > Open Perspective > Other...
툴바에서 아래의 이미지가 이미 나와 있다면 그냥 클릭하여 사용할 수 있다.
Debug view
위에 그림과 같이 디버그를 실행하면 아래의 그림과 같이 디버그 화면이 나온다.
이때 원하는 디버그를 하나 클릭하면 빨간 테두리 안에 있는 것들이 활성화 된다.
Variables view
variables를 선택하면 해당하는 부분의 사이즈나 값등의 정보를 볼 수 있다.
Breakpoints view
이 리스트에서 모든 작업 중인 프로젝트의 break point를 볼 수 있다.
이것으로 break point를 지우거나 새로운 것을 추가 할 수 있거나 할 수 없다.
또한 더블 클릭하면 에디터로 갈 수 있다.
이것은 exceptions을 추가 또는 삭제 가능하다.
Expressions view
각각의 클래스로부터 suspended thread와 다른 지역에서 이것을 보고 검사할 수 있다.
Item이 view에 추가될때 자동적으로 오픈된다
Debug a web project
http://www.laliluna.de/assets/tutorials/java-servlets-jsp-tutorial.zip
사이트에서 어떻게 디버깅하는지에 대해 다운 받을 수 있다.
아래의 그림과 같이 오른쪽을 더블클릭하면 파란 동그라미가 생기고 그 부분부터 디버깅이 된다.
Note: If you don't have installed MyEclipse, you can't set a breakpoint in jsp and included
files.
Breakpoint Properties
생성된 파란 동그라미를 마우스 오른 버튼을 눌러 아래와 같이 Breakpoint Properties 을
선택한다.
Hit Count
The hit count sets a number of times the breakpoint can be executed before the thread
suspends. Very helpful in a loop expression or if you want to know the value of a expression
after some hits.
Enable Condition
There are two options to suspend a thread by using a condition.
-
if the enabled condition is true
-
if the enabled condition changes
If you want that the condition suspends the thread when it is true select the option condition
is true on Suspend when.
Example:
action.equals("edit");
If you want that the condition suspends the thread when the value of the condition changes
select the option value of the condition changes on Suspend when.
Suspend Policy
You can define if the breakpoint suspends only the thread or the complete virtual machine.
Deploy and Debug
Now we want to debug the project, so deploy it and call it in your web browser.
Choose Edit on the list of books.
After you clicked the Edit link, eclipse shows you the following confirm window. You can
choose if you want to switch to the debug perspective. Yes, you want it ;- )
The first entry in the debug view represents the state of the method where the breakpoint was
set. You can preview the state of a entry simply by clicking on it, also the file will be open
where the method is placed.
You can see the values of all variables of the selected entry in the Variables view.
A marked line and an arrow at the breakpoint shows that the debugger is suspended on this
line.
If you've decided that you missed an important place in the execution process, perhaps the
breakpoint was in the wrong place, or maybe you accidentally stepped over some code you
wanted to inspect earlier in the process. Eclipse has a feature called Drop to frame, that
essentially lets you 'rewind' the execution to the beginning of any method in the stack. This is
especially useful when you perform variable modification or code hot swapping.
Right click on the frame and choose the option Drop to Frame.
Inspect expressions
To get informations about expression, you can inspect a expression. Right click on the marked
expression, you want to inspect and choose Inspect or press Ctrl + Shift + I. A pop-up
window appears that holds the informations about the expression.
Watch expressions
Watch is similar to inspect an expression. Watch means that the expression will be added to
the Expressions view, where you can watch the informations about the expression. Add two
expressions to the Expressions view.
Mark the expressions, right click and choose Watch.
Now the two expression are in the Expressions view.
Display expressions
If you want to display the type and the value of an expression, mark the expression and choose the Display option from the context menu (right mouse button) or press Ctrl + Shift +
D.
Run to Line
If you set a breakpoint and somewhere under the breakpoint is a line you want to go, you can use the option Run to Line. The code between the breakpoint and the selected line will be
executed. Select the line you want to go, press the right mouse button and choose the option
Run to Line or use the key binding Ctrl + R.
Debugging JSP files (supported by MyEclipse)
Debugging a JSP file is the same like debugging a Java class, but the most features (Watch,
Inspect, etc) are not implemented. The only way to get the values of variables is the Variables
view.
[출처] http://www.laliluna.de (랠리루나)
[출처] [MyEclipse] 디버깅|작성자 연서