Quoting Ned Batchelder (2013-11-09 14:24:34) > On Friday, November 8, 2013 9:03:51 PM UTC-5, Demian Brecht wrote: > > Hi all, > > > > I have an .py file with a simple assignment in it: > > foo = 'bar' > > > > Now, I want to set a conditional breakpoint in gdb, breaking on that > > assignment (I'm guessing the top of the stack would be breaking on the > > LOAD_CONST with a value or 'bar'). How would I go about doing that? > > > > b ceval.c:1368 if [?] > > > > Thanks, > > > > -- > > Demian Brecht > > http://demianbrecht.github.com > > I don't know how to use gdb the way you want, but it sounds like you are on a > fascinating journey of discovery. What are you trying to learn? Perhaps we > can talk about how the interpreter works. > > --Ned. > -- > https://mail.python.org/mailman/listinfo/python-list
Hi all, In the purpose of debugging C/C++ Python extensions, I've been also looking for a way to put a gdb breakpoint on a Python line file, like this: (gdb) b foo.py:47 But I have no idea how this could be implemented. To break in a C/C++ extension with gdb, on can declare a function, for example 'Py_DebugTrap' [1], and call it call in the C/C++ code where he/she want to break, then in gdb: (gdb) b Py_DebugTrap So a altenative to break into Python could be to do the same: wrap the Py_DebugTrap in a Python module, then in the Python file, call the trap function, for example: import gdbbreak gdbbreak.breakpoint_here() foo = 'bar' The function gdbbreak.breakpoint_here() would just call the 'Py_DebugTrap' function, and then in gdb: (gdb) b Py_DebugTrap (gdb) next # until foo = 'bar' assignement is reach (I never try this, be it should work.) [1] http://joyrex.spc.uchicago.edu/bookshelves/python/cookbook/pythoncook-CHP-16-SECT-8.html -- https://mail.python.org/mailman/listinfo/python-list