Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'debug': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'thus,': 0.09; 'variable,': 0.09; 'python': 0.11; 'def': 0.12; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'true:': 0.16; 'variable.': 0.16; 'subject:python': 0.16; 'attach': 0.16; 'language': 0.16; 'variable': 0.18; 'trying': 0.19; 'command': 0.22; 'memory': 0.22; 'import': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'script.': 0.24; 'script': 0.25; 'define': 0.26; '(for': 0.26; 'header:X-Complaints-To:1': 0.27; 'context.': 0.31; 'writes:': 0.31; 'file': 0.32; 'figure': 0.32; 'quite': 0.32; 'level.': 0.33; 'knowledge': 0.35; 'case,': 0.35; 'test': 0.35; 'next': 0.36; 'charset:us-ascii': 0.36; 'two': 0.37; 'list': 0.37; 'level': 0.37; 'to:addr:python-list': 0.38; 'expect': 0.39; 'obtain': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'applicable': 0.60; 'commands': 0.60; 'simple': 0.61; 'received:217': 0.63; 'skip:n 10': 0.64; 'here': 0.66; 'between': 0.67; 'carefully': 0.74; 'distinguish': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: dieter Subject: Re: gdb python how to output integer for examine memory Date: Tue, 25 Mar 2014 08:49:09 +0100 References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Gmane-NNTP-Posting-Host: pd9e08fb0.dip0.t-ipconnect.de User-Agent: Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux) Cancel-Lock: sha1:c/5TvFLE4l8j8y6neO7k8DOAazg= 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: 42 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395733762 news.xs4all.nl 2883 [2001:888:2000:d::a6]:44148 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68994 Wesley writes: > I am trying to use gdb debug python script. > I am using gdb7.7 and python2.7.6, here is my simple test script: > import time > > def next(i): > time.sleep(10) > i = 1 - i > > i = 1 > while True: > next(i) > When this script running, gdb attach to it, and here is snippet: > > ... > (gdb) frame 5 > #5 0x00000000004d01a7 in PyEval_EvalFrameEx (f=Frame 0x201e130, for file test.py, line 6, in next (i=1), throwflag=0) at Python/ceval.c:2666 > 2666 x = call_function(&sp, oparg); > (gdb) py-locals > i = 1 > (gdb) pyo i > No symbol "i" in current context. Quite a lot of time has passed since I last had to debug Python processes at C level -- thus, my memory may be unreliable. When I remember right, then "pyo" is used to interprete a C level variable as a Python object (and print it) -- not a Python level variable. In your case, "i" is a Python level variable. You must carefully distinguish between the C level and the Python level. Some commands expect C level names/objects; others may expect Python level names/objects. To learn how you can obtain the value of a Python variable, I see two approaches: look through the list of provided commands (and their documentation) and try to figure out which might be applicable and then may some tests; or look at the implementation of "py-locals" and use this knowledge to define you own command (for this, you will also need to understand the gdb language to define commands).