调试Android OS的本机库 [英] Debugging native libraries for Android OS
问题描述
我要为Android OS创建一个共享库.尽管我已经在Eclipse中完成了一些Android应用程序,但我还是决定使用Visual Studio和vs-Android附加组件开始本机开发:
I am to create a shared library for Android OS. Although I have done some Android apps in Eclipse I decided to start my native development with Visual Studio and vs-Android add-on:
http://code.google.com/p/vs-android/
我对VS非常熟悉,并且Google将该插件作为第一个结果之一.我已经完成了整个设置过程,安装了JDK,NDK,Ant,设置了系统变量,最后得到了一个可以正常工作的项目.它就像一个魅力!但是有一个很大的缺点.我无法调试本机代码.
I am really familiar with VS and Google found that add-on as one of the first results. I have gone through the whole setup procedure, installed JDK, NDK, Ant, set system variables and finally got a working project. It works like a charm! But there is a BIG drawback. I am not able to debug the native code.
我知道有NDK-GDB工具,但是在尝试设置它时却一直失败.我已经阅读了NDK-GDB.html文档,扔掉了最初的vs-Android解决方案,并成功完成了以下教程:
I know there is NDK-GDB tool, but I am constantly failing when trying to setup it. I have read NDK-GDB.html document, threw away the initial vs-Android solution and successfully gone through the following tutorial:
http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-development/
但是现在,当我尝试通过以下操作时,我再次陷入困境:
but now I am stuck again when trying to go through the:
http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-debugging/
http://mhandroid.wordpress. com/2011/01/23/using-cgdb-with-ndk-debug-and-cgdb-tutorial/
我还尝试了WinGDB-只是导入了工作的包含本机代码和Java代码的Eclipse项目,但它甚至没有编译.
I also tried WinGDB - just imported working Eclipse project containing both native and Java code, but it doesn't even compile.
简而言之,这个难题有很多,但我仍然缺少其中的一些.恐怕我缺少使用像NDK-GDB这样的命令行工具调试代码的整个想法.
In short, there are many pieces of the puzzle, but I am still missing some of them. I am afraid that I am missing the whole idea of debugging code with a command line tool like NDK-GDB is.
有人可以给我一些解释和明确的步骤来调试本地库(与vs-android或Eclipse或其他无关紧要)吗?请注意,我不是Linux专家,也不熟悉cygwin或gdbserver.
Can someone provide me some explanation and clear steps how to debug native libraries (doesn't matter if with vs-android or Eclipse or whatever else)? Please be aware I am not a Linux guru and also not familiar with cygwin or gdbserver.
推荐答案
我能够使用ndk-gdb
要构建
在jnk/Android.mk中设置-g
编译器标记以构建gdb服务器
Set the -g
compiler flag in jnk/Android.mk to build the gdb-server
LOCAL_CFLAGS := -g
构建用于调试NDK_DEBUG=1
ndk-build NDK_DEBUG=1
在清单中设置可调试的应用程序.
Set the application debuggable in the manifest.
android:debuggable=true
打开cygwin和cd到项目路径.将路径设置为adb.
Open cygwin and cd to the project path. Set the path to adb.
export PATH=$PATH:/path_to_android_sdk/platform-tools
然后启动gdb
ndk-gdb --verbose --adb=adb.exe
连接到gdb服务器后,您将必须键入continue
You will have to type continue
when you have connected to the gdb-server
这篇关于调试Android OS的本机库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!