Wednesday, January 16, 2008

Create google android strace tool

Prerequisite, you already have the cross compiler downloaded from download GNU toolchain site, make sure you select ARM GNU/Linux, and IA32 GNU/Linux.

  1. Download the strace source distribution from SourceForge strace project
  2. Extract the strace package on your linux machine
  3. Set your cross compiler information with command: # export CC=your_cross_compiler_folder/bin/arm-none-linux-gnueabi-gcc
  4. Add your_cross_compiler_folder/bin into your $PATH for path searching
  5. Change your current folder to strace package extract folder, use command: # ./configure -host=arm-linux
  6. You have the Makefile generated, edit it, append -static after CFLAGS variable in Makefile
  7. Compile it with simple command: # make
  8. You have the strace now, verify it with 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"
Done, you have another powerful tool for your android

13 comments:

Unknown said...

According guide,I ran my strace on my android emulator shell.However I got a error like this,
# ./strace ./hello
execve("./hello", ["./hello"], [/* 10 vars */]) = 0
syscall: unknown syscall trap 0xe8bd8010.
Could you help me?Thanks

rtm said...

It looks your "hello" can not be executed. Do you have error if you just run "./hello"? How is your hello created? It must be a static linked executable or dynamic linked to bionic libc.

sasha said...

The Team Android phenomenon is spreading like wildfire. Lots of people are turning to the openness and diversity of Android smartphones when choosing a mobile device.
best android apps

best iphone apps

Unknown said...

That an interesting post. I never thought about this before. But, looking back at different situations, this might be right. Keep it up friend!
best online pharmacy

Jasmine Carrel said...

I want to express my admiration of your writing skill and ability to make readers read from the beginning to the end.
Generic Plavix

jean-michel said...

give us directly the binary

Unknown said...

Wow!! What a great writing, really I appreciate such kind of topics. It will be very helpful for us. Waiting for more articles, blogs like this. I’m going bookmark your blog for future reference. Thanks a lot for sharing this.
advertising | top advertising agencies in Pakistan | Marketing Agency | Advertisement

Unknown said...

Hi,
I have a strace command, but when I run it I recive the following message:
PTRACE_SYSCALL doesn't work: Function not implemented

Unknown said...

Thanks, this post solves my problem. But things have changed after this post, so here I pasted my procedures here for the followers:

building strace for android

# download sources
```
git clone https://github.com/strace/strace.git

cd strace
```

# set compiler info
```
export COMPILER_PATH=/home/xcy/Android/Sdk/my-android-toolchain
export CC=$COMPILER_PATH/bin/arm-linux-androideabi-gcc

export STRIP=$COMPILER_PATH/bin/arm-linux-androideabi-strip

export CFLAGS="-O2 -static"

export PATH=$PATH:$COMPILER_PATH/bin
```

# compile

enter the source folder and do following steps,

```
// use autoconf to generate configure from configure.ac
xcy@uxcy:~/ws/strace/strace$ autoconf
configure.ac:25: error: possibly undefined macro: AM_INIT_AUTOMAKE
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
configure.ac:26: error: possibly undefined macro: AM_MAINTAINER_MODE

xcy@uxcy:~/ws/strace/strace$ ls | grep configure
configure
configure.ac
README-configure

// generate makefile.in
xcy@uxcy:~/ws/strace/strace$ ./bootstrap
...
xcy@uxcy:~/ws/strace/strace$ ls | grep Make
Makefile.am
Makefile.in

xcy@uxcy:~/ws/strace/strace$ ./configure --host=arm-linux

xcy@uxcy:~/ws/strace/strace$ make

xcy@uxcy:~/ws/strace/strace$ file strace
strace: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, not stripped

xcy@uxcy:~/ws/strace/strace$ $STRIP strace
xcy@uxcy:~/ws/strace/strace$ file strace
strace: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, stripped

```

Unknown said...

Hello,

Can you please number your steps for cross compiling strace on android because i can't understand which are the commands and which are the output.
Also are these commands run on git before connecting the android phone to usb?

Digisol Hub said...

DigisolHub
Search Engine Optimization SEO is an organic method step by step that gives the website “search words” importance. SEO-friendly content which is written on the website can be optimised easily. If you want to rank your website on Google or Amazon, SEO experts plan and execute strategies in such a way that your content on websites gets more traffic. Usually, a website takes 4 to 6 months to get optimised. Here are the following tips which should be kept in mind in order to avoid SEO errors… read more

BUY ROUTERS AND SWITCHES said...

IT Innovation Inc is a leading provider of network products with 27000+ customers in over 200 countries and regions. We provide original new and used network equipment (Cisco, Huawei, HPE, Dell, Juniper, Fortinet) to our global customer base.

amd 5950x price
c9200l 24t 4g e
ws c2960x 48fpd l
fg 30e
fg 100f
ws c2960l 16ps ll
ws c2960x 48td l

BUY ROUTERS AND SWITCHES said...

IT Innovation Inc is a leading provider of network products with 27000+ customers in over 200 countries and regions. We provide original new and used network equipment (Cisco, Huawei, HPE, Dell, Juniper, Fortinet) to our global customer base.

WS-C2960X-48LPS-L
ws-c2960x-48fpd-l
WS-C2960S-48TD-L
WS-C2960X-48LPD-L
WS-C2960+48TC-L
WS-C2960S-24TS-L
ws c2960x 48td l
ws-c2960l-16ps-ll