This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Met Problem on Enable SystemTap on Android


On 08/30/2011 02:13 PM, Yao,Yanjun wrote:
> I am a starter of both Android Kernel and SystemTap.

I think you'll find it helpful to try running simple examples just on
your computer, so you can better understand the concept of SystemTap.  A
tutorial and a beginner's guide are here:

  http://sourceware.org/systemtap/documentation.html

The cross-compilation for Android is an extra complication, which I
think may be better attempted later.  For Android, you will be running
stap on the host computer to compile the .ko, and then staprun on the
target Android device to run it.  This is described here:

  http://omappedia.org/wiki/Systemtap#Systemtap_and_Cross_Compilation

> I am not sure what kind of wrapper the system can be use, but I did
> not make any change to the kernel code. I just downloaded the source
> by following the instructions in 
> http://source.android.com/source/initializing.html.
> 
>> It may also help to try with a few verbose flags, -vvvv
>>
> 
> I tried it with the -vvvv, but the same problem happens:
> 
> # ./stap -vvvv
> ./stap: 57: Syntax error: "(" unexpected
> # ./staprun -vvv
> ./staprun: 1: Syntax error: ")" unexpected
> 
> All of the above run in "adb shell", is this the problem?

The stap command for cross compilation needs to be done on your
computer.  Only the staprun part is meant to run on Android directly.

I suspect that stap and staprun binaries that you copied to Android are
really the host binaries in ELF x86 form.  I don't have a full devel
environment for my phone at the moment, but I just tried copying an x86
binary to my phone anyway to run it, and I got similar message like
Syntax error: ")" unexpected.  It looks like Android tries to run these
unknown binaries with a script interpreter, which is just wrong.

Really only staprun and stapio are needed on Android, and those must be
compiled for the ARM target.

> I tried to get the .ko file but not succeed. The command should be in format:
> ./stap -gv -a arm -D OMAP_REL_FAMILY -B
> CROSS_COMPILE=arm-none-linux-gnueabi- -r FULLKERNELPATH -I
> FULLTAPSETPATH -R SYSTEMTAPCFILEPATH -m SYSTEMTAPMODULENAME SCRIPTNAME

I actually don't like that this is recommending to use -I and -R; if you
did a "make install" and run from the configured prefix, these should
not be necessary.

> 
> So I set (the command is run in UBUNTU 11.04):
>    OMAP_REL_FAMILY  == OMAP_L25
>    FULLKERNELPATH  ==
> /home/xxx/WORKING_DIRECTORY/prebuilt/android-arm/kernel/vmlinux-qemu
>    FULLTAPSETPATH  ==  /data/systemtap-1.5-macharm/share/systemtap/tapset/
>    SYSTEMTAPCFILEPATH  == /data/systemtap-1.5-macharm/share/systemtap/runtime
>    SYSTEMTAPMODULENAME  == contextswitch
>    SCRIPTNAME ==
> 
> The problem is that:
> 1. The did not download the kernel code, as I can get a user debug
> enabled kernel with android source. There are prebuild codes for the
> building, however, the binary I found with the name
> "/home/xxx/WORKING_DIRECTORY/prebuilt/android-arm/kernel/vmlinux-qemu"
> seems does not work fine. May I ask do I need to download the kernel
> code, and get the kernel img from that? Or it is just because I found
> the wrong prebuild kernel file.

Since SystemTap is building kernel modules out of your .stp scripts, it
does need the source corresponding to your running kernel to get all the
right headers and configuration.  So the "-r FULLKERNELPATH" needs to
point to the kernel source directory, not vmlinux itself.

> 2. I did not find the contextswitch.stp as mentioned in
> http://omappedia.org/wiki/Systemtap#Systemtap_Scripts_compilation. Is
> there other scripts has the same functionality? If not, where can I
> download the contextswitch.stp?

I don't know exactly what script that example is referring to, but you
could just as well use the syscalls_by_pid.stp that you had before.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]