2013-09-29 97 views
4

我正在使用ndk-r9,我正在努力让ndk-gdb为我工作。我开始了一个名为“LittlestAndroid”的小型Android应用程序,它可以简单地调用返回硬编码字符串的本地C++方法。该应用程序构建/安装/运行得很好。现在我正在重新调整应用程序以了解ndk-gdb。我在清单中设置了debuggable =“true”。我已经设定这些ENV在我的化妆瓦尔:Android调试本机代码

APP_OPTIM=debug 
LOCAL_CFLAGS := -g 

,我已经破解了$ NDK_HOME /编译/核心/ build-binary.mk文件使用有条件剥离调试符号如下:

$(LOCAL_INSTALLED): $(LOCAL_BUILT_MODULE) clean-installed-binaries 
    @$(HOST_ECHO) "Install  : $(PRIVATE_NAME) => $(call pretty-dir,$(PRIVATE_DST))" 
    $(hide) $(call host-install,$(PRIVATE_SRC),$(PRIVATE_DST)) 
# $(hide) $(PRIVATE_STRIP_CMD) 
# CCC Modifications start 
ifneq ($(APP_OPTIM),debug) 
    @ $(HOST_ECHO) "Stripping the library for the release mode....." 
    $(hide) $(PRIVATE_STRIP_CMD) 
endif 
# CCC Modifications end 
#$(hide) $(PRIVATE_OBJCOPY_CMD) 

$(call generate-file-dir,$(LOCAL_INSTALLED)) 

endif 

当我尝试调试对抗模拟器我得到这个:

~/workspace/LittlestAndroid$ ndk-gdb -s emulator-5554 --start 
java.io.IOException: handshake failed - connection prematurally closed 
    at com.sun.tools.jdi.SocketTransportService.handshake(SocketTransportService.java:136) 
    at com.sun.tools.jdi.SocketTransportService.attach(SocketTransportService.java:232) 
    at com.sun.tools.jdi.GenericAttachingConnector.attach(GenericAttachingConnector.java:116) 
    at com.sun.tools.jdi.SocketAttachingConnector.attach(SocketAttachingConnector.java:90) 
    at com.sun.tools.example.debug.tty.VMConnection.attachTarget(VMConnection.java:519) 
    at com.sun.tools.example.debug.tty.VMConnection.open(VMConnection.java:328) 
    at com.sun.tools.example.debug.tty.Env.init(Env.java:63) 
    at com.sun.tools.example.debug.tty.TTY.main(TTY.java:1066) 

Fatal error: 
Unable to attach to target VM. 
GNU gdb (GDB) 7.3.1-gg2 
Copyright (C) 2011 Free Software Foundation, Inc. 
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 
This is free software: you are free to change and redistribute it. 
There is NO WARRANTY, to the extent permitted by law. Type "show copying" 
and "show warranty" for details. 
This GDB was configured as "--host=x86_64-apple-darwin --target=arm-linux-android". 
For bug reporting instructions, please see: 
<http://source.android.com/source/report-bugs.html>. 
warning: Could not load shared library symbols for 66 libraries, e.g. libstdc++.so. 
Use the "info sharedlibrary" command to see the complete listing. 
Do you need "set solib-search-path" or "set sysroot"? 
warning: Breakpoint address adjusted from 0x40005a53 to 0x40005a52. 
0x400380e0 in __futex_syscall3() from /Users/clifton/workspace/LittlestAndroid/obj/local/armeabi/libc.so 
(gdb) quit 
A debugging session is active. 

    Inferior 1 [Remote target] will be detached. 

Quit anyway? (y or n) y 
Ending remote debugging. 

辞职,并试图再次GDB连接(无需点击“强制关闭”在模拟器上)我得到这个后:

~/workspace/LittlestAndroid$ ndk-gdb -s emulator-5554 
GNU gdb (GDB) 7.3.1-gg2 
Copyright (C) 2011 Free Software Foundation, Inc. 
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 
This is free software: you are free to change and redistribute it. 
There is NO WARRANTY, to the extent permitted by law. Type "show copying" 
and "show warranty" for details. 
This GDB was configured as "--host=x86_64-apple-darwin --target=arm-linux-android". 
For bug reporting instructions, please see: 
<http://source.android.com/source/report-bugs.html>. 
warning: Could not load shared library symbols for 66 libraries, e.g. libstdc++.so. 
Use the "info sharedlibrary" command to see the complete listing. 
Do you need "set solib-search-path" or "set sysroot"? 
warning: Breakpoint address adjusted from 0x40005a53 to 0x40005a52. 
0x400380e0 in __futex_syscall3() from /Users/clifton/workspace/LittlestAndroid/obj/local/armeabi/libc.so 
(gdb) c 
Continuing. 

我错过了什么或做错了什么?在这两种情况下,我都无法让调试器连接和/或继续执行我的应用程序。我也试着开始NDK-GDB后设置断点,但我得到以下几点:

(gdb) b libs/info.cpp:7 
No symbol table is loaded. Use the "file" command. 
Make breakpoint pending on future shared library load? (y or [n]) y 
Breakpoint 1 (libs/info.cpp:7) pending. 
(gdb) 

有没有人成功运行NDK-gdb的,如果这样你可以提供指导?我已经搜遍了所有的东西,但除了最基本的教程之外我什么都没发现,没有深入的解释如何真正设置断点(如上所述,我是否使用相对路径指向我的cpp,或者只是指出文件基本名称?解决我所看到的错误。

UPDATE 我刚刚发现this question这似乎表明在NDK-R9的问题。我会下载一个较早的版本并给它一个镜头。

回答

2

是的,最新的ndk-r9调试工具确实存在问题。降级至修订版8e后,所有内容似乎都能像广告一样工作。

更新

我只是尝试了最新9D NDK和问题依然存在,虽然错误是稍有不同。我试图在运行4.4的摩托罗拉G上调试我的应用程序,调试器抛出一个套接字错误,试图建立连接。

第二次更新 我在想这个古老的问题,想知道NDK是否与特定操作系统有亲和力。换句话说,最新的NDK版本是否适用于以后的操作系统?我在4.4上试过V9,但失败了,但是9会在5.0或5.5上运行?食物的思考...

+0

与Moto G 2-gen和Android Studio/JDK在这里一样的问题。 – Kamil

+0

是的问题出现在工具集中。我最近没有尝试,但我希望他们能够在最新的更新中修复它。 – Cliff

+0

呃,他们没有。我使用最新的SDK。 – Kamil

相关问题