2013-09-29 4 views
4

저는 ndk-r9를 사용하고 있습니다. ndk-gdb를 작동 시키려고 애 쓰고 있습니다. 하드 코딩 된 문자열을 반환하는 네이티브 C++ 메서드에 대한 간단한 호출을 만드는 "LittlestAndroid"라는 작은 안드로이드 응용 프로그램을 시작했습니다. 응용 프로그램 빌드/설치/잘 실행합니다. 이제는 앱을 사용하여 ndk-gdb에 대해 배울 수 있습니다. 매니페스트에 debuggable = "true"를 설정했습니다. 나는이 ENV 내 메이크업에 바르 설정 한 :안드로이드 네이티브 코드 디버그

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 
을 종료 내가이 얻을 (에뮬레이터에 "강제 종료"를 클릭하지 않고) 다시 GDB 연결을 시도하면

~/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. 

: 나는 에뮬레이터에 대해 디버깅 할 때

나는이 얻을

~/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 난 그냥 NDK-R9에 문제가있는 것으로 보인다 this question을 발견했다. 나는 이전 버전을 다운로드하고 그것을 제공 할 것이다.

답변

2

예, 최신 ndk-r9 디버깅 도구에는 문제가 있습니다. 개정판 8e로 다운 그레이드 한 후 모든 것이 광고 된대로 작동하는 것 같습니다.

업데이트

난 그냥 최신 9D NDK를 시도하고 오류가 약간 다릅니다하지만 문제는 여전히 존재한다. 내가 실행중인 Motorola G에서 4.4 디버깅을 시도했는데 디버거가 소켓 오류를 던져서 연결을 시도했다.

두 번째 업데이트 NDK가 특정 OS에 친화적인지 궁금한이 고대 문제에 대해 생각해 보았습니다. 즉, 최신 NDK 버전은 이후 OS와 함께 작동합니까? 나는 4.4에서 V9를 시도했지만 실패했으나 5.0이나 5.5에서 9가 작동 할까? 생각을위한 음식 ...

+0

Moto G 2-gen 및 Android Studio/JDK와 동일한 문제가 있습니다. – Kamil

+0

예, 문제가 툴셋에 있습니다. 최근에 시도한 적은 없지만 최신 업데이트에서 해결할 수 있기를 바랍니다. – Cliff

+0

글쎄, 그들은하지 않았다. 최신 SDK를 사용하고 있습니다. – Kamil

관련 문제