斷點(diǎn)調(diào)試
復(fù)制的網(wǎng)上的 算是懂得了調(diào)試的方法 但還是不懂的調(diào)試有何作用
最基本的操作是:
1, 首先在一個(gè)java文件中設(shè)斷點(diǎn),然后運(yùn)行,當(dāng)程序走到斷點(diǎn)處就會(huì)轉(zhuǎn)到debug視圖下,
2, F5鍵與F6鍵均為單步調(diào)試,F(xiàn)5是step into,也就是進(jìn)入本行代碼中執(zhí)行,F(xiàn)6是step over,
也就是執(zhí)行本行代碼,跳到下一行,
3,F7是跳出函數(shù) step return
4,F8是執(zhí)行到最后。
=====================================
1.Step Into (also F5) 跳入
2.Step Over (also F6) 跳過(guò)
3.Step Return (also F7) 執(zhí)行完當(dāng)前method,然后return跳出此method
4.step Filter 逐步過(guò)濾 一直執(zhí)行直到遇到未經(jīng)過(guò)濾的位置或斷點(diǎn)(設(shè)置Filter:window-preferences-java-Debug-step Filtering)
5.resume 重新開(kāi)始執(zhí)行debug,一直運(yùn)行直到遇到breakpoint
6.hit count 設(shè)置執(zhí)行次數(shù) 適合程序中的for循環(huán)(設(shè)置 breakpoint view-右鍵hit count)
7.inspect 檢查 運(yùn)算。執(zhí)行一個(gè)表達(dá)式顯示執(zhí)行值
8.watch 實(shí)時(shí)地監(jiān)視變量的變化
9.我們常說(shuō)的斷點(diǎn)(breakpoints)是指line breakpoints,除了line breakpoints,還有其他的斷點(diǎn)類(lèi)型:field(watchpoint)breakpoint,method breakpoint,exception breakpoint.
10.field breakpoint 也叫watchpoint(監(jiān)視點(diǎn)) 當(dāng)成員變量被讀取或修改時(shí)暫掛
11.添加method breakpoint 進(jìn)入/離開(kāi)此方法時(shí)暫掛(Run-method breakpoint)
12.添加Exception breakpoint 捕抓到Execption時(shí)暫掛(待續(xù)...)
斷點(diǎn)屬性:
1.hit count 執(zhí)行多少次數(shù)后暫掛 用于循環(huán)
2.enable condition 遇到符合你輸入條件(為ture\改變時(shí))就暫掛
3.suspend thread 多線程時(shí)暫掛此線程
4.suspend VM 暫掛虛擬機(jī)
13.variables 視圖里的變量可以改變變量值,在variables 視圖選擇變量點(diǎn)擊右鍵--change value.一次來(lái)進(jìn)行快速調(diào)試。
14.debug 過(guò)程中修改了某些code后--〉save&build-->resume-->重新暫掛于斷點(diǎn)
===========================
例如你有如下程序:
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)處加斷點(diǎn),運(yùn)行到此處時(shí)如果Step Into (also F5)為跳入,則接著執(zhí)行到(3)。再執(zhí)行Step Over (also F6)執(zhí)行本行,則執(zhí)行到(4)。最后執(zhí)行Step Return (also F7),則跳出addDays方法,跳到(2)
MyEclipse斷點(diǎn)調(diào)試JavaScript我們可以從以下的幾個(gè)步驟來(lái)說(shuō)明:
1.在站點(diǎn)下準(zhǔn)備兩個(gè)文件:1.js和index.html,在index.html中引入1.js,點(diǎn)擊index.html中的按鈕,就會(huì)調(diào)用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="測(cè)試" onclick="test()"/﹥
﹤/body﹥
﹤/html﹥
2.啟動(dòng)tomcat后,用myEclipse的web2.0瀏覽器瀏覽頁(yè)面:
MyEclipse斷點(diǎn)調(diào)試JavaScript淺析圖1
3.在web2.0瀏覽器中,輸入頁(yè)面地址,出現(xiàn)頁(yè)面后,點(diǎn)擊工具欄中的“js調(diào)試”按鈕,這時(shí)會(huì)在“Javascript Scripts Inspector”窗口中列出當(dāng)前頁(yè)面設(shè)計(jì)的所有js文件。選擇需要斷點(diǎn)調(diào)試的js文件,雙擊進(jìn)入。
MyEclipse斷點(diǎn)調(diào)試JavaScript淺析圖2
4.進(jìn)入到1.js文件后,就可以給js代碼加斷點(diǎn)了:
MyEclipse斷點(diǎn)調(diào)試JavaScript淺析圖3
5.這時(shí)再回到剛才web2.0的瀏覽頁(yè)面,點(diǎn)擊 按鈕,調(diào)用1.js中的test()方法,系統(tǒng)就會(huì)自動(dòng)跳轉(zhuǎn)到調(diào)試狀態(tài),并定位到1.js中剛才設(shè)置斷點(diǎn)的位置了。
最基本的操作是:
1, 首先在一個(gè)java文件中設(shè)斷點(diǎn),然后運(yùn)行,當(dāng)程序走到斷點(diǎn)處就會(huì)轉(zhuǎn)到debug視圖下,
2, F5鍵與F6鍵均為單步調(diào)試,F(xiàn)5是step into,也就是進(jìn)入本行代碼中執(zhí)行,F(xiàn)6是step over,
也就是執(zhí)行本行代碼,跳到下一行,
3,F7是跳出函數(shù) step return
4,F8是執(zhí)行到最后。
=====================================
1.Step Into (also F5) 跳入
2.Step Over (also F6) 跳過(guò)
3.Step Return (also F7) 執(zhí)行完當(dāng)前method,然后return跳出此method
4.step Filter 逐步過(guò)濾 一直執(zhí)行直到遇到未經(jīng)過(guò)濾的位置或斷點(diǎn)(設(shè)置Filter:window-preferences-java-Debug-step Filtering)
5.resume 重新開(kāi)始執(zhí)行debug,一直運(yùn)行直到遇到breakpoint
6.hit count 設(shè)置執(zhí)行次數(shù) 適合程序中的for循環(huán)(設(shè)置 breakpoint view-右鍵hit count)
7.inspect 檢查 運(yùn)算。執(zhí)行一個(gè)表達(dá)式顯示執(zhí)行值
8.watch 實(shí)時(shí)地監(jiān)視變量的變化
9.我們常說(shuō)的斷點(diǎn)(breakpoints)是指line breakpoints,除了line breakpoints,還有其他的斷點(diǎn)類(lèi)型:field(watchpoint)breakpoint,method breakpoint,exception breakpoint.
10.field breakpoint 也叫watchpoint(監(jiān)視點(diǎn)) 當(dāng)成員變量被讀取或修改時(shí)暫掛
11.添加method breakpoint 進(jìn)入/離開(kāi)此方法時(shí)暫掛(Run-method breakpoint)
12.添加Exception breakpoint 捕抓到Execption時(shí)暫掛(待續(xù)...)
斷點(diǎn)屬性:
1.hit count 執(zhí)行多少次數(shù)后暫掛 用于循環(huán)
2.enable condition 遇到符合你輸入條件(為ture\改變時(shí))就暫掛
3.suspend thread 多線程時(shí)暫掛此線程
4.suspend VM 暫掛虛擬機(jī)
13.variables 視圖里的變量可以改變變量值,在variables 視圖選擇變量點(diǎn)擊右鍵--change value.一次來(lái)進(jìn)行快速調(diào)試。
14.debug 過(guò)程中修改了某些code后--〉save&build-->resume-->重新暫掛于斷點(diǎn)
===========================
例如你有如下程序:
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)處加斷點(diǎn),運(yùn)行到此處時(shí)如果Step Into (also F5)為跳入,則接著執(zhí)行到(3)。再執(zhí)行Step Over (also F6)執(zhí)行本行,則執(zhí)行到(4)。最后執(zhí)行Step Return (also F7),則跳出addDays方法,跳到(2)
MyEclipse斷點(diǎn)調(diào)試JavaScript我們可以從以下的幾個(gè)步驟來(lái)說(shuō)明:
1.在站點(diǎn)下準(zhǔn)備兩個(gè)文件:1.js和index.html,在index.html中引入1.js,點(diǎn)擊index.html中的按鈕,就會(huì)調(diào)用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="測(cè)試" onclick="test()"/﹥
﹤/body﹥
﹤/html﹥
2.啟動(dòng)tomcat后,用myEclipse的web2.0瀏覽器瀏覽頁(yè)面:
MyEclipse斷點(diǎn)調(diào)試JavaScript淺析圖1
3.在web2.0瀏覽器中,輸入頁(yè)面地址,出現(xiàn)頁(yè)面后,點(diǎn)擊工具欄中的“js調(diào)試”按鈕,這時(shí)會(huì)在“Javascript Scripts Inspector”窗口中列出當(dāng)前頁(yè)面設(shè)計(jì)的所有js文件。選擇需要斷點(diǎn)調(diào)試的js文件,雙擊進(jìn)入。
MyEclipse斷點(diǎn)調(diào)試JavaScript淺析圖2
4.進(jìn)入到1.js文件后,就可以給js代碼加斷點(diǎn)了:
MyEclipse斷點(diǎn)調(diào)試JavaScript淺析圖3
5.這時(shí)再回到剛才web2.0的瀏覽頁(yè)面,點(diǎn)擊 按鈕,調(diào)用1.js中的test()方法,系統(tǒng)就會(huì)自動(dòng)跳轉(zhuǎn)到調(diào)試狀態(tài),并定位到1.js中剛才設(shè)置斷點(diǎn)的位置了。
posted on 2012-07-14 06:52 zx_bing 閱讀(201) 評(píng)論(0) 編輯 收藏 所屬分類(lèi): java