This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: doing a comparison in python


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]