5

私はこれと何日も戦っていて、近づいてきましたが、まだ運がありません. 正常に動作する ndk-build NDK_DEBUG=1 を介して Android アプリをビルドしようとしています。Eclipse から起動して実行することはできますが、コマンド ラインからデバッグしたいと考えています。そのため、ndk-gdb でさまざまなアプローチを試みましたが、うまくいきませんでした。「ndk-gdb --start --nowait --verbose」、「ndk-gdb --start --verbose」、「ndk-debug」を試しましたが、何も動作しないようです。「no-wait」フラグを外すと、わずかに異なる出力が得られますが、同じエラーがポップアップします...

no-wait フラグなし:

Claudias-MacBook-Pro:Android claudia$ ndk-gdb --start --verbose
Android NDK installation path: /Applications/Intel/INDE/Framework/NDK
Using default adb command: /Applications/Intel/INDE/Framework/ADT/sdk/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.31
Using ADB flags: 
Using JDB command: /usr/bin/jdb
Using auto-detected project path: .
Found package name: com.yourcompany.neckrowfish
ABIs targetted by application: armeabi armeabi-v7a
Device API Level: 19
Device CPU ABIs: x86 armeabi-v7a
Compatible device ABI: armeabi-v7a
Using gdb setup init: ./libs/armeabi-v7a/gdb.setup
Using toolchain prefix: /Applications/Intel/INDE/Framework/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-
Using app out directory: ./obj/local/armeabi-v7a
Found debuggable flag: true
Found data directory: '/data/data/com.yourcompany.neckrowfish'
Found device gdbserver: /data/data/com.yourcompany.neckrowfish/lib/gdbserver
Found first launchable activity: .neckrowfish
Launching activity: com.yourcompany.neckrowfish/.neckrowfish
## COMMAND: adb_cmd shell am start -D -n com.yourcompany.neckrowfish/.neckrowfish
Starting: Intent { cmp=com.yourcompany.neckrowfish/.neckrowfish }
## COMMAND: adb_cmd shell sleep 2
Found running PID: 17094
Launched gdbserver succesfully.
Setup network redirection
## COMMAND: adb_cmd forward tcp:5039 localfilesystem:/data/data/com.yourcompany.neckrowfish/debug-socket
## COMMAND: adb_cmd shell run-as com.yourcompany.neckrowfish /data/data/com.yourcompany.neckrowfish/lib/gdbserver +debug-socket --attach 17094
## COMMAND: adb_cmd pull /system/bin/app_process ./obj/local/armeabi-v7a/app_process
Cannot attach to lwp 17094: Function not implemented (38)

Exiting
2859 KB/s (12780 bytes in 0.004s)
Pulled app_process from device/emulator.
## COMMAND: adb_cmd pull /system/bin/linker ./obj/local/armeabi-v7a/linker
5510 KB/s (183465 bytes in 0.032s)
Pulled linker from device/emulator.
## COMMAND: adb_cmd pull /system/lib/libc.so ./obj/local/armeabi-v7a/libc.so
3730 KB/s (824333 bytes in 0.215s)
Pulled libc.so from device/emulator.
Setup JDB connection
## COMMAND: adb_cmd forward tcp:65534 jdwp:17094
java.io.IOException: handshake failed - connection prematurally closed
    at com.sun.tools.jdi.SocketTransportService.handshake(SocketTransportService.java:118)
    at com.sun.tools.jdi.SocketTransportService.attach(SocketTransportService.java:214)
    at com.sun.tools.jdi.GenericAttachingConnector.attach(GenericAttachingConnector.java:98)
    at com.sun.tools.jdi.SocketAttachingConnector.attach(SocketAttachingConnector.java:72)
    at com.sun.tools.example.debug.tty.VMConnection.attachTarget(VMConnection.java:358)
    at com.sun.tools.example.debug.tty.VMConnection.open(VMConnection.java:168)
    at com.sun.tools.example.debug.tty.Env.init(Env.java:64)
    at com.sun.tools.example.debug.tty.TTY.main(TTY.java:1010)

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>.
./obj/local/armeabi-v7a/gdb.setup:4: Error in sourced command file:
Remote connection closed
(gdb) 

これにより、Androidデバイスで「デバッガーを待っています」という通知が発生するため、次のフラグを取得します。

Claudias-MacBook-Pro:Android claudia$ ndk-gdb --start --nowait --verbose
Android NDK installation path: /Applications/Intel/INDE/Framework/NDK
Using default adb command: /Applications/Intel/INDE/Framework/ADT/sdk/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.31
Using ADB flags: 
Using JDB command: /usr/bin/jdb
Using auto-detected project path: .
Found package name: com.yourcompany.neckrowfish
ABIs targetted by application: armeabi armeabi-v7a
Device API Level: 19
Device CPU ABIs: x86 armeabi-v7a
Compatible device ABI: armeabi-v7a
Using gdb setup init: ./libs/armeabi-v7a/gdb.setup
Using toolchain prefix: /Applications/Intel/INDE/Framework/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-
Using app out directory: ./obj/local/armeabi-v7a
Found debuggable flag: true
Found data directory: '/data/data/com.yourcompany.neckrowfish'
Found device gdbserver: /data/data/com.yourcompany.neckrowfish/lib/gdbserver
Found first launchable activity: .neckrowfish
Launching activity: com.yourcompany.neckrowfish/.neckrowfish
## COMMAND: adb_cmd shell am start -n com.yourcompany.neckrowfish/.neckrowfish
Starting: Intent { cmp=com.yourcompany.neckrowfish/.neckrowfish }
Warning: Activity not started, its current task has been brought to the front
## COMMAND: adb_cmd shell sleep 2
Found running PID: 17094
Launched gdbserver succesfully.
Setup network redirection
## COMMAND: adb_cmd forward tcp:5039 localfilesystem:/data/data/com.yourcompany.neckrowfish/debug-socket
## COMMAND: adb_cmd shell run-as com.yourcompany.neckrowfish /data/data/com.yourcompany.neckrowfish/lib/gdbserver +debug-socket --attach 17094
## COMMAND: adb_cmd pull /system/bin/app_process ./obj/local/armeabi-v7a/app_process
Cannot attach to lwp 17094: Function not implemented (38)

Exiting
2539 KB/s (12780 bytes in 0.004s)
Pulled app_process from device/emulator.
## COMMAND: adb_cmd pull /system/bin/linker ./obj/local/armeabi-v7a/linker
4498 KB/s (183465 bytes in 0.039s)
Pulled linker from device/emulator.
## COMMAND: adb_cmd pull /system/lib/libc.so ./obj/local/armeabi-v7a/libc.so
2676 KB/s (824333 bytes in 0.300s)
Pulled libc.so from device/emulator.
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>.
./obj/local/armeabi-v7a/gdb.setup:4: Error in sourced command file:
Remote connection closed
(gdb) 

誰かが私の問題が何であるか手がかりを持っていますか?? ありがとうございました!!

4

2 に答える 2

3

試してください - ndk-gdb.py

この問題はかなり一般的なようです。私の解決策は、ndk-gdb提供された bash スクリプトを使用しないことでした。いずれにせよ、bash スクリプトは機能しませんでしたが、python バージョンは機能しました。

python バージョンは、NDK の最新バージョンに含まれている可能性がありますが、含まれていない場合は、 NDK ソースmasterのブランチから取得できます。

次の場所で複製できます。

git clone https://android.googlesource.com/platform/ndk

ファイルを取り出してndk-gdb.py、NDK フォルダーに配置します。この記事の執筆時点では、brewを使用して NDK の r10c をインストールしていたため、NDK は/usr/local/opt/android-ndk.

  1. ndk-buildデバッグ フラグを指定して呼び出します。

    ndk-build clean all NDK_DEBUG=1

  2. アプリを再インストールします。

  3. gdb を使用して起動します。

    ndk-gdb.py --start --verbose --project=/dir/with/android/xml

Eclipse が開いている場合は、デバッガーが起動していることに気付くはずです。

于 2014-11-03T15:31:00.573 に答える
3

あなたが試すことができます:

ndk-gdb --start --verbose --force --nowait

わたしにはできる

于 2015-02-05T13:48:32.440 に答える