Developing and debugging Mesa libraries

Downloading the latest source code for Mesa: http://www.mesa3d.org/download.html

Compile thus:
./configure --prefix /sda3/mesa

where the directory is /sda3/mesa will be the temporary output directory of the compiled Mesa libraries files. This will enable us to run any OpenGL applications with just the Mesa libraries being loaded from /sda3/mesa.

Then make and “make install”, the directory /sda3/mesa will be populated with libraries and header files:
interface.h
│ │ ├── osmesa.h
│ │ ├── wglext.h
│ │ └── wmesa.h
│ └── KHR
│ └── khrplatform.h
└── lib
├── dri
│ ├── gallium_drv_video.la
│ ├── gallium_drv_video.so
│ ├── i915_dri.so
│ ├── i965_dri.so
│ ├── kms_swrast_dri.so
│ ├── nouveau_vieux_dri.so
│ ├── r200_dri.so
│ ├── r300_dri.so
│ ├── r600_dri.so
│ ├── radeon_dri.so
│ ├── swrast_dri.so
│ └── vmwgfx_dri.so
├── libEGL.la
├── libEGL.so -> libEGL.so.1.0.0
├── libEGL.so.1 -> libEGL.so.1.0.0
├── libEGL.so.1.0.0
├── libglapi.la
├── libglapi.so -> libglapi.so.0.0.0
├── libglapi.so.0 -> libglapi.so.0.0.0
├── libglapi.so.0.0.0
├── libGL.la
├── libGL.so -> libGL.so.1.2.0
├── libGL.so.1 -> libGL.so.1.2.0
├── libGL.so.1.2.0
└── pkgconfig
├── dri.pc
├── egl.pc
└── gl.pc

Then define “export LD_LIBRARY_PATH=/sda3/mesa/lib:$LD_LIBRARY_PATH” in the environment shell. After that, using the same environment shell, execute “python torusv1.py” to run some python progam (that does OpenGL graphics, for example,
https://github.com/tthtlc/sansagraphics
).

 

j1

There after use gdb to attach to the python process:

First see all the loaded libraries:
"info sharedlibraries":

(gdb) info sharedlibrary
From To Syms Read Shared Object Library
0x00007f6c99a99610 0x00007f6c99a9ac96 Yes (*) /usr/lib/python2.7/lib-dynload/_hashlib.x86_64-linux-gnu.so
0x00007f6c99716dc0 0x00007f6c9980669f Yes (*) /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
0x00007f6c9941a3f0 0x00007f6c994840d6 Yes /sda3/mesa/lib/libGL.so.1
0x00007f6c991d3b90 0x00007f6c991ec759 Yes (*) /lib/x86_64-linux-gnu/libexpat.so.1
0x00007f6c98f91150 0x00007f6c98fa80d0 Yes /sda3/mesa/lib/libglapi.so.0
0x00007f6c98d5b580 0x00007f6c98d64ce0 Yes (*) /usr/lib/x86_64-linux-gnu/libXext.so.6
0x00007f6c98b50b90 0x00007f6c98b5149b Yes (*) /usr/lib/x86_64-linux-gnu/libXdamage.so.1
0x00007f6c989494e0 0x00007f6c9894b708 Yes (*) /usr/lib/x86_64-linux-gnu/libXfixes.so.3
0x00007f6c987405e0 0x00007f6c987406eb Yes (*) /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1

From above we can see that “libGL.so.1” is loaded. Next, trying out some API which is found in libGL.so.1:

Breakpoint 381, glBindBuffer (target=34962, buffer=1) at ../../src/mapi/glapi/glapi_mapi_tmp.h:5677
5677 const struct mapi_table *_tbl = entry_current_get();
(gdb) bt
#0 glBindBuffer (target=34962, buffer=1) at ../../src/mapi/glapi/glapi_mapi_tmp.h:5677
#1 0x00007f6c99ca5adc in ffi_call_unix64 () from /usr/lib/x86_64-linux-gnu/libffi.so.6
#2 0x00007f6c99ca540c in ffi_call () from /usr/lib/x86_64-linux-gnu/libffi.so.6
#3 0x00007f6c99ebc5fe in _ctypes_callproc () from /usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so
#4 0x00007f6c99ebdf9e in ?? () from /usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so
xxx
xxx
xxx
#25 0x0000000000469663 in ?? ()
#26 0x00000000004699e3 in PyRun_FileExFlags ()
#27 0x0000000000469f1c in PyRun_SimpleFileExFlags ()
#28 0x000000000046ab81 in Py_Main ()
#29 0x00007f6c9b191ec5 in __libc_start_main (main=0x46ac3f <main>, argc=2, argv=0x7fff4528a378, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fff4528a368)
at libc-start.c:287
#30 0x000000000057497e in _start ()

And listing the source code (the binary program will cross-reference the source code downloaded for compilation):

(gdb) list
5672 ((void (APIENTRY *)(GLenum target, GLuint id)) _func)(target, id);
5673 }
5674
5675 GLAPI void APIENTRY GLAPI_PREFIX(BindBuffer)(GLenum target, GLuint buffer)
5676 {
5677 const struct mapi_table *_tbl = entry_current_get();=====>
5678 mapi_func _func = ((const mapi_func *) _tbl)[461];
5679 ((void (APIENTRY *)(GLenum target, GLuint buffer)) _func)(target, buffer);
5680 }

And so there you go is the generic analysis.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: