doing a comparison in python

Thiago Jung Bauermann bauerman@br.ibm.com
Tue Aug 17 01:40:00 GMT 2010


On Mon, 2010-08-16 at 17:34 -0700, Mathew Yeates wrote:
> On Mon, Aug 16, 2010 at 5:26 PM, Michael Snyder <msnyder@vmware.com> wrote:
> > Mathew Yeates wrote:
> >> I am debugging fortran code and I want to see if an interior value is
> >> equal to .FALSE.
> >> I know how to get the value with parse_and_eval but what do I do with it?
> >
> > Can we assume this value is an integer?
> > Then you should be able to do something like this:
> >
> >   long foo = value_as_long (parse_and_eval (my_value));
> >
> >   if (foo == 0)
> >      [...];
> 
> no. it's a logical. Either .TRUE. or .FALSE.

GDB values in Python scripts can be directly compared with Python's
native types, so you can just say:

foo = gdb.parse_and_eval ("foo")
if foo == True:
  print 'hooray'
-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center



More information about the Gdb mailing list