From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27649 invoked by alias); 24 Mar 2008 14:38:59 -0000 Received: (qmail 27639 invoked by uid 22791); 24 Mar 2008 14:38:58 -0000 X-Spam-Check-By: sourceware.org Received: from igw2.br.ibm.com (HELO igw2.br.ibm.com) (32.104.18.25) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 24 Mar 2008 14:38:34 +0000 Received: from mailhub1.br.ibm.com (mailhub1 [9.18.232.109]) by igw2.br.ibm.com (Postfix) with ESMTP id B2AB717F49C for ; Mon, 24 Mar 2008 11:29:55 -0300 (BRST) Received: from d24av02.br.ibm.com (d24av02.br.ibm.com [9.18.232.47]) by mailhub1.br.ibm.com (8.13.8/8.13.8/NCO v8.7) with ESMTP id m2OEbxEM4108366 for ; Mon, 24 Mar 2008 11:37:59 -0300 Received: from d24av02.br.ibm.com (loopback [127.0.0.1]) by d24av02.br.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m2OEbwCq004916 for ; Mon, 24 Mar 2008 11:37:59 -0300 Received: from [9.18.238.95] ([9.18.238.95]) by d24av02.br.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id m2OEbwwG004913; Mon, 24 Mar 2008 11:37:58 -0300 Subject: Re: repo to work on python scripting support From: Thiago Jung Bauermann To: tromey@redhat.com Cc: gdb ml In-Reply-To: References: <1205538908.6643.138.camel@localhost.localdomain> Content-Type: text/plain Date: Mon, 24 Mar 2008 17:16:00 -0000 Message-Id: <1206369478.29533.15.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.12.3 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-03/txt/msg00203.txt.bz2 Hi everybody, My turn at the status update. :-) I did the OO rewrite for the frames support, it has a few useful methods already (equals, is_inner_than, get_name, get_pc, get_prev, get_next, find_sal). You can also call gdb.frames(), which will return a tuple containing all frames in the stack (or throw an exception if there's a problem with the unwinding). I also exposed a little bit of struct symtab and struct symtab_and_line (which is returned by Frame.find_sal), just enough to be able to implement a mostly complete backtrace command in Python (it's only missing ability to print function arguments, which I plan to work on later). Regarding the values work that Tromey mentioned, I didn't add functionality to the code that Volodya implemented, just converted it to OO form and worked on lifetime of struct value vs lifetime of Python Value object (I believe I is correct now). Here's the Python implementation of an "rbt" command which prints the backtrace in reverse (or right :-P) order: python import sys def gdb_rbacktrace (): frames = gdb.frames () for i in reversed (range (len (frames))): sal = frames[i].find_sal () pc = frames[i].get_pc () sys.stdout.write ("#%-2d" % i) if pc != sal.get_pc () or not sal.symtab: sys.stdout.write (" 0x%08x in" % pc) sys.stdout.write (" " + frames[i].get_name ()) if sal.symtab and sal.symtab.get_filename (): sys.stdout.write (" at " + sal.symtab.get_filename ()) sys.stdout.write (":" + str (sal.get_line ())) if not frames[i].get_name () or (not sal.symtab or not sal.symtab.get_filename ()): lib = gdb.solib_address (pc) if lib: sys.stdout.write (" from " + lib) sys.stdout.write ("\n") end define rbt dont-repeat python gdb_rbacktrace () end Here's sample output: (gdb) rbt #2 0x080483bb in main at ../../src/examples/funcs.c:15 #1 0x08048391 in f1 at ../../src/examples/funcs.c:10 #0 f2 at ../../src/examples/funcs.c:5 (gdb) -- []'s Thiago Jung Bauermann Software Engineer IBM Linux Technology Center