| With the promotion of Google’s Andorid platform on the phone, tablet and othermobile terminals, the development and research of Dalvik virtual machine as theruntime core of ther Android operating system also comes to a flourishing. However,limiting factors like sepcial demand, narrow scope of usage, and non-open source, haveleft the demond for debugging tools for Java Virtual Machine including the Dalvikvirtual machine still not perfect enough, especially for Java instruction level debugging.Though enough tools can be found to do a Java sourcecode level debugging work, butno one mature tools appropriate to burden the duty of Java Instruction level debugggingwork.To make this problem history, this paper designed and implemented a Javaprogram instruction-level debugging module for Dalvik virtual machine, and integratedit to stardard Eclipse Java debug plugin, the research work mainly includes thefollowing4aspects:Firstly, we proposed a asynchronous working mechanism in the Dalvik VM,different with the debug commands that can self-complete on the debugger thread suchas get version number, single-step command requires the debugger thread and the userthread to cooperate to complete. The instruction-level single-step debugging and debugresults returnning is achieved by following steps: When single-step command isreceived, debugger thread set the corresponding single request mark on debugged thread,and the debugger side receive a confirm message,but not debug results immediately.The debugged thread then compares the request with current produced events until thecontrast established, and sent a single-setp event to debugger thread. debugger threadthen sends real single-step debug results to the debugger side.Secondly, in order to achieve single-step to instruction level, an instruction-levelsingle-step event is definded and added in the JPDA(Java Platform Debug Architecture)framework in Dalvik VM, and correspoinding debugging event processing module isadded in the user thread. Within this mechanism the debuggee thread can correctlyindentify our request in each proofreading requests and events, then trigger right single-step event and stop at the correct position.Thirdly, for the purpose of monitoring instruction-level debugging, we need todisplay related program data and instrcution stream. So we added two importantfunctions in the Dalvikvm, namely request for instruction stream and registers’ values,by which we can have a intuitive understanding of virtual machine state.lastly, on the Eclipse side, the function of standard Eclipse Java debug plug-in wasextended, including debug target, single instruction stepping, breakpoints, source locator,register view and instruction stream view,and made a test on a real application.The experimental results showed that the design and implementation of this tool iscorrect and feasible for Dalvik VM instruction debugging. So we now have ameaningful tool in Java VM’s assisting development. |