[C++-sig] debugging c++ extension

Pierre Barbier de Reuille pierre.barbier at cirad.fr
Wed Sep 7 10:46:12 CEST 2005


Hello,

Yes, gdb is really able to debug your code !
What I do to debug Python modules is :

1 - launch python with gdb (you don't need debug information in your
python executable to do so ...):

$ gdb python


2 - launch python and load your module

(gdb) run
Starting program: /usr/bin/python
(no debugging symbols found)
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 1885)]
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
Python 2.3.5 (#2, May  4 2005, 08:51:39)
[GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
>>> import my_module
>>>

3 - Hit "Ctrl-C"

Program received signal SIGINT, Interrupt.
[Switching to Thread 16384 (LWP 1885)]
0x40039178 in read () from /lib/libpthread.so.0
(gdb)

4 - place your breakpoints and continue execution

(gdb) b my_module.cc:54
Breakpoint 1 at 0x804a205: file my_module.cc, line 54.
(gdb) cont

5 - Enter some Python commands and debug as you will do with any program
once your breakpoint is hit.

Hope that's help,

Pierre


Nariman Habili a écrit :
> Hi,
> 
> I'm wondering how I can debug my c++ code that has been interfaced to python 
> using python boost? I read somewhere that gdb can be used to debug, however 
> the information provided to do this is limited. I would appreciate your 
> help, thanks.
> 
> Regards,
> Nari
> 
> 
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
> 

-- 
Pierre Barbier de Reuille

INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP
Botanique et Bio-informatique de l'Architecture des Plantes
TA40/PSII, Boulevard de la Lironde
34398 MONTPELLIER CEDEX 5, France

tel   : (33) 4 67 61 65 77    fax   : (33) 4 67 61 56 68



More information about the Cplusplus-sig mailing list