调试混合JNI代码的方法

Way to debug mixed JNI code?

本文关键字:方法 代码 JNI 混合 调试      更新时间:2023-10-16

我一直在寻找一种简单的方法来调试我的JNI代码,你知道,能够自由地跳转到本机代码和返回到java代码。

我找到的解决方案有点过时或有一些限制。有些需要特定的ndk版本,有些需要特定的Eclipse版本。这里我的目标是Android 1.6;2.2,我使用Eclipse 3.6 Helios,和NDK r5b。对于这种混合调试是否有一个通用的解决方案?Thx .

引用自$NDK/docs/NDK-GDB.html:

重要:本机调试只能在所有条件满足的情况下工作:

1. Your application is built with the 'ndk-build' script:
    Building with the legacy "make APP=<name>" method is not
    supported by ndk-gdb.
2. Your application is debuggable:
    In other words, your AndroidManifest.xml has an <application>
    element that sets the android:debuggable attribute to "true"
3. You are running your application on Android 2.2 (or higher):
    ndk-gdb will not work if you try to run your application on
    previous versions of the system. That does not mean that your
    application should target the Android 2.2. API level, just
    that the debugging session should happen on a 2.2+ device or
    emulator system image.

所以,你不能使用1.6的设备。

如何设置环境来调试jni代码:我使用了这个配方,它适用于我。