Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!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; '+++': 0.03; 'else:': 0.03; 'debug': 0.05; '-0500': 0.07; 'python': 0.09; '16)': 0.09; '===': 0.09; 'advice.': 0.09; 'likewise': 0.09; 'subject:using': 0.09; 'def': 0.10; 'extension': 0.13; 'receives': 0.13; 'resulting': 0.13; 'applies': 0.15; 'dec': 0.15; 'stack': 0.15; '"set': 0.16; 'assumptions': 0.16; 'correctly,': 0.16; 'frames': 0.16; 'hexadecimal': 0.16; 'integer.': 0.16; 'subject:Problem': 0.16; 'subject:etc.': 0.16; 'string': 0.17; 'wrote:': 0.17; 'fix': 0.17; 'thu,': 0.17; 'to:name:python-list@python.org': 0.20; "python's": 0.23; "haven't": 0.23; "i've": 0.23; 'seems': 0.23; 'patch': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; '---': 0.26; 'values': 0.26; 'wondering': 0.26; 'trouble': 0.28; 'attempting': 0.29; 'closer': 0.29; 'though.': 0.29; 'convert': 0.29; 'this.': 0.29; "i'm": 0.29; '(from': 0.30; 'checked': 0.30; 'could': 0.32; 'problem': 0.33; 'anyone': 0.33; 'to:addr:python- list': 0.33; 'follows:': 0.35; 'identified': 0.35; 'subject:]': 0.35; 'posting': 0.35; 'there': 0.35; 'but': 0.36; 'charset:us- ascii': 0.36; 'ok,': 0.37; 'two': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'some': 0.38; 'shows': 0.38; 'to:addr:python.org': 0.39; 'subject:-': 0.40; 'easy': 0.60; 'content- disposition:inline': 0.60; 'subject:, ': 0.61; 'identify': 0.61; 'information': 0.63; 'skip:= 30': 0.64; 'here': 0.65; 'offer': 0.65; 'subject:. ': 0.66; '7.4': 0.84; 'briefly,': 0.84; 'each,': 0.84; 'subject:during': 0.84 Date: Thu, 6 Dec 2012 19:22:12 -0500 From: Mark Shroyer To: "python-list@python.org" Subject: Re: Problem using py-bt, py-locals, etc. during GDB debugging [solved] References: <20121206213941.GA5363@mshroyer-d> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20121206213941.GA5363@mshroyer-d> User-Agent: Mutt/1.5.21 (2010-09-15) 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: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1354839735 news.xs4all.nl 6924 [2001:888:2000:d::a6]:56504 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:34440 On Thu, Dec 06, 2012 at 04:39:41PM -0500, Mark Shroyer wrote: > I'm having trouble with the py-bt, py-locals, etc. GDB commands (from > Python's python-gdb.py) while using GDB 7.4 to debug Python 2.7.3; I was > wondering if anyone here could offer advice. > > Briefly, py-bt seems to identify the python stack frames correctly, but > shows "(unable to read python frame information)" for each, and likewise > py-locals fails with "Unable to read information on python frame". OK, I took a closer look at this and I've identified the issue; posting my fix here in case someone else Googles this. The problem in my case was that the python-gdb.py extension makes some fragile assumptions about the format of values it receives from GDB, and I had the line "set output-radix 16" in my .gdbinit, ultimately resulting in the extension attempting to convert the string representation of a hexadecimal number into an integer. So there are two easy workarounds: 1. set output-radix 10 in GDB, or 2. Patch Python 2.7.3's python-gdb.py as follows: === 8< ================================= --- python-gdb.py.orig 2012-12-06 15:12:18.666760664 -0500 +++ python-gdb.py 2012-12-06 19:17:19.588356874 -0500 @@ -1074,7 +1074,11 @@ def int_from_int(gdbval): - return int(str(gdbval)) + int_str = str(gdbval) + if int_str.startswith("0x"): + return int(int_str[2:], 16) + else: + return int(int_str) def stringify(val): === 8< ================================= I haven't checked to see whether this also applies to the GDB extension for Python 3, though.