The dynamic debugging method of Android program

Source: Internet
Author: User

First, the use of DDMS

1. Convert the program using Apktool to Smali code, inject the log code (in Smali form, such as the value of the output register V0) around the key code, then repackage the APK, and then you can see the output from the Logcat when you execute it.

2. Stack tracking method: For example, insert new Exception ("Print Trace") around the key code. Printstacktrace (); Smali code form, then repackage the signature and run again to get stack trace information in the Logcat window.

3.method Profiling: You can use the method profiling function in Ddms to track which methods have been called. The Android SDK itself also supports method profiling, which provides the startmethodtracing () and stopmethodtracing () two ways to turn on and off methods in the Android.os.Debug class Profiling Such as

Android.os.Debug.startMethodTracing ("123");

A ();

Android.os.Debug.stopMethodTracing ("123");

The string "123" is the trace file name, and after execution the code generates a 123.trace file at the SD card root, which contains information such as the invocation of all methods during the execution of the A () method, which can be opened using the TraceView tool provided by the SDK, which is an Android A script file under the Tools directory of the SDK. First copy the file down with ADB pull/mnt/sdcard/123.trace, then execute TraceView 123.trace to open the TraceView window to view the file. You can inject code in the Smali file to track the execution of the method, such as Start Trace in OnCreate (), stop Trace in OnStop. Note that you want to add Android.permission.WRITE_EXTERNAL_STORAGE permissions to the manifest.

Second, the use of Andbug

Andbug is written in a Python script, does not support single-step debugging, and cannot set breakpoints on custom methods, so it can be a lot of inconvenience during use. But allows the analyst to extend the script.

Third, IDA Pro

Supports dynamic debugging of Android native programs starting from version 6.1.

Look very strong. A PC for a Windows system must be tested sometime.

The dynamic debugging method of Android program

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.