基于Dalvik虚拟机的java指令调试设计与实现
发布时间:2019-01-03 13:58
【摘要】:随着Google推出的Android平台在手机、平板等移动终端的推广,Dalvik虚拟机作为Android操作系统核心,其开发与研究也如日中天。但由于需求专业化,使用范围较窄,工具未开源,以及完全内部使用等因素的制约,对于开发调试包括Dalvik虚拟机在内的Java虚拟机自身的工具的发展仍然不够完善。虽然已有若干调试器能够针对Java程序进行源码级调试,但对于虚拟机开发过程中需要的Java指令级调试,目前还没有成熟的工具可以使用。 为解决以上问题,本课题提出了设计并实现针对Dalvik虚拟机的Java程序的指令级调试功能,并将该调试功能集成到Eclipse调试器中。研究内容主要包括以下4个方面: 首先,提出在Dalvik虚拟机上采用异步运行方式,实现指令级单步调试命令的功能,获取调试命令及调试结果。单步命令调试不同于在调试器线程自身就能完成的调试命令,需要调试器线程与用户线程配合完成。具体方法如下:收到单步命令后,调试器线程在被单步调试的线程中设置相应的单步请求标示;同时,调试器端立收到一个消息确认,而非调试结果。被调试线程在运行过程中将该请求与当前产生的各种调试事件进行对比,对比成立后向调试器线程发送单步事件。调试器线程收到单步事件后,向调试器端发送真正的单步运行结果。 其次,为了让单步能够达到指令级,在Dalvik虚拟机实现的JPDA(Java平台调试架构)框架中添加与指令级单步请求相对应的指令级单步触发事件,并在用户线程的调试事件处理中加入了相应的处理模块,使得被单步的线程能够在每次校对请求与事件时正确的识别单步请求,,并在正确的指令位置触发单步事件,以及在正确的位置停下来。 再次,为了能够对指令单步调试的过程进行监控,我们需要在调试器端同步显示每次单步之后的相关程序数据和指令流,为此在Dalvik虚拟机端加入了两个重要功能,即对函数指令流的获取和栈寄存器值的获取两个命令的相应,使在进行单步调试的同时能够对程序的运行状态有直观的了解。 最后,在Eclipse调试器端实现对Eclipse标准Java调试插件的扩展,包括调试模型、指令级单步、断点、源定位器、寄存器视图和指令流视图,并对实例程序进行运行测试。 通过实验结果表明本课题工具的设计和实现是正确可行的,能够实现Dalvik虚拟机的指令集单步调试,对Java虚拟机的辅助开发有重要的意义。
[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.
【学位授予单位】:电子科技大学
【学位级别】:硕士
【学位授予年份】:2013
【分类号】: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.
【学位授予单位】:电子科技大学
【学位级别】:硕士
【学位授予年份】:2013
【分类号】:TP302
【参考文献】
相关期刊论文 前5条
1 张e
本文编号:2399474
本文链接:https://www.wllwen.com/kejilunwen/jisuanjikexuelunwen/2399474.html