Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'interpreter': 0.05; 'that?': 0.05; 'assignment': 0.07; 'debugging': 0.07; 'friday,': 0.09; 'function,': 0.09; 'implemented.': 0.09; 'url:github': 0.09; 'works.': 0.09; 'python': 0.11; "(i'm": 0.16; '.py': 0.16; 'breakpoint': 0.16; 'c/c++': 0.16; 'conditional': 0.16; 'discovery.': 0.16; 'guessing': 0.16; 'learn?': 0.16; 'subject:Conditional': 0.16; 'work.)': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'all,': 0.19; 'trying': 0.19; 'file,': 0.19; 'stack': 0.19; 'example': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'module,': 0.24; "i've": 0.25; 'extension': 0.26; 'this:': 0.26; 'url:edu': 0.26; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'function': 0.29; '[1]': 0.29; 'url:mailman': 0.30; 'code': 0.31; "skip:' 10": 0.31; 'breaking': 0.31; 'file': 0.32; 'url:python': 0.33; 'received:fr': 0.33; 'could': 0.34; 'but': 0.35; 'url:listinfo': 0.36; 'doing': 0.36; 'next': 0.36; 'url:org': 0.36; 'should': 0.36; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'how': 0.40; 'break': 0.61; 'simple': 0.61; 'reach': 0.63; 'batchelder': 0.84; 'fascinating': 0.91; 'journey': 0.93; '2013': 0.98 X-IronPort-AV: E=Sophos;i="4.93,683,1378850400"; d="scan'208";a="42263330" Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: David Froger User-Agent: alot/0.3.5 X-Sender-Computer: INRIA-ROCQ-UBUNTU-fl-58186.rocq.inria.fr To: python-list@python.org References: In-Reply-To: Subject: Re: Conditional breakpoints in ceval.c Date: Tue, 12 Nov 2013 09:44:22 +0100 X-Mailman-Approved-At: Tue, 12 Nov 2013 09:53:59 +0100 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 65 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1384246441 news.xs4all.nl 15932 [2001:888:2000:d::a6]:60881 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:59164 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 =3D '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? Perh= aps 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 =3D '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 =3D 'bar' assignement is reach (I never try this, be it should work.) [1] http://joyrex.spc.uchicago.edu/bookshelves/python/cookbook/pythoncook-C= HP-16-SECT-8.html