[PySide] Building a debug PySide+python+valgrind [Newbie dev Tutorial ? :-)]

Stefan Champailler schampailler at skynet.be
Sat Apr 13 14:03:55 CEST 2013


Dear ml,

A while ago I posted my notes about compiling PySide in debug mode + 
python + valgrind (see below).

I've got some questions :

1. Do these notes seem right to you ? I ask because I'm not very 
knowledgeable about cmake and I may be doing things that are just not 
necessary (such as setting all those env. variables, or maybe not using 
the PySide build scripts to their full power)

2. Maybe these notes qualify for the wiki as well ? (provided they are 
correct)

3. Once I had built pyside debug, python debug  and valgrind, I started 
to use them. However it didn't help me much to track some memory leaks. 
So i was wondering if that's a productive way of looking at bugs. Maybe 
there are more powerful tools to track issues ? I was dreaming of a way 
to print the list of PySide managed objects...

Stefan

-----

* Valgrind (bugged on Debian => I build it myself)

./configure --prefix=/home/stefan/Projects/valgrind
make
make install

export VALGRIND_LIB=/home/stefan/Projects/valgrind/lib/valgrind

* I build a Python debug like this  :

Download Python source then :

make clean
./configure --without-pymalloc --with-valgrind --with-pydebug 
--enable-shared --prefix=/home/stefan/Projects/python-valgrind 
--enable-unicode=ucs4
make
make install

Note the --enable-unicode, somehow it was hard to figure out...
I'm also thinking that --with-valgrind implies --without-pymalloc...


* PySide debug built with :

export PYTHONBASE=$HOME/Projects/python-valgrind
export PYSIDESANDBOXPATH=$HOME/Projects/PL/pyside-valgrind

# Prepare to tell cmake to use our Python debug build

export PYTHON_EXEC=$PYTHONBASE/bin/python
export PYTHON_LIB=$PYTHONBASE/lib
export PYTHON_INC=$PYTHONBASE/include
export PYTHONPATH=$PYSIDESANDBOXPATH/lib/python2.7/site-packages:$PYTHONBASE

export PATH=$PYSIDESANDBOXPATH/bin:$PATH
export LD_LIBRARY_PATH=$PYSIDESANDBOXPATH/lib:$PYTHONBASE/lib

#I guess the following is for the build only
export PKG_CONFIG_PATH=$PYSIDESANDBOXPATH/lib/pkgconfig:$PKG_CONFIG_PATH
# set -DENABLE_ICECC=1 if you're using the icecream distributed compiler
alias runcmake='cmake .. -DCMAKE_INSTALL_PREFIX=$PYSIDESANDBOXPATH 
-DCMAKE_BUILD_TYPE=Debug -DENABLE_ICECC=0'

and, as explianed on the wiki, but extended for the prupose of a debug 
build (so I've added a few var. definitions -D):

     cmake .. -DCMAKE_INSTALL_PREFIX=$PYSIDESANDBOXPATH 
-DCMAKE_BUILD_TYPE=Debug -DENABLE_ICECC=0 
-DPYTHON_EXECUTABLE:PATH=$PYTHON_EXEC -DPYTHON_INCLUDE_DIRS:PATH=$PYT\
HON_INC -DPYTHON_LIBRARY:FILEPATH=$PYTHON_LIB/libpython2.7.so 
<http://libpython2.7.so>  && make -j4 && make install

... on all the directories of PySide ("apiextractor" "generatorrunner" 
"shiboken" "pyside")



* Running some python code in Valgrind :

/home/stefan/Projects/valgrind/bin/valgrind --tool=memcheck 
/home/stefan/Projects/python-valgrind/bin/python python.py


* Debug the same code with gdb :

export LD_LIBRARY_PATH= # This makes gdb mad, will have to redefine it 
in gdb environment, see below
gdb /home/stefan/Projects/python-valgrind/bin/python

and once in gdb :

(gdb) set environment 
LD_LIBRARY_PATH=/home/stefan/Projects/PL/pyside-valgrind/lib:/home/stefan/Projects/python-valgrind/lib
(gdb) r python.py




-- 
Timeo Danaos et dona ferentes

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20130413/31bc3295/attachment.html>


More information about the PySide mailing list