gpt4 book ai didi

android - 如何使用 ndk-gdb 调试 native 代码

转载 作者:太空宇宙 更新时间:2023-11-03 13:27:19 25 4
gpt4 key购买 nike

这是我根据许多教程运行 ndk-gdb 后得到的结果,当它链接到 (gdb) 服务器时,您必须键入 continue 但是在那之后如何调试代码。在我的例子中,它显示 Continuing 并保持这样。我完全不知道我还需要做什么。

Arathore@chd-arathore-AND /cygdrive/d/All_Work/All_ARathore/All_Workspace_Practice/ndkfoo
$ /cygdrive/d/All_Required_Stuff/Android/android-ndk-r8e/ndk-gdb --verbose --adb=/cygdrive/D/All_Required_Stuff/Android/android-sdk-windows/platform-tools/adb.exe
Android NDK installation path: /cygdrive/d/All_Required_Stuff/Android/android-ndk-r8e
Using specific adb command: /cygdrive/D/All_Required_Stuff/Android/android-sdk-windows/platform-tools/adb.exe
ADB version found: Android Debug Bridge version 1.0.31
Using ADB flags:
Using auto-detected project path: .
Found package name: com.example.ndkfoo
/cygdrive/d/All_Required_Stuff/Android/android-ndk-r8e/build/core/add-application.mk:128: Android NDK: WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion 8 in /cygdrive/d/All_Work/All_ARathore/All_Workspace_Practice/ndkfoo/AndroidManifest.xml
ABIs targetted by application: armeabi
Device API Level: 17
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi
/cygdrive/d/All_Required_Stuff/Android/android-ndk-r8e/build/core/add-application.mk:128: Android NDK: WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion 8 in /cygdrive/d/All_Work/All_ARathore/All_Workspace_Practice/ndkfoo/AndroidManifest.xml
Using gdb setup init: /cygdrive/d/All_Work/All_ARathore/All_Workspace_Practice/ndkfoo/libs/armeabi/gdb.setup
/cygdrive/d/All_Required_Stuff/Android/android-ndk-r8e/build/core/add-application.mk:128: Android NDK: WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion 8 in /cygdrive/d/All_Work/All_ARathore/All_Workspace_Practice/ndkfoo/AndroidManifest.xml
Using toolchain prefix: /cygdrive/d/All_Required_Stuff/Android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-
/cygdrive/d/All_Required_Stuff/Android/android-ndk-r8e/build/core/add-application.mk:128: Android NDK: WARNING: APP_PLATFORM android-14 is larger than android:minSdkVersion 8 in /cygdrive/d/All_Work/All_ARathore/All_Workspace_Practice/ndkfoo/AndroidManifest.xml
Using app out directory: ./obj/local/armeabi
Found debuggable flag: true
Found device gdbserver: /data/data/com.example.ndkfoo/lib/gdbserver
Found data directory: '/data/data/com.example.ndkfoo'
Found running PID: 1106
Launched gdbserver succesfully.
Setup network redirection
## COMMAND: adb_cmd shell run-as com.example.ndkfoo lib/gdbserver +debug-socket --attach 1106
## COMMAND: adb_cmd forward tcp:5039 localfilesystem:/data/data/com.example.ndkfoo/debug-socket
## COMMAND: adb_cmd pull /system/bin/app_process obj/local/armeabi/app_process
Attached; pid = 1106
Listening on Unix socket debug-socket
99 KB/s (9592 bytes in 0.093s)
Pulled app_process from device/emulator.
## COMMAND: adb_cmd pull /system/bin/linker obj/local/armeabi/linker
54 KB/s (63240 bytes in 1.140s)
Pulled linker from device/emulator.
## COMMAND: adb_cmd pull /system/lib/libc.so obj/local/armeabi/libc.so
75 KB/s (297604 bytes in 3.828s)
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=i586-pc-mingw32msvc --target=arm-linux-android".
For bug reporting instructions, please see:
<http://source.android.com/source/report-bugs.html>.
Remote debugging from host 0.0.0.0
libthread_db:td_ta_new: Probing system for platform bug.
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1147/task/1147/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1106/task/1106/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1106/task/1109/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1106/task/1111/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1106/task/1112/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1106/task/1113/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1106/task/1114/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1106/task/1115/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1106/task/1116/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1106/task/1117/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/1106/task/1118/status
libthread_db:td_ta_new: Victory: We can debug theads!
0x40037ebc in epoll_wait () from D:/All_Work/All_ARathore/All_Workspace_Practice/ndkfoo/obj/local/armeabi/libc.so
warning: Could not load shared library symbols for 72 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.
(gdb) continue
Continuing.

如何调试?

根据ndk-Docs

You can set breakpoints with 'b <location>' and resume execution with 'c'
(for 'continue'). See the GDB manual for a list of commands.

如何做到这一点。

最佳答案

命令与 gdb 中的命令相同。基础入门:

  • 输入 b <function name> 设置断点或 b <file>:<line number>
  • 通过键入 s 进入函数
  • 输入 n 转到下一行
  • 继续执行 c
  • print <exp>打印一个变量或表达式值
  • 只需按回车即可重复上次输入的命令

您可以在线找到更全面的 gdb 教程。我个人打印了一份 gdb 备忘单并张贴在我的墙上。这应该足以让您入门。

关于android - 如何使用 ndk-gdb 调试 native 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17593284/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com