From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15817 invoked by alias); 14 Apr 2011 07:48:23 -0000 Received: (qmail 15804 invoked by uid 22791); 14 Apr 2011 07:48:21 -0000 X-SWARE-Spam-Status: No, hits=1.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-vw0-f41.google.com (HELO mail-vw0-f41.google.com) (209.85.212.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 14 Apr 2011 07:48:17 +0000 Received: by vws4 with SMTP id 4so1469178vws.0 for ; Thu, 14 Apr 2011 00:48:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.89.167 with SMTP id bp7mr674505vdb.60.1302767296854; Thu, 14 Apr 2011 00:48:16 -0700 (PDT) Received: by 10.220.49.1 with HTTP; Thu, 14 Apr 2011 00:48:16 -0700 (PDT) In-Reply-To: References: Date: Thu, 14 Apr 2011 07:48:00 -0000 Message-ID: Subject: gdb command output in python script From: Surya Kiran Gullapalli To: gdb@sourceware.org Content-Type: text/plain; charset=UTF-8 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: 2011-04/txt/msg00052.txt.bz2 On Thu, Apr 14, 2011 at 09:44, Surya Kiran Gullapalli wrote: > > Hello all, > I'm trying to implement some pretty-printers for my C++ classes and I wan= t two types of outputs in debug. verbose and concise. User can turn on/off = the verbosity levels on gdb command prompt like this > > (gdb) set gs-verbose on > or > (gdb) set gs-verbose off > > where gs-verbose is the custom command (sets a boolean flag to true/false= ). Now In pretty printer I want to do something like this > > define to_string(): > =C2=A0=C2=A0=C2=A0 if_less_verbose: > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return concise_string > =C2=A0=C2=A0=C2=A0 else: > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return string > > My question is, how can i get the value of verbosity in python code. I ca= n use gdb.execute to get the output of the gdb command, but it will be stor= ed in a string. Is string comparison is the only option. Can I get a boolea= n value from > custom command ? > > Thanks in advance, > Surya Hi, I've achieved this using custom parameter (derived from gdb.Parameter) and calling gdb.parameter() function from python to fetch the parameter value. Thanks, Surya