在Cygwin下能不能使用Android NDK包里面的ndk-gdb命令对so库文件进行调试?
解决方案 »
- 碉堡了,居然OutOfMemoryError了
- 一个类继承于Application,启动应用的时候,这个类是什么时候创建的呢?
- 紧急求助QQ微博列表长按效果的实现原理
- 關於com.google.android.maps.MyLocationOverlay 問題
- 在页面上,利用滑动手势,手指在屏幕上,由左至右滑动,也能能调出。同理,由右至左,也可以收起。
- 求大神Android framework中的Camera.java中想实例一个context
- service怎么向Activity传值
- Android 中的 Button 按钮 点击后反映慢 甚至没有反映 点击几次才成功
- ListView和RecycleView显示问题
- 安卓开发数据库数据统计怎么实现?
- 关于ListView中CheckBox 用程序全选的问题
- jqmobile data-rel
http://blog.csdn.net/xqhrs232/article/details/7612745原文地址::E:\DirectX\Android_NDK_JNI\android-ndk-r5-windows\android-ndk-r5\documentation.html 'ndk-gdb' OverviewIMPORTANT: IF YOU ARE DEBUGGING THREADED PROGRAMS, PLEASE READ THE
SECTION BELOW TITLED 'Thread Support'.I. Usage:
---------The Android NDK r4 introduced a helper shell script named 'ndk-gdb' to
easily launch a native debugging session for your NDK-generated machine code.The script is located at the top-level directory of the NDK, and shall
be invoked from the command-line when in your application project
directory, or any of its sub-directories. For example: cd $PROJECT
$NDK/ndk-gdbWhere $NDK points to your NDK installation path. You can also create an
alias or add $NDK to your PATH to avoid typing it every time.IMPORTANT: Native debugging can only work if *all* these conditions are met: 1. Your application is built with the 'ndk-build' script: Building with the legacy "make APP=<name>" method is not
supported by ndk-gdb. 2. Your application is debuggable: In other words, your AndroidManifest.xml has an <application>
element that sets the android:debuggable attribute to "true" 3. You are running your application on Android 2.2 (or higher): ndk-gdb will not work if you try to run your application on
previous versions of the system. That does not mean that your
application should target the Android 2.2. API level, just
that the debugging session should happen on a 2.2+ device or
emulator system image. IMPORTANT IMPORTANT IMPORTANT !! If you are using the ADT Eclipse plug-in to build your
application, make sure you're using version 0.9.7 or
later. If you are using the 'ant' build tool, make sure that you
have the latest revision of the SDK Platform components.
The following minimal revisions are required: Android 1.5 r4
Android 1.6 r3
Android 2.1 r2
Android 2.2 r1 These should be available through the SDK updater. If these conditions are not met, the generated .apk will
not contain required support files and native debugging
will not be possible.'ndk-gdb' handles many error conditions and will dump an informative error
message if it finds a problem. For example, it: - checks that adb is in your path. - checks that your application is declared debuggable in its manifest. - checks that, on the device, the installed application with the same
package name is also debuggable.
By default, ndk-gdb will search for an already-running application process,
and will dump an error if it doesn't find one. You can however use the --start
or --launch=<name> option to automatically start your activity before the
debugging session.When it successfully attaches to your application process, ndk-gdb will give
you a normal GDB prompt, after setting up the session to properly look for
your source files and symbol/debug versions of your generated native
libraries.You can set breakpoints with 'b <location>' and resume execution with 'c'
(for 'continue'). See the GDB manual for a list of commands.IMPORTANT: When quitting the GDB prompt, your debugged application process
will be stopped! This is a gdb limitation.IMPORTANT: The GDB prompt will be preceded by a long list of error messages,
where gdb complains that it cannot find various system libraries
(e.g. libc.so, libstdc++.so, liblog.so, libcutils.so, etc...) This is normal, because there are no symbol/debug versions of
these libraries corresponding to your target device on your
development machine. You can safely ignore these messages.II. Options:
------------To see a list of options, type 'ndk-gdb --help'. Notable ones are: --verbose:
Print verbose information about the native debugging session setup.
Only needed to debug problems when you can't connect and that the
error messages printed by ndk-gdb are not enough. --force:
By default, ndk-gdb aborts if it finds that another native debugging
session is running on the same device. Using --force will kill the
session, and replace it with a new one. Note that the debugged program
is *not* killed and will be stopped again. --start:
By default, ndk-gdb will try to attach to an existing running instance
of your application on the target device. You can use --start to
explicitly launch your application before the debugging session. NOTE: This launches the first launchable activity listed from your
application manifest. Use --launch=<name> to start another one.
See --launch-list to dump the list of such activities. --launch=<name>:
This is similar to --start, except that it allows you to start a specific
activity from your application. This is only useful if your manifest
defines several launchable activities. --launch-list:
Convenience option that prints the list of all launchable activity names
found in your application manifest. The first one will be used by --start --project=<path>:
Specify application project directory. Useful if you want to launch
the script without cd-ing to the directory before that. --port=<port>:
By default, ndk-gdb will use local TCP port 5039 to communicate with
the debugged application. By using a different port, it is possible
to natively debug programs running on different devices/emulators
connected to the same development machine. --adb=<file>:
Specify the adb tool executable, in case it is not in your path. -d, -e, -s <serial>:
These flags are similar to the ADB ones and allow you to handle the
case where you have several devices/emulators connected to your
development machine. -d: Connect to a single physical device
-e: Connect to a single emulator device
-s <serial>: Connect to a specific device or emulator
where <serial> is the device's name as listed
by the "adb devices" command. Alternatively, you can define the ADB_SERIAL environment variable
to list a specific device, without the need for a specific option. --exec=<file>:
-x <file>:
After connecting to the debugged process, run the GDB initialization
commands found in <file>. This is useful if you want to do something
repeatedly, e.g. setting up a list of breakpoints then resuming
execution automatically.
III. Requirements:
------------------At the moment 'ndk-gdb' requires a Unix shell to run. This means that
Cygwin is required to run it on Windows. We hope to get rid of this
limitation in a future NDK release.The other NDK requirements apply: e.g. GNU Make 3.81 or higher.
IV. Thread Support:
-------------------If your application runs on a platform older than Android 2.3, ndk-gdb will
not be able to debug native threads properly. Instead, the debugger will only
be able to put breakpoints on the main thread, completely ignoring the
execution of other ones.The root of the problem is complex, but is essentially due to a very unfortunate
bug in the platform, which was only discovered lately.The gdbserver binary that comes with this NDK has special code to detect this
condition at runtime and adapt its behaviour automatically (in other words,
you don't have anything special to do when building your code).What this means in practical terms are:- If you are on Android 2.3, or a prior platform release which has had the
platform bugfix back-ported to it, you will be able to debug native
threads automatically.- If you are not, you will only be able to debug the main thread
(as in previous NDK releases). You will also see the following message
when launching ndk-gdb (just before the gdb prompt): Thread debugging is unsupported on this Android platform! If you place a breakpoint on a function executed on a non-main thread, the
program will exit with the following message in GDB: Program terminated with signal SIGTRAP, Trace/breakpoint trap.
The program no longer exists.
http://blog.chinaunix.net/space.php?uid=8272118&do=blog&id=2033358&page=1
http://vilimpoc.org/blog/2010/09/23/hello-gdbserver-a-debuggable-jni-example-for-android/
http://forum.openframeworks.cc/index.php?topic=8555.0Not able to attach the ndk-gdb to the android application
http://stackoverflow.com/questions/8266852/not-able-to-attach-the-ndk-gdb-to-the-android-application很多时候可以使用$ $NDK/ndk-gdb --verbose进行调试
--verbose:
Print verbose information about the native debugging session setup.
Only needed to debug problems when you can't connect and that the
error messages printed by ndk-gdb are not enough.
$ $NDK/ndk-gdb --verbose
Android NDK installation path: /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5
Using default adb command: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.29
Using final ADB command: '/cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb'
Using auto-detected project path: .
Found package name: com.KT.NDKOpenGL_Test
ABIs targetted by application: armeabi
Device API Level: 10
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi
Found debuggable flag: true
Found device gdbserver: /data/data/com.KT.NDKOpenGL_Test/lib/gdbserver: No such file or directory
ERROR: Non-debuggable application installed on the target device.
Please re-install the debuggable version!如何解决上面的问题----把NDK下设置NDK_DEBUG=1编译开关多编译出来的gdb.setup及gdbserver文件跟SO库文件一样一起COPY到APK的LIBS的目录下!!!
http://forum.openframeworks.cc/index.php?topic=8555.0
$ /c/Development/android-ndk-r6b-custom/ndk-gdb --verbose
Android NDK installation path: /c/Development/android-ndk-r6b-custom
Using default adb command: /c/Development/android-sdk/platform-tools/adb.exe
ADB version found: Android Debug Bridge version 1.0.29
Using final ADB command: '/c/Development/android-sdk/platform-tools/adb.exe'
Using auto-detected project path: .
Found package name: com.AB.NB
ABIs targetted by application: armeabi
Device API Level: 8
Device CPU ABI: armeabi
Compatible device ABI: armeabi
Found debuggable flag: true
Found device gdbserver: //data/data/com.AB.NB/lib/gdbserver
Using gdb setup init: /e/projects/AB/NB/trunk/OF/apps/android/No
deBeatPhone/libs/armeabi/gdb.setup
Using toolchain prefix: /c/Development/android-ndk-r6b-custom/toolchains/arm-lin
ux-androideabi-4.6.2/prebuilt/windows/bin/arm-linux-androideabi-
Using app out directory: /e/projects/AB/NB/trunk/OF/apps/android
/NBPhone/obj/local/armeabi
Found data directory: '/data/data/com.AB.NB'
Found running PID: 918
gdbserver version is
Launched gdbserver succesfully.
http://forum.openframeworks.cc/index.php?topic=8555.0
$ /c/Development/android-ndk-r6b-custom/ndk-gdb --verbose
Android NDK installation path: /c/Development/android-ndk-r6b-custom
Using default adb command: /c/Development/android-sdk/platform-tools/adb.exe
ADB version found: Android Debug Bridge version 1.0.29
Using final ADB command: '/c/Development/android-sdk/platform-tools/adb.exe'
Using auto-detected project path: .
Found package name: com.AB.NB
ABIs targetted by application: armeabi
Device API Level: 8
Device CPU ABI: armeabi
Compatible device ABI: armeabi
Found debuggable flag: true
Found device gdbserver: //data/data/com.AB.NB/lib/gdbserver
Using gdb setup init: /e/projects/AB/NB/trunk/OF/apps/android/No
deBeatPhone/libs/armeabi/gdb.setup
Using toolchain prefix: /c/Development/android-ndk-r6b-custom/toolchains/arm-lin
ux-androideabi-4.6.2/prebuilt/windows/bin/arm-linux-androideabi-
Using app out directory: /e/projects/AB/NB/trunk/OF/apps/android
/NBPhone/obj/local/armeabi
Found data directory: '/data/data/com.AB.NB'
Found running PID: 918
gdbserver version is
Launched gdbserver succesfully.
Android NDK installation path: /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5
Using default adb command: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.29
Using final ADB command: '/cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb'
Using auto-detected project path: .
Found package name: com.KT.NDKOpenGL_Test
ABIs targetted by application: armeabi
Device API Level: 10
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi
Found debuggable flag: true
Found device gdbserver: /data/data/com.KT.NDKOpenGL_Test/lib/gdbserver
Using gdb setup init: /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/NDKOpenGL_Test/libs/armeabi/gdb.setup
Using toolchain prefix: /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/toolchains/arm-linux-androideabi-4.4.3/prebuilt/wind
ows/bin/arm-linux-androideabi-
Using app out directory: /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/NDKOpenGL_Test/obj/local/armeabi
Found data directory: '/data/data/com.KT.NDKOpenGL_Test'
Found running PID: 0
ERROR: Could not extract PID of application on device/emulator.
Are you sure the application is already started?
Consider using --start or --launch=<name> if not.
http://comments.gmane.org/gmane.comp.handhelds.android.ndk/13685Can you try the command adb shell ps and post what you get.Personally I am using a rooted device and I don't know if that makes a
difference but I know I had to alter the awk script NDK\build\awk\extract-
pid.awk to make it work, That script assumes that the PID will be in
the second column while I was finding that to not be true. If you also
experience this then you may need to change that script or come up
with another solution.
http://nv-tegra.nvidia.com/gitweb/?p=android/platform/ndk.git;a=commitdiff;h=a08d605794902f5c7ed79b3d894adb722e1b6cac
This is a helper script used to launch a native debugging session.
To use it, follow these steps:1. Make your application debuggable
2. Build the machine code with 'ndk-build' (make APP=<name> is not supported)
3. Build the package with ant or the ADT Eclipse plugin
4. Install it on your device/emulator
5. Launch it
6. Run 'ndk-gdb' from your application project directory.Change-Id: Ie3b0557e70cefa0080075a34ad0ca46bebef3c42
NOTE: To work properly, a modified gdbserver binary must be used
(one that binds to Unix sockets instead of TCP ones). Patch
upcoming.
http://blog.k-res.net/wap/index-wap2.php?p=920
问题描述:按着Sequoyah Native Debug的教程走,到执行ndk-gdb起服务的时候,提示”found running pid:0 could not extract pid of application…”说找不到程序的PID(顺带一提,之前还有一次是提示could not extract package’s data directory…,经查发现原因应该是设备没有root),执行adb shell ps发现要调试程序的进程就在那里,PID也看到正常,为什么ndk-gdb说获取不到PID呢?
翻了一下ndk-gdb的脚本,发现它获取PID的方法是通过执行这个:\android-ndk-r6\build\awk\extract-pid.awk,打开awk一看,里面这样写着:# We use the fact that the 9th column of the 'ps' output
# contains the package name, while the 2nd one contains the pid
#
$9 ~ PACKAGE {
PID=$2
}又看了一下adb shell里ps的输出:
ps
PID USER VSZ STAT COMMAND
1 0 352 S /init
2 0 0 SW [kthreadd]
3 0 0 SW [ksoftirqd/0]
4 0 0 SW [watchdog/0]
5 0 0 SW [events/0]
6 0 0 SW [khelper]
9 0 0 SW [async/mgr]
12 0 0 SW [suspend]
13 0 0 SW [npa/0]
229 0 0 SW [sync_supers]我勒个去,是因为版本变更年代久远,还是这脚本在坑我的爹?PID和程序包名分明应该是对应第1列和第5列,怎么就说是2和9列呢?
改了一下awk脚本:
$5 ~ PACKAGE {
PID=$1
}
再次执行ndk-gdb,这下ok了,PID正常获得,gdb server正常启动并attach上了!UPDATE1:有幸检查了一下emulator上的ps输出,确实是2-9对应关系,唉,无语...
UPDATE2:又查了一个机器,Win7上看WildFire G8,官方2.2系统,shell ps也是2-9对应,不知道是什么原因了...
$ $NDK/ndk-gdb --verbose
Android NDK installation path: /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5
Using default adb command: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.29
Using final ADB command: '/cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb'
Using auto-detected project path: .
Found package name: com.KT.NDKOpenGL_Test
ABIs targetted by application: armeabi
Device API Level: 10
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi
Found debuggable flag: true
Found device gdbserver: /data/data/com.KT.NDKOpenGL_Test/lib/gdbserver
Using gdb setup init: /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/NDKOpenGL_Test/libs/armeabi/gdb.setup
Using toolchain prefix: /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/toolchains/arm-linux-androideabi-4.4.3/prebuilt/wind
ows/bin/arm-linux-androideabi-
Using app out directory: /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/NDKOpenGL_Test/obj/local/armeabi
Found data directory: '/data/data/com.KT.NDKOpenGL_Test'
Found running PID: 10603
Launched gdbserver succesfully.
Setup network redirection
## COMMAND: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb shell run-as com.KT.NDKOpenGL_Test lib/gdbs
erver +debug-socket --attach 10603
## COMMAND: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb forward tcp:5039 localfilesystem:/data/data
/com.KT.NDKOpenGL_Test/debug-socket
[1] Segmentation fault run-as com.KT.ND...
## COMMAND: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb pull /system/bin/app_process E:/DirectX/And
roid_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/NDKOpenGL_Test/obj/local/armeabi/app_process
5 KB/s (5720 bytes in 1.000s)
Pulled app_process from device/emulator.
## COMMAND: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb pull /system/lib/libc.so E:/DirectX/Android
_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/NDKOpenGL_Test/obj/local/armeabi/libc.so
2445 KB/s (273880 bytes in 0.109s)
Pulled libc.so from device/emulator.
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i586-mingw32msvc --target=arm-elf-linux".
Warning: G:/IMX53_Smd_PatchAll_SourceCode/home/xqhrs232/IMX53_Smd/external/skia/include/config: No such file or directory.
(no debugging symbols found)
E:/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/NDKOpenGL_Test/obj/local/armeabi/gdb.setup:4: Error in sourced command file:
Remote communication error: Bad file descriptor.
(gdb) ls
Undefined command: "ls". Try "help".
(gdb) list
No symbol table is loaded. Use the "file" command.
(gdb)
A step-by-step guide for debugging native code
http://wiki.eclipse.org/Sequoyah/ndk_guide
Integrating the Android NDK C++ Native Support into Eclipse Using Sequoyahhttp://www.aton.com/integrating-the-android-ndk-c-native-support-into-eclipse-using-sequoyah/
$ $NDK/ndk-gdb
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i586-mingw32msvc --target=arm-elf-linux".
Warning: G:/IMX53_Smd_PatchAll_SourceCode/home/xqhrs232/IMX53_Smd/external/skia/include/config: No such file or directory.
(no debugging symbols found)
E:/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/NDKOpenGL_Test/obj/local/armeabi/gdb.setup:4: Error in sourced command file:
Remote communication error: Bad file descriptor.
(gdb) list
No symbol table is loaded. Use the "file" command.
(gdb) continue
Continuing.
putpkt: write failed: No such file or directory.
(gdb) p
The history is empty.
(gdb) x
0x0: putpkt: write failed: No error.
(gdb)
http://topic.csdn.net/u/20110702/09/362528d5-0256-411b-a822-4cd2cd94efd0.html?seed=708353934&r=78713369#r_78713369
简单的说就是先在JAVA端设置断点.最好是你即将要调用的C++ 本地代码函数那个位置设好断点.
然后运行APK.停在断点处,再$NDK/ndk-gdb.等启动完毕后,输入
b cpp文件全称 :函数名(不需要括号)
回车用c命令.
最后再在JAVA端释放断点,然后就可以跟进你的本地C代码函数了.你需要先进入全局函数,再用你说的那种方式就可以了.
比如.
先 ndk-gdb后
b tiros_gis_vos_SkView.cpp :Java_tiros_gis_vos_SkView_showMap
待进入Java_tiros_gis_vos_SkView_showMap这个全局函数的断点后.
再设某一类的函数为断点.比如:b CVOSStr::Init
就OK了.
我的就是这么做的.不知是不是你要的答案.
http://groups.google.com/group/android-ndk/browse_thread/thread/ff824d758fe1e79f/b542a480fbcfdcbd
http://sqbing.diandian.com/post/2012-04-18/17690370
Remote communication error: Bad file descriptor.遇到这个错误的时候,可以试试删除jni/obj/local/armeabi/gdb.setup,再运行ndk-gdb20120502补充:出现问题的根源是在错误的目录调用了ndk-gdb。//-----------------------
确实是这样的,我在jni目录调用了ndk-gdb,出现此问题;我转移到项目的根目录,就没有这个问题了;
Can you answer me these following questions that will help me help you?
1. Did you copy the first gdb.setup to gdb2.setup and configure the
Native Debugger to use this setup?
2. Did you take out the target remote:5039 line from gdb2.setup?
3. Did you start the Java (Application) debug mode first, then run
$NDK/ndk-gdb from your projects directory, then return to your project
(in Eclipse) and run the second debugger?
4. Did you issue adb forward tcp:5039 tcp:5039?
5. Is your windows firewall completely disabled?
Thanks
Kevin
On 9/8/2011 3:50 PM, Ike Starnes wrote:
Launched gdbserver succesfully.
Setup network redirection
## COMMAND: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb shell run-as com.KT.NDKOpenGL_Test lib/gdbs
erver +debug-socket --attach 10603
## COMMAND: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb forward tcp:5039 localfilesystem:/data/data
/com.KT.NDKOpenGL_Test/debug-socket
[1] Segmentation fault run-as com.KT.ND...还是出现Segmentation fault的错误?gdbserver有问题???自己编译Android gdbserver(解决运行 gdbserver时 Segmentation fault 问题)
http://blog.csdn.net/xqhrs232/article/details/7495804
http://blog.csdn.net/xqhrs232/article/details/75322762. 调试工具 及调试环境 在搭建android调试环境过程中,很多文章中原理上做了比较好的介绍,但开始始终无法成功,最后发现运行的平台,使用的工具等一些细节方面是失败的主要原因。 运行环境 : cygwin ndk : android-ndk-r7b gdb : ${ndk-home}\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\bin\arm-linux-androideabi-gdb (version = 6.6) gdbserver : 每个模拟器上, 在system/bin/gdbserver 有默认的程序 失败配置: gdbserver (version 7.1) : android emulator : 4.0 (version) 14 (API level) 成功配置: gdbserver() : android emulator : 2.3.3 (version) 10 (API level) 注意:经过尝试必须注意 gdb vs gdbserver版本的匹配, 如果system/bin下的gdbserver 不匹配,可以把匹配的gdbserver push emulator 然后指定./gdbserver , 必须指定"./",因为linux下面,默认是寻找 system目录 (第一个陷阱)
http://blog.csdn.net/xqhrs232/article/details/7531345gdb在android中的使用
http://blog.csdn.net/xqhrs232/article/details/7531358
Android 2.2 ndk-gdb on real hardware target
http://groups.google.com/group/android-ndk/browse_thread/thread/cb62db99ff91f228
Android 2.2 ndk-gdb on real hardware target
http://groups.google.com/group/android-ndk/browse_thread/thread/cb62db99ff91f228
http://blog.csdn.net/xqhrs232/article/details/7492955(gdb)
Display all 128 possibilities? (y or n)
actions directory init-if-undefined quit tbreak
add-shared-symbol-files disable inspect rbreak tcatch
add-symbol-file disassemble interpreter-exec remote tdump
add-symbol-file-from-memory disconnect interrupt restore tfind
advance display jump return thbreak
append document kill reverse-search thread
apropos dont-repeat list run tp
attach down load rwatch trace
awatch down-silently macro save-tracepoints tstart
backtrace dump maintenance search tstatus
break echo make section tstop
bt edit mem select-frame tty
call enable monitor set undisplay
catch end next sharedlibrary unset
cd exec-file nexti shell until
clear file ni show up
collect finish nosharedlibrary si up-silently
commands flushregs output signal watch
compare-sections forward-search overlay source whatis
complete frame passcount start where
condition handle path step while
continue hbreak print stepi while-stepping
core-file help print-object stepping ws
define if printf stop x
delete ignore ptype symbol-file
detach info pwd target
(gdb)
qhx@eng-xiong-qh /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/myjni
$ $NDK/ndk-gdb --verbose
Android NDK installation path: /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5
Using default adb command: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.29
Using final ADB command: '/cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb'
Using auto-detected project path: .
Found package name: com.example.JNI
ABIs targetted by application: armeabi
Device API Level: 10
Device CPU ABI: armeabi
Compatible device ABI: armeabi
Found debuggable flag: false
Found gdbserver under libs/armeabi, assuming app was built with NDK_DEBUG=1
Found device gdbserver: /data/data/com.example.JNI/lib/gdbserver
Using gdb setup init:
Using toolchain prefix: /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/toolchains/arm-linux-androideabi-4.4.3/prebuilt/wind
ows/bin/arm-linux-androideabi-
Using app out directory: /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/myjni/obj/local/armeabi
Found data directory: '/data/data/com.example.JNI'
Found running PID: 7836
Launched gdbserver succesfully.
Setup network redirection
## COMMAND: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb shell run-as com.example.JNI lib/gdbserver
+debug-socket --attach 7836
## COMMAND: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb forward tcp:5039 localfilesystem:/data/data
/com.example.JNI/debug-socket
Attached; pid = 7836
Listening on sockaddr socket debug-socket
## COMMAND: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb pull /system/bin/app_process E:/DirectX/And
roid_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/myjni/obj/local/armeabi/app_process
35 KB/s (5660 bytes in 0.156s)
Pulled app_process from device/emulator.
## COMMAND: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb pull /system/lib/libc.so E:/DirectX/Android
_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/myjni/obj/local/armeabi/libc.so
120 KB/s (273868 bytes in 2.218s)
Pulled libc.so from device/emulator.
cp: missing destination file operand after `/cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/myjni/obj/local/armeabi/
gdb.setup'
Try `cp --help' for more information.
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i586-mingw32msvc --target=arm-elf-linux".
(no debugging symbols found)
Error while mapping shared library sections:
/system/bin/linker: No such file or directory.
Error while mapping shared library sections:
libc.so: No error.
Error while mapping shared library sections:
libstdc++.so: No error.
Error while mapping shared library sections:
libm.so: No error.
Error while mapping shared library sections:
liblog.so: No error.
Error while mapping shared library sections:
libcutils.so: No error.
Error while mapping shared library sections:
libz.so: No error.
Error while mapping shared library sections:
libutils.so: No error.
Error while mapping shared library sections:
libbinder.so: No error.
Error while mapping shared library sections:
libexpat.so: No error.
Error while mapping shared library sections:
libcrypto.so: No error.
Error while mapping shared library sections:
libicuuc.so: No error.
Error while mapping shared library sections:
libicui18n.so: No error.
Error while mapping shared library sections:
libsqlite.so: No error.
Error while mapping shared library sections:
libssl.so: No error.
Error while mapping shared library sections:
libnativehelper.so: No error.
Error while mapping shared library sections:
libnetutils.so: No error.
Error while mapping shared library sections:
libEGL.so: No error.
Error while mapping shared library sections:
libwpa_client.so: No error.
Error while mapping shared library sections:
libhardware_legacy.so: No error.
Error while mapping shared library sections:
libpixelflinger.so: No error.
Error while mapping shared library sections:
libhardware.so: No error.
Error while mapping shared library sections:
libui.so: No error.
Error while mapping shared library sections:
libgui.so: No error.
Error while mapping shared library sections:
libsurfaceflinger_client.so: No error.
Error while mapping shared library sections:
libcamera_client.so: No error.
Error while mapping shared library sections:
libemoji.so: No error.
Error while mapping shared library sections:
libjpeg.so: No error.
Error while mapping shared library sections:
libskia.so: No error.
Error while mapping shared library sections:
libGLESv1_CM.so: No error.
Error while mapping shared library sections:
libskiagl.so: No error.
Error while mapping shared library sections:
libdvm.so: No error.
Error while mapping shared library sections:
libGLESv2.so: No error.
Error while mapping shared library sections:
libETC1.so: No error.
Error while mapping shared library sections:
libsonivox.so: No error.
Error while mapping shared library sections:
libmedia.so: No error.
Error while mapping shared library sections:
libnfc_ndef.so: No error.
Error while mapping shared library sections:
libandroid_runtime.so: No error.
Error while mapping shared library sections:
libvorbisidec.so: No error.
Error while mapping shared library sections:
libstagefright_amrnb_common.so: No error.
Error while mapping shared library sections:
libstagefright_enc_common.so: No error.
Error while mapping shared library sections:
libstagefright_avc_common.so: No error.
Error while mapping shared library sections:
libstagefright_foundation.so: No error.
Error while mapping shared library sections:
libstagefright_color_conversion.so: No error.
Error while mapping shared library sections:
libstagefright.so: No error.
Error while mapping shared library sections:
libmedia_jni.so: No error.
Error while mapping shared library sections:
libexif.so: No error.
Error while mapping shared library sections:
libsoundpool.so: No error.
Error while mapping shared library sections:
libstlport.so: No error.
Error while mapping shared library sections:
libwebcore.so: No error.
Error while mapping shared library sections:
libmyjni.so: No error.
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
warning: shared library handler failed to enable breakpoint
0xafd0c738 in ?? ()
gdb: Unable to get location for thread creation breakpoint: requested event is not supported
(no debugging symbols found)
gdb: Unable to get location for thread creation breakpoint: requested event is not supported
gdb: Unable to get location for thread creation breakpoint: requested event is not supported
Killing inferior
E:/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/myjni/obj/local/armeabi/gdb.setup:4: Error in sourced command file:
Remote communication error: Bad file descriptor.
(gdb)
http://topic.csdn.net/u/20110702/09/362528d5-0256-411b-a822-4cd2cd94efd0.html?seed=1398963705&r=78722315#r_78722315
参考http://iunknown.iteye.com/blog/73064。在详细看了当前版本的ndk-gdb.html之后,发现有这样一段话:IMPORTANT: The GDB prompt will be preceded by a long list of error messages, where gdb complains that it cannot find various system libraries (e.g. libc.so, libstdc++.so, liblog.so, libcutils.so, etc...) This is normal, because there are no symbol/debug versions of these libraries corresponding to your target device on your development machine. You can safely ignore these messages.也就是说,当前的这些错误信息可以忽略。
参考http://iunknown.iteye.com/blog/73064。在详细看了当前版本的ndk-gdb.html之后,发现有这样一段话:IMPORTANT: The GDB prompt will be preceded by a long list of error messages, where gdb complains that it cannot find various system libraries (e.g. libc.so, libstdc++.so, liblog.so, libcutils.so, etc...) This is normal, because there are no symbol/debug versions of these libraries corresponding to your target device on your development machine. You can safely ignore these messages.也就是说,当前的这些错误信息可以忽略。
(no debugging symbols found)
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
warning: shared library handler failed to enable breakpoint
0xafd0c738 in __futex_syscall3 ()
from E:/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/NDKOpenGL_Test_lib/obj/local/armeabi/libc.so
(gdb) b com_KT_NDKOpenGL_Test_NDKOpenGL.cpp:Java_com_KT_NDKOpenGL_1Test_NDKOpenGL_nativeInit
Breakpoint 1 at 0x80406e3c: file E:/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/NDKOpenGL_Test/jni/com_KT_NDKOpenGL_Test_NDK
OpenGL.cpp, line 578.
(gdb) list
obj\local\armeabi还是libs\armeabi
5。针对gdb.setup文件也有类似于上面第4项的问题,到底该用那一个?要不要进行修改?为什么要进行修改?因为两个gdb.setup还是不一样的6。为什么在模拟下进行ndk-gdb对应的包名下面有debug-socket文件,而在实际的设备上却没有
具体路径为/data/data/packagename/debug-socket7。每个SO工程设置调试编译出来的gdbserver文件跟系统的/system/bin/gdbserver文件有什么不同,进行ndk-gdb用的是那一个?8。ndk-gdb脚本文件会执行gdbserver程序,但为什么我用PS命令没看到跑起来的gdbserver进程在进程列表呢?难道gdbserver只需要跑一下就OK?gdbserver不是要做服务器的意思吗?那在ndk-gdb的整个过程中都应该运行的啊!
obj\local\armeabi还是libs\armeabi
5。针对gdb.setup文件也有类似于上面第4项的问题,到底该用那一个?要不要进行修改?为什么要进行修改?因为两个gdb.setup还是不一样的6。为什么在模拟下进行ndk-gdb对应的包名下面有debug-socket文件,而在实际的设备上却没有
具体路径为/data/data/packagename/debug-socket7。每个SO工程设置调试编译出来的gdbserver文件跟系统的/system/bin/gdbserver文件有什么不同,进行ndk-gdb用的是那一个?8。ndk-gdb脚本文件会执行gdbserver程序,但为什么我用PS命令没看到跑起来的gdbserver进程在进程列表呢?难道gdbserver只需要跑一下就OK?gdbserver不是要做服务器的意思吗?那在ndk-gdb的整个过程中都应该运行的啊!
This GDB was configured as "--host=i686-pc-cygwin --target=arm-elf-linux".
----http://blog.csdn.net/xqhrs232/article/details/7618136 但为什么我的显示却是如下,不明白!
This GDB was configured as "--host=i586-mingw32msvc --target=arm-elf-linux".
我的明明是在cygwin下进行ndk-gdb,为什么显示i586-mingw32msvc ?
#./gdbserver
./gdbserver
Usage:gdbserver COMM PROG[ARGS...]
gdbserver COMM --attach PID [--close-fd FD]COMM may either be a tty device <for serial debugging>, or
HOST:POST to listen for a TCP connection.
Exiting
#pwd
pwd
/system/bin
# pwd
pwd
/system/bin# ./gdbserver
./gdbserver
[1] Segmentation fault ./gdbserver#
# pwd
pwd
/system/bin# ./gdbserver
./gdbserver
[1] Segmentation fault ./gdbserver#
0003c460 T fork
00000000 a fork.c
rbissell@rvb-android-dev0:~/src/android$ addr2line -e ./gdbserver 0003c460
/opt/digit/android/main/cupcake/android/bionic/libc/bionic/fork.c:34 (Again, the was the gdbserver taken from the Gingerbread AOSP tree, back in early February 2011.)Hope that helps in some way.
$ $NDK/ndk-gdb --verbose
Android NDK installation path: /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5
Using default adb command: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.29
Using final ADB command: '/cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb'
Using auto-detected project path: .
Found package name: com.example.JNI
ABIs targetted by application: armeabi
Device API Level: 10
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi
Found debuggable flag: true
Found device gdbserver: /data/data/com.example.JNI/lib/gdbserver
Using gdb setup init: /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/JNI/libs/armeabi/gdb.setup
Using toolchain prefix: /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/toolchains/arm-linux-androideabi-4.4.3/prebuilt/wind
ows/bin/arm-linux-androideabi-
Using app out directory: /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/JNI/obj/local/armeabi
Found data directory: '/data/data/com.example.JNI'
Found running PID: 2707
Launched gdbserver succesfully.
## COMMAND: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb shell run-as com.example.JNI lib/gdbserver
Setup network redirection07
## COMMAND: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb forward tcp:5039 localfilesystem:/data/data
/com.example.JNI/debug-socket
Attached; pid = 2707
Listening on sockaddr socket debug-socket
## COMMAND: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb pull /system/bin/app_process E:/DirectX/And
roid_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/JNI/obj/local/armeabi/app_process
357 KB/s (5720 bytes in 0.015s)
Pulled app_process from device/emulator.
## COMMAND: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb pull /system/lib/libc.so E:/DirectX/Android
_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/JNI/obj/local/armeabi/libc.so
3423 KB/s (273880 bytes in 0.078s)
Pulled libc.so from device/emulator.
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i586-mingw32msvc --target=arm-elf-linux".
(no debugging symbols found)
Error while mapping shared library sections:
/system/bin/linker: No such file or directory.
Error while mapping shared library sections:
libstdc++.so: No such file or directory.
Error while mapping shared library sections:
libm.so: No such file or directory.
Error while mapping shared library sections:
liblog.so: No such file or directory.
Error while mapping shared library sections:
libcutils.so: No such file or directory.
Error while mapping shared library sections:
libz.so: No such file or directory.
Error while mapping shared library sections:
libutils.so: No such file or directory.
Error while mapping shared library sections:
libbinder.so: No such file or directory.
Error while mapping shared library sections:
libexpat.so: No such file or directory.
Error while mapping shared library sections:
libcrypto.so: No such file or directory.
Error while mapping shared library sections:
libicuuc.so: No such file or directory.
Error while mapping shared library sections:
libicui18n.so: No such file or directory.
Error while mapping shared library sections:
libsqlite.so: No such file or directory.
Error while mapping shared library sections:
libssl.so: No such file or directory.
Error while mapping shared library sections:
libnativehelper.so: No such file or directory.
Error while mapping shared library sections:
libnetutils.so: No such file or directory.
Error while mapping shared library sections:
libEGL.so: No such file or directory.
Error while mapping shared library sections:
libwpa_client.so: No such file or directory.
Error while mapping shared library sections:
libipu.so: No such file or directory.
Error while mapping shared library sections:
libhardware_legacy.so: No such file or directory.
Error while mapping shared library sections:
libpixelflinger.so: No such file or directory.
Error while mapping shared library sections:
libhardware.so: No such file or directory.
Error while mapping shared library sections:
libui.so: No such file or directory.
Error while mapping shared library sections:
libgui.so: No such file or directory.
Error while mapping shared library sections:
libsurfaceflinger_client.so: No such file or directory.
Error while mapping shared library sections:
libcamera_client.so: No such file or directory.
Error while mapping shared library sections:
libemoji.so: No such file or directory.
Error while mapping shared library sections:
libjpeg.so: No such file or directory.
Error while mapping shared library sections:
libskia.so: No such file or directory.
Error while mapping shared library sections:
libGLESv1_CM.so: No such file or directory.
Error while mapping shared library sections:
libskiagl.so: No such file or directory.
Error while mapping shared library sections:
libdvm.so: No such file or directory.
Error while mapping shared library sections:
libGLESv2.so: No such file or directory.
Error while mapping shared library sections:
libETC1.so: No such file or directory.
Error while mapping shared library sections:
libsonivox.so: No such file or directory.
Error while mapping shared library sections:
libmedia.so: No such file or directory.
Error while mapping shared library sections:
libnfc_ndef.so: No such file or directory.
Error while mapping shared library sections:
libbluedroid.so: No such file or directory.
Error while mapping shared library sections:
libdbus.so: No such file or directory.
Error while mapping shared library sections:
libandroid_runtime.so: No such file or directory.
Error while mapping shared library sections:
libvorbisidec.so: No such file or directory.
Error while mapping shared library sections:
libstagefright_amrnb_common.so: No such file or directory.
Error while mapping shared library sections:
libstagefright_enc_common.so: No such file or directory.
Error while mapping shared library sections:
libstagefright_avc_common.so: No such file or directory.
Error while mapping shared library sections:
libstagefright_foundation.so: No such file or directory.
Error while mapping shared library sections:
libstagefright_color_conversion.so: No such file or directory.
Error while mapping shared library sections:
libstagefright.so: No such file or directory.
Error while mapping shared library sections:
lib_omx_osal_v2_arm11_elinux.so: No such file or directory.
Error while mapping shared library sections:
lib_omx_utils_v2_arm11_elinux.so: No such file or directory.
Error while mapping shared library sections:
lib_omx_core_mgr_v2_arm11_elinux.so: No such file or directory.
Error while mapping shared library sections:
lib_omx_res_mgr_v2_arm11_elinux.so: No such file or directory.
Error while mapping shared library sections:
libfsl_jpeg_enc_arm11_elinux.so: No such file or directory.
Error while mapping shared library sections:
lib_omx_client_arm11_elinux.so: No such file or directory.
Error while mapping shared library sections:
libsurfaceflinger.so: No such file or directory.
Error while mapping shared library sections:
lib_omx_player_arm11_elinux.so: No such file or directory.
Error while mapping shared library sections:
lib_id3_parser_arm11_elinux.so: No such file or directory.
Error while mapping shared library sections:
libmedia_jni.so: No such file or directory.
Error while mapping shared library sections:
libexif.so: No such file or directory.
Error while mapping shared library sections:
libsoundpool.so: No such file or directory.
Error while mapping shared library sections:
libacc.so: No such file or directory.
Error while mapping shared library sections:
libRS.so: No such file or directory.
Error while mapping shared library sections:
librs_jni.so: No such file or directory.
Error while mapping shared library sections:
libstlport.so: No such file or directory.
Error while mapping shared library sections:
libwebcore.so: No such file or directory.
(no debugging symbols found)
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
warning: shared library handler failed to enable breakpoint
0xafd0c738 in __futex_syscall3 () from E:/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/JNI/obj/local/armeabi/libc.so
(gdb) list
1
$ $NDK/ndk-gdb --verbose
Android NDK installation path: /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5
Using default adb command: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.29
Using final ADB command: '/cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb'
Using auto-detected project path: .
Found package name: com.example.JNI
ABIs targetted by application: armeabi
Device API Level: 10
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi
Found debuggable flag: true
Found device gdbserver: /data/data/com.example.JNI/lib/gdbserver
Using gdb setup init: /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/JNI/libs/armeabi/gdb.setup
Using toolchain prefix: /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/toolchains/arm-linux-androideabi-4.4.3/prebuilt/wind
ows/bin/arm-linux-androideabi-
Using app out directory: /cygdrive/e/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/JNI/obj/local/armeabi
Found data directory: '/data/data/com.example.JNI'
Found running PID: 2707
Launched gdbserver succesfully.
## COMMAND: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb shell run-as com.example.JNI lib/gdbserver
Setup network redirection07
## COMMAND: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb forward tcp:5039 localfilesystem:/data/data
/com.example.JNI/debug-socket
Attached; pid = 2707
Listening on sockaddr socket debug-socket
## COMMAND: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb pull /system/bin/app_process E:/DirectX/And
roid_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/JNI/obj/local/armeabi/app_process
357 KB/s (5720 bytes in 0.015s)
Pulled app_process from device/emulator.
## COMMAND: /cygdrive/e/DirectX/Android_SDK/android-sdk_r07-windows/android-sdk-windows/platform-tools/adb pull /system/lib/libc.so E:/DirectX/Android
_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/JNI/obj/local/armeabi/libc.so
3423 KB/s (273880 bytes in 0.078s)
Pulled libc.so from device/emulator.
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i586-mingw32msvc --target=arm-elf-linux".
(no debugging symbols found)
Error while mapping shared library sections:
/system/bin/linker: No such file or directory.
Error while mapping shared library sections:
libstdc++.so: No such file or directory.
Error while mapping shared library sections:
libm.so: No such file or directory.
Error while mapping shared library sections:
liblog.so: No such file or directory.
Error while mapping shared library sections:
libcutils.so: No such file or directory.
Error while mapping shared library sections:
libz.so: No such file or directory.
Error while mapping shared library sections:
libutils.so: No such file or directory.
Error while mapping shared library sections:
libbinder.so: No such file or directory.
Error while mapping shared library sections:
libexpat.so: No such file or directory.
Error while mapping shared library sections:
libcrypto.so: No such file or directory.
Error while mapping shared library sections:
libicuuc.so: No such file or directory.
Error while mapping shared library sections:
libicui18n.so: No such file or directory.
Error while mapping shared library sections:
libsqlite.so: No such file or directory.
Error while mapping shared library sections:
libssl.so: No such file or directory.
Error while mapping shared library sections:
libnativehelper.so: No such file or directory.
Error while mapping shared library sections:
libnetutils.so: No such file or directory.
Error while mapping shared library sections:
libEGL.so: No such file or directory.
Error while mapping shared library sections:
libwpa_client.so: No such file or directory.
Error while mapping shared library sections:
libipu.so: No such file or directory.
Error while mapping shared library sections:
libhardware_legacy.so: No such file or directory.
Error while mapping shared library sections:
libpixelflinger.so: No such file or directory.
Error while mapping shared library sections:
libhardware.so: No such file or directory.
Error while mapping shared library sections:
libui.so: No such file or directory.
Error while mapping shared library sections:
libgui.so: No such file or directory.
Error while mapping shared library sections:
libsurfaceflinger_client.so: No such file or directory.
Error while mapping shared library sections:
libcamera_client.so: No such file or directory.
Error while mapping shared library sections:
libemoji.so: No such file or directory.
Error while mapping shared library sections:
libjpeg.so: No such file or directory.
Error while mapping shared library sections:
libskia.so: No such file or directory.
Error while mapping shared library sections:
libGLESv1_CM.so: No such file or directory.
Error while mapping shared library sections:
libskiagl.so: No such file or directory.
Error while mapping shared library sections:
libdvm.so: No such file or directory.
Error while mapping shared library sections:
libGLESv2.so: No such file or directory.
Error while mapping shared library sections:
libETC1.so: No such file or directory.
Error while mapping shared library sections:
libsonivox.so: No such file or directory.
Error while mapping shared library sections:
libmedia.so: No such file or directory.
Error while mapping shared library sections:
libnfc_ndef.so: No such file or directory.
Error while mapping shared library sections:
libbluedroid.so: No such file or directory.
Error while mapping shared library sections:
libdbus.so: No such file or directory.
Error while mapping shared library sections:
libandroid_runtime.so: No such file or directory.
Error while mapping shared library sections:
libvorbisidec.so: No such file or directory.
Error while mapping shared library sections:
libstagefright_amrnb_common.so: No such file or directory.
Error while mapping shared library sections:
libstagefright_enc_common.so: No such file or directory.
Error while mapping shared library sections:
libstagefright_avc_common.so: No such file or directory.
Error while mapping shared library sections:
libstagefright_foundation.so: No such file or directory.
Error while mapping shared library sections:
libstagefright_color_conversion.so: No such file or directory.
Error while mapping shared library sections:
libstagefright.so: No such file or directory.
Error while mapping shared library sections:
lib_omx_osal_v2_arm11_elinux.so: No such file or directory.
Error while mapping shared library sections:
lib_omx_utils_v2_arm11_elinux.so: No such file or directory.
Error while mapping shared library sections:
lib_omx_core_mgr_v2_arm11_elinux.so: No such file or directory.
Error while mapping shared library sections:
lib_omx_res_mgr_v2_arm11_elinux.so: No such file or directory.
Error while mapping shared library sections:
libfsl_jpeg_enc_arm11_elinux.so: No such file or directory.
Error while mapping shared library sections:
lib_omx_client_arm11_elinux.so: No such file or directory.
Error while mapping shared library sections:
libsurfaceflinger.so: No such file or directory.
Error while mapping shared library sections:
lib_omx_player_arm11_elinux.so: No such file or directory.
Error while mapping shared library sections:
lib_id3_parser_arm11_elinux.so: No such file or directory.
Error while mapping shared library sections:
libmedia_jni.so: No such file or directory.
Error while mapping shared library sections:
libexif.so: No such file or directory.
Error while mapping shared library sections:
libsoundpool.so: No such file or directory.
Error while mapping shared library sections:
libacc.so: No such file or directory.
Error while mapping shared library sections:
libRS.so: No such file or directory.
Error while mapping shared library sections:
librs_jni.so: No such file or directory.
Error while mapping shared library sections:
libstlport.so: No such file or directory.
Error while mapping shared library sections:
libwebcore.so: No such file or directory.
(no debugging symbols found)
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
warning: shared library handler failed to enable breakpoint
0xafd0c738 in __futex_syscall3 () from E:/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/JNI/obj/local/armeabi/libc.so
(gdb) list
1
http://blog.csdn.net/xqhrs232/article/details/7491732
使用GDB调试:hchen/test> gdb tst <---------- 启动GDB
GNU gdb 5.1.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-suse-linux"...
(gdb) l <-------------------- l命令相当于list,从第一行开始例出原码。
1 #include <stdio.h>
2
3 int func(int n)
4 {
5 int sum=0,i;
6 for(i=0; i<n; i++)
7 {
8 sum+=i;
9 }
10 return sum;
(gdb) <-------------------- 直接回车表示,重复上一次命令
11 }
12
13
14 main()
15 {
16 int i;
17 long result = 0;
18 for(i=1; i<=100; i++)
19 {
20 result += i;
(gdb) break 16 <-------------------- 设置断点,在源程序第16行处。
Breakpoint 1 at 0x8048496: file tst.c, line 16.
(gdb) break func <-------------------- 设置断点,在函数func()入口处。
Breakpoint 2 at 0x8048456: file tst.c, line 5.
(gdb) info break <-------------------- 查看断点信息。
Num Type Disp Enb Address What
1 breakpoint keep y 0x08048496 in main at tst.c:16
2 breakpoint keep y 0x08048456 in func at tst.c:5
(gdb) r <--------------------- 运行程序,run命令简写
Starting program: /home/hchen/test/tstBreakpoint 1, main () at tst.c:17 <---------- 在断点处停住。
17 long result = 0;
(gdb) n <--------------------- 单条语句执行,next命令简写。
18 for(i=1; i<=100; i++)
(gdb) n
20 result += i;
(gdb) n
18 for(i=1; i<=100; i++)
(gdb) n
20 result += i;
(gdb) c <--------------------- 继续运行程序,continue命令简写。
Continuing.
result[1-100] = 5050 <----------程序输出。Breakpoint 2, func (n=250) at tst.c:5
5 int sum=0,i;
(gdb) n
6 for(i=1; i<=n; i++)
(gdb) p i <--------------------- 打印变量i的值,print命令简写。
$1 = 134513808
(gdb) n
8 sum+=i;
(gdb) n
6 for(i=1; i<=n; i++)
(gdb) p sum
$2 = 1
(gdb) n
8 sum+=i;
(gdb) p i
$3 = 2
(gdb) n
6 for(i=1; i<=n; i++)
(gdb) p sum
$4 = 3
(gdb) bt <--------------------- 查看函数堆栈。
#0 func (n=250) at tst.c:5
#1 0x080484e4 in main () at tst.c:24
#2 0x400409ed in __libc_start_main () from /lib/libc.so.6
(gdb) finish <--------------------- 退出函数。
Run till exit from #0 func (n=250) at tst.c:5
0x080484e4 in main () at tst.c:24
24 printf("result[1-250] = %d /n", func(250) );
Value returned is $6 = 31375
(gdb) c <--------------------- 继续运行。
Continuing.
result[1-250] = 31375 <----------程序输出。Program exited with code 027. <--------程序退出,调试结束。
(gdb) q <--------------------- 退出gdb。
hchen/test>好了,有了以上的感性认识,还是让我们来系统地认识一下gdb吧。
http://blog.csdn.net/xqhrs232/article/details/7491732
使用GDB调试:hchen/test> gdb tst <---------- 启动GDB
GNU gdb 5.1.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-suse-linux"...
(gdb) l <-------------------- l命令相当于list,从第一行开始例出原码。
1 #include <stdio.h>
2
3 int func(int n)
4 {
5 int sum=0,i;
6 for(i=0; i<n; i++)
7 {
8 sum+=i;
9 }
10 return sum;
(gdb) <-------------------- 直接回车表示,重复上一次命令
11 }
12
13
14 main()
15 {
16 int i;
17 long result = 0;
18 for(i=1; i<=100; i++)
19 {
20 result += i;
(gdb) break 16 <-------------------- 设置断点,在源程序第16行处。
Breakpoint 1 at 0x8048496: file tst.c, line 16.
(gdb) break func <-------------------- 设置断点,在函数func()入口处。
Breakpoint 2 at 0x8048456: file tst.c, line 5.
(gdb) info break <-------------------- 查看断点信息。
Num Type Disp Enb Address What
1 breakpoint keep y 0x08048496 in main at tst.c:16
2 breakpoint keep y 0x08048456 in func at tst.c:5
(gdb) r <--------------------- 运行程序,run命令简写
Starting program: /home/hchen/test/tstBreakpoint 1, main () at tst.c:17 <---------- 在断点处停住。
17 long result = 0;
(gdb) n <--------------------- 单条语句执行,next命令简写。
18 for(i=1; i<=100; i++)
(gdb) n
20 result += i;
(gdb) n
18 for(i=1; i<=100; i++)
(gdb) n
20 result += i;
(gdb) c <--------------------- 继续运行程序,continue命令简写。
Continuing.
result[1-100] = 5050 <----------程序输出。Breakpoint 2, func (n=250) at tst.c:5
5 int sum=0,i;
(gdb) n
6 for(i=1; i<=n; i++)
(gdb) p i <--------------------- 打印变量i的值,print命令简写。
$1 = 134513808
(gdb) n
8 sum+=i;
(gdb) n
6 for(i=1; i<=n; i++)
(gdb) p sum
$2 = 1
(gdb) n
8 sum+=i;
(gdb) p i
$3 = 2
(gdb) n
6 for(i=1; i<=n; i++)
(gdb) p sum
$4 = 3
(gdb) bt <--------------------- 查看函数堆栈。
#0 func (n=250) at tst.c:5
#1 0x080484e4 in main () at tst.c:24
#2 0x400409ed in __libc_start_main () from /lib/libc.so.6
(gdb) finish <--------------------- 退出函数。
Run till exit from #0 func (n=250) at tst.c:5
0x080484e4 in main () at tst.c:24
24 printf("result[1-250] = %d /n", func(250) );
Value returned is $6 = 31375
(gdb) c <--------------------- 继续运行。
Continuing.
result[1-250] = 31375 <----------程序输出。Program exited with code 027. <--------程序退出,调试结束。
(gdb) q <--------------------- 退出gdb。
hchen/test>好了,有了以上的感性认识,还是让我们来系统地认识一下gdb吧。
2。info break----列出所有设置的断点情况
3。next(n)----程序单步执行,跳过函数调用,对应step
4。step----程序单步执行,进入函数调用
5。continue(c)----程序执行执行,停在下一个断点处,没断点就执行完成
6。print(p) /x i/j/k----打印调试上下文的临时变量
7。x /u 0x30000000----按格式查看内存地址存储的数值
8。list----列出程序的源代码,按行
9。bt Backtrace----显示程序堆栈信息
10。watch----使你能监视一个变量的值而不管它何时被改变
11。finish---- 继续执行,直到当前函数返回
12。quit----退出gdb.
http://blog.csdn.net/xqhrs232/article/details/7492955三.gdb的命令字介绍
我们简要介绍一下在gdb调试中需要用到的命令字
file [filename]
装入想要调试的可执行文件
kill [filename]
终止正在调试的程序
break [file:]function
在(file文件的)function函数中设置一个断点
clear
删除一个断点,这个命令需要指定代码行或者函数名作为参数
run [arglist]
运行您的程序 (如果指定了arglist,则将arglist作为参数运行程序)
bt Backtrace
显示程序堆栈信息
print expr
打印表达式的值
continue
继续运行您的程序 (在停止之后,比如在一个断点之后)
list
列出产生执行文件的源代码的一部分
next
单步执行 (在停止之后); 跳过函数调用(与step相对应,step会进入函数内部)
nexti
执行下一行的源代码中的一条汇编指令
set
设置变量的值。例如:set nval=54 将把54保存到nval变量中;设置输入参数也可以通过这个命令(例如当三个入参分别为a、b、c的话,set args a b c)
step
单步执行 (在停止之后); 进入函数调用
stepi
继续执行程序下一行源代码中的汇编指令。如果是函数调用,这个命令将进入函数的内部,单步执行函数中的汇编代码
watch
使你能监视一个变量的值而不管它何时被改变
rwatch
指定一个变量,如果这个变量被读,则暂停程序运行,在调试器中显示信息,并等待下一个调试命令。参考rwatch和watch命令
awatch
指定一个变量,如果这个变量被读或者被写,则暂停程序运行,在调试器中显示信息,并等待下一个调试命令。参考rwatch和watch命令
Ctrl-C
在当前位置停止执行正在执行的程序,断点在当前行
disable
禁止断点功能,这个命令需要禁止的断点在断点列表索引值作为参数
display
在断点的停止的地方,显示指定的表达式的值。(显示变量)
undisplay
删除一个display设置的变量显示。这个命令需要将display list中的索引做参数
enable
允许断点功能,这个命令需要允许的断点在断点列表索引值作为参数
finish
继续执行,直到当前函数返回
ignore
忽略某个断点制定的次数。例:ignore 4 23 忽略断点4的23次运行,在第24次的时候中断
info [name]
查看name信息
load
动态载入一个可执行文件到调试器
xbreak
在当前函数的退出的点上设置一个断点
whatis
显示变量的值和类型
ptype
显示变量的类型
return
强制从当前函数返回
txbreak
在当前函数的退出的点上设置一个临时的断点(只可使用一次)
make
使你能不退出 gdb 就可以重新产生可执行文件
shell
使你能不离开 gdb 就执行 UNIX shell 命令
help [name]
显示GDB命令的信息,或者显示如何使用GDB的总体信息
quit
退出gdb.
from E:/DirectX/Android_NDK_JNI/android-ndk-r5-windows/android-ndk-r5/samples/NDKOpenGL_Test/obj/local/armeabi/libc.so
(gdb) b 639
$7 = (unsigned char *) 0x4ae02008 <Address 0x4ae02008 out of bounds>
上面的表示内存没有分配成功,已经释放的意思?因为malloc的情况如下
(gdb) p change_data
$3 = (unsigned char *) 0x4ae02008 ""是不是表明不存在什么内存没释放的问题?
call to OpenGL ES API with no current context (logged once per thread)
http://blog.sina.com.cn/s/blog_5fd9454d0100drfw.html delete 指针的指针(或者指针数组) 这几天碰到程序中内存被不断吞噬的问题,怎么找都没发现,后来经一个一个排除,抓出了这个内鬼,释放指针的指针的空间时,只释放了一次,以下是一个例子,说明如何解决这个问题。以指针的指针为例,指针数组的原理也一样。 假设:char **p=new char *[total*pa*sizeof(char)]; for(int i=0,i<total;i++) { p[i]=new int[pa]; } .........................................以上定义了一个指针的指针p,并为他分配了空间。下面进行空间的释放。 for(int i=0,i<total;i++) { delete []p[i]; } delete []p; p=NULL;.....................................到此分配的空间完全被吐了出来(小样,看你下次还敢吃我内存)一定要记住,对于指针的指针这类空间的释放问题,不是一次释放就可以的,要与分配时相对应。呵呵,就到这了。