使用Android 预装 gdbserver 调试 动态库时出现,Segmentation fault错误。不得不使用现有编译链重新编译一份gdbserver。我的解决过程如下。
这里要强调一点:下面编译sysroot时sysroot的目标路径,和编译gdbserver时指定的sysroot路径,一定要是用[绝对路径]。我编译过程中,曾因未使用绝对路径浪费不少精力。
二、开发环境
Ubuntu 11.04
编译通过的Android 2.3 源码
三、解决过程
1、因已经有了Android 2.3源码,省去下载源码并编译的漫长过程。
#设置Android源码目录为环境变量:$ANDROID_SRC
simba@simba-Vostro-3400:~$ export ANDROID_SRC=/home/simba/neptune/android_2.3
2、下载gdb源码,并打补丁
simba@simba-Vostro-3400:~$ mkdir gdb_build
simba@simba-Vostro-3400:~/neptune/gdb_src$ git clone https://android.googlesource.com/toolchain/gdb.git
#坐等下载完毕,然后...
#将以下保存成.patch文件
[plain]
<span style="font-size:13px;"> diff --git a/gdb-7.1.x/gdb/gdbserver/Makefile.in b/gdb-7.1.x/gdb/gdbserver/Makefile.in index 5bf82e2..488bfb6 100644 --- a/gdb-7.1.x/gdb/gdbserver/Makefile.in +++ b/gdb-7.1.x/gdb/gdbserver/Makefile.in @@ -176,13 +176,13 @@ clean-info: gdbserver$(EXEEXT): $(OBS) ${ADD_DEPS} ${CDEPS} rm -f gdbserver$(EXEEXT) - ${CC-LD} $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbserver$(EXEEXT) $(OBS) \ - $(GDBSERVER_LIBS) $(XM_CLIBS) + ${CC-LD} $(INTERNAL_CFLAGS) -o gdbserver$(EXEEXT) $(OBS) \ + $(GDBSERVER_LIBS) $(XM_CLIBS) $(INTERNAL_LDFLAGS) gdbreplay$(EXEEXT): $(GDBREPLAY_OBS) rm -f gdbreplay$(EXEEXT) - ${CC-LD} $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) -o gdbreplay$(EXEEXT) $(GDBREPLAY_OBS) \ - $(XM_CLIBS) + ${CC-LD} $(INTERNAL_CFLAGS) -o gdbreplay$(EXEEXT) $(GDBREPLAY_OBS) \ + $(XM_CLIBS) $(INTERNAL_LDFLAGS) # Put the proper machine-specific files first, so M-. on a machine # specific routine gets the one for the correct machine. diff --git a/gdb-7.1.x/gdb/gdbserver/linux-arm-low.c b/gdb-7.1.x/gdb/gdbserver/linux-arm-low.c index 54668f8..7a78cce 100644 --- a/gdb-7.1.x/gdb/gdbserver/linux-arm-low.c +++ b/gdb-7.1.x/gdb/gdbserver/linux-arm-low.c @@ -43,10 +43,7 @@ void init_registers_arm_with_neon (void); # define PTRACE_SETWMMXREGS 19 #endif -#ifndef PTRACE_GETVFPREGS -# define PTRACE_GETVFPREGS 27 # define PTRACE_SETVFPREGS 28 -#endif static unsigned long arm_hwcap;</span> #打补丁simba@simba-Vostro-3400:~/gdb_build$ cd gdb/
simba@simba-Vostro-3400:~/gdb_build/gdb$ patch -p1 <./gdb_patch.patch
3、下载build源码
simba@simba-Vostro-3400:~/gdb_build$ git clone https://android.googlesource.com/toolchain/build.git#坐等下载完毕,然后...
#编译 sysroot