Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[UTILITY] STrace 4.8 - Ultimate debugging utility now ported to Android !

OP alireza7991

7th November 2013, 05:52 AM   |  #1  
alireza7991's Avatar
OP Senior Member
Flag Shahrekord
Thanks Meter: 2,274
 
771 posts
Join Date:Joined: Sep 2012
Donate to Me
More
about Strace

Android provides Logcat for tracing and debugging Apps , Logcat provides too short information and limited apps also programs has to support logcat or there wo'nt be any log ! this makes Android logcar be completely un-useful in large/advanced programs .

strace is a debugging utility to monitor a program system calls or signals it receives . strace is used while we want to find the reason a program crashes or finding out what causes a process not to work as expected .

strace is much more powerful than Android Logcat . unlike logcat , any process may be monitored by strace also there is no need to rewrite a program for support of strace

usage & downloading

I have ported strace to Android and it works without any bugs

download the lastest binary from this post , move it to /system/bin and set permissions to 755 .

strace has a lot of options you can find by running it using :

Code:
strace --help
most common functions are :

1- using strace to monitor a command :

Code:
strace echo hello
2- using strace to monitor an App/process :

Code:
strace -p 123
(123 is a example , use any other PID you wish )

here is an example of running strace with hello command :

Code:
ALIREZA | strace echo hello
execve("/system/xbin/echo", ["echo", "hello"], [/* 26 vars */]) = 0
mprotect(0x4005d000, 75164, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
mprotect(0x4005d000, 77824, PROT_READ|PROT_EXEC) = 0
mprotect(0x40070000, 4096, PROT_READ)   = 0
gettid()                                = 31648
set_tls(0x40080f6c, 0x40080f30, 0x40081068, 0x40, 0x40080f30) = 0
getpid()                                = 31648
sigaction(SIGILL, {0x40062ba1, [], SA_RESTART|SA_SIGINFO}, NULL, 0x397a4) = 0
sigaction(SIGABRT, {0x40062ba1, [], SA_RESTART|SA_SIGINFO}, NULL, 0x397a4) = 0
sigaction(SIGBUS, {0x40062ba1, [], SA_RESTART|SA_SIGINFO}, NULL, 0x397a4) = 0
sigaction(SIGFPE, {0x40062ba1, [], SA_RESTART|SA_SIGINFO}, NULL, 0x397a4) = 0
sigaction(SIGSEGV, {0x40062ba1, [], SA_RESTART|SA_SIGINFO}, NULL, 0x397a4) = 0
sigaction(SIGSTKFLT, {0x40062ba1, [], SA_RESTART|SA_SIGINFO}, NULL, 0x397a4) = 0
sigaction(SIGPIPE, {0x40062ba1, [], SA_RESTART|SA_SIGINFO}, NULL, 0x397a4) = 0
mprotect(0x8000, 500100, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
stat64("/vendor/lib/libc.so", 0xbea736b8) = -1 ENOENT (No such file or directory)
stat64("/system/lib/libc.so", {st_mode=S_IFREG|0644, st_size=286596, ...}) = 0
open("/system/lib/libc.so", O_RDONLY)   = 7
lseek(7, 0, SEEK_SET)                   = 0
read(7, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\0\0\0\0004\0\0\0"..., 4096) = 4096
lseek(7, -8, SEEK_END)                  = 286588
read(7, "\1\0\0\0\0\0\0\0", 8)          = 8
mmap2(NULL, 331776, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x400f7000
madvise(0x400f7000, 331776, 0xc /* MADV_??? */) = 0
mmap2(0x400f7000, 271932, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 7, 0) = 0x400f7000
madvise(0x400f7000, 271932, 0xc /* MADV_??? */) = 0
mprotect(0x400f7000, 274432, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
mmap2(0x4013a000, 10344, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 7, 0x43) = 0x4013a000
madvise(0x4013a000, 10344, 0xc /* MADV_??? */) = 0
mmap2(0x4013d000, 45051, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4013d000
madvise(0x4013d000, 45051, 0xc /* MADV_??? */) = 0
close(7)                                = 0
mprotect(0x400f7000, 274432, PROT_READ|PROT_EXEC) = 0
stat64("/vendor/lib/liblog.so", 0xbea736b8) = -1 ENOENT (No such file or directory)
stat64("/system/lib/liblog.so", {st_mode=S_IFREG|0644, st_size=13536, ...}) = 0
open("/system/lib/liblog.so", O_RDONLY) = 7
lseek(7, 0, SEEK_SET)                   = 0
read(7, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\0\0\0\0004\0\0\0"..., 4096) = 4096
lseek(7, -8, SEEK_END)                  = 13528
read(7, "\1\0\0\0\0\0\0\0", 8)          = 8
mmap2(NULL, 20480, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4000d000
madvise(0x4000d000, 20480, 0xc /* MADV_??? */) = 0
mmap2(0x4000d000, 11235, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 7, 0) = 0x4000d000
madvise(0x4000d000, 11235, 0xc /* MADV_??? */) = 0
mprotect(0x4000d000, 12288, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
mmap2(0x40010000, 4116, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 7, 0x2) = 0x40010000
madvise(0x40010000, 4116, 0xc /* MADV_??? */) = 0
close(7)                                = 0
stat64("/vendor/lib/libstdc++.so", 0xbea73618) = -1 ENOENT (No such file or directory)
stat64("/system/lib/libstdc++.so", {st_mode=S_IFREG|0644, st_size=5336, ...}) = 0
open("/system/lib/libstdc++.so", O_RDONLY) = 7
lseek(7, 0, SEEK_SET)                   = 0
read(7, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\0\0\0\0004\0\0\0"..., 4096) = 4096
lseek(7, -8, SEEK_END)                  = 5328
read(7, "\1\0\0\0\0\0\0\0", 8)          = 8
mmap2(NULL, 12288, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40082000
madvise(0x40082000, 12288, 0xc /* MADV_??? */) = 0
mmap2(0x40082000, 2656, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 7, 0) = 0x40082000
madvise(0x40082000, 2656, 0xc /* MADV_??? */) = 0
mprotect(0x40082000, 4096, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
mmap2(0x40083000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 7, 0) = 0x40083000
madvise(0x40083000, 4096, 0xc /* MADV_??? */) = 0
mmap2(0x40084000, 16, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40084000
madvise(0x40084000, 16, 0xc /* MADV_??? */) = 0
close(7)                                = 0
mprotect(0x40082000, 4096, PROT_READ|PROT_EXEC) = 0
mprotect(0x40083000, 4096, PROT_READ)   = 0
stat64("/vendor/lib/libm.so", 0xbea73618) = -1 ENOENT (No such file or directory)
stat64("/system/lib/libm.so", {st_mode=S_IFREG|0644, st_size=91288, ...}) = 0
open("/system/lib/libm.so", O_RDONLY)   = 7
lseek(7, 0, SEEK_SET)                   = 0
read(7, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\0\0\0\0004\0\0\0"..., 4096) = 4096
lseek(7, -8, SEEK_END)                  = 91280
read(7, "\1\0\0\0\0\0\0\0", 8)          = 8
mmap2(NULL, 98304, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x400d8000
madvise(0x400d8000, 98304, 0xc /* MADV_??? */) = 0
mmap2(0x400d8000, 85924, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 7, 0) = 0x400d8000
madvise(0x400d8000, 85924, 0xc /* MADV_??? */) = 0
mprotect(0x400d8000, 86016, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
mmap2(0x400ee000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 7, 0x15) = 0x400ee000
madvise(0x400ee000, 4096, 0xc /* MADV_??? */) = 0
mmap2(0x400ef000, 32, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x400ef000
madvise(0x400ef000, 32, 0xc /* MADV_??? */) = 0
close(7)                                = 0
mprotect(0x400d8000, 86016, PROT_READ|PROT_EXEC) = 0
mprotect(0x400ee000, 4096, PROT_READ)   = 0
mprotect(0x4000d000, 12288, PROT_READ|PROT_EXEC) = 0
mprotect(0x40010000, 4096, PROT_READ)   = 0
stat64("/vendor/lib/libcutils.so", 0xbea736b8) = -1 ENOENT (No such file or directory)
stat64("/system/lib/libcutils.so", {st_mode=S_IFREG|0644, st_size=63252, ...}) = 0
open("/system/lib/libcutils.so", O_RDONLY) = 7
lseek(7, 0, SEEK_SET)                   = 0
read(7, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\0\0\0\0004\0\0\0"..., 4096) = 4096
lseek(7, -8, SEEK_END)                  = 63244
read(7, "\1\0\0\0\0\0\0\0", 8)          = 8
mmap2(NULL, 126976, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40148000
madvise(0x40148000, 126976, 0xc /* MADV_??? */) = 0
mmap2(0x40148000, 58972, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED, 7, 0) = 0x40148000
madvise(0x40148000, 58972, 0xc /* MADV_??? */) = 0
mprotect(0x40148000, 61440, PROT_READ|PROT_WRITE|PROT_EXEC) = 0
mmap2(0x40157000, 4620, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 7, 0xe) = 0x40157000
madvise(0x40157000, 4620, 0xc /* MADV_??? */) = 0
mmap2(0x40159000, 57096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40159000
madvise(0x40159000, 57096, 0xc /* MADV_??? */) = 0
close(7)                                = 0
mprotect(0x40148000, 61440, PROT_READ|PROT_EXEC) = 0
mprotect(0x40157000, 4096, PROT_READ)   = 0
mprotect(0x8000, 503808, PROT_READ|PROT_EXEC) = 0
mmap2(NULL, 49152, PROT_READ, MAP_SHARED, 8, 0) = 0x400a4000
futex(0x40140734, FUTEX_WAKE_PRIVATE, 2147483647) = 0
open("/dev/urandom", O_RDONLY)          = 7
read(7, "@\236", 4)                   = 4
close(7)                                = 0
clock_gettime(CLOCK_MONOTONIC, {29544, 299349465}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40167000
madvise(0x40167000, 4096, 0xc /* MADV_??? */) = 0
mprotect(0x40167000, 4096, PROT_READ)   = 0
getuid32()                              = 0
brk(0)                                  = 0xf0d000
brk(0xf0d000)                           = 0xf0d000
brk(0xf0e000)                           = 0xf0e000
write(1, "hello\n", 6hello
)                  = 6
mprotect(0x40167000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x40167000, 4096, PROT_READ)   = 0
futex(0x4014072c, FUTEX_WAKE_PRIVATE, 2147483647) = 0
munmap(0x40167000, 4096)                = 0
exit_group(0)                           = ?
and now lastest download link :

Download Strace 4.8 from here

license

strace is a free software, you may download source of strace from here
The Following 54 Users Say Thank You to alireza7991 For This Useful Post: [ View ]
30th November 2013, 05:58 PM   |  #2  
alireza7991's Avatar
OP Senior Member
Flag Shahrekord
Thanks Meter: 2,274
 
771 posts
Join Date:Joined: Sep 2012
Donate to Me
More
Only 4 downloads ?!
The Following 3 Users Say Thank You to alireza7991 For This Useful Post: [ View ]
2nd December 2013, 01:19 PM   |  #3  
Senior Member
Thanks Meter: 1,017
 
2,135 posts
Join Date:Joined: Jun 2012
Segfault any attemp to use it!

Running on LG P500 (ARMv6) cm-10.2

OK, guess what? Already have it on /system/xbin and that does work.
Last edited by Dovidhalevi; 2nd December 2013 at 01:21 PM.
2nd December 2013, 03:34 PM   |  #4  
abhi922's Avatar
Recognized Contributor
Flag punjab
Thanks Meter: 3,842
 
1,206 posts
Join Date:Joined: Jul 2012
Donate to Me
More
Smile
Very nice tool/utility man.....
will try it to solve issues on my roms...
thanks man

regards,
abhi922.
The Following User Says Thank You to abhi922 For This Useful Post: [ View ]
2nd December 2013, 04:26 PM   |  #5  
TecknoFreak's Avatar
Recognized Contributor
Flag Deltona
Thanks Meter: 920
 
2,022 posts
Join Date:Joined: Feb 2011
Donate to Me
More
Quote:
Originally Posted by abhi922

Very nice tool/utility man.....
will try it to solve issues on my roms...
thanks man

regards,
abhi922.

Dido, I needed such a tool too.
Thanks
2nd December 2013, 04:46 PM   |  #6  
Senior Member
Thanks Meter: 5
 
272 posts
Join Date:Joined: Aug 2010
Would like to try it, but the download link requires me to sign up for an account. Can't you make this available some other way?
2nd December 2013, 04:56 PM   |  #7  
TecknoFreak's Avatar
Recognized Contributor
Flag Deltona
Thanks Meter: 920
 
2,022 posts
Join Date:Joined: Feb 2011
Donate to Me
More
you dont need an account to download. Between the 2 ads is the download button
2nd December 2013, 05:01 PM   |  #8  
Senior Member
Thanks Meter: 5
 
272 posts
Join Date:Joined: Aug 2010
Quote:
Originally Posted by SVLAN

you dont need an account to download. Between the 2 ads is the download button

Thanks, I got it! I really hate these purposely misleading download sites.
2nd December 2013, 05:41 PM   |  #9  
TecknoFreak's Avatar
Recognized Contributor
Flag Deltona
Thanks Meter: 920
 
2,022 posts
Join Date:Joined: Feb 2011
Donate to Me
More
Once i run strace -p 123 it will come back
Code:
strace: attach: ptrace(PTRACE_ATTACH, ...): Operation not permitted
2nd December 2013, 06:26 PM   |  #10  
alireza7991's Avatar
OP Senior Member
Flag Shahrekord
Thanks Meter: 2,274
 
771 posts
Join Date:Joined: Sep 2012
Donate to Me
More
Quote:
Originally Posted by SVLAN

Once i run strace -p 123 it will come back

Code:
strace: attach: ptrace(PTRACE_ATTACH, ...): Operation not permitted

I said :

Quote:

(123 is a example , use any other PID you wish )

You must use the a valid PID , 123 is an example .

For getting PID of an APP/Process , use the this command in terminal :

Code:
ps | grep "abc"
instead of abc , write the process name you want ! for example :

Code:
ps | grep "com.android.acore"
then search for PID in the output and use it with strace !

The Following 5 Users Say Thank You to alireza7991 For This Useful Post: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes