Android ndk debugging knowledge

Source: Internet
Author: User

Ndk-gdb
I recently used NDK to develop some things and learned a lot about result debugging. Because I am also a beginner, I cannot guarantee that the content described next is completely correct.

Compile the debuggable code NDK_DEBUG = 1; Set androidmanifest. xml of apk to debugable = true.
In case of trouble, NDK_LOG = 1, -- verbose, V = 1 can output more detailed information for troubleshooting.

Debug symbol./obj/local/armeabi. If the dynamic library is not placed here, the system prompts no debug symbol.
If you want to know which dynamic libraries contain debugging information, use the shared command.
Gdb) shared

Assembly debugging
All disass and dump Functions
Ni, one-step debugging assembly
Si, go to the assembly sub-function
Display/5i $ pc, which is my favorite setting before debugging. In this way, each debugging step will automatically print the next five commands, which is very comfortable.

Arm Assembly the assembly of arm is somewhat different from that of x86, which is common:

Bl, similar to call, function call. The r0-rn is an incoming parameter, and r0 is the return value after the call.
Ldr: Load memory into registers.
Str: writes registers to the memory.
Ldr rn, [pc, # offset]
Add rn, pc, rn
This kind of command combination is special. In fact, it is to load the variable address outside the function, that is, to access the global variable.
Local variables, including the current function parameters, use sp + # offset to indicate the memory location.
The rest is similar to that of x86.


From LOGOS

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.