From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1626 invoked by alias); 17 Jan 2012 16:29:06 -0000 Received: (qmail 1613 invoked by uid 22791); 17 Jan 2012 16:29:03 -0000 X-SWARE-Spam-Status: No, hits=-7.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 17 Jan 2012 16:28:50 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0HGSmSO011206 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 17 Jan 2012 11:28:49 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q0HGSmi3010791; Tue, 17 Jan 2012 11:28:48 -0500 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id q0HGSkrp016904; Tue, 17 Jan 2012 11:28:47 -0500 From: Tom Tromey To: Sinbad Cc: gdb@sourceware.org Subject: Re: gdb user defined function References: Date: Tue, 17 Jan 2012 16:29:00 -0000 In-Reply-To: (Sinbad's message of "Tue, 17 Jan 2012 11:40:17 +0530") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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: 2012-01/txt/msg00058.txt.bz2 >>>>> "Sinbad" == Sinbad writes: Sinbad> i've never used python with gdb or python at all. but i want to learn Sinbad> enough of python to achieve the following. how do one use python Sinbad> with gdb, will gdb become slow, can you give me some pointers Sinbad> on how to achieve the following using python. There are plenty of docs: http://sourceware.org/gdb/onlinedocs/gdb/Python.html What you want is the stuff about writing a function: http://sourceware.org/gdb/onlinedocs/gdb/Functions-In-Python.html#Functions-In-Python and also the Value API. The core of your function will probably be something along these lines: try: arg = arg.deref() return 1 except: return 0 Untested of course. About speed... well, evaluating Python does have a cost. I wouldn't worry about it in advance; especially if the alternative is using the gdb CLI, which in general is less well-tuned than Python. If your situation is truly performance critical, then (1) measure the effects of Python, and (2) if it is too slow, write a convenience function in C instead. Sinbad> Please don't yell ;) Don't worry. Tom