如何使用NDK-GDB调试本地code [英] How to Debug native code using ndk-gdb

查看:165
本文介绍了如何使用NDK-GDB调试本地code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我运行后 NDK-GDB据很多教程,当它链接到你(GDB) 服务器,您需要输入继续但什么之后如何到那里后,调试code。在我的情况下,它会显示继续,并保持这个样子。我有什么做进一步的我完全无能。

This is what I am getting after running ndk-gdb according to many tutorials when it links to you to (gdb) server you have to type continue but what after that how to debug the code there after. In my case it displays Continuing and remain like this. WHat i have to do further I am totally clueless.

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-文档

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

如何做到这一点。

How to make this happen.

推荐答案

的命令是一样的gdb。一个基本的底漆:

The commands are the same as in gdb. A basic primer:


  • 输入设置断点 B&lt;作用名称&gt; B&LT;文件&gt;:&LT;行号&GT;

  • 步入功能通过键入取值

  • 转到下一行键入 N

  • 继续执行ç

  • 打印变量或前pression值为打印&LT;&EXP GT;

  • 只需按下回车键
  • 重复上一次输入的命令
  • Set a breakpoint by entering b <function name> or b <file>:<line number>
  • step into functions by typing s
  • go to next line by typing n
  • continue execution with c
  • print a variable or expression value with print <exp>
  • repeat the last typed command by just hitting enter

您可以找到更多的COM prehensive gdb的在线教程。我个人有一个GDB的cheatsheet打印出​​来,并贴在墙上。这应该足以让你开始。

You can find much more comprehensive gdb tutorials online. I personally have a gdb cheatsheet printed out and posted on my wall. This should be enough to get you started.

这篇关于如何使用NDK-GDB调试本地code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆