This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
gdb command output in python script
- From: Surya Kiran Gullapalli <suryakiran dot gullapalli at gmail dot com>
- To: gdb at sourceware dot org
- Date: Thu, 14 Apr 2011 13:18:16 +0530
- Subject: gdb command output in python script
- References: <BANLkTikJ2EL53+czXAZmG-w4itXgso=27Q@mail.gmail.com> <BANLkTinuSmy6eTW=0afTZ75Ne5+9u59QRQ@mail.gmail.com>
On Thu, Apr 14, 2011 at 09:44, Surya Kiran Gullapalli
<suryakiran.gullapalli@gmail.com> wrote:
>
> Hello all,
> I'm trying to implement some pretty-printers for my C++ classes and I want 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():
> ÂÂÂ if_less_verbose:
> ÂÂÂÂÂÂÂ return concise_string
> ÂÂÂ else:
> ÂÂÂÂÂÂÂ return string
>
> My question is, how can i get the value of verbosity in python code. I can use gdb.execute to get the output of the gdb command, but it will be stored in a string. Is string comparison is the only option. Can I get a boolean 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