Android Debug Series-debug Smali code with Android Studio

Source: Internet
Author: User

1. Introduction of tools

Using tools

Android killer: For anti-compilation apk package, get Smali code

Android Studio: Debugging the Smali Code tool, or using Idea,android Studio is modified based on idea

Smalidea-0.03.zip:as plug-ins that need to be installed in Android Studio,

Simulator or a real machine: Run the program you want to debug

Sample: Using an APK program on the network,

2. Pre-Preparation

2.1 Mobile phone or simulator installation application

ADB instll ggndktest1.apk

2.2 Using the Android Killer Disassembly Test Package GGNdkTest1 package, generate Smali folder

2.3 Android Studio installs smalidea-0.03 plugin, click File->settings->plugins->instal Plugins from disk, select Download Zip package on line, do not unzip. After the installation is complete, the as prompt restarts to take effect, restart can

2.3 As Import project, select the previous step of the Smali directory, all the way next, the final results such as

3. Commissioning steps

3.1 Configure as Debug configuration, Run->edit configurations, click + Sign, new remote type debugger, set name, modify port number, can choose any port occupied, this time set to 8800

3.2 Start the app in debug mode at the end of as, the process hangs, and the Run command looks at the app's process number 28881

3.3 Set the port forwarding, the meaning of this command can be considered in the local 8800 port and mobile phone 28881 process to establish a channel, when debugging started, as connected to the local 8800 port, through this channel control program operation

3.4 The breakpoint, in order to clear, in the left column, the right mouse button to select the display line number, row number next to click on the breakpoint, it should be noted that Smali not every line can be the breakpoint, the current breakpoint is not successful, choose another place under the breakpoint test.

3.5 Debug Run->debug Select the debugger you just added, at which point the program breaks the line of the breakpoint set, and the debugger decrypts the following

On the left, the top row of the debug bar is running, stepping, entering functions, forcing entry, jumping out, and so on, the call stack is shown below

Middle variables column to see the value of the variable

The right Watch bar can be concerned with registers, such as v1.

4. Summary

Search on the Internet some tutorials, what open DDMS, set 8700 or what port, and then close Ddms, and so on, all kinds of methods flying around, see the most confused is the DDMS to open the shutdown and port settings.

According to the content of the online search, summarized below, as shown in

ADBD: Runs on the phone side, daemon process, communicates with ADB server while communicating with debugger on the phone, debugging individual programs

Adbserver: Runs on PC, communicates with ADBD while listening on 5037 ports.

Ddms:1, connect 5037 ports.

2, monitor each process, and establish a separate debug port for each process, such as 8600, 8601, etc., the various debuggers can directly connect these ports for debugging.

3, provide a special debug port 8700, it can receive 8600, 8601 ... The data for these ports and communicates with any process of the phone.

3, self-provided some means to debug each process.

Debugger: A variety of debuggers, you can choose to connect 8700 or other individual debug ports per process.

Knowing the role of each of these components, then a few scenarios can work properly

1, open DDMS, debugger connection 8700 port, do not need to set port forwarding, can be successfully debugged

2, open Ddms, debugger connection 86** port, do not need to set port forwarding, can be successfully debugged

3. Do not turn on DDMS, check the process ID to be debugged, set port forwarding (step 3.3 above) to debug successfully

The first two are easier to understand, the third one can be successful, some don't understand

View port Information First

When port forwarding is done, port 8800 is listening, and 5037 with the input ADB server process

When debugging is started, the as process is connected to the 8800 port of ADB.

So the guess is that ADB server listens to port 5037 by default, and DDMS can debug the process through 5037 ports, and the debugger connects to ADB server via DDMS.

When the port forwarding is performed, the ADB server listens on another port 8800, so debugger can directly connect to the port for debugging without having to go through the DDMS

Personal guess, where there is a mistake, please.

Android Debug Series-debug Smali code with Android Studio

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.