我怎样才能有效地调试多数民众赞成包裹着JNI在Eclipse C code吗? (Android开发)有效地、裹着、民众、JNI

2023-09-12 08:43:27 作者:与昨日相同

我有段错误,但我完全不知道如何找到它。

I've got a segfault but I have absolutely no idea how to locate it.

提示?

Tips?

推荐答案

您可以得到使用的的Andr​​oid NDK堆栈跟踪分析。

本步骤是在维基,但基本上你需要从logcat的堆栈跟踪到一个文件中(亚行logcat> mycrash.log ),然后倾倒你的库到一个文本文件,然后在两个运行程序对他们。这里的shell脚本我用来做很多的:

The steps are on the wiki, but basically you need to get the stack trace from logcat into a file (adb logcat > mycrash.log), then dump your library to a text file, then run the program on the two of them. Here's the shell script I use to do the lot:

#!/bin/sh
if test $# -lt 2 ; then
    echo "Extract readable stack trace from Android logcat crash"
    echo "Usage $0 lib.so crash.log"
    exit 1
fi
of=$(mktemp)
echo "Disassemble $1"
~/tools/android-ndk-r5/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-objdump -S $1 > $of
echo "Parse stack trace in $2"
~/bin/parse_stack.py $of $2

更改路径到Android NDK和parse_stack.py文件,因为你需要。

Change the paths to the Android NDK and parse_stack.py file as you need.