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


Hi,

Here are recommendations to make it work. OMAP wiki page assumes some knowledge of systemtap. I will by the way update the wiki with some of the remarks below:

- are you working on an OMAP3 or OMAP4 platform ?

- be sure to correctly understand systemtap. .stp script is converted and compiled into a kernel module (the .ko) through stap binary.
There is also a userspace tool to load the module, control it and gather trace (staprun/stapio)

- be sure to correctly understand the http://omappedia.org/wiki/Systemtap#Systemtap_and_Cross_Compilation
   * We build 1 host version of the tool to convert and cross-compile .stp into an ARM kernel module => stap -a arm ...
   * we build 1 target version of the tool to "execute/control" ARM kernel module on target => staprun xxx.ko
Host version executes on your desktop PC while target version has to be copied on Android (generally /data).

Error like "./stap: 1: Syntax error: "&" unexpected" is typical of a binary that does not have right architecture. Try "file staprun" -> xxx/staprun: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.16, from '16]', not stripped

- you are building a module. Therefore your cross-compilation kernel environment must be set-up. Unfortunately I don't use prebuilt kernel on Android.
>From past experience, Systemtap will require the kernel config (.config file), System.map and on ARM (until recently), you need debug symbols vmlinux. Building module also requires some tools, which are built by kernel makefile in scripts and scripts/basic folders. Well, it is possible that these tools are built when you compile your first module (never tried)
My biggest concern is about compilation flags enabled in the kernel. KPROBES are a must and they are often disabled so there are chances you will have to recompile kernel.

- contextswitch.stp is in fact http://sourceware.org/systemtap/examples/process/schedtimes.stp. But this is a complex one to start with. Try a "probe begin { printf("my first script"); }" first. Then something like http://sourceware.org/systemtap/examples/io/traceio.stp

- Josh: I will clarify -R/-I on the wiki. We did that because our IT forces use of /home/$USER folder, still 1 developer compiles the tool for many others. So tool is hard-coded to /home/developer1 while it is stored in /home/developer2. And we add a temporary LD_LIBRARY_PATH. We never really looked for cleaner solution to exchange binaries.

- systemtap on ARM Ubuntu is much easier to use

Summary of what I do on my side:
- desktop PC: get kernel code, configure right features and compile
- desktop PC: compile the host and target tool. Copy target tool on target
- desktop PC: edit my .stp then ./stap -a arm xxx.stp. Copy resulting .ko on target
- target: ./staprun xxx.ko > yyy/zzz.txt (you can use -o yyy/zzz.txt also)

Regards
Fred

Frederic Turgis
OMAP Platform Business Unit - OMAP System Engineering - Platform Enablement



>
Texas Instruments France SA, 821 Avenue Jack Kilby, 06270 Villeneuve Loubet. 036 420 040 R.C.S Antibes. Capital de EUR 753.920

-----Original Message-----

> From: systemtap-owner@sourceware.org
> [mailto:systemtap-owner@sourceware.org] On Behalf Of Josh Stone
> Sent: Wednesday, August 31, 2011 12:16 AM
> To: Yao,Yanjun
> Cc: systemtap@sourceware.org
> Subject: 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]