SlideShare a Scribd company logo
Debug JNI code with ndk-gdb
and eclipse GUI
Tom Chen
Overview
● Prerequisite
● Debug with ndk-gdb
● Set up eclipse gdb environment
● Debug JNI in eclipse
Prerequisite
Build Debuggable JNI Lib
● Download android-ndk-r9
● In AndroidManifest.xml
● android:debuggable=true
● In Application.mk, APP_OPTIM := debug.
● Without this variable is also fine. Just don't let it be
"release".
● Build Code: ndk-build NDK_DEBUG=1
Prerequisite
Cygwin Environment
● Download and install cygwin
● Remember to install make(2.7 or higher)
● Install JDK and set up env variables, PATH and
CLASSPATH
● Without JDK is also fine, but have to run ndk-gdb
with "--nowait".
● Set up path to android-sdk and ndk in PATH
env variables.
● For unix-like env, just set up these relative
paths.
Debug with ndk-gdb
Steps
● First, run your debuggle app directly or via
eclipse.
● Open cygwin and go to where your project
resides.
● Execute ndk-gdb
● With --nowait specified if no JDK installed.
● Set up some break points and start debugging!
Debug with ndk-gdb
Basic gdb commands
● break (br or b): Setup break points
● info br: Show all break points
● bt: Display call stack
● list: Show next ten lines of code
● print (p): Print the content of variable
● continue (c): Continue the process.
● step (s): Step to next line
Set up eclipse gdb
● CDT plugin is required!
● Create C/C++ debug configuration.
Debug JNI code with ndk-gdb and eclipse GUI
{ndk path}toolchainsarm-linux-androideabi-4.6prebuiltwindows-
x86_64binarm-linux-androideabi-gdb.exe
Debug JNI code with ndk-gdb and eclipse GUI
Set up eclipse gdb
Modify scripts
● ndk-gdb
● Make a copy and rename it as ndk-gdb-eclipse
● Edit the new file and comment out the last line
– #$GDBCLIENT -x `native_path $GDBSETUP`
● gdb.setup
● The file located at objlocalarmeabigdb.setup .
● Make a copy named gdb2.setup
● Delete the last line
– target remote :5039
Debug JNI in eclipse
● First, run your debuggle app directly or via
eclipse
● Open cygwin and go to where your project
resides.
● Execute ndk-gdb-eclipse
● With --nowait specified if no JDK installed.
● Wait until the command finish
● Go back to eclipse and execute the debug
configuration just created!
Debug JNI code with ndk-gdb and eclipse GUI
Reference
● http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-debuggi
● http://www.gnu.org/software/gdb/documentation/
●

More Related Content

PDF
[Szjug] Docker. Does it matter for java developer?
PPT
Tp web
PPTX
Using openCV 3.2.0 with CodeBlocks
PPTX
Docker slides
PPTX
PPTX
CI-CD WITH GITLAB WORKFLOW
PDF
Geo script opengeo spring 2013
PPTX
Install, Compile, Setup, Setting OpenCV 3.2, Visual C++ 2015, Win 64bit,
[Szjug] Docker. Does it matter for java developer?
Tp web
Using openCV 3.2.0 with CodeBlocks
Docker slides
CI-CD WITH GITLAB WORKFLOW
Geo script opengeo spring 2013
Install, Compile, Setup, Setting OpenCV 3.2, Visual C++ 2015, Win 64bit,

What's hot (20)

PDF
From Docker Run To Docker Compose
PDF
Linux programming
PDF
NUS-ISS Learning Day 2017 - Bots-Managed CloudOps
PDF
sysprog2 Part2
PPTX
what is docker
PDF
Using GeoServer with NASA WorldWind
PDF
OpenCms Days 2012 - Developing OpenCms with Gradle
PPTX
PPTX
Frontend application architecture, patterns, and workflows
PDF
Start your container journey safely
PDF
Caching in Docker - the hardest thing in computer science
PDF
Virtual Machines and Docker
PDF
Deploy a MongoDB Replica Set using Docker
PDF
Kubernetes on CRI-O
PPTX
Docker session II: Introduction to Docker
PDF
[UDS] Cloud Computing "pour les nuls" (Exemple avec LinShare)
PDF
OpenCms Days 2013 - Gradle based OpenCms build automated setup
PDF
TDC2018SP | Trilha Containers - CI/CD com Docker e Drone
PDF
Migration from Drupal 7 to Drupal 8 - How Docker can save our lives!
PDF
Migration from drupal 7 to drupal 8
From Docker Run To Docker Compose
Linux programming
NUS-ISS Learning Day 2017 - Bots-Managed CloudOps
sysprog2 Part2
what is docker
Using GeoServer with NASA WorldWind
OpenCms Days 2012 - Developing OpenCms with Gradle
Frontend application architecture, patterns, and workflows
Start your container journey safely
Caching in Docker - the hardest thing in computer science
Virtual Machines and Docker
Deploy a MongoDB Replica Set using Docker
Kubernetes on CRI-O
Docker session II: Introduction to Docker
[UDS] Cloud Computing "pour les nuls" (Exemple avec LinShare)
OpenCms Days 2013 - Gradle based OpenCms build automated setup
TDC2018SP | Trilha Containers - CI/CD com Docker e Drone
Migration from Drupal 7 to Drupal 8 - How Docker can save our lives!
Migration from drupal 7 to drupal 8
Ad

Similar to Debug JNI code with ndk-gdb and eclipse GUI (20)

PPTX
Debuging like a pro
PDF
Writing mruby Debugger
PPTX
Debugging Modern C++ Application with Gdb
PDF
Android Platform Debugging and Development at ELCE 2013
PDF
gdb-tutorial.pdf
PDF
lab1-ppt.pdf
PDF
Android Platform Debugging and Development
PDF
Ninja Build: Simple Guide for Beginners
PPT
Native Android for Windows Developers
PDF
Working with the AOSP - Linaro Connect Asia 2013
PPTX
Android - ADB
PDF
Debugging embedded devices using GDB
PPTX
Gnu debugger
PPTX
GNU Debugger
PPTX
Advanced Debugging with GDB
PDF
Metasepi team meeting #8': Haskell apps on Android NDK
PDF
Android Platform Debugging and Development at ABS 2014
ODP
NovaProva, a new generation unit test framework for C programs
PDF
Gdb tutorial-handout
PDF
OpenCV Workshop
Debuging like a pro
Writing mruby Debugger
Debugging Modern C++ Application with Gdb
Android Platform Debugging and Development at ELCE 2013
gdb-tutorial.pdf
lab1-ppt.pdf
Android Platform Debugging and Development
Ninja Build: Simple Guide for Beginners
Native Android for Windows Developers
Working with the AOSP - Linaro Connect Asia 2013
Android - ADB
Debugging embedded devices using GDB
Gnu debugger
GNU Debugger
Advanced Debugging with GDB
Metasepi team meeting #8': Haskell apps on Android NDK
Android Platform Debugging and Development at ABS 2014
NovaProva, a new generation unit test framework for C programs
Gdb tutorial-handout
OpenCV Workshop
Ad

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
cuic standard and advanced reporting.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Empathic Computing: Creating Shared Understanding
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
DOCX
The AUB Centre for AI in Media Proposal.docx
Encapsulation_ Review paper, used for researhc scholars
sap open course for s4hana steps from ECC to s4
Machine learning based COVID-19 study performance prediction
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
NewMind AI Weekly Chronicles - August'25 Week I
Per capita expenditure prediction using model stacking based on satellite ima...
cuic standard and advanced reporting.pdf
20250228 LYD VKU AI Blended-Learning.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Understanding_Digital_Forensics_Presentation.pptx
Chapter 3 Spatial Domain Image Processing.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Empathic Computing: Creating Shared Understanding
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Reach Out and Touch Someone: Haptics and Empathic Computing
The AUB Centre for AI in Media Proposal.docx

Debug JNI code with ndk-gdb and eclipse GUI