From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21857 invoked by alias); 17 Jan 2012 06:10:37 -0000 Received: (qmail 21845 invoked by uid 22791); 17 Jan 2012 06:10:36 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-lpp01m010-f41.google.com (HELO mail-lpp01m010-f41.google.com) (209.85.215.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 17 Jan 2012 06:10:19 +0000 Received: by lagw12 with SMTP id w12so146499lag.0 for ; Mon, 16 Jan 2012 22:10:17 -0800 (PST) MIME-Version: 1.0 Received: by 10.112.38.226 with SMTP id j2mr3816335lbk.74.1326780617548; Mon, 16 Jan 2012 22:10:17 -0800 (PST) Received: by 10.112.90.21 with HTTP; Mon, 16 Jan 2012 22:10:17 -0800 (PST) In-Reply-To: References: Date: Tue, 17 Jan 2012 06:10:00 -0000 Message-ID: Subject: Re: gdb user defined function From: Sinbad To: Tom Tromey Cc: gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 2012-01/txt/msg00056.txt.bz2 hi tom, i've never used python with gdb or python at all. but i want to learn enough of python to achieve the following. how do one use python with gdb, will gdb become slow, can you give me some pointers on how to achieve the following using python. Please don't yell ;) thanks On Tue, Jan 17, 2012 at 2:16 AM, Tom Tromey wrote: >>>>>> "Sinbad" =3D=3D Sinbad =A0 writes: > > Sinbad> i am trying to write a user-defined function in gdb. > Sinbad> while analyzing the core is it possible to see if a > Sinbad> pointer variable is accessible or not inside a gdb > Sinbad> user-defined function. for example. > Sinbad> (gdb) p *ptr > Sinbad> cannot access memory at address 0x35336 > Sinbad> is there any way to find this inside a gdb function. > Sinbad> i need something as follows > Sinbad> define sub > Sinbad> =A0 =A0is_accessible(ptr) > Sinbad> end > > I can't think of an easy way to do this from the gdb CLI, but you can do > it from Python by catching the exception. > > You could straightforwardly write a $is_valid function that examines a > pointer for validity. > > Tom