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