I'm trying to work out methods for black box testing APKs with tools such as APKTOOL, Smali, and IDEs such as Eclipse and NetBeans. I have most of what I need - I can decompile/debug instrument/recompile/sign/align and run on a device.
The problem I am having is setting breakpoints once a debugger is attached (breakpoints are set in Smali code). It appears the breakpoints are not submitted to Dalvik or Dalvik is not honoring the breakpoints. Either way, the debugger is not snapping when the program encounters a breakpoint. Some research shows I might need Debug.waitForDebugger
. (http://stackoverflow.com/questions/3107587/android-with-jdb-confusion-using-waitfordebugger).
Assuming waitForDebugger
is the next hurdle, I can insert it using Smali syntax with invoke-static {}, Landroid/os/Debug;->waitForDebugger()V
after adjusting the local stack.
My question is, where do I insert the call to waitForDebugger
? Should I chose the MainActivity
(from the manifest) in the static constructor (clinit
), instance constructor (init
), onCreate
, or elsewhere? How does IDEs such as Eclipse, NetBeans, etc do this in their debug builds?