MyEclipse斷點調試 ,JavaScript斷點調試__Java

來源:互聯網
上載者:User
複製的網上的 算是懂得了調試的方法 但還是不懂的調試有何作用
最基本的操作是:
1, 首先在一個java檔案中設斷點,然後運行,當程式走到斷點處就會轉到debug視圖下,
2, F5鍵與F6鍵均為單步調試,F5是step into,也就是進入本行代碼中執行,F6是step over,
也就是執行本行代碼,跳到下一行,
3,F7是跳出函數 step return
4,F8是執行到最後。

=====================================

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-->重新暫掛於斷點


===========================
例如你有如下程式:
public static void main(String args[]) {

MyDate aa = new MyDate();
aa.addDays(day);                       =============》(1)
System.out.println("eeeeeeeeeeeeeee");=============》(2)
}

public String addDays(int more_days) {
System.out.println("1");                =============》(3)
String result = "";          =============》(4)
System.out.println("2");                =============》(5)
return result;
}

你在(1)處加斷點,運行到此處時如果Step Into (also F5)為跳入,則接著執行到(3)。再執行Step Over (also F6)執行本行,則執行到(4)。最後執行Step Return (also F7),則跳出addDays方法,跳到(2)

MyEclipse斷點調試JavaScript我們可以從以下的幾個步驟來說明:
1.在網站下準備兩個檔案:1.js和index.html,在index.html中引入1.js,點擊index.html中的按鈕,就會調用1.js中的test()方法:
xml 代碼
﹤html﹥
﹤head﹥
﹤meta http-equiv="Content-Type" content="text/html; charset=gb2312" /﹥
﹤/head﹥
﹤script type='text/javascript' src='./1.js'﹥﹤/script﹥
﹤body﹥
﹤input type="button" name="t" value="測試" onclick="test()"/﹥
﹤/body﹥
﹤/html﹥
2.啟動tomcat後,用myEclipse的web2.0瀏覽器瀏覽頁面:

MyEclipse斷點調試JavaScript淺析圖1
3.在web2.0瀏覽器中,輸入頁面地址,出現頁面後,點擊工具列中的“js調試”按鈕,這時會在“Javascript Scripts Inspector”視窗中列出當前頁面設計的所有js檔案。選擇需要斷點調試的js檔案,雙擊進入。

MyEclipse斷點調試JavaScript淺析圖2
4.進入到1.js檔案後,就可以給js代碼加斷點了:

MyEclipse斷點調試JavaScript淺析圖3
5.這時再回到剛才web2.0的瀏覽頁面,點擊 按鈕,調用1.js中的test()方法,系統就會自動跳轉到調試狀態,並定位到1.js中剛才設定斷點的位置了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.