Wednesday, 15 July 2015

Which tool (gdb? xcode? pdb? etc) can I use to find a memory leak in a C-extended python program? -



Which tool (gdb? xcode? pdb? etc) can I use to find a memory leak in a C-extended python program? -

i writing python programme includes extension module written in c. extension module defines function used in programme continually.

i have memory leak somewhere in program, don't know how find it. have tried 1) installing valgrind. can't work since have osx mavericks (10.9) , valgrind supports oxs 10.7 (and 10.8 unstably). 2) using gdb. can't seem gdb run python scripts, i'd need set breakpoint in c function gets called python code. believe need install python-debuginfo in order that, have not been able to. 3) using pdb. had, however, no thought debug c code using pdb.

is there tool utilize debug memory leaks in program?

the debugger ships mac development tools lldb, replaces gdb. interface similar gdb. can install gdb using homebrew.

the way debug c extensions other shared library. debug executable (python) loads shared library (your extension), , set breakpoints become valid after executable loads shared library.

run lldb:

lldb /path/to/python -- your_python_script.py

set breakpoints (replace relevant breakpoints)

(lldb) b some_source_file.c:4343

then run, , debugger stop @ breakpoint

(lldb) r

now can debug c extension normally.

python c memory-leaks python-extensions

No comments:

Post a Comment