android_server x86,Build gdbserver for x86 Android

http://www.voidcn.com/article/p-wsxnwrsz-uz.html

http://omappedia.org/wiki/Android_-_How-to_Rebuild_gdbserver

The reference links are for ARM target and old Andriod version, when I tried to build gdbserver for x86 target with Android JB 4.2.2_r1, I got some differences:

Environment

Ubuntu 12.04

gdb-7.3.x

Android JB 4.2.2_r1

It seems the modification(Makefile.in and linux-arm-lower.c) in gdb server is not required for me.

Modification of build scripts

diff --git a/build/tools/build-gdbserver.sh b/build/tools/build-gdbserver.sh

index 2b6c1aa..b1ff8a5 100755

--- a/build/tools/build-gdbserver.sh

+++ b/build/tools/build-gdbserver.sh

@@ -143,30 +143,6 @@ BUILD_SYSROOT="$BUILD_OUT/sysroot"

run mkdir -p "$BUILD_SYSROOT"

run cp -RHL "$SYSROOT"/* "$BUILD_SYSROOT"

-# Remove libthread_db to ensure we use exactly the one we want.

-rm -f $BUILD_SYSROOT/usr/lib/libthread_db*

-rm -f $BUILD_SYSROOT/usr/include/thread_db.h

-

-if [ "$NOTHREADS" != "yes" ] ; then

- # We're going to rebuild libthread_db.o from its source

- # that is under sources/android/libthread_db and place its header

- # and object file into the build sysroot.

- LIBTHREAD_DB_DIR=$ANDROID_NDK_ROOT/sources/android/libthread_db/gdb-$GDB_VERSION

- if [ ! -d "$LIBTHREAD_DB_DIR" ] ; then

- dump "ERROR: Missing directory: $LIBTHREAD_DB_DIR"

- exit 1

- fi

- # Small trick, to avoid calling ar, we store the single object file

- # with an .a suffix. The linker will handle that seamlessly.

- run cp $LIBTHREAD_DB_DIR/thread_db.h $BUILD_SYSROOT/usr/include/

- run $TOOLCHAIN_PREFIX-gcc --sysroot=$BUILD_SYSROOT -o $BUILD_SYSROOT/usr/lib/libthread_db.o -c $LIBTHREAD_DB_DIR/libthread_db.c

- run $TOOLCHAIN_PREFIX-ar -r $BUILD_SYSROOT/usr/lib/libthread_db.a $BUILD_SYSROOT/usr/lib/libthread_db.o

- if [ $? != 0 ] ; then

- dump "ERROR: Could not compile libthread_db.c!"

- exit 1

- fi

-fi

-

log "Using build sysroot: $BUILD_SYSROOT"

# configure the gdbserver build now

diff --git a/build/tools/prebuilt-common.sh b/build/tools/prebuilt-common.sh

index 9a13d29..9b111a6 100644

--- a/build/tools/prebuilt-common.sh

+++ b/build/tools/prebuilt-common.sh

@@ -1127,7 +1127,7 @@ get_toolchain_install ()

get_toolchain_install_subdir ()

{

local SYSTEM=${2:-$(get_prebuilt_host_tag)}

- echo "toolchains/$1/prebuilt/$SYSTEM"

+ echo "prebuilts/gcc/$SYSTEM/x86/i686-linux-android-4.6"

}

# Return the relative install prefix for prebuilt host

Compiling errors and solutions

conflicting types

error

/home/peter/workspace/android_4.2.2_r1/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.6/bin/i686-linux-android-gcc --sysroot=/home/peter/workspace/gdb_build/install/sysroot -o memmem.o -c -O2 -nostdlib -D__ANDROID__ -DANDROID -DSTDC_HEADERS -I/home/peter/workspace/android_4.2.2_r1/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.6/lib/gcc/i686-linux-android//include -I/home/peter/workspace/gdb_build/install/sysroot/usr/include -I. -I/home/peter/workspace/gdb_build/gdb/gdb-7.3.x/gdb/gdbserver -I/home/peter/workspace/gdb_build/gdb/gdb-7.3.x/gdb/gdbserver/../common -I/home/peter/workspace/gdb_build/gdb/gdb-7.3.x/gdb/gdbserver/../regformats -I/home/peter/workspace/gdb_build/gdb/gdb-7.3.x/gdb/gdbserver/../../include -Wall -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral -Wno-char-subscripts /home/peter/workspace/gdb_build/gdb/gdb-7.3.x/gdb/gdbserver/../gnulib/memmem.c

In file included from /home/peter/workspace/gdb_build/install/sysroot/usr/include/sys/_types.h:40:0,

from /home/peter/workspace/gdb_build/install/sysroot/usr/include/stdint.h:32,

from /home/peter/workspace/android_4.2.2_r1/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.6/bin/../lib/gcc/i686-linux-android/4.6/include/stdint.h:3,

from /home/peter/workspace/gdb_build/gdb/gdb-7.3.x/gdb/gdbserver/../gnulib/str-two-way.h:45,

from /home/peter/workspace/gdb_build/gdb/gdb-7.3.x/gdb/gdbserver/../gnulib/memmem.c:34:

/home/peter/workspace/gdb_build/install/sysroot/usr/include/machine/_types.h:44:24: error: conflicting types for 'size_t'

/home/peter/workspace/android_4.2.2_r1/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.6/bin/../lib/gcc/i686-linux-android/4.6/include/stddef.h:212:23: note: previous declaration of 'size_t' was here

/home/peter/workspace/gdb_build/install/sysroot/usr/include/machine/_types.h:46:24: error: conflicting types for 'ptrdiff_t'

/home/peter/workspace/android_4.2.2_r1/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.6/bin/../lib/gcc/i686-linux-android/4.6/include/stddef.h:150:26: note: previous declaration of 'ptrdiff_t' was here

/home/peter/workspace/gdb_build/gdb/gdb-7.3.x/gdb/gdbserver/../gnulib/memmem.c:40:1: error: conflicting types for 'memmem'

/home/peter/workspace/gdb_build/install/sysroot/usr/include/string.h:44:15: note: previous declaration of 'memmem' was here

solution

sysroot/usr/include/machine/_types.h:

#if 0//!defined(__ARM_EABI__)

/* the kernel defines size_t as unsigned int, but g++ wants it to be unsigned long */

#define _SIZE_T

#define _SSIZE_T

#define _PTRDIFF_T

typedef unsigned long size_t;

typedef long ssize_t;

typedef long ptrdiff_t;

#endif

no such instruction

error

/home/peter/workspace/gdb_build/gdb/gdb-7.3.x/gdb/gdbserver/gdbreplay.c: Assembler messages:

/home/peter/workspace/gdb_build/gdb/gdb-7.3.x/gdb/gdbserver/gdbreplay.c:232: Error: no such instruction: `rev16 %ax,%ax'

make: *** [gdbreplay.o] Error 1

make: *** Waiting for unfinished jobs....

/home/peter/workspace/gdb_build/gdb/gdb-7.3.x/gdb/gdbserver/remote-utils.c: Assembler messages:

/home/peter/workspace/gdb_build/gdb/gdb-7.3.x/gdb/gdbserver/remote-utils.c:410: Error: no such instruction: `rev16 %ax,%ax'

/home/peter/workspace/gdb_build/gdb/gdb-7.3.x/gdb/gdbserver/remote-utils.c:426: Error: no such instruction: `rev16 %si,%si'

solution

copy following files from host /usr/include/bits

sysroot/usr/include/bits/

├── byteswap.h

└── wordsize.h

--- /usr/include/bits/byteswap.h2013-09-30 23:03:21.000000000 +0800

+++ sysroot/usr/include/bits/byteswap.h2014-01-05 14:07:28.222628058 +0800

@@ -19,7 +19,7 @@

02111-1307 USA. */

#if !defined _BYTESWAP_H && !defined _NETINET_IN_H && !defined _ENDIAN_H

-# error "Never use directly; include instead."

+//# error "Never use directly; include instead."

#endif

#ifndef _BITS_BYTESWAP_H

@@ -134,4 +134,9 @@

# endif

#endif

+# define ntohl(x) __bswap_32 (x)

+# define ntohs(x) __bswap_16 (x)

+# define htonl(x) __bswap_32 (x)

+# define htons(x) __bswap_16 (x)

+

#endif /* _BITS_BYTESWAP_H */

gdb-7.3.x/gdb/gdbserver/remote-utils.c

gdb-7.3.x/gdb/gdbserver/gdbreplay.c

#ifdef HAVE_NETINET_IN_H

+#include

#include

#endif

'EAX' undeclared here (not in a function)

copy reg.h from /usr/include/sys/reg.h

--- a/gdb-7.3.x/gdb/gdbserver/linux-x86-low.c

+++ b/gdb-7.3.x/gdb/gdbserver/linux-x86-low.c

@@ -57,7 +57,7 @@ static const char *xmltarget_amd64_linux_no_xml = "@\

";

#endif

-#ifdef HAVE_SYS_REG_H

+#if 1 //def HAVE_SYS_REG_H

#include

#endif

#ifdef HAVE_SYS_PROCFS_H

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值