SlideShare a Scribd company logo
1 of 14
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.
{ndk path}toolchainsarm-linux-androideabi-4.6prebuiltwindows-
x86_64binarm-linux-androideabi-gdb.exe
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!
Reference
● http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-debuggi
● http://www.gnu.org/software/gdb/documentation/
●

More Related Content

What's hot

From Docker Run To Docker Compose
From Docker Run To Docker ComposeFrom Docker Run To Docker Compose
From Docker Run To Docker ComposeFitra Aditya
 
NUS-ISS Learning Day 2017 - Bots-Managed CloudOps
NUS-ISS Learning Day 2017 - Bots-Managed CloudOpsNUS-ISS Learning Day 2017 - Bots-Managed CloudOps
NUS-ISS Learning Day 2017 - Bots-Managed CloudOpsNUS-ISS
 
Using GeoServer with NASA WorldWind
Using GeoServer with NASA WorldWindUsing GeoServer with NASA WorldWind
Using GeoServer with NASA WorldWindIlya Rosenfeld
 
Frontend application architecture, patterns, and workflows
Frontend application architecture, patterns, and workflowsFrontend application architecture, patterns, and workflows
Frontend application architecture, patterns, and workflowsCesar Andreu
 
Start your container journey safely
Start your container journey safelyStart your container journey safely
Start your container journey safelyRachid Zarouali
 
Caching in Docker - the hardest thing in computer science
Caching in Docker - the hardest thing in computer scienceCaching in Docker - the hardest thing in computer science
Caching in Docker - the hardest thing in computer scienceJarek Potiuk
 
Virtual Machines and Docker
Virtual Machines and DockerVirtual Machines and Docker
Virtual Machines and DockerDanish Khakwani
 
Deploy a MongoDB Replica Set using Docker
Deploy a MongoDB Replica Set using DockerDeploy a MongoDB Replica Set using Docker
Deploy a MongoDB Replica Set using DockerHakan Özler
 
Docker session II: Introduction to Docker
Docker session II: Introduction to DockerDocker session II: Introduction to Docker
Docker session II: Introduction to DockerDegendra Sivakoti
 
[UDS] Cloud Computing "pour les nuls" (Exemple avec LinShare)
[UDS] Cloud Computing "pour les nuls" (Exemple avec LinShare)[UDS] Cloud Computing "pour les nuls" (Exemple avec LinShare)
[UDS] Cloud Computing "pour les nuls" (Exemple avec LinShare)LINAGORA
 
OpenCms Days 2013 - Gradle based OpenCms build automated setup
OpenCms Days 2013 - Gradle based OpenCms build automated setupOpenCms Days 2013 - Gradle based OpenCms build automated setup
OpenCms Days 2013 - Gradle based OpenCms build automated setupAlkacon Software GmbH & Co. KG
 
TDC2018SP | Trilha Containers - CI/CD com Docker e Drone
TDC2018SP | Trilha Containers - CI/CD com Docker e DroneTDC2018SP | Trilha Containers - CI/CD com Docker e Drone
TDC2018SP | Trilha Containers - CI/CD com Docker e Dronetdc-globalcode
 
Migration from Drupal 7 to Drupal 8 - How Docker can save our lives!
Migration from Drupal 7 to Drupal 8 - How Docker can save our lives!Migration from Drupal 7 to Drupal 8 - How Docker can save our lives!
Migration from Drupal 7 to Drupal 8 - How Docker can save our lives!DrupalCamp Kyiv
 

What's hot (20)

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

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

Writing mruby Debugger
Writing mruby DebuggerWriting mruby Debugger
Writing mruby Debuggeryamanekko
 
Debugging Modern C++ Application with Gdb
Debugging Modern C++ Application with GdbDebugging Modern C++ Application with Gdb
Debugging Modern C++ Application with GdbSenthilKumar Selvaraj
 
Android Platform Debugging and Development at ELCE 2013
Android Platform Debugging and Development at ELCE 2013Android Platform Debugging and Development at ELCE 2013
Android Platform Debugging and Development at ELCE 2013Opersys inc.
 
gdb-tutorial.pdf
gdb-tutorial.pdfgdb-tutorial.pdf
gdb-tutorial.pdfligi14
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and DevelopmentOpersys inc.
 
Ninja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for BeginnersNinja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for BeginnersChang W. Doh
 
Native Android for Windows Developers
Native Android for Windows DevelopersNative Android for Windows Developers
Native Android for Windows DevelopersYoss Cohen
 
Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013Opersys inc.
 
Debugging embedded devices using GDB
Debugging embedded devices using GDBDebugging embedded devices using GDB
Debugging embedded devices using GDBChris Simmonds
 
Advanced Debugging with GDB
Advanced Debugging with GDBAdvanced Debugging with GDB
Advanced Debugging with GDBDavid Khosid
 
Metasepi team meeting #8': Haskell apps on Android NDK
Metasepi team meeting #8': Haskell apps on Android NDKMetasepi team meeting #8': Haskell apps on Android NDK
Metasepi team meeting #8': Haskell apps on Android NDKKiwamu Okabe
 
Android Platform Debugging and Development at ABS 2014
Android Platform Debugging and Development at ABS 2014Android Platform Debugging and Development at ABS 2014
Android Platform Debugging and Development at ABS 2014Opersys inc.
 
NovaProva, a new generation unit test framework for C programs
NovaProva, a new generation unit test framework for C programsNovaProva, a new generation unit test framework for C programs
NovaProva, a new generation unit test framework for C programsGreg Banks
 
Gdb tutorial-handout
Gdb tutorial-handoutGdb tutorial-handout
Gdb tutorial-handoutSuraj Kumar
 

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

Debuging like a pro
Debuging like a proDebuging like a pro
Debuging like a pro
 
Writing mruby Debugger
Writing mruby DebuggerWriting mruby Debugger
Writing mruby Debugger
 
Debugging Modern C++ Application with Gdb
Debugging Modern C++ Application with GdbDebugging Modern C++ Application with Gdb
Debugging Modern C++ Application with Gdb
 
Android Platform Debugging and Development at ELCE 2013
Android Platform Debugging and Development at ELCE 2013Android Platform Debugging and Development at ELCE 2013
Android Platform Debugging and Development at ELCE 2013
 
gdb-tutorial.pdf
gdb-tutorial.pdfgdb-tutorial.pdf
gdb-tutorial.pdf
 
lab1-ppt.pdf
lab1-ppt.pdflab1-ppt.pdf
lab1-ppt.pdf
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Ninja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for BeginnersNinja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for Beginners
 
Native Android for Windows Developers
Native Android for Windows DevelopersNative Android for Windows Developers
Native Android for Windows Developers
 
Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013
 
Android - ADB
Android - ADBAndroid - ADB
Android - ADB
 
Debugging embedded devices using GDB
Debugging embedded devices using GDBDebugging embedded devices using GDB
Debugging embedded devices using GDB
 
GNU Debugger
GNU DebuggerGNU Debugger
GNU Debugger
 
Gnu debugger
Gnu debuggerGnu debugger
Gnu debugger
 
Advanced Debugging with GDB
Advanced Debugging with GDBAdvanced Debugging with GDB
Advanced Debugging with GDB
 
Metasepi team meeting #8': Haskell apps on Android NDK
Metasepi team meeting #8': Haskell apps on Android NDKMetasepi team meeting #8': Haskell apps on Android NDK
Metasepi team meeting #8': Haskell apps on Android NDK
 
Android Platform Debugging and Development at ABS 2014
Android Platform Debugging and Development at ABS 2014Android Platform Debugging and Development at ABS 2014
Android Platform Debugging and Development at ABS 2014
 
NovaProva, a new generation unit test framework for C programs
NovaProva, a new generation unit test framework for C programsNovaProva, a new generation unit test framework for C programs
NovaProva, a new generation unit test framework for C programs
 
Gdb tutorial-handout
Gdb tutorial-handoutGdb tutorial-handout
Gdb tutorial-handout
 
OpenCV Workshop
OpenCV WorkshopOpenCV Workshop
OpenCV Workshop
 

Recently uploaded

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 

Recently uploaded (20)

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 

Debug JNI code with ndk-gdb and eclipse GUI

  • 1. Debug JNI code with ndk-gdb and eclipse GUI Tom Chen
  • 2. Overview ● Prerequisite ● Debug with ndk-gdb ● Set up eclipse gdb environment ● Debug JNI in eclipse
  • 3. 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
  • 4. 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.
  • 5. 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!
  • 6. 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
  • 7. Set up eclipse gdb ● CDT plugin is required! ● Create C/C++ debug configuration.
  • 8.
  • 10.
  • 11. 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
  • 12. 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!
  • 13.