From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21805 invoked by alias); 6 Jan 2011 14:55:04 -0000 Mailing-List: contact archer-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: List-Id: Received: (qmail 21782 invoked by uid 22791); 6 Jan 2011 14:55:03 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_GT,TW_YG,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org From: Tom Tromey To: David Malcolm Cc: archer@sourceware.org Subject: Re: Pretty-printing backtraces when "python" is the inferior process References: <1261524321.2228.70.camel@brick> Date: Thu, 06 Jan 2011 14:55:00 -0000 In-Reply-To: <1261524321.2228.70.camel@brick> (David Malcolm's message of "Tue, 22 Dec 2009 18:25:21 -0500") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2011-q1/txt/msg00000.txt.bz2 >>>>> "David" == David Malcolm writes: [ replying to an old thread ] David> I'm trying to use a freshly-built gdb to debug a pygtk app named David> "istanbul" (using system python and system copy of instanbul): [...] David> I'd like to access the local "PyCodeObject *co" at this point: David> (gdb) p co David> $5 = (PyCodeObject *) 0x81274e8 David> This API hook works: David> (gdb) python print gdb.parse_and_eval("co") David> 0x81274e8 David> But this one doesn't: David> (gdb) python print gdb.selected_frame().read_var('co') David> Traceback (most recent call last): David> File "", line 1, in David> ValueError: variable 'co' not found David> Error while executing Python code. I looked at this again and I found a bug in py-frame.c that accounts for this behavior. I am testing a patch. The above isn't quite right though, even with the fix in place. The problem is that a given frame may have multiple blocks associated with it ("block" is basically just a block in C). In this case there are a couple, and "co" appears in one of the outer ones. I used this snippet to look at what symbols were in which block in the frame: b = gdb.selected_frame().block() while True: for sym in b: print sym.name if b.function is not None: break print "== new block" b = b.superblock I think you have to find the right block to pass to read_var. Tom