基于Dalvik虛擬機(jī)的java指令調(diào)試設(shè)計(jì)與實(shí)現(xiàn)
發(fā)布時(shí)間:2019-01-03 13:58
【摘要】:隨著Google推出的Android平臺(tái)在手機(jī)、平板等移動(dòng)終端的推廣,Dalvik虛擬機(jī)作為Android操作系統(tǒng)核心,其開發(fā)與研究也如日中天。但由于需求專業(yè)化,使用范圍較窄,工具未開源,以及完全內(nèi)部使用等因素的制約,對(duì)于開發(fā)調(diào)試包括Dalvik虛擬機(jī)在內(nèi)的Java虛擬機(jī)自身的工具的發(fā)展仍然不夠完善。雖然已有若干調(diào)試器能夠針對(duì)Java程序進(jìn)行源碼級(jí)調(diào)試,但對(duì)于虛擬機(jī)開發(fā)過程中需要的Java指令級(jí)調(diào)試,目前還沒有成熟的工具可以使用。 為解決以上問題,本課題提出了設(shè)計(jì)并實(shí)現(xiàn)針對(duì)Dalvik虛擬機(jī)的Java程序的指令級(jí)調(diào)試功能,并將該調(diào)試功能集成到Eclipse調(diào)試器中。研究?jī)?nèi)容主要包括以下4個(gè)方面: 首先,提出在Dalvik虛擬機(jī)上采用異步運(yùn)行方式,實(shí)現(xiàn)指令級(jí)單步調(diào)試命令的功能,獲取調(diào)試命令及調(diào)試結(jié)果。單步命令調(diào)試不同于在調(diào)試器線程自身就能完成的調(diào)試命令,需要調(diào)試器線程與用戶線程配合完成。具體方法如下:收到單步命令后,調(diào)試器線程在被單步調(diào)試的線程中設(shè)置相應(yīng)的單步請(qǐng)求標(biāo)示;同時(shí),調(diào)試器端立收到一個(gè)消息確認(rèn),而非調(diào)試結(jié)果。被調(diào)試線程在運(yùn)行過程中將該請(qǐng)求與當(dāng)前產(chǎn)生的各種調(diào)試事件進(jìn)行對(duì)比,對(duì)比成立后向調(diào)試器線程發(fā)送單步事件。調(diào)試器線程收到單步事件后,向調(diào)試器端發(fā)送真正的單步運(yùn)行結(jié)果。 其次,為了讓單步能夠達(dá)到指令級(jí),在Dalvik虛擬機(jī)實(shí)現(xiàn)的JPDA(Java平臺(tái)調(diào)試架構(gòu))框架中添加與指令級(jí)單步請(qǐng)求相對(duì)應(yīng)的指令級(jí)單步觸發(fā)事件,并在用戶線程的調(diào)試事件處理中加入了相應(yīng)的處理模塊,使得被單步的線程能夠在每次校對(duì)請(qǐng)求與事件時(shí)正確的識(shí)別單步請(qǐng)求,,并在正確的指令位置觸發(fā)單步事件,以及在正確的位置停下來。 再次,為了能夠?qū)χ噶顔尾秸{(diào)試的過程進(jìn)行監(jiān)控,我們需要在調(diào)試器端同步顯示每次單步之后的相關(guān)程序數(shù)據(jù)和指令流,為此在Dalvik虛擬機(jī)端加入了兩個(gè)重要功能,即對(duì)函數(shù)指令流的獲取和棧寄存器值的獲取兩個(gè)命令的相應(yīng),使在進(jìn)行單步調(diào)試的同時(shí)能夠?qū)Τ绦虻倪\(yùn)行狀態(tài)有直觀的了解。 最后,在Eclipse調(diào)試器端實(shí)現(xiàn)對(duì)Eclipse標(biāo)準(zhǔn)Java調(diào)試插件的擴(kuò)展,包括調(diào)試模型、指令級(jí)單步、斷點(diǎn)、源定位器、寄存器視圖和指令流視圖,并對(duì)實(shí)例程序進(jìn)行運(yùn)行測(cè)試。 通過實(shí)驗(yàn)結(jié)果表明本課題工具的設(shè)計(jì)和實(shí)現(xiàn)是正確可行的,能夠?qū)崿F(xiàn)Dalvik虛擬機(jī)的指令集單步調(diào)試,對(duì)Java虛擬機(jī)的輔助開發(fā)有重要的意義。
[Abstract]:With the promotion of Android platform launched by Google in mobile terminals such as mobile phones and tablets, Dalvik Virtual Machine (VM) is the core of Android operating system, and its development and research are also in the ascendant. However, due to specialized requirements, narrow scope of use, non-open source tools, complete internal use and other factors, the development of tools for debugging Java virtual machines, including Dalvik virtual machines, is still not perfect. Although several debuggers have been able to debug the Java program at source level, there is no mature tool to debug the Java instruction level in the process of virtual machine development. In order to solve the above problems, we design and implement the instruction level debugging function of Java program for Dalvik virtual machine, and integrate the debugging function into Eclipse debugger. The main contents of this paper are as follows: firstly, this paper proposes an asynchronous running mode on Dalvik virtual machine to realize the function of instruction level single step debugging command and obtain debugging command and debugging result. One-step command debugging is different from debugging commands which can be completed by debugger thread itself. It needs debugger thread and user thread to complete debugging command. The specific method is as follows: after receiving the single step command, the debugger thread sets the corresponding single step request mark in the single step debug thread; at the same time, the debugger terminal receives a message confirmation instead of debugging result. The debugged thread compares the request with the current debugging events and sends a single step event to the debugger thread. When the debugger thread receives a single step event, it sends the true step run result to the debugger side. Secondly, in order to achieve instruction level in single step, add instruction level single step trigger event corresponding to instruction level single step request in the framework of JPDA (Java platform debugging architecture implemented by Dalvik virtual machine. A corresponding processing module is added to the debugging event processing of the user thread, which enables the one-step thread to correctly identify the single-step request and trigger the one-step event in the correct instruction position. And stop in the right place. Thirdly, in order to monitor the process of instruction step debugging, we need to synchronously display the relevant program data and instruction flow after each step in the debugger. For this reason, we add two important functions in the Dalvik virtual machine. That is to say, two commands, namely, the acquisition of function instruction stream and the acquisition of stack register value, make it possible to realize the running state of the program directly while debugging step by step. Finally, the extension of Eclipse standard Java debugging plug-in is implemented in the Eclipse debugger, including debugging model, instruction level single step, breakpoint, source locator, register view and instruction stream view. The experimental results show that the design and implementation of this tool is correct and feasible, and it can realize the instruction set of Dalvik virtual machine in one step, which is of great significance to the development of Java virtual machine.
【學(xué)位授予單位】:電子科技大學(xué)
【學(xué)位級(jí)別】:碩士
【學(xué)位授予年份】:2013
【分類號(hào)】:TP302
[Abstract]:With the promotion of Android platform launched by Google in mobile terminals such as mobile phones and tablets, Dalvik Virtual Machine (VM) is the core of Android operating system, and its development and research are also in the ascendant. However, due to specialized requirements, narrow scope of use, non-open source tools, complete internal use and other factors, the development of tools for debugging Java virtual machines, including Dalvik virtual machines, is still not perfect. Although several debuggers have been able to debug the Java program at source level, there is no mature tool to debug the Java instruction level in the process of virtual machine development. In order to solve the above problems, we design and implement the instruction level debugging function of Java program for Dalvik virtual machine, and integrate the debugging function into Eclipse debugger. The main contents of this paper are as follows: firstly, this paper proposes an asynchronous running mode on Dalvik virtual machine to realize the function of instruction level single step debugging command and obtain debugging command and debugging result. One-step command debugging is different from debugging commands which can be completed by debugger thread itself. It needs debugger thread and user thread to complete debugging command. The specific method is as follows: after receiving the single step command, the debugger thread sets the corresponding single step request mark in the single step debug thread; at the same time, the debugger terminal receives a message confirmation instead of debugging result. The debugged thread compares the request with the current debugging events and sends a single step event to the debugger thread. When the debugger thread receives a single step event, it sends the true step run result to the debugger side. Secondly, in order to achieve instruction level in single step, add instruction level single step trigger event corresponding to instruction level single step request in the framework of JPDA (Java platform debugging architecture implemented by Dalvik virtual machine. A corresponding processing module is added to the debugging event processing of the user thread, which enables the one-step thread to correctly identify the single-step request and trigger the one-step event in the correct instruction position. And stop in the right place. Thirdly, in order to monitor the process of instruction step debugging, we need to synchronously display the relevant program data and instruction flow after each step in the debugger. For this reason, we add two important functions in the Dalvik virtual machine. That is to say, two commands, namely, the acquisition of function instruction stream and the acquisition of stack register value, make it possible to realize the running state of the program directly while debugging step by step. Finally, the extension of Eclipse standard Java debugging plug-in is implemented in the Eclipse debugger, including debugging model, instruction level single step, breakpoint, source locator, register view and instruction stream view. The experimental results show that the design and implementation of this tool is correct and feasible, and it can realize the instruction set of Dalvik virtual machine in one step, which is of great significance to the development of Java virtual machine.
【學(xué)位授予單位】:電子科技大學(xué)
【學(xué)位級(jí)別】:碩士
【學(xué)位授予年份】:2013
【分類號(hào)】:TP302
【參考文獻(xiàn)】
相關(guān)期刊論文 前5條
1 張e
本文編號(hào):2399474
本文鏈接:http://sikaile.net/kejilunwen/jisuanjikexuelunwen/2399474.html
最近更新
教材專著