easiest way to debug crash in native library, linked by Android app?

前端 未结 5 1063
太阳男子
太阳男子 2021-02-06 00:53

I have ported and created several low-level C-libraries to Android for my use in my application. I cross-compiled them using the NDK, and then link to them using System.loadLib

相关标签:
5条回答
  • 2021-02-06 01:12

    You can use the sequoyah project via eclipse to debug native code, it was a real pain for me to set this up and get it to work, I don't remember all the steps, but it's doable

    0 讨论(0)
  • 2021-02-06 01:15

    Use ARM CE5 Community edition tools for eclipse and can debug any native code

    0 讨论(0)
  • 2021-02-06 01:20

    I have asked something like this How to compile library with source code with NDK tools? My suggestion is deassembling with source code, then everything will be easy.

    0 讨论(0)
  • 2021-02-06 01:34

    Try using NDK-STACK with the logcat output, it will at least tell you what file is the culprit and also the function.

    https://developer.android.com/ndk/guides/ndk-stack

    0 讨论(0)
  • 2021-02-06 01:35

    If your application is truly crashing in native code, I highly recommend the following:

    1. Set a java breakpoint that will be hit after your native library has been loaded but before it starts executing.
    2. Go to the terminal and launch the ndk's version of gdb (it's called "ndk-gdb"). Initially, just type "c" to continue.
    3. Back in java, continue execution.
    4. Once your app crashes, gdb will pause and you can examine the integrity of the stack in native code via the "bt" command (backtrace).

    At any rate, you should be able to fully debug native code and catch problems via ndk-gdb. You can find specific documentation on the ndk's version of gdb in your local installation of the ndk (for example, on my machine it's here):

    android-ndk-r6/documentation.html

    Finally, here's a basic tutorial on gdb:

    gdb tutorial

    Hope this helps!

    0 讨论(0)
提交回复
热议问题