Android Systrace tool internally uses strace or ftrace? - android

Systrace Android tool calls internally a tool called atrace which is and extension of ftrace or strace (Linux tools).
If we connect via the emulator console (ADB shell) to Android Jelly Bean we can execute strace tool but we can not execute ftrace tool (command not installed).
Doing some reseach over the Internet I found that strace is a predecessor of ftrace:
http://crtags.blogspot.de/2012/04/dtrace-ftrace-ltrace-strace-so-many-to.html
Looking to Android Source Code, the most "internal" reference that I found is Trace.h file:
http://androidxref.com/4.1.1/xref/frameworks/native/include/utils/Trace.h
I think that this file is then resolved to a native Linux driver.
However, I'm still unable to know if this implementation driver belongs to strace or ftrace. "Normally", it should be ftrace because it is newer, but in that case I don't know why we can not run ftrace from the emulator. In contrast, strace is completely available from the emulator.
Then, does someone knows if Systrace Android tool uses at a very low level strace or ftrace?
Thank you!

I've follow the instructions found here, related to ftrace,:
http://www.linuxforu.com/2010/11/kernel-tracing-with-ftrace-part-1/
Everything works perfect. I wasn't able to execute ftrace before because interacting and retrieving data is done via logical paths.
To execute ftrace, after correctly configuration (many steps...), inside adb shell:
root#android:# cat /sys/kernel/debug/tracing/trace > mytracefile.txt
atrace makes configuration process easier, so we can access to trace information the following way:
root#android:# atrace -s -w -t 100 > mytracefile.txt
On the other hand, I've found information about executing strace here:
http://www.hokstad.com/5-simple-ways-to-troubleshoot-using-strace
All indicated examples were successfully executed in my environment using adb shell.
Interaction and access to results of both tools are very different.
Now I can say that systrace Android tool is based in atrace which in turn is based in ftrace.
strace is also supported but serves to another purposes and is not related to systrace.
Regards,

Related

Execute shell commands

I developed a standalone executable for Android, and I try to execute some shell commands in the c++ code.
I firstly tried to use popen and it worked on some devices but there is a specific device which fails.
exec and fork also not working on this device and even "system()" doesn't.
I understand the libc of Android (bionic) may not include these calls but I can't find a generic way to execute some shell commands which works in all of my devices.
I also couldn't find any documentation about it in the NDK documentation.
That is very weird because Android Java API expose the "Runtime.exec()" function which works great, then why it's so hard to do it in the native side.
EDIT:
errno of system is "Success".

Compile and run ARM assembly code via SSH on Android Lollipop

I am trying to run some ARM assembly codes on Snapdragon 810 development board to evaluate performance on Cortex-A53 and A57 processors. My codes are nothing to do with android applications and they are C/Assembly coeds. Moreover, I want to get remote access to the board preferably via SSH and run gcc commands. The board default OS in Android Lollipop and my first intention was to install Linux on it to make things work desirably. However, Qualcomm customer support informed me that Linux isn't supported by this board and I have to deal with Android.
I've already searched over various forums. Some of them suggest to root the Android device, install QuickSSHD or SSHDroid on the device and simply SSH to it. However, I am not sure if the provided console has the capability of running gcc commands, generating executable and running it. Others, suggest to generate executable using cross-compilation and push the executable via adb console and run it on the Android device. This approach makes more sense, but I need to have remote access via SSH to the board and edit my code on the device continuously.
My question is, what is the best and easiest approach to get remote access via SSH to this device, compile and run C/ARM Assembly code, transfer files and get the real timing of my codes?!
Cross compile is the easiest option to generate the executable. Else you will have to port GCC to the target first. Don't even bother.
And Adb is a lot better when dealing with Android devices as you need not install any additional applications/executables to get it working. Adb can work on TCP connection as well. So there is no need of SSH for the task. And if the device is rooted, "adb root" followed by "adb shell" would give you the root console.

How to compile and use adb on Ubuntu 12.04?

I am following Google's instructions
to build Android on Ubuntu 12.04.
Somewhere on https://source.android.com/source/building-devices.html it says
If you don't already have those tools, fastboot and adb can be built
with the regular build system. Follow the instructions on the page
about Building and Running, and replace the main make command with
$ make fastboot adb
After using that command, the compile seems to complete fine. I then found an adb binary at
<path>/out/target/product/generic/system/bin/adb
However, when I try to use that I get an "cannot execute binary file" error.
Could it be that it was compiled for the wrong architecture? Do I need to configure something (e.g., with lunch) before the "make fastboot adb"?
Found the solution myself. I was looking at the wrong binary. The right one was at
<path>/out/host/linux-x86/obj/EXECUTABLES/adb_intermediates/adb
Now
adb devices
produces a list of devices (with one entry for the phone).

wpl_cli :not found with rooted android device?

i rooted my android device then i go to adb shell, then type su to enter wpa_cli. i surprise that this appeared : wpa_cli: not found although i get information when i type : wpa_supplicant?
i know that wpa_cli from same library wpa_supplicant?
from this link
android is linux based!! so why these commands can't be found in their kernel ?
Because wpa_supplicant is not a library, it's an executable. Brief introduction is here: http://en.wikipedia.org/wiki/Wpa_supplicant‎ and source code is here: https://github.com/android/platform_external_wpa_supplicant
Yes, wpa_cli is built from the same code base, but is not included on most phones. Android uses the wpa_crl.c/wpa_ctrl.h interface, not the command line utility wpa_cli.
The kernel doesn't contain commands and executables invoked through a shell.

Getting Android SDK version of a device from command line

I'm planning to build an automated system for deploying an Android build to various devices, in order to make development for multiple platforms a bit more comfortable. Is there a way to get the sdk version of a connected device through android shell or adb?
There will be a computer to which several test devices is connected, and I was planning to write a script which will fetch the correct build for each of those from a build-server, install the different apks on their respective devices, launch them and collect log info, to be made available through some other program whose specifications are beside the point.
The point is that I need to know the sdk version each device is running to install the correct apk, and I was hoping I could get this through adb, but I can't seem to find a way to access it short of building a tiny app, compatible with all versions, whose sole purpose would be to output android.os.Build.VERSION.SDK or similar somewhere my script could read it.
you can use this command:
adb shell grep ro.build.version.sdk= system/build.prop
It will output something like this:
ro.build.version.sdk=10
adb shell getprop ro.build.version.sdk
Note #Tim: this works even on phones without grep support on all host OS :-). (i.e. on old phones where toolbox does not support grep you you need to have busybox on your phone).
I also discovered a way to get the exact version of Android e.g. 4.2.2 based on the following web article http://xayon.net/looking-for-android-version-with-adb/ You need to be using a unix-like operating system - Linux and Mac OSX are fine, and windows users can use cygwin or equivalent.
At a command line:
echo version=$(adb shell getprop |awk -F":" '/build.version.release/ { print $2 }')|tr -d '[]'
Here is the result for my Nexus 4:
version= 4.2.2
I think you can by accessing the device with adb shell - change directories to position you at system and do a cat of build.prop. Here you will find for instance, ro.build.description=google_sdk-eng 2.2, ro.build.version.release=2.2 etc

Categories

Resources