Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #59164
| From | David Froger <david.froger@inria.fr> |
|---|---|
| References | <mailman.2274.1383962639.18130.python-list@python.org> <e4e2892f-76a6-43a8-b59d-42ee01dfa023@googlegroups.com> |
| Subject | Re: Conditional breakpoints in ceval.c |
| Date | 2013-11-12 09:44 +0100 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2436.1384246441.18130.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Conditional breakpoints in ceval.c Demian Brecht <demianbrecht@gmail.com> - 2013-11-08 18:03 -0800
Re: Conditional breakpoints in ceval.c Ned Batchelder <ned@nedbatchelder.com> - 2013-11-09 05:24 -0800
Re: Conditional breakpoints in ceval.c David Froger <david.froger@inria.fr> - 2013-11-12 09:44 +0100
csiph-web