GDB: don't know how to run

debugging 专栏收录该内容
1 篇文章 0 订阅

(未经许可不得转载)(Noreproductionorrepublicationwithoutwrittenpermission)

Issue:

GDB: don't know how to run


Solution:

$ gdb --version

checking gdb configuration "This GDB was configured as xxx"


-----------------------------------information----------------------------------

Syntax:

gdb file-to-be-debugged


Rule:

gdb should recognize/parse the file to be debugged.


Steps:

1. Use a tool to analyze the file format(ARM/Intel etc)

    In ubuntu, we can use tool "file"

   $ file file-to-be-debugged
  •     if we see (case 1)

ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped,

    it means "gdb" should be configured as the following option(from gdb --version)

    This GDB was configured as "i686-pc-linux-gnu"

  •     if we see (case 2)

ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.27, not stripped,

    it means "gdb" should be configured as the following option(from arm-linux-gdb --version)

    This GDB was configured as "--host=i686-pc-linux-gnu--target=arm-linux"

2. Create your own gdb

a. for debugging in x86 only

$ tar zxf gdb-x.x.x.tar.gz

$ ./configure

$ make

$ ls -l gdb/gdb /* case 1 */


b. for remote debugging of arm platform(including gdbserver)

$ tar zxf gdb-x.x.x.tar.gz

$ ./configure --target=arm-linux

$ make

$ file gdb/gdb
gdb/gdb: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped

$ cp gdb/gdb gdb/arm-linux-gdb /* case 2 */

cd gdb/gdbserver

$ CC=/opt/armtoolchain/bin/arm-linux-gnueabi-gcc ./configure --target=arm-linux --host=arm-linux

$ make

$ file gdbserver
gdbserver: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.27, not stripped/* running on ARM board */



  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值