Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,731,170 Members 49,163 Now Online
XDA Developers Android and Mobile Development Forum

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

Tip us?
 
alireza7991
Old
#1  
alireza7991's Avatar
Senior Member - OP
Thanks Meter 2205
Posts: 748
Join Date: Sep 2012
Location: Shahrekord

 
DONATE TO ME
Database [UTILITY] STrace 4.8 - Ultimate debugging utility now ported to Android !

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
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it.

Brian Kernighan
The Following 54 Users Say Thank You to alireza7991 For This Useful Post: [ Click to Expand ]
 
alireza7991
Old
#2  
alireza7991's Avatar
Senior Member - OP
Thanks Meter 2205
Posts: 748
Join Date: Sep 2012
Location: Shahrekord

 
DONATE TO ME
Only 4 downloads ?!
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it.

Brian Kernighan
The Following 3 Users Say Thank You to alireza7991 For This Useful Post: [ Click to Expand ]
 
Dovidhalevi
Old
(Last edited by Dovidhalevi; 2nd December 2013 at 12:21 PM.)
#3  
Senior Member
Thanks Meter 955
Posts: 1,972
Join Date: 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.
 
abhi922
Old
#4  
abhi922's Avatar
Recognized Contributor
Thanks Meter 3348
Posts: 1,105
Join Date: Jul 2012
Location: punjab

 
DONATE TO ME
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: [ Click to Expand ]
 
TecknoFreak
Old
#5  
TecknoFreak's Avatar
Senior Member
Thanks Meter 705
Posts: 1,781
Join Date: Feb 2011
Location: Deltona

 
DONATE TO ME
Quote:
Originally Posted by abhi922 View Post
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
Motorola Atrix HD(MB886)
Just Thank me if I Helped you. That will pay off my time if you do
If you think I did great then why not buy me a small coffee
 
kmandel
Old
#6  
Senior Member
Thanks Meter 3
Posts: 251
Join Date: 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?
 
TecknoFreak
Old
#7  
TecknoFreak's Avatar
Senior Member
Thanks Meter 705
Posts: 1,781
Join Date: Feb 2011
Location: Deltona

 
DONATE TO ME
you dont need an account to download. Between the 2 ads is the download button
Motorola Atrix HD(MB886)
Just Thank me if I Helped you. That will pay off my time if you do
If you think I did great then why not buy me a small coffee
 
kmandel
Old
#8  
Senior Member
Thanks Meter 3
Posts: 251
Join Date: Aug 2010
Quote:
Originally Posted by SVLAN View Post
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.
 
TecknoFreak
Old
#9  
TecknoFreak's Avatar
Senior Member
Thanks Meter 705
Posts: 1,781
Join Date: Feb 2011
Location: Deltona

 
DONATE TO ME
Once i run strace -p 123 it will come back
Code:
strace: attach: ptrace(PTRACE_ATTACH, ...): Operation not permitted
Motorola Atrix HD(MB886)
Just Thank me if I Helped you. That will pay off my time if you do
If you think I did great then why not buy me a small coffee
 
alireza7991
Old
#10  
alireza7991's Avatar
Senior Member - OP
Thanks Meter 2205
Posts: 748
Join Date: Sep 2012
Location: Shahrekord

 
DONATE TO ME
Quote:
Originally Posted by SVLAN View Post
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 !
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it.

Brian Kernighan

The Following 4 Users Say Thank You to alireza7991 For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes