`
yanlijun250
  • 浏览: 749671 次
文章分类
社区版块
存档分类
最新评论

Android - How-to Rebuild gdbserver

 
阅读更多

Android - How-to Rebuild gdbserver

The gdbserver provided in Android releases is statically linked to Bionic libraries like libc and libthread_db. When there are large changes to bionic, it will be useful to rebuild gdbserver because you might otherwise see some strange behavior when debugging with GDB.

Contents

[hide]

[edit]Assumptions

  1. An Android baseline is located at $MYDROID and you have already followed instructions to build the baseline. For instructions, see [Getting Started]
  2. The examples in this tutorial assume that you built Android forBlazeplatform, but you should be able to apply them to any platform.
  3. We will be building gdbserver in a folder namedgdb_buildin your HOME directory.

[edit]Step 1: Download GDB Source and Toolchain Build Scripts

Android's toolchain repo manifest is located at git://android.git.kernel.org/toolchain/manifest.git. You can choose to repo init/sync the whole manifest, but for the purposes of this tutorial, we will just be cloning thegdbandbuildtrees. GDB source for Android is located at git://android.git.kernel.org/toolchain/gdb.git, and build scripts source is located at git://android.git.kernel.org/toolchain/build.git. For this tutorial, we will be downloading from the latest on the master branch.

[edit]Step 2: Create sysroot Directory

The sysroot directory contains all the header files and libraries needed to build gdbserver (and other Android toolchains but that will be for another topic). The script to generate the sysroot directory is in thebuildtree that we cloned in the last step. It basically just copies the relevant libraries and header files located in various places in your Android environment into a central location.

Syntax forbuild-sysroot.shscript:

 ./build/build-sysroot.sh <product out directory> <install directory>

Usage:

 

[edit]Step 3: Build gdbserver

Thendktree in your $MYDROID repo provides a script (build-gdbserver.sh) to rebuildgdbserver.

[edit]Modify Scripts

However, the scripts in NDK tree are for NDK users and not for developers with an entire Android environment, so we will need to make some small modifications.

$MYDROID/ndk/build/tools/build-gdbserver.sh removes the libthread_db related binaries and header files from the sysroot directory and tries to replace them with the ones found in the NDK. In our case, we want to use the libthread_db binaries that we built.

$

MYDROID/ndk/build/tools/prebuilt-common.sh points to the toolchain found in NDK. We want to use the toolchain provided in the $MYDROID/prebuilts tree.

[edit]Modify GDB 7.1.x

There is a small bug in the GDB 7.1.x code in the Android GDB tree.

  1. The Makefile.in for gdbserver has the LDFLAG in the wrong place for linking of gdbserver and gdbreplay
  2. PTRACE_GETVFPREGS is defined in Bionic's ptrace.h, but PTRACE_SETVFPREGS is undefined. Need to define it in gdb-7.1.x/gdb/gdbserver/linux-arm-low.c

Apply the following patch:

[edit]Build

To build gdbserver, run the following:

gdbserverwill be at$HOME/gdb_build/install/gdbserver

build-gdbserver.sh --help:

转自:http://www.omappedia.org/wiki/Android_-_How-to_Rebuild_gdbserver
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics