<div dir="ltr">Hello,<div>We are trying to collect openGLES traces from android application  in particular templerun. </div><div>We followed the exact same procedures that you have in the Dalvik.markdown in apitrace repository. </div>
<div><br></div><div>We have changed the init.rc file to preload egltrace.so before zygote </div><div><br></div><div>Then we executed the following commands ... </div><div><pre style="white-space:pre-wrap;margin-top:15px;margin-bottom:15px;padding:6px 10px;border:1px solid rgb(204,204,204);font-size:13px;font-family:Consolas,'Liberation Mono',Courier,monospace;background-color:rgb(248,248,248);line-height:19px;overflow:auto;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)">
<code style="margin:0px;padding:0px;border:none;font-size:12px;font-family:Consolas,'Liberation Mono',Courier,monospace;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">PROCNAME=com.imangi.templerun2
adb shell setprop wrap.$PROCNAME LD_PRELOAD=/data/egltrace.so
adb shell setprop debug.apitrace.procname $PROCNAME</code></pre></div><div><br></div><div>The following command does not work to start templerun </div><div><pre style="white-space:pre-wrap;margin-top:15px;margin-bottom:15px;padding:6px 10px;border:1px solid rgb(204,204,204);font-size:13px;font-family:Consolas,'Liberation Mono',Courier,monospace;background-color:rgb(248,248,248);line-height:19px;overflow:auto;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)">
<code style="margin:0px;padding:0px;border:none;font-size:12px;font-family:Consolas,'Liberation Mono',Courier,monospace;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">adb shell am start -S $PROCNAME
</code></pre><div><code style="margin:0px;padding:0px;border:none;font-size:12px;font-family:Consolas,'Liberation Mono',Courier,monospace;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">says no intent supplied ... </code></div>
<div><code style="margin:0px;padding:0px;border:none;font-size:12px;font-family:Consolas,'Liberation Mono',Courier,monospace;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px"><br>
</code></div><div><code style="margin:0px;padding:0px;border:none;font-size:12px;font-family:Consolas,'Liberation Mono',Courier,monospace;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Then we tried the following command </code></div>
</div><div><br></div><div>adb shell am start -a android.intent.action.MAIN -n com.imangi.templerun2/com.unity3d.player.UnityPlayerNativeActivity <br></div><div><br clear="all" style="font-family:arial,sans-serif;font-size:13px">
<div style="font-family:arial,sans-serif;font-size:13px">The app gets started. However we always get a empty tracefile. </div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
Can you please give us suggestion which may resolve the issue ? </div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Thanks. I will highly appreciate your response. </div>
<div class="" style="font-family:arial,sans-serif;font-size:13px"></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Apr 10, 2013 at 8:29 AM, José Fonseca <span dir="ltr"><<a href="mailto:jose.r.fonseca@gmail.com" target="_blank">jose.r.fonseca@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks. I don't use Android, so can't comment on the correctness of<br>
the updated instructions, but given I heard no objection I'll commit<br>
it.<br>
<br>
That said, I'd prefer that _all_ Android instructions (including<br>
non-Java) are the Android.markdown, otherwise a first reader might<br>
miss the Android section in README.<br>
<br>
Alternatively, if you prefer to only discuss Java apps as you have<br>
now, then Android.markdown should be renamed to something less<br>
abragent like Dalvik.markdown, Zygote.markdown, or something like<br>
that.<br>
<br>
Jose<br>
<div class="HOEnZb"><div class="h5"><br>
On Fri, Apr 5, 2013 at 6:53 PM, Alexander Monakov <<a href="mailto:amonakov@ispras.ru">amonakov@ispras.ru</a>> wrote:<br>
> Tracing of Java applications on Android is quite different from tracing native<br>
> executables, so move it to a separate file.<br>
><br>
> Add instructions on using wrapping support that appeared in Android 4.0, which<br>
> simplifies usage of apitrace on Android.<br>
><br>
> Add a reference to adjust-child-env tool that allows to inject tracing library<br>
> on Android without rebuilding and reflashing recovery image.<br>
> ---<br>
>  Android.markdown | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br>
>  README.markdown  | 65 +++------------------------------------------------<br>
>  2 files changed, 74 insertions(+), 62 deletions(-)<br>
>  create mode 100644 Android.markdown<br>
><br>
> diff --git a/Android.markdown b/Android.markdown<br>
> new file mode 100644<br>
> index 0000000..0cbf4de<br>
> --- /dev/null<br>
> +++ b/Android.markdown<br>
> @@ -0,0 +1,71 @@<br>
> +Tracing Dalvik VM (Java) applications on Android<br>
> +================================================<br>
> +<br>
> +Android's Java machine, DalvikVM, runs as a system service (started at bootup<br>
> +by `init`) and Java applications are run by forks of the initial resident<br>
> +process.  Thus, injecting apitrace's tracing library is different from other<br>
> +operating systems.<br>
> +<br>
> +The following discussion assumes that tracing library is copied to '/data':<br>
> +<br>
> +        adb push /path/to/apitrace/build/wrappers/egltrace.so /data<br>
> +<br>
> +Tracing on Android 4.0 and newer<br>
> +--------------------------------<br>
> +<br>
> +Starting from Android 4.0 (Ice Cream Sandwich) release, Dalvik supports<br>
> +running designated processes with wrappers, in which case a new Java VM is<br>
> +started with 'system()' library call for that process.<br>
> +<br>
> +Obtain the process name of the application to be traced (the one reported in<br>
> +`ps` output, such as `com.android.settings`), and set two system properties:<br>
> +<br>
> +        PROCNAME=com.android.settings<br>
> +        adb shell setprop wrap.$PROCNAME LD_PRELOAD=/data/egltrace.so<br>
> +        adb shell setprop debug.apitrace.procname $PROCNAME<br>
> +<br>
> +(the former is read by Dalvik and specifies wrapping prefix, the latter is<br>
> +read by apitrace itself and used in case apitrace is preloaded into Java VM<br>
> +globally to specify which process should be traced).<br>
> +<br>
> +Make sure the process is not loaded before starting to trace it, for example<br>
> +use `-S` flag to `am start`:<br>
> +<br>
> +        adb shell am start -S $PROCNAME<br>
> +<br>
> +Use `adb logcat \*:S apitrace` to examine apitrace debug output.  Trace files<br>
> +are saved into '/data/' directory by default:<br>
> +<br>
> +        adb pull /data/$PROCNAME.trace<br>
> +        adb shell rm /data/$PROCNAME.trace<br>
> +<br>
> +(you need to `chmod 0777 /data` beforehand).<br>
> +<br>
> +<br>
> +Injecting tracing library globally<br>
> +----------------------------------<br>
> +<br>
> +If `LD_PRELOAD` is supported (Android 2.3 "Gingerbread" and newer), it is<br>
> +possible to inject `egltrace.so` into the resident Java VM, in which case<br>
> +`debug.apitrace.procname` system propery is used to control for which process<br>
> +tracing will be active.<br>
> +<br>
> +Restarting 'zygote' (Java VM) service is not straightforward, since '/init.rc'<br>
> +is read only once at system bootup, and restored from the recovery image on<br>
> +reboots.   Thus, you either need to augment '/init.rc' in the recovery image<br>
> +with `setenv LD_PRELOAD /data/egltrace.so` in `service zygote` section, or you<br>
> +can use a tool such as<br>
> +[adjust-child-env](<a href="https://github.com/amonakov/adjust-child-env" target="_blank">https://github.com/amonakov/adjust-child-env</a>) to restart<br>
> +the service with modified environment.<br>
> +<br>
> +Put `adjust-child-env` and a script with the following contents into `/data`:<br>
> +<br>
> +        stop zygote<br>
> +        /data/adjust-child-env 1 /system/bin/app_process LD_PRELOAD=/data/egltrace.so &<br>
> +        sleep 1<br>
> +        start zygote<br>
> +<br>
> +The scripts restarts the Java VM ('zygote') with modified environment.<br>
> +<br>
> +Invoke the script with `adb shell` to prepare for tracing, and then follow the<br>
> +Android 4.0 directions.<br>
> diff --git a/README.markdown b/README.markdown<br>
> index 5fa3ab9..eeaaee7 100644<br>
> --- a/README.markdown<br>
> +++ b/README.markdown<br>
> @@ -151,68 +151,9 @@ To trace the application inside gdb, invoke gdb as:<br>
><br>
>  ### Android ###<br>
><br>
> -The following instructions should work at least for Android Ice Scream<br>
> -Sandwitch.<br>
> -<br>
> -To trace applications started from within the Android VM process<br>
> -(`app_process` aka zygote) you'll have to wrap this process and enable<br>
> -tracing dynamically for the application to be traced.<br>
> -<br>
> -- Wrapping the android main VM process:<br>
> -<br>
> -  In the Android root /init.rc add the `LD_PRELOAD` setting to zygote's<br>
> -  environment in the 'service zygote' section:<br>
> -<br>
> -        service zygote ...<br>
> -           setenv LD_PRELOAD /data/egltrace.so<br>
> -           ...<br>
> -<br>
> -  Note that ICS will overwrite the /init.rc during each boot with the<br>
> -  version in the recovery image. So you'll have to change the file in<br>
> -  your ICS source tree, rebuild and reflash the device.<br>
> -  Rebuilding/reflashing only the recovery image should be sufficient.<br>
> -<br>
> -- Copy egltrace.so to /data<br>
> -<br>
> -  On the host:<br>
> -<br>
> -        adb push /path/to/apitrace/build/wrappers/egltrace.so /data<br>
> -<br>
> -- Adjust file permissions to store the trace file:<br>
> -<br>
> -  By default egltrace.so will store the trace in<br>
> -  `/data/app_process.trace`. For this to work for applications running<br>
> -  with a uid other than 0, you have to allow writes to the `/data`<br>
> -  directory on the device:<br>
> -<br>
> -        chmod 0777 /data<br>
> -<br>
> -- Enable tracing for a specific process name:<br>
> -<br>
> -  To trace for example the Settings application:<br>
> -<br>
> -        setprop debug.apitrace.procname com.android.settings<br>
> -<br>
> -  In general this name will match what `ps` reports.<br>
> -<br>
> -- Start the application:<br>
> -<br>
> -  If the application was already running, for example due to ICS's way<br>
> -  of pre-starting the apps, you might have to kill the application<br>
> -  first:<br>
> -<br>
> -        kill <pid of app><br>
> -<br>
> -  Launch the application for example from the application menu.<br>
> -<br>
> -To trace standalone applications do:<br>
> -<br>
> -    adb push /path/to/apitrace/build/wrappers/egltrace.so /data<br>
> -    adb shell<br>
> -    # cd /data/local/tmp<br>
> -    # LD_PRELOAD=/data/egltrace.so test-opengl-gl2_basic<br>
> -    adb pull /data/local/tmp/test-opengl-gl2_basic.trace<br>
> -    apitrace replay test-opengl-gl2_basic.trace<br>
> +To trace standalone native OpenGL ES applications, use<br>
> +`LD_PRELOAD=/path/to/egltrace.so /path/to/application` like described in the<br>
> +previous section.  To trace Java applications, refer to Android.markdown.<br>
><br>
>  ### Mac OS X ###<br>
><br>
> --<br>
> 1.8.1.2<br>
><br>
> _______________________________________________<br>
> apitrace mailing list<br>
> <a href="mailto:apitrace@lists.freedesktop.org">apitrace@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/apitrace" target="_blank">http://lists.freedesktop.org/mailman/listinfo/apitrace</a><br>
_______________________________________________<br>
apitrace mailing list<br>
<a href="mailto:apitrace@lists.freedesktop.org">apitrace@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/apitrace" target="_blank">http://lists.freedesktop.org/mailman/listinfo/apitrace</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Rajib Nath<br>PhD Student, UCSD<br><a href="http://cseweb.ucsd.edu/~rknath/" target="_blank">http://cseweb.ucsd.edu/~rknath/</a>
</div>