Personal tools
You are here: Home documentation developer DebuggingPdExternals

Edit history

Edit: -1 of 1
Time: 2014-01-08 17:31:29
Note: /pd/pd/docs/developer/DebuggingPdExternals/vote

Using gdb

GDB is particularly useful if your external causes a crash, and you want to identify the line in your code that caused the crash.


``hans$ gdb /Applications/Pd-0.39.2-extended-test3/Contents/Resources/bin/pd``

``(gdb) add-symbol-file my_blah.pd_darwin``

start Pd then attach to it using the process name and PID:

``(gdb) attach pd.12341``

With tab completion, you'll see that there are two **pd** processes.  On Mac OS X, the one with the higher number is the one you want to attach to.

Now set a breakpoint:

``(gdb) break hid_free``

and start Pd running again:

``(gdb) continue``

Here's a transcript of my session:


 hans@sla:~ > gdb  /Applications/ 
 GNU gdb 6.1-20040303 (Apple version gdb-384) (Mon Mar 21 00:05:26 GMT 2005)
 Copyright 2004 Free Software Foundation, Inc.
 GDB is free software, covered by the GNU General Public License, and you are
 welcome to change it and/or distribute copies of it under certain conditions.
 Type "show copying" to see the conditions.
 There is absolutely no warranty for GDB.  Type "show warranty" for details.
 This GDB was configured as "powerpc-apple-darwin"...unable to open symbol file: /usr/local/lib/Jack: No such file or  directory.
 warning: Unable to read symbols from "/Volumes/Document1/Developpement/ProjectsCVS/JackCVS/Jack_CVS_HEAD - Tiger - CVS  CURRENT/config/os/macosx/build/Jack.framework/Versions/A/Jack".
 warning: Unable to read symbols from "/Volumes/Document1/Developpement/ProjectsCVS/JackCVS/Jack_CVS_HEAD - Tiger - CVS  CURRENT/config/os/macosx/build/Jack.framework/Versions/A/Jack";  skipping.
 Reading symbols for shared libraries ........ done
 (gdb) add-symbol-file ~/cvs/pure-data/externals/hcs/hid/hid.pd_darwin 
 add symbol table from file "/Users/hans/cvs/pure-data/externals/hcs/hid/hid.pd_darwin"? (y or n) y
 Reading symbols from /Users/hans/cvs/pure-data/externals/hcs/hid/hid.pd_darwin...done.
 (gdb) attach pd.
 1234  3954  4057  4099  
 (gdb) attach pd.4099 
 Attaching to program: `/Applications/', process 4099.
 Reading symbols for shared libraries  ........................................................................  done
 0x9001f5ec in select ()
 (gdb) break hid_free
 Breakpoint 1 at 0xa370: file /Users/hans/cvs/pure-data/externals/../externals/hcs/hid/hid.c, line 366.
 (gdb) continue 

Using valgrind

Valgrind is particularly useful for monitoring the memory usage (allocations and frees) of your program, finding memory leaks, and finding memory-related errors such as attempting to read past the end of an array.


Valgrind is invoked as follows:

``valgrind pd``

Interpreting the output

See the `Valgrind documentation`_.

.. _Valgrind documentation:

Powered by IEM Powered by Plone Section 508 WCAG Valid XHTML Valid CSS Usable in any browser