GDB: don't know how to run

(未经许可不得转载)(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 */



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值