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. iOS 证书、真机调试、发布 App Store

    之前对iOS的证书弄的很不清楚,Xcode里面也有各种证书,作为一只有强迫症的巨蟹座,这是不能忍的 趁着准备发布自己的第一个app,梳理一下这块内容 主要参考了这几篇文章: iOS开发:创建真机调试证 ...

  2. vue 正则判断

    value=value.replace(/[^\d.]/g,'').replace(/\.{2,}/g,'.').replace('.','$#$').replace(/\./g,'').replac ...

  3. windows 2008r2+php5.6.28环境搭建详细过程

    安装IIS7 安装php 网站验证 安装IIS7 1.打开服务器管理器(开始-计算机-右键-管理-也可以打开),添加角色 直接下一步 勾选Web服务器(IIS),下一步,有个注意事项继续下一步(这里我 ...

  4. 通过源码编译安装VIM

    开发中使用的是Ubuntu 12.04 LTS,通过sudo apt-get install vim安装的版本较低,不支持YCM,所以,用源码编译并安装最新的Vim. 卸载旧版本的Vim: sudo ...

  5. python入门学习笔记1:Python与C的简单区别

    转载于:https://www.cnblogs.com/mlgjb/p/7892130.html 并做适当修改 一:简单比较   C语言 python 执行速度 快 慢 跨平台 不可以 可以 用途 操 ...

  6. LeetCode(151) Reverse Words in a String

    题目 Given an input string, reverse the string word by word. For example, Given s = "the sky is b ...

  7. stm32L011F3使用开发小记——开发坏境

    今日,因工作需要,使用到了stm32L011F3芯片,此芯片基于CM0+内核,属于低功耗芯片 开发平台可以免费用于KEILMDK,keil公司用免费的许可证,网址:https://www2.keil. ...

  8. Artwork Gym - 101550A 离线并查集

    题目:题目链接 思路:每个空白区域当作一个并查集,因为正着使用并查集分割的话dfs会爆栈,判断过于复杂也会导致超时,我们采用离线反向操作,先全部涂好,然后把黑格子逐步涂白,我们把每个空白区域当作一个并 ...

  9. poj 3187 三角数问题

    题意:给你两个数,一个n表示这个三角有多少层,一个sum表示总和 思路: 类似杨辉三角 1 1       1 1      2     1 第n行的第k个数 为 n!/k!(n-k)! 暴力枚举,因 ...

  10. LA 7056 Colorful Toy Polya定理

    题意: 平面上给出一个\(N\)个点\(M\)条边的无向图,要用\(C\)种颜色去给每个顶点染色. 如果一种染色方案可以旋转得到另一种染色方案,那么说明这两种染色方案是等价的. 求所有染色方案数 \( ...