How can I effectively debug C code that#39;s wrapped with JNI in Eclipse? (Android Dev)(如何在 Eclipse 中有效地调试用 JNI 包装的 C 代码?(安卓开发))
问题描述
我有一个段错误,但我完全不知道如何找到它.
I've got a segfault but I have absolutely no idea how to locate it.
提示?
推荐答案
可以使用Android NDK Stacktrace Analyzer.
这些步骤在 wiki 上,但是基本上你需要从 logcat 获取堆栈跟踪到一个文件 (adb 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.
这篇关于如何在 Eclipse 中有效地调试用 JNI 包装的 C 代码?(安卓开发)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Eclipse 中有效地调试用 JNI 包装的 C 代码
基础教程推荐
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
