From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25043 invoked by alias); 14 Apr 2011 08:08:06 -0000 Received: (qmail 25032 invoked by uid 22791); 14 Apr 2011 08:08:05 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mail-vx0-f169.google.com (HELO mail-vx0-f169.google.com) (209.85.220.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 14 Apr 2011 08:08:01 +0000 Received: by vxk20 with SMTP id 20so1486386vxk.0 for ; Thu, 14 Apr 2011 01:08:00 -0700 (PDT) Received: by 10.220.164.136 with SMTP id e8mr130611vcy.79.1302768480283; Thu, 14 Apr 2011 01:08:00 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.175.197 with HTTP; Thu, 14 Apr 2011 01:07:40 -0700 (PDT) In-Reply-To: References: From: Kevin Pouget Date: Thu, 14 Apr 2011 08:08:00 -0000 Message-ID: Subject: Re: gdb command output in python script To: Surya Kiran Gullapalli 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: 2011-04/txt/msg00053.txt.bz2 another way would be not to use >> (gdb) set gs-verbose on but rather >> (gdb) set_gs-verbose on where `set_gs-verbose' is a python command you defined. In this function, you can set your (global/class variable) verbosity level according to the `args', so that's is directly available from your `to_string()' Kevin On Thu, Apr 14, 2011 at 3:48 AM, Surya Kiran Gullapalli wrote: > 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 wa= nt 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/fals= e). Now In pretty printer I want to do something like this >> >> define to_string(): >> =A0=A0=A0 if_less_verbose: >> =A0=A0=A0=A0=A0=A0=A0 return concise_string >> =A0=A0=A0 else: >> =A0=A0=A0=A0=A0=A0=A0 return string >> >> My question is, how can i get the value of verbosity in python code. I c= an use gdb.execute to get the output of the gdb command, but it will be sto= red in a string. Is string comparison is the only option. Can I get a boole= an 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 >