繁体   English   中英

如何使用ndk-gdb调试本机代码

[英]How to Debug native code using ndk-gdb

这是我在运行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>打印变量或表达式值
  • 只需按Enter即可重复上一个键入的命令

您可以在线找到更全面的gdb教程。 我亲自打印出一张gdb cheatsheet贴在我的墙上。 这应该足以让你入门。

教程将向您展示如何在eclipse中使用ndk-gdb进行调试。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM