GDB: don't know how to run

来源:互联网 发布:thinking in java 4th 编辑:程序博客网 时间:2024/05/21 06:13

(未经许可不得转载)(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
原创粉丝点击