blob: f7bcf24785854e0a4674b06d1631f1a22f73cfcf [file] [log] [blame] [view]
Corentin Wallezcbdf7362015-07-21 15:47:47 -07001# Debugging Tips
2
3There are many ways to debug ANGLE using generic or platform-dependent tools. Here is a list of tips on how to use them.
4
5## Running ANGLE under apitrace on Linux
6
7[Apitrace](http://apitrace.github.io/) that captures traces of OpenGL commands for later analysis, allowing us to see how ANGLE translates OpenGL ES commands. In order to capture the trace, it inserts a driver shim using `LD_PRELOAD` that records the command and then forwards it to the OpenGL driver.
8
9The problem with ANGLE is that it exposes the same symbols as the OpenGL driver so apitrace captures the entry point calls intended for ANGLE and reroutes them to the OpenGL driver. In order to avoid this problem, use the following:
Jamie Madille865bb12016-01-12 16:21:37 -050010
111. Compile ANGLE as a static library so that it doesn't get shadowed by apitrace's shim using the `-D angle_gl_library_type=static_library` gyp flag.
122. Ask apitrace to explicitly load the driver instead of using a dlsym on the current module. Otherwise apitrace will use ANGLE's symbols as the OpenGL driver entrypoint (causing infinite recursion). To do this you must point an environment variable to your GL driver. For example: `export TRACE_LIBGL=/usr/lib/libGL.so.1`. You can find your libGL with `ldconfig -p | grep libGL`.
133. Link ANGLE against libGL instead of dlsyming the symbols at runtime; otherwise ANGLE won't use the replaced driver entry points. This can be done by adding `-D angle_link_glx=1`.
Corentin Wallezcbdf7362015-07-21 15:47:47 -070014
15If you follow these steps, apitrace will work correctly aside from a few minor bugs like not being able to figure out what the default framebuffer size is if there is no glViewport command.
16
17For example, to trace a run of `hello_triangle`, assuming you are using the ninja gyp generator and the apitrace executables are in `$PATH`:
18
19```
Corentin Wallez7f07caa2016-10-25 07:43:33 -040020./gyp/gyp_angle -D angle_link_glx=1 -D angle_gl_library_type=static_library
Corentin Wallezcbdf7362015-07-21 15:47:47 -070021ninja -C out/Debug
Jamie Madille865bb12016-01-12 16:21:37 -050022export TRACE_LIBGL="/usr/lib/libGL.so.1" # may require a different path
Corentin Wallezcbdf7362015-07-21 15:47:47 -070023apitrace trace -o mytrace ./out/Debug/hello_triangle
24qapitrace mytrace
25```