zoukankan      html  css  js  c++  java
  • 使用gdb在Android Emulator中进行调试

    gdb在android开发中的使用相信很多开发人员都很想掌握,今天我们就用gdb在Android Emulator中进行调试,让大家学习gdb调试。在Android手机开发平台的emulator里,有两种方式可以做Gdb调试:直接使用GdbServer或利用Gdb调试进行调试。

      1、利用Gdb Server进行调试:

      A、从下面的链接中下载针对Android的Gdb Server  http://www.billrocks.org/android_libs/bin/

      B、把下载的Gdb Server安装到你的emulator 中
      1)、 启动emulator 
      2)、下载Gdb Server到你的emulator 
      打开一个终端,运行:
        $ adb shell
        #cd data
        #mkdir bin
      在另外一个终端里运行:
        $ adb push gdbserver /data/bin

      这样通过Android自己的adb,把gdbserver 下载到emulator 中了。

      C、运行gdbserver :
         # /data/bin/gdbserver 10.0.2.2:1234 [args...]

      D、回到另一终端,映射端口:
           $telnet localhost 5554
          telnet到emulator 中,运行下面的命令:
           redir add tcp:1234:1234

      E、在第三个终端中运行 gdb:
           $gdb test
           test 是你要调试的程序,然后在gdb命令行运行:
           (gdb) target remote localhost:1234

           然后你就可以像以前用gdb那样进行程序调试了。

      2、直接用本地Gdb进行调试

      A、从下面的链接中下载Android调试包,它是用Android的toolchain编译好的二进制文件:

          http://ortegaalfredo.googlepages.com/android-debug.tbz

      B、解压调试包,然后把gdb下载到你的emulator 中,当然如果你有真的手机,也可以这样调试:
       $adb push gdb /data/bin

      C、利用adb连接到emulator

       $adb shell

      运行gdb,会出现下面的信息:

       # /data/bin/gdb

    dlopen failed on 'libthread_db.so.1' - libthread_db.so.1: cannot open shared object file: No such file or directory
    GDB will not be able to debug pthreads.

    GNU gdb 6.7
    Copyright (C) 2007 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=arm-none-linux-gnueabi --target=".
    (gdb)

      D、    然后你就可以像以前用gdb那样对程序进行调试了。

  • 相关阅读:
    htmlUnil-2.33 jar包
    HtmlUnil 不兼容问题
    Java 网页抓取 工具类
    浏览器不兼容
    Chrome常用调试技巧1
    关于社交网络的思考
    google浏览器历史旧版
    EJB是什么Java使用EJB容器的详细概述
    何必言精通——十年杂感(转载)
    搜索优化—如何在Google搜索引擎上排名靠前Google左侧排名
  • 原文地址:https://www.cnblogs.com/luxiaofeng54/p/2014858.html
Copyright © 2011-2022 走看看