Once the app of interest is decompiled back to Java code, it can be debugged like usual source code in any IDE supporting it. This part has already been covered in Chapter 8, Reversing Bytecode Languages: .NET, Java, and More.
However, sometimes it is required to debug the native Dalvik instructions. Luckily, there are tools that can facilitate this process. One that deserves particular attention is smalidea. It is a plugin for IntelliJ IDEA (or Android Studio, based on it) allowing for step-by-step execution of the analyzed code. This project belongs to the Smali authors and can be found with the corresponding assembler and disassembler tools.
In addition, Android already provides several options to debug apps and processes using the console, particularly gdb and jdb:
- gdbclient can be used to attach to already running apps and native daemons
- Native process startup can be debugged using a combination of the gdbserver and gdbclient tools:
adb shell gdbserver64 :<port>...