简体   繁体   English

如何使用Eclipse调试JNI代码(Java和C / C ++)

[英]How to Use Eclipse to Debug JNI code (Java & C/C++)

While I can debug my application with the Eclipse JDT debugger for Java code and GDB for C code, I would prefer to use a single tool for all my debugging. 虽然我可以使用用于Java代码的Eclipse JDT调试器和用于C代码的GDB调试我的应用程序,但我更倾向于使用单个工具进行所有调试。 I found several projects that enable "mixed-mode" debugging in Eclipse and include support for single stepping between Java and native code. 我找到了几个在Eclipse中启用“混合模式”调试的项目,并支持Java和本机代码之间的单步执行。

Unfortunately, one claims to be pre-release quality and the other is currently unmaintained. 不幸的是,一个声称是预发布质量,另一个目前没有维护。 Are there any plug-ins that bring mixed mode debugging functionality to Eclipse in a reliable way or should I continue to use two separate debuggers? 是否有任何插件以可靠的方式为Eclipse带来混合模式调试功能,还是应该继续使用两个单独的调试器?

For those looking to debug NDK/JNI code in the Eclipse Juno release, it is essentially built into the software after installing the Android plugins and CDT plugins. 对于那些希望在Eclipse Juno版本中调试NDK / JNI代码的人来说,它在安装Android插件和CDT插件后基本上内置于软件中。 You may have issues though since there is a problem that was introduced with the C/C++ Development tools (CDT 8.1) that as of 7/24/12 has not been fixed. 您可能遇到问题,因为C / C ++开发工具(CDT 8.1)引入了一个问题,截至7/24/12尚未修复。 For details on the issue see the following link. 有关该问题的详细信息,请参阅以下链接。 If you just want to debug, keep reading. 如果您只想调试,请继续阅读。

http://code.google.com/p/android/issues/detail?id=33788 http://code.google.com/p/android/issues/detail?id=33788

If it is working correctly, you simply set your breakpoints in the C and Debug As -> Android Native Application . 如果它正常工作,您只需在C和Debug As - > Android Native Application中设置断点。 Unfortunately, you can not debug the java and C at the same time. 不幸的是,您无法同时调试java和C. If the problem is in the Java and you want to debug you do so by clicking Debug As -> Android Application . 如果问题出在Java中并且您想要调试,请单击Debug As - > Android Application

If it is not working correctly, and you want to figure out how to get it correctly, the following packages worked for me. 如果它无法正常工作,并且您想弄清楚如何正确使用它,以下包对我有用。

  Android DDMS  20.0.1.v201207132230-403220
  Android Development Tools 20.0.1.v201207132230-403220 
  Android Hierarchy Viewer  20.0.1.v201207132230-403220 
  Android Native Development Tools  20.0.1.v201207132230-403220 
  Android Traceview 20.0.1.v201207132230-403220 
  Autotools support for CDT (Incubation)    3.0.1.201202152032  
  C/C++ Development Tools   8.0.2.201202111925  
  C/C++ Development Tools SDK   8.0.2.201202111925
  C/C++ Library API Documentation Hover Help (Incubation)   
  Eclipse SDK   4.2.0.I20120608-1400    
  Tracer for OpenGL ES  20.0.1.v201207132230-403220

The android packages came from setting Work With: option on the Eclipse Help->Install New Software... dialog to android包来自Eclipse 帮助 - >安装新软件...对话框中的设置工作:选项

dl-ssl.google.com/android/eclipse/

The older 8.02... CDT packages came from setting the Work With: option to the Indigo release packages. 较旧的8.02 ... CDT软件包来自于将Indice版本包的Work With:选项设置为。

download.eclipse.org/releases/indigo

If installed, you will need to remove the Android tools, and the new version of the CDT prior to installing the old version of the CDT. 如果已安装,则需要在安装旧版CDT之前删除Android工具和新版CDT。 Once the 8.02... version of CDT is installed, you can install the Android tools and commence debugging. 安装8.02 ...版本的CDT后,您可以安装Android工具并开始调试。

Ensure you use the Build command "ndk-build NDK_DEBUG=1" 确保使用Build命令“ndk-build NDK_DEBUG = 1”

Autotools may not be required but since it is installed I have it listed. 可能不需要Autotools,但由于它已安装,我已将其列出。

Note that stepping through the code can be quirky sometimes. 请注意,单步执行代码有时会很古怪。

I don't think there is anything available today which will fix it, but I know that Doug Schaefer has this pretty high on his list of things he wants to get done. 我认为今天没有什么东西可以修复它,但我知道Doug Schaefer在他想要完成的事情清单上有这么高的优势。 Keep an eye on his blog for updates on that. 关注他的博客 ,关注他的博客

ARM itself seems to have a toolkit: http://ds.arm.com/ds-5-community-edition/ ARM本身似乎有一个工具包: http//ds.arm.com/ds-5-community-edition/

Requires Eclipse 4.4 ("Luna"). 需要Eclipse 4.4(“Luna”)。

With the new Android ADT bundle (as of 05/12/2013), there is no longer a need for the older 8.02 software package. 使用新的Android ADT软件包(截至2013年12月5日),不再需要旧的8.02软件包。 If you find yourself editing text files to get the debugging working, you are following old directions that no longer apply. 如果您发现自己正在编辑文本文件以使调试正常工作,那么您将遵循不再适用的旧方向。 Use the android ADT and Debug As-> Android Native Application. 使用android ADT和Debug As-> Android Native Application。 You may still need to set NDK_DEBUG=1 if its not already done in the setup. 如果尚未在设置中完成,则可能仍需要设置NDK_DEBUG = 1。

Eclipse Sequoyah 1.0具有android ndk功能..Eclipse 3.6发布列车和3.5发布于6月初。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM