Android Debugging Tool Ddms

Source: Internet
Author: User
Tags stack trace

DDMS working mechanism DDMS full name Dalvik Debug Monitor Service. DDMS A bridge over the IDE and Emultor and real android devices,android DDMS will capture the ID of the terminal and build a debugger through ADB, To achieve the purpose of sending instructions to the test terminal 1) Each Android application runs in a Dalvik virtual machine instance, and each virtual machine instance is a separate process space. The threading mechanism of virtual machines, memory allocation and management, mutexes, etc. are all dependent on the underlying operating system. All Android apps have threads that correspond to one Linux thread. 2) A device monitoring service is established between the DDMS and ADB to monitor the device when it starts. When the device is disconnected or linked, the service notifies DDMS3) When a device is linked, a VM monitoring service is established between DDSM and ADB to monitor the virtual machine on the device.
4) Establish a link with the debugger of the virtual machine on the device via ADB Deamon, so that Ddms starts to talk to the virtual machine through DDMS to see the process running on the target machine/out-of-the-box status, can be Android screen to the development machine, you can see the heap information of the process, you can view the Logcat information, you can see the process allocated memory, you can send text messages and phone calls like the target machine, You can send geo-location information to Android. You can debug a process like GDB attach. The Android SDK tools provide DDMS functionality. Eclipse will have a DDMS perspective after installing ADT. Switch to DDMS view:<ignore_js_op> DDMS View Compositionas shown, the Ddms view consists of 3 parts: the upper-left window (device window), the lower-left window (Emulator Control), and the right-hand panel. 1. Device window
The Device window displays a list of all the emulators or devices that are currently available and the list of virtual machines that each device is currently running. The virtual machine is displayed according to the program's package life. The top-right corner of the Device tab bar is: Debug a process, update a process, update the process stack information, stop a process, and the last Picture button to crawl Android's current screen. 2. Emulator Control
Here, you can simulate some device states and behaviors.
Telephony Status: Change the state of phone voice and data scenarios to simulate different network speeds.
TelePhony Actions: Send analog phone calls and SMS to the simulator.
Location Controls: Send virtual location data to the simulator and we can perform operations such as positioning. It can be done in manual. Enter latitude and longitude to the simulator, or you can pass GPX and KML files. 3. Right panelThe window on the right has threads, heap,Allocation Tracker, File Explorer tab. Displays thread statistics, stack information, distribution tracker , and Android file system, respectively.
1) Threads
The Threads view lists all the threads for this process. <ignore_js_op>

ID: The unique thread ID assigned by the virtual machine, in Dalvik, which is an odd number starting from 3.
Tid:linux thread id,for The main thread in a process, this would match the process ID.
Stauts: Thread state, Utime: Cumulative time to execute user code
Stime: Cumulative time to execute system code
Name: The names of the threads

2) VM Heap
Shows the status of some heaps, updated during garbage collection. When a virtual machine is selected, the VM heap view cannot display data, click the Green Show heap updates button on the right side of the bread, and then click Cause GC to implement garbage collection update heap status.
3) Allocation Tracker
In this view, we can track the memory allocation of each selected virtual machine. Click "Start Tracking" and click "Get Allocations" to see.
4) File Explorer
The file Explorer is opened through device > File Explorer. Here you can browse files, upload and delete files, of course, there is a corresponding permission restrictions.   Common Tools 1. Heap View
Click the Update heap button to get information about the heap allocations in the selected virtual machines.

<ignore_js_op>
Figure 2

<ignore_js_op>
Figure 3
Click "Cause GC" to begin. The heap details are displayed with an allocation size icon for a specific allocation type. If you have an allocation leak, this can be a good checkpoint by watching the overall trend of the heap size (heap sizes), ensuring that it does not grow larger during application run time. 2. Allocation Tracker (distribution Tracker)
The Allocation Tracker (Assignment Tracker) view shows more in-depth details about the assignment. Click Start Tracking, perform an action in the app, and then tap get allocations (get assigned).
<ignore_js_op>
Figure 4

The list shown is sorted by assignment, and the most recent assignment is displayed first. Select to see a stack trace about how the assignment was created.
Looking at the allocation details carefully, the following code looks to have improved space:
Datastr + = String.Format ("Std. Dev.:%.3f,%.3f,%.3f\n", DevX, Devy, DEVZ);
The above example can be simply refactored into the following code, saving the overhead of constructing a temporary char[].
Datastrbuilder.append (String.Format ("Std. Dev.:%.3f,%.3f,%.3f\n", DevX, Devy, Devz));

3. Method Profiling (Methods analysis)

Methods Profiling (method Analysis) is a DDMS tool that is useful for a quick overview of the consumption distribution of time in an application or for a detailed view of time-critical functions.

<ignore_js_op>

Figure 6

If you want more performance data about the task while the app is running and performing some interesting task, click Start Method Profiling (Start methods Analysis). The parser collects only a small amount of data (no more than 2 or 3 seconds), so click the icon again after a few minutes to stop the collection. Activating the method Analyzer from DDMS enables the tool to automatically use internal storage to store analysis results, and when the capture is complete, send them back to the host for further analysis.

The IDE automatically launches the TraceView window to help you analyze the results in the IDE (Figure 6).

<ignore_js_op>

Figure 6
Parsing results is the most interesting part. Click a method call in the bottom pane to create a hierarchy that shows you the current method-first calling the method's parent method, and then the child method that is called from the selected method.

Android Debugging Tool Ddms

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.