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的更多相关文章

  1. 使用Eclipse调试Android Native Application---cocos2d-x + Eclipse + Android + ndk

    纠结很多天的ndk 调试, 终于在 mac  下面顺利完成(注意在windows还是没弄成功,蛋疼...) 调试方法: 1:先google, ndk demo .  把ndk 最基本的hellword ...

  2. javah tool for Android Native Application

    javah可以在Eclipse中配置成为External Tools,选择External Tools Configurations,配置如下,经过测试通过. Location: ${system_p ...

  3. [原]Android Native Debug

    1,安装adt插件,cdt插件2,SDK目录配置: Eclipse文件菜单选择“Window”--->“Preferences”--->“Android”--->设置“SDK Loc ...

  4. NDK开发历程(一):android native code的调试方法

    引用:http://www.cnblogs.com/ychellboy/archive/2013/02/22/2922683.html 使用NDK在android上做开发是一件“痛并快乐着”的差事,之 ...

  5. 如何debug android cts

    启动和关闭ADB服务(adb start-server和adbkill-server) 经作者测试,模拟器在运行一段时间后,adb服务有可能(在Windows进程中可以找到这个服务,该服务用来为模拟器 ...

  6. GDB + gdbserver 远程调试android native code

    原文地址:GDB + gdbserver 远程调试android native code 作者:tq08g2z 以调试模拟器中的native library code为例. Host: ubuntuT ...

  7. Android NDK Application.mk(中文翻译)

    作者:阿宝 更新:2016-08-31 来源:彩色世界(https://blog.hz601.org/2016/07/26/android-NDK-application-mk/index.html) ...

  8. 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 ...

  9. Ubuntu18.04 从头开始编译 Android Native WebRTC

    本文详细记录Mac下使用PD虚拟机安装ubuntu18.4桌面版,编译Android Native WebRTC的过程. 注意如果仅仅是使用WebRTC没必要手动编译源码,直接用官方提供的预编译包即可 ...

随机推荐

  1. ssh整合思想 Spring与Hibernate的整合 项目在服务器启动则自动创建数据库表

    Spring整合Hibernate Spring的Web项目中,web.xml文件会自动加载,以出现欢迎首页.也可以在这个文件中对Spring的配置文件进行监听,自启动配置文件, 以及之前Struts ...

  2. PCA检测人脸的简单示例_matlab实现

    PCA检测人脸的简单示例,matlab R2009b上实现训练:训练用的20副人脸: %训练%Lx=X'*Xclear;clc;train_path='..\Data\TrainingSet\';ph ...

  3. jmeter操作mysql数据库

    1.导入jdbc的jar包,因为jmeter本身不能直接连接mysql,所以需要导入第三方的jar包,来连接mysql 2.创建数据库连接配置,mysql的url.端口号.账号.密码 在JDBC Co ...

  4. 怎样处理jmeter中文乱码

    jmeter返回 中文乱码: 1.在jmeter的bin目录下,找到jmeter的配置文件,jmeter.properties,然后把 sampleresult.default.encoding=UT ...

  5. LeetCode(166) Fraction to Recurring Decimal

    题目 Given two integers representing the numerator and denominator of a fraction, return the fraction ...

  6. Shell脚本完成hadoop的集群安装

    虽然整体实现的自动安装,但还是有很多需要完善的地方,比如说: 1. 代码目前只能在root权限下运行,否则会出错,这方面需要加权限判断: 2.另外可以增加几个函数,减少代码冗余: 3.还有一些判断不够 ...

  7. 【Netty】Netty入门之WebSocket小例子

    服务端: 引入Netty依赖 <!-- netty --> <dependency> <groupId>io.netty</groupId> <a ...

  8. Python之log的处理方式

    配置文件: #! /usr/bin/env python # -*- coding: utf-8 -*- """ logging配置 """ ...

  9. PHP全栈开发

     DAY01_PHP基础第一天                 01.了解php  00:09:26 ★  02.php的开发环境准备  00:13:47 ★  03.人人都会编程  00:10:26 ...

  10. [git 学习篇]删除文件

    1 现在本地文件管理器删除了readme.txt(这个readme.txt已经在创库存在的) rm -rf readme.txt 2 此时git status查看 $ git status # On ...