How to debug Android Native Application with eclipse
This blog is inspired by this tutorial http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-debugging/, but that tutorial is for NDK. However what I am doing is a pure Native debugging (AOSP 4.2.2 + a Pure Native C++ application, so it is not NDK based, but a pure C++ application which has real main() function). The steps for debugging setup are as following:
1) Since my applicaton is pure C++ application which is like the Android bootanimation, I build it from the AOSP command line, not from eclipse, so when I want to debug it, I have to import the executable from filesystem.
2) When the project is created, create a Debug configuration (select the project, then right click, then select "Debug As"). When the "Debug Configurations" diaglog appears, add/select the entry for your debugging application; Then in the "Main" tab, choose the applicaton path by clicking the "Browse" button:
3) By default, the eclipse will use "GDB (DSF) Create Process Launcher", we must change the launcher, to do this, in the bottom of the "Main" tab, click the "Using GDB (DSF) Create Process Launcher - Select other..." button, and then select "Standard Create Process Launcher". This is very important, becasue the next steps will need this step to populate the "Debugger" tab contents. If you do not change this, then the "Debugger" tab will not be what we will see in the next step.
4) Switch to the "Debugger" tab, then fill the fileds contents as bellow:
5) Change to the "Connection" sub tab of the "Debugger" tab, and change the connection settings as below (which will need to match the gdbserver settings as done in the next step):
6) Click the "Apply" button;
7) Before you click the "Debug" button, you need to:
a) start the Android emulator: emultator &
b) farward tcp port: adb forward tcp:1234 tcp:1234
c) start gdb server: adb shell gdbserver 192.168.1.107:1234 /system/bin/SkiWin
8) Now its time to start the Debugging by clicking the "Debug" button. Once clicked, eclipse will use the gdb (such as prebuilt/linux-x86/bin/arm-linux-androideabi-gdb which you have choosen in the previous steps) to connect the gdbserver, once connected, it will switch to the "Debug perspective". When you choose "Yes", you will see the dynamic libs are loaded in the eclipse console, and then the source code is stopped/displayed on the main() function (as you have requested this in the previous steps in the Debugger configuration).
9) Now, its time to start the application, of course, you could set some breakpoints before you go. For example, I have set a breakpoint as below, and when I click the "Resume (F8)" button, the code runs to the breakpoint as below (meanwhile, dynamic libs are loaded when it is first time loaded):
10) Since I am going to catch and debug a "Segmentation Fault" in the code (AOSP skia), I am going to run the applicaton in full speed and perform some operations before it triggers the fault (or anytime something went wrong and want to have a peek of what is going on). For the fault, the debugger will automatically stop at the code where it triggers; for the situation where you don't know what is going on, but want to have an on-line check, you need to click the "Suspend" button.
11) What is now remaining is to do normal debugging, checking variables, registers, etc. In my unlucky case, it is clear the "view->handleInval" is a NULL pointer, which causes a jump to zero (thus a Segmentation Fault) - shit, why would this be happening (since there is actually a SkView::handleInval() method)?! Anyway, it is my homework to do this checking!
Hope it helps someone someday!
Cory
How to debug Android Native Application with eclipse的更多相关文章
- 使用Eclipse调试Android Native Application---cocos2d-x + Eclipse + Android + ndk
纠结很多天的ndk 调试, 终于在 mac 下面顺利完成(注意在windows还是没弄成功,蛋疼...) 调试方法: 1:先google, ndk demo . 把ndk 最基本的hellword ...
- javah tool for Android Native Application
javah可以在Eclipse中配置成为External Tools,选择External Tools Configurations,配置如下,经过测试通过. Location: ${system_p ...
- [原]Android Native Debug
1,安装adt插件,cdt插件2,SDK目录配置: Eclipse文件菜单选择“Window”--->“Preferences”--->“Android”--->设置“SDK Loc ...
- NDK开发历程(一):android native code的调试方法
引用:http://www.cnblogs.com/ychellboy/archive/2013/02/22/2922683.html 使用NDK在android上做开发是一件“痛并快乐着”的差事,之 ...
- 如何debug android cts
启动和关闭ADB服务(adb start-server和adbkill-server) 经作者测试,模拟器在运行一段时间后,adb服务有可能(在Windows进程中可以找到这个服务,该服务用来为模拟器 ...
- GDB + gdbserver 远程调试android native code
原文地址:GDB + gdbserver 远程调试android native code 作者:tq08g2z 以调试模拟器中的native library code为例. Host: ubuntuT ...
- Android NDK Application.mk(中文翻译)
作者:阿宝 更新:2016-08-31 来源:彩色世界(https://blog.hz601.org/2016/07/26/android-NDK-application-mk/index.html) ...
- Wait… What Happens When my React Native Application Starts? — An In-depth Look Inside React Native
Discover how React Native functions internally, and what it does for you without you knowing it. Dis ...
- Ubuntu18.04 从头开始编译 Android Native WebRTC
本文详细记录Mac下使用PD虚拟机安装ubuntu18.4桌面版,编译Android Native WebRTC的过程. 注意如果仅仅是使用WebRTC没必要手动编译源码,直接用官方提供的预编译包即可 ...
随机推荐
- 如何理解JavaScript中的this关键字
前言 王福朋老师的 JavaScript原型和闭包系列 文章看了不下三遍了,最为一个初学者,每次看的时候都会有一种 "大彻大悟" 的感觉,而看完之后却总是一脸懵逼.原型与闭包 可以 ...
- STL之stack操作
c++ stl栈stack介绍 C++ Stack(堆栈) 是一个容器类的改编,为程序员提供了堆栈的全部功能,——也就是说实现了一个先进后出(FILO)的数据结构. c++ stl栈stack的头文件 ...
- LeetCode_6
问题: 6. Z字形变换 链接:https://leetcode-cn.com/problems/zigzag-conversion/description/ 分析: A 仿真方法 直接模拟整个过程, ...
- destoon 后台入口文件分析
<?php/* [Destoon B2B System] Copyright (c) 2008-2015 www.destoon.com This is NOT a freeware, use ...
- jflash合并两个文件
有时候需要将两个代码块烧写进入单片机的flash,可以使用合并的方法将两个文件合并为一个文件进行烧写,也可以分两次烧写,但要注意不要擦写不相关的存储空间. 打开J-FLASH,新建一个工程,然后fil ...
- 树状数组:CDOJ1583-曜酱的心意(树状数组心得)
曜酱的心意 Time Limit: 3000/1000MS (Java/Others) Memory Limit: 131072/131072KB (Java/Others) Description ...
- HDU 4348 To the moon 主席树
题意: 给出一个长度为\(n(n \leq 10^5)\)的序列,最开始时间\(t=0\),支持下面几个操作: \(C \, l \, r \, d\):将区间\([l,r]\)每个数都加上\(d\) ...
- Django one
WEB-Django: Http协议: http协议:超文本传输协议,基于TCP/IP通信协议来传递数据 特点: 1.灵活:允许传输任意类型的数据对象.正在传输的类型有Content-Type标记 2 ...
- cache共享问题
经测试发现,cache在web中与windows service中是不能共享的.但在windows service可以使用cache.
- 写iOS SDK注意事项
转载http://www.devtang.com/blog/2015/01/31/write-sdk-tips/