Unix/Linux Go Back    


Android Brand new forum for folks interesting in Linux and Java-based Android OS and multi-platform mobile computing in general.

Strace help

Android


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 02-17-2013
far001han far001han is offline
Registered User
 
Join Date: Feb 2013
Last Activity: 18 February 2013, 3:03 PM EST
Posts: 11
Thanks: 2
Thanked 0 Times in 0 Posts
Error Strace help

I need to run and monitor applications on Android Emulator. I am using the strace utility to monitor system calls. Everytime to start strace i need to manually start the application , get the process Id of the application and then give it to strace to start logging all the system calls.

So is there a way by which i can automate all the process, i mean the moment i install an application , it should start the application and internally start the strace for the current application and start logging.

The application will be a user apllication , which i will install using adb install command.

So if somebody could help me with this, would be great .. Thanks in advance
Sponsored Links
    #2  
Old Unix and Linux 02-18-2013
DGPickett DGPickett is offline Forum Advisor  
Registered User
 
Join Date: Oct 2010
Last Activity: 1 February 2016, 3:35 PM EST
Location: Southern NJ, USA (Nord)
Posts: 4,673
Thanks: 8
Thanked 587 Times in 560 Posts
Sure, you just put the command at the end of the strace line. I have seen some apps balk at this manner of calling, so you can also do this at the shell prompt or in a wrapper script you execute in place of the app:
Code:
$ (sleep 2; run_app_with_args)& strace ... -o /tmp/this_trace.tr -p $!

The Following User Says Thank You to DGPickett For This Useful Post:
far001han (02-18-2013)
Sponsored Links
    #3  
Old Unix and Linux 02-18-2013
far001han far001han is offline
Registered User
 
Join Date: Feb 2013
Last Activity: 18 February 2013, 3:03 PM EST
Posts: 11
Thanks: 2
Thanked 0 Times in 0 Posts
Strace help (Android)

Quote:
Originally Posted by DGPickett View Post
Sure, you just put the command at the end of the strace line. I have seen some apps balk at this manner of calling, so you can also do this at the shell prompt or in a wrapper script you execute in place of the app:
Code:
$ (sleep 2; run_app_with_args)& strace ... -o /tmp/this_trace.tr -p $!


Hello DGPickett, do u mean this way
Code:
(sleep 2; am start com.android.mail)& strace  -o /tmp/this_trace.tr -p $!

because it says invalid PID $!
    #4  
Old Unix and Linux 02-18-2013
DGPickett DGPickett is offline Forum Advisor  
Registered User
 
Join Date: Oct 2010
Last Activity: 1 February 2016, 3:35 PM EST
Location: Southern NJ, USA (Nord)
Posts: 4,673
Thanks: 8
Thanked 587 Times in 560 Posts
Maybe the android shell has no '$!' for pid of last '&' ? Here is my hp-ux run, trussx being a wrapper for tusc, which is like strace, with lots of options:
Code:
$ (sleep 2;date)&trussx -o /tmp/date.tr -p $!
[1]     3554
tusc: ttrace feature level 6.
Mon Feb 18 11:28:05 EST 2013
[1] +  Done                    (sleep 2;date)&trussx -o /tmp/date.tr -p $!
$

Once we have $! happy, you need options like -aefl for args, env, fork and threads, and -rall -wall for full io reporting.

Last edited by DGPickett; 02-18-2013 at 11:40 AM..
Sponsored Links
    #5  
Old Unix and Linux 02-18-2013
far001han far001han is offline
Registered User
 
Join Date: Feb 2013
Last Activity: 18 February 2013, 3:03 PM EST
Posts: 11
Thanks: 2
Thanked 0 Times in 0 Posts
Strace help (Android)

Quote:
Originally Posted by DGPickett View Post
Maybe the android shell has no '$!' for pid of last '&' ? Here is my run, trussx being a wrapper for tusc, which is like strace, with lots of options:
Code:
$ (sleep 2;date)&trussx -o /tmp/date.tr -p $!
[1]     3554
tusc: ttrace feature level 6.
Mon Feb 18 11:28:05 EST 2013
[1] +  Done                    (sleep 2;date)&trussx -o /tmp/date.tr -p $!
$

Once we have $! happy, you need options like -aefl for args, env, fork and threads, and -rall -wall for full io reporting.
Does here sleep 2 means run for 2 seconds ???? .
Sponsored Links
    #6  
Old Unix and Linux 02-18-2013
DGPickett DGPickett is offline Forum Advisor  
Registered User
 
Join Date: Oct 2010
Last Activity: 1 February 2016, 3:35 PM EST
Location: Southern NJ, USA (Nord)
Posts: 4,673
Thanks: 8
Thanked 587 Times in 560 Posts
Yes, the subshell sleeps 2 seconds and then takes on the target command. The subshell runs in the background, and the tusc attaches to the subshell process. When the sleep ends, the subshell trace will show that and all the startup of the next command and its children, since I specify -f to follow forked children.
Sponsored Links
    #7  
Old Unix and Linux 02-18-2013
far001han far001han is offline
Registered User
 
Join Date: Feb 2013
Last Activity: 18 February 2013, 3:03 PM EST
Posts: 11
Thanks: 2
Thanked 0 Times in 0 Posts
Hii , DGPickett , thanks you code is working. A little more help , i am supposed to provide the package name in the command as input , so is there a way to read the package name from a path store in some variable and give as input to this??
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need help on strace output klng UNIX for Advanced & Expert Users 4 10-21-2012 08:55 PM
strace big123456 UNIX for Advanced & Expert Users 6 10-10-2011 06:59 AM
ioctl : strace angad.makkar UNIX for Advanced & Expert Users 1 03-12-2009 10:03 AM
strace p4cldba UNIX for Advanced & Expert Users 0 07-11-2008 12:31 PM
help running strace klam UNIX for Advanced & Expert Users 4 09-25-2006 10:06 AM



All times are GMT -4. The time now is 12:28 AM.