Я использую ndk-r9, и я изо всех сил пытаюсь заставить ndk-gdb работать для меня. Я начал небольшое андроидное приложение под названием «LittlestAndroid», которое делает простой вызов собственного C++-метода, который возвращает строчную строку. Приложение строит/устанавливает/работает просто отлично. Теперь я перепрограммирую приложение, чтобы узнать о ndk-gdb. Я установил debuggable = "true" в манифесте. Я установил эти окр вары в моей марки:Android Отладка собственного кода
APP_OPTIM=debug
LOCAL_CFLAGS := -g
и я взломал/сборки/ядро / build-binary.mk файл $ NDK_HOME условно раздеть символы отладки, используя следующие:
$(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.
Я пропустил что-то или что-то не так? В любом случае я не могу заставить отладчик подключиться и/или возобновить выполнение моего приложения. Я также попытался установить точки останова после запуска НДК-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)
Кто-нибудь когда-нибудь успешно запустить НДК-GDB и если да вы могли бы дать указания? Я googled повсюду, но я не мог найти ничего, кроме самых простых уроков, и ничто не углублялось в объяснение того, как фактически устанавливать точки останова (я использую относительные пути к моему cpp, как указано выше, или просто указать имя базы данных?) Или как для устранения ошибок, которые я вижу.
UPDATE Я только что нашел this question, который, кажется, указывает на проблему в НДК-r9. Я загружу более раннюю версию и сделаю снимок.
Такая же проблема здесь с Moto G 2-gen и Android Studio/JDK. – Kamil
Да, проблема в наборе инструментов. Я не пробовал в последнее время, но я надеялся, что они исправят это в последнем обновлении. – Cliff
Ну, они этого не сделали. Я использую последний SDK. – Kamil