怎樣在Eclipse中使用debug調試程序?
最基本的操做是:
1, 首先在一個java文件中設斷點,而後運行,當程序走到斷點處就會轉到debug視圖下,
2, F5鍵與F6鍵均爲單步調試,F5是step into,也就是進入本行代碼中執行,F6是step over,
也就是執行本行代碼,跳到下一行,
3,F7是跳出函數
4,F8是執行到最後。php
按F5/F6跟進,當執行語句有變量時,在eclipse右上角的 variables 框裏,會有變量的值,或者對象裏的成員。java
也能夠經過 鼠標 選擇 變量,單擊右鍵 --> watch 來查看變量值。android
------------------------------------------------------------------------------------------------------多線程
偶爾會遇到程序跟進到了API中的class的狀況,app
能夠下載 jadClipse || http://jadclipse.sourceforge.net/wiki/index.php/Main_Pageeclipse
來查看反編譯 class文件。函數
配合 jad || http://www.varaneckas.com/jadui
------------------------------------------------------------------------------------------------------this
////////////////////////////////////////////////
1.Step Into (also F5) 跳入
2.Step Over (also F6) 跳過
3.Step Return (also F7) 執行完當前method,而後return跳出此method
4.step Filter 逐步過濾 一直執行直到遇到未通過濾的位置或斷點(設置Filter:window-preferences-java-Debug-step Filtering)
5.resume 從新開始執行debug,一直運行直到遇到breakpoint
6.hit count 設置執行次數 適合程序中的for循環(設置 breakpoint view-右鍵hit count)
7.inspect 檢查 運算。執行一個表達式顯示執行值
8.watch 實時地監視變量的變化
9.咱們常說的斷點(breakpoints)是指line breakpoints,除了line breakpoints,還有其餘的斷點類型:field(watchpoint)breakpoint,method breakpoint,exception breakpoint.
10.field breakpoint 也叫watchpoint(監視點) 當成員變量被讀取或修改時暫掛
11.添加method breakpoint 進入/離開此方法時暫掛(Run-method breakpoint)
12.添加Exception breakpoint 捕抓到Execption時暫掛(待續...)
斷點屬性:
1.hit count 執行多少次數後暫掛 用於循環
2.enable condition 遇到符合你輸入條件(爲ture/改變時)就暫掛
3.suspend thread 多線程時暫掛此線程
4.suspend VM 暫掛虛擬機
13.variables 視圖裏的變量能夠改變變量值,在variables 視圖選擇變量點擊右鍵--change value.一次來進行快速調試。
14.debug 過程當中修改了某些code後--〉save&build-->resume-->從新暫掛於斷點spa
=================================
1, let cell phone connects to computer
2, to confirm that APK file can install device via USB
For example: you choose run Android Application in eclipse, this project could be installed in device directly
3, go to project IMP/AndroidManifest.xml, please in <application> element add android:debuggable="true",
like <application android:icon="@drawable/icon" android:label="@string/app_name"android:debuggable="true" >
4, add break point into source code then go to Debug As --- > Android Application
http://blog.csdn.net/vincent_czz/article/details/5690816 原文連接