The Dalvik Virtual Machine (DVM) is no exception. This made it necessary to
implement Dalvik VM Awareness as a TRACE32 Extension, so that it can be.
VM Debugger Dalvik TRACE32 Online Help TRACE32 Directory TRACE32 Index TRACE32 Documents ......................................................................................................................
VM Debugging ...............................................................................................................................
VM Debugger Dalvik ...................................................................................................................
1
Introduction .............................................................................................................................
2
Dalvik VM Awareness Extension
2
Preparation
3
Development Note
3
TRACE32 Extension Commands
4
Added TRACE32 JAVA Functionality
4
Dalvik Extension Commands ................................................................................................. EXTension.VMList
5
List virtual machine threads
5
View virtual machine thread stack
6
EXTension.VMClass
Load class symbols for a task
7
EXTension.VMAInfo
View virtual machine awareness information
8
EXTension.VMView
©1989-2017 Lauterbach GmbH
VM Debugger Dalvik
1
VM Debugger Dalvik Version 29-Mar-2017
Introduction For debugging, Virtual Machines pose a “moving target” problem. Unlike real hardware, they can and will be changed and implemented differently by different people, depending on current platform and market requirements. The Dalvik Virtual Machine (DVM) is no exception. This made it necessary to implement Dalvik VM Awareness as a TRACE32 Extension, that can be easily adapted - e.g. by a customer or third party - to a concrete target platform and/or VM implementation. Because the Android “Dalvik VM” (DVM) runs inside a Linux thread, the Dalvik VM Awareness depends heavily on services provided by the “RTOS Debugger for Linux - Stop Mode” (rtos_linux_stop.pdf). Dalvik VM Awareness (dalvik.t32) currently supports Android 2.x and 4.x and provides these functions: •
List DVM threads with their class descriptors and method names
•
Display the DVM Stack for a single DVM thread
•
Source code lookup for a method/offset listed in the DVM stack view (requires TRACE32 build 33924 or later)
•
Display VM Awareness Information
Next planned development steps are: •
Basic DVM execution control (stop/step/go inside a method)
This document is only a brief command reference manual. Please read “Training Android Debugging” (training_vm_android.pdf) for background information and setup.
Dalvik VM Awareness Extension The directory “dalvik” contains the current state of the Dalvik VM Awareness implementation: dalvik.t32
TRACE32 extension file for Dalvik VM awareness
dalvik.men
TRACE32 menu definition for ’Dalvik’ menu entry
©1989-2017 Lauterbach GmbH
VM Debugger Dalvik
2
Introduction
Preparation For VMList and VMView functionality, you need at least the Linux kernel (vmlinux) and the Dalvik library (libdvm.so) symbols. This is the bare minimum. If you want to list the Java source code that belongs to a running Dalvik VM thread, additionally you need the Dalvik executable files (*.dex/*.odex/*.apk/*.jar) and the matching source code for them (*.java). The sample files provided in the panda subdirectory are based on a PandaBoard JellyBean setup (Linaro build #42 and #50). Please check and adapt the pandademo-jb.cmm demo script for your platform, your TRACE32 installation, and your execution environment: •
Check and adapt the Linux awareness settings - e.g. load the correct awareness for your kernel version (linux3.t32 vs. linux.t32), check and set the memory ranges for kernel and shared libraries, check and adapt the MMU translation settings, define color groups, etc.
•
Adapt the symbol source path translation to your file system, so that the Linux autoloader script autoload.cmm can find the symbol information for the Android services and shared libraries.
•
Check - and if necessary adapt - the name of the module that contains dalvik_mterp, the machine -optimized flavor of the Dalvik VM interpreter. dalvik.t32 needs a synthetic function definition t32_dalvik_vm with an address range that covers at least the full interpreter. Because there is often no available symbol for this, we chose to use the whole module address range instead.
•
Please have a quick look at dalvik.men for additional configuration options in dalvik.t32.
Development Note This functionality is currently implemented for ARM platforms only: •
Java Call Stack display in stack frame (Frame or Var.Frame) window
•
Java Source Breakpoint translation from ‘Program’ to ‘Task/Data Read’
Reason: Currently the required Dalvik stack walk functionality is hard-coded in TRACE32. Plans exist to implement this with help from an EXTension callback. Please contact Lauterbach if you develop an Dalvik VM Awareness extension for any other platform.
©1989-2017 Lauterbach GmbH
VM Debugger Dalvik
3
Introduction
TRACE32 Extension Commands EXTension.LOAD
Load TRACE32 extension from .
EXTension.DELETE
Remove TRACE32 extension .
EXTension.DEBUG {0|1}
Switch on=1/off=0 Extension Debugging messages (sent to AREA window) for extension .
Added TRACE32 JAVA Functionality Java.CONFIG DALVIK
Select Dalvik mode for DeXfile loader and for Java symbol processing.
Java.LOAD
Pre-load *.dex/*.odex/*.apk/*.jar file into an internal cache for LOADCLASS.
Java.LOADCLASS
Load the symbols for the named Dalvik/Java class from the cache (filled with Java.LOAD).
For general options, please see “General Commands Reference Guide J” (general_ref_j.pdf).
©1989-2017 Lauterbach GmbH
VM Debugger Dalvik
4
Introduction
Dalvik Extension Commands
EXTension.VMList
Format:
List virtual machine threads
EXTension.VMList
Parameters: •
(Display Mode) if set to 1, VMList will display all threads for a given process. This may slow down TRACE32 a lot, therefore any other (or no) value selects the old behavior as default. You can see the current Display Mode value with EXTension.VMAInfo.
Display list of Dalvik VM processes/tasks. •
Analyzes Linux task list for Dalvik VM processes, and displays magic, pid and process/task name.
•
Walks task stack to find a frame that belongs to t32_dalvik_vm (the optimized Dalvik VM interpreter).
•
For open “trees”, reads t32_dalvik_vm [formerly dalvik_mterp] stack data information, and displays method, class descriptor and class source file name.
•
Click on a magic value or a proc/task name to open the corresponding EXTension.VMView.
NOTE:
To make the necessary symbols available to TRACE32, please see “Preparation”.
©1989-2017 Lauterbach GmbH
VM Debugger Dalvik
5
Dalvik Extension Commands
EXTension.VMView
Format:
View virtual machine thread stack
EXTension.VMView
Parameters: •
Task ID (e.g. EXT.VMView 0xEFEA8A20), or Task Name (e.g. EXT.VMView “com.android.phone:ReferenceQueueD”). (Please note: the name is case sensitive, and you have to use quotes for the name.)
Display Dalvik VM Stack for one VM instance. •
Searches for Dalvik VM (DVM) stack data on the current task stack. The DVM stack data is recognized by belonging to program code that executes in the synthetic symbol range t32_dalvik_vm (formerly dalvik_mterp).
•
Reads Dalvik VM "Frame Pointer" (rFP) from DVM stack.
•
Walks Frame Pointer chain and displays “method”, “class descriptor”, “class source” file name, the saved Current PC from stack frame “frmCurPC” and the StackSaveArea "frameptr" address.
•
Click on the class descriptor performs JAVA.LOADCLASS with the correct address, which is required for correct stack frame and Java source code displays. If you have a Data.ListJava window open for this class, and if TRACE32 finds your source code, the Java code is shown alongside Dalvik assembly.
•
rFP points at the end of the StackSaveArea, dalvik.t32 corrects this. Click on any frameptr entry to open a Var.View window and inspect it.
•
Click on a number in the column frmCurPC to open a Data.ListJava window with Dalvik bytecode and/or Java source code at the indicated position.
Note about the display output: •
(blank entry): T32DisplayStringTarget() could not access the display string
•
(n/a) : (Method*)method is NULL, therefore method->class->descriptor and method->class>sourceFile are also not available. (Happens for JNI native function dummy blocks.)
•
NO_ACCESS: referenced string memory is not memory-accessible
©1989-2017 Lauterbach GmbH
VM Debugger Dalvik
6
Dalvik Extension Commands
EXTension.VMClass
Format:
Load class symbols for a task
EXTension.VMClass
Parameters: •
Task ID (e.g. EXT.VMClass 0xEFEA8A20), or Task Name (e.g. EXT.VMView “com.android.phone:ReferenceQueueD”). (Please note: the name is case sensitive, and you have to use quotes for the name.)
Load all symbols for Display classes of this thread. •
Searches for Dalvik VM (DVM) stack data on the current task stack. The DVM stack data is recognized by belonging to program code that executes in the synthetic symbol range t32_dalvik_vm.
•
Walks Java stack and issues Java.LOADCLASS commands with the correct load address and class descriptor name.
If a magic or task name can not be found, the command will print a message to the AREA window: “EXT.VMC - magic or taskname not found”.
©1989-2017 Lauterbach GmbH
VM Debugger Dalvik
7
Dalvik Extension Commands
EXTension.VMAInfo
Format:
View virtual machine awareness information
EXTension.VMAInfo
Display Dalvik VM Awareness information: •
“Dalvik VM Awareness” (dalvik.t32 name)
•
“Compiled:” date of dalvik.t32 compilation
•
“TaskMax#”, the maximum number of analyzed and displayed tasks (Linux threads)
•
“DispMode”, the current value of the (VMList) Display Mode
©1989-2017 Lauterbach GmbH
VM Debugger Dalvik
8
Dalvik Extension Commands