The instructions are very precise, following them you get your statically linked
strace
.
Just to be safe (in case the original source disappears), I'll back up the instructions for myself:
- Prerequisite: you already have downloaded Sourcery CodeBench Lite (which includes a free GNU toolchain and cross-compiler), make sure you select ARM GNU/Linux and then IA32 GNU/Linux.
- Download the strace source distribution from the SourceForge strace project.
- Extract the strace package on your linux machine.
- Set your compiler information:
export CC=your_cross_compiler_folder/bin/arm-none-linux-gnueabi-gcc
export STRIP=your_cross_compiler_folder/bin/arm-none-linux-gnueabi-strip
export CFLAGS="-O2 -static"
Note: CFLAGS
is by default -g -O2
, but we need static linking and (optionally) no debug information. You can even leave out -static
, but in that case you'll have to ship the compiled executable with all the referenced shared libs from the cross compiler!
- Add
your_cross_compiler_folder/bin
into your $PATH
.
- Change your current folder to the strace folder (where you extracted the source), use command:
./configure --host=arm-linux
Optionally you might want to specify a prefix with --prefix=/data/local
.
- Compile:
make
- Verify the result (eg. static linking) with the command:
file strace
You shall see:
strace: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.14, statically linked, not stripped
- Optionally you can strip symbols from it with:
$STRIP strace
(if you only need the executable)
Or package it into a TGZ:
tmpdir="$(mktemp -d)"
mkdir -p "$tmpdir/data/local"
make install-strip prefix="$tmpdir/data/local"
dir="$(dirname "$(pwd)")"
packagefile="$dir/$(basename "$(pwd)")-bin.tgz"
cd "$tmpdir"
fakeroot -- sh -c "chmod -R a+rX,u+w,go-w data && chown -R root:root data && tar czf \"$packagefile\" data"
cd "$dir"
rm -rf "$tmpdir"
Done, you have another powerful tool for your Android.
To use it to trace an already running app (APK), run
ps
to get the PID of the process, then use the
-p
switch.
Eg.
/data/local/bin/strace -p 4132
P.S.: I've made a few changes (imho optimizations) to the original instructions.
Update (2013.05.23): I've reapplied the same instructions to compile strace v4.7 with Sourcery CodeBench Lite 2013.05-24. I installed the latter with the linux installer (arm-2013.05-24-arm-none-linux-gnueabi.bin) in my user home directory on a 32-bit Ubuntu 10.10 (x86) server. I've attached the compiled TGZ package that you can simply extract into your filesystem and it'll put all strace files into
/data/local
.
Update (2014.01.25): I've reapplied the same instructions to compile strace v4.8 with Sourcery CodeBench Lite 2013.05-24 (note that the compilation failed with the latest version -which was 2013.11-33 at the time of writing-, so I reverted back to 2013.05-24). This time I used a 32-bit Ubuntu 12.04 (x86) virtual machine. I've attached the compiled TGZ package that you can simply extract into your filesystem and it'll put all strace files into
/data/local
.
Comments
How to use strace-4.6 to see binder ioctl logs?
I tried this version. It seems almost same with strace 4.6. Could you tell me how to use this version to see /dev/binder ioctl buffers?
Thanks
-Leon
Please help me about Strace at android emulator
I download adnroid ndk and copy it inti C drive
I push strace folder into data/local/tmp and
set chnod 777 to ./configure and strace folder!
now i must set
export STRIP=C:\android-ndk-r8b\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\arm-linux-androideabi\bin/strip ????
and when i run ./configure at adb root
after set chmod 777 i get error that configure not fonud!
and before this show only permission denide !
Re: Please help me about Strace at android emulator
I want use strace at android
I download strace binary and push it into android ! /xbin
but I think this binary dosnt work truely!
I need use strace into android emulator (armeabi) emergency!
can you get me binary of strace !
Re: I want use strace at android emulator!