如何debug沒有原始碼的class檔案—eclipse+jad

來源:互聯網
上載者:User

 

   elipse的調試功能想必大家都已經很熟悉了,雖然通過jdb可以達到同樣的目的,但可視化的調試工具會大大提高大家的效率。通過eclipse調試一般的應用程式或是調試基於伺服器的程式都非常的方便,設定完斷點後點擊debug按鈕就OK了。今天給大家介紹下如何通過eclipse+jad對沒有原始碼的class檔案進行調試.
    jad工具是一個非常優秀的java反編譯工具,通過jad可將classs檔案反編譯,但是通過jad反編譯的java檔案的行位置與原class檔案對應不上,將會導致無法在eclipse中正確設定斷點,通過研究,我得出了在沒有源碼的情況下設定斷點的方法,總結後通過eclipse+jad調試沒有源碼的程式主要有三步:

1.用jad反編譯class後查看源檔案
記得一定要帶上-lnc參數,這樣源檔案中會有正確的行數作為注釋顯示出來。

2.使用breakpoints的import匯入修改過的斷點記錄檔案.
斷點記錄檔案可通過匯出後修改了再匯入。如這個斷點燒錄檔案:

breakpoint enabled=true persistant=true registered=true
resource path=homeAlonesrcjavacomhaajaxMMSenderTest.java
type=1
marker charStart=-1 lineNumber=760
type=org.eclipse.jdt.debug.javaLineBreakpointMarker
attrib name=org.eclipse.jdt.debug.core.typeName
   value=com.huawei.mm7.vasp.pdu.MM7SOAPEncoder
attrib name=charEnd value=-1
attrib name=charStart value=-1
attrib name=org.eclipse.debug.core.enabled value=true
attrib name=org.eclipse.jdt.debug.ui.member_start
   value=285
attrib name=org.eclipse.debug.core.id
   value=org.eclipse.jdt.debug
attrib name=message
   value=Line breakpointMM7SOAPEncoder [line 760] - main(String[])
attrib name=org.eclipse.jdt.debug.core.suspendPolicy
   value=2
attrib name=org.eclipse.jdt.debug.ui.member_end value=297
attrib name=org.eclipse.jdt.debug.ui.JAVA_ELEMENT_HANDLE_ID
   value==homeAlonesrcjava<com.ha.ajax{MMSenderTest.java[MMSenderTest
marker
breakpoint

注意修改:lineNumber屬性為想要設定斷點的行數,attrib name=org.eclipse.jdt.debug.core.typeName
的value設定為想要debug的class,其它屬性基本不用修改。

2.debug
啟動debug,運行至斷點處會自動suspend,可查看,修改變數的值等debug操作。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.