2011年3月10日 星期四

[Embedded] How to Cross Compile GNU Project Debugger

0.assume that your toolchain is
arm-linux-gcc
arm-linux-g++
arm-linux-ar
arm-linux-ld
arm-linux-as
arm-linux-strip
...
and under your PATH

1.download termcap
$ wget ftp://ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz

2.configure termcap
$ ./configure --target=arm-linux --prefix=/path/to/install/termcap

3.modify Makefile
$ vim Makefile
-CC = gcc
-AR = ar
-RANLIB = ranlib
+CC = arm-linux-gcc
+AR = arm-linux-ar
+RANLIB = arm-linux-ranlib

4.install
$ make && sudo make install

5.download GDB
$ wget ftp://ftp.gnu.org/gnu/gdb/gdb-6.7.1.tar.gz

6.configure GDB
$ env CPPFLAGS=-I/path/to/install/termcap/include LDFLAGS=-L/path/to/install/termcap/lib ./configure --target=arm-linux --prefix=/path/to/install/gdb

7.if error has occurred like this:
cc1: warnings being treated as errors
eval.c: In function 'evaluate_subexp_standard':
eval.c:1676: error: 'subscript_array' may be used uninitialized in this function
make[2]: *** [eval.o] Error 1
make[2]: Leaving directory `/usr/local/src/gdb-6.7.1/gdb'
make[1]: *** [all-gdb] Error 2
make[1]: Leaving directory `/usr/local/src/gdb-6.7.1'
make: *** [all] Error 2

patch code
--- insight-6.7.1.dfsg.1.orig/gdb/eval.c
+++ insight-6.7.1.dfsg.1/gdb/eval.c
@@ -1627,6 +1627,8 @@
if (nargs != ndimensions)
error (_("Wrong number of subscripts"));

+       memset(&subscript_array, 0, sizeof(subscript_array));
+
/* Now that we know we have a legal array subscript expression
let us actually find out where this element exists in the array. */

8.modify Makefile
$ vim Makefile
-CC = gcc
-CXX = g++
+CC = arm-linux-gcc
+CXX = arm-linux-gcc++

9.make & check
$ make && make install
$ file /path/to/install/gdb/bin/gdb: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.27, dynamically linked (uses shared libs), not stripped


/** install gdb-7.3.1 @ 2011-12-14 **/
1.get source
wget http://ftp.gnu.org/gnu/gdb/gdb-7.3.1.tar.gz
wget ftp://ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz

2.configure termcap
$ ./configure --target=arm-linux --prefix=/path/to/termcap
$ make && sudo make install

3.configure gdb & gdbserver
$ cd gdb-7.3.1
$ env CPPFLAGS=-I/path/to/termcap/include LDFLAGS=-L/path/to/termcap/lib ./configure --target=arm-linux
$ make
$ file gdb/gdb
gdb/gdb: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.27, not stripped
$ file gdbserver
gdb/gdbserver/gdbserver: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.27, not stripped


reference:
* How to Cross Compile GNU Project Debugger a Step by Step Guide
* insight: FTBFS: configure: error: /bin/bash '../.././itcl/itk/configure' failed for itk
* Cross-compile GDB 6.8 for Android

沒有留言: