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没必要手动编译源码,直接用官方提供的预编译包即可 ...
随机推荐
- C#经典面试题——递归运算
今天开始写递归,然而始终不得甚解.借鉴别人的理解:假设我们现在都不知道什么是递归,我们自然想到打开浏览器,输入到谷歌的网页,我们点击搜索递归,然后我们在为维基百科中了解到了递归的基本定义,在了解到了递 ...
- 修改broadcom 4322无线网卡ID教程,不再显示第三方无线网卡
本帖最后由 hellokingabc 于 2016-1-11 03:07 编辑 黑苹果已经基本完美,但是无线网卡总是出现问题,经常断网,经过搜索,原因在于无线网卡在OSX系统下显示为第三方无线网卡,只 ...
- JS与 JSON(一个菜鸟的不正经日常)
今天学习了json的一些知识, 1 . 什么是json 1.1 JSON 英文全称 JavaScript Object Notation. 1.2 JSON 是一种轻量级的数据交换格式,用于存储和 ...
- Golang 简单web测试
// mhoso project main.go package main import ( "log" "net/http" "./controll ...
- k8s搭建WebUI--Dashborad管理界面
k8s的webUI管理界面可以更好更直观更便捷的让我们去管理我们的k8s集群. 我们知道,由于某些原因我们无法直接拉取dashboard的镜像,但是国内有些人已经将镜像下载到dockerhub中可以给 ...
- 安装cfssl证书生成工具
wget https://pkg.cfssl.org/R1.2/cfssl_linux-amd64 wget https://pkg.cfssl.org/R1.2/cfssljson_linux-am ...
- 怎样处理jmeter中文乱码
jmeter返回 中文乱码: 1.在jmeter的bin目录下,找到jmeter的配置文件,jmeter.properties,然后把 sampleresult.default.encoding=UT ...
- ccf 201712-2 游戏(Python实现)
一.原题 问题描述 试题编号: 201712-2 试题名称: 游戏 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 有n个小朋友围成一圈玩游戏,小朋友从1至n编号,2号小朋友坐 ...
- Tcl/Cmds
- 系统测试过程截获SQL方法
1 摘要 测试过程中,经常会遇到莫名的各种问题,可能从开发同学的日志无法发现具体出现问题的原因,本着测试同学深入分析.定位问题的目的,经常需要一些额外的手段获得更多的错误异常信息. 我们涉及 ...