I prefer plain GDB, but if want to use Eclipse, it’s possible.
Assuming the sources are located inside /home/ohad/mydroid/external/dragons (and you have eclipse, eclipse-cdt installed),
- Create a “Standard Make C Project”.
- Don’t use the default location. Instead, set it to /home/ohad/mydroid/external/dragons
- Don’t use the default Build command. Instead, set it to /home/ohad/mydroid/external/dragons/make_dragons
- Remove the “all” from the “Build (Incremental Build)” field, and uncheck “Clean”.
- Finish.
Next, create those two files:
- /home/ohad/mydroid/external/dragons/make_dragons
#!/bin/bash
ONE_SHOT_MAKEFILE=/home/ohad/mydroid/external/dragons/Android.mk make -C /home/ohad/mydroid files 2>&1 | sed -f /home/ohad/mydroid/external/dragons/android_sed_filter - /home/ohad/mydroid/external/dragons/android_sed_filter
# Streamlined Editor filter for Android native development with Eclipse
/WARNING: adding test OTA key/d
/implicitly installing apns-conf_sdk.xml/d
By now, you can use Eclipse to build dragons. Let’s move on to debugging.
Assuming that your target IP is 10.0.0.2 and your Eclipse host IP is 10.0.0.1,
- Create a “C/C++ Local Application” debug instance.
- Set “C/C++ Application” to your dragons binary, e.g., to “/home/ohad/mydroid/out/target/product/myboard/symbols/system/bin/dragons” (ignore the ‘CPU not supported’ warning for now).
- Choose “gdbserver Debugger”
- Set “GDB debugger” to your toolchain’s gdb binary
- Add “/home/ohad/mydroid/out/target/product/myboard/symbols/system/lib” to the “Shared Libraries” list tab.
- Fill up the Connection tab (e.g., TCP, 10.0.0.2, 1234).
Everything’s in place now. Before starting a debug session, execute (on the target) “gdbserver 10.0.0.1:1234 system/bin/dragons” (or gdbserver 10.0.0.1:1234 –attach <PID of dragons>).
Happy debugging