public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* doing a comparison in python
@ 2010-08-17  0:19 Mathew Yeates
  2010-08-17  0:26 ` Michael Snyder
  0 siblings, 1 reply; 6+ messages in thread
From: Mathew Yeates @ 2010-08-17  0:19 UTC (permalink / raw)
  To: gdb

Hi
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?

-Mathew

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: doing a comparison in python
  2010-08-17  0:19 doing a comparison in python Mathew Yeates
@ 2010-08-17  0:26 ` Michael Snyder
  2010-08-17  0:35   ` Mathew Yeates
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Snyder @ 2010-08-17  0:26 UTC (permalink / raw)
  To: Mathew Yeates; +Cc: gdb

Mathew Yeates wrote:
> Hi
> 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)
       [...];

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: doing a comparison in python
  2010-08-17  0:26 ` Michael Snyder
@ 2010-08-17  0:35   ` Mathew Yeates
  2010-08-17  1:40     ` Thiago Jung Bauermann
  0 siblings, 1 reply; 6+ messages in thread
From: Mathew Yeates @ 2010-08-17  0:35 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb

no. it's a logical. Either .TRUE. or .FALSE.

On Mon, Aug 16, 2010 at 5:26 PM, Michael Snyder <msnyder@vmware.com> wrote:
> Mathew Yeates wrote:
>>
>> Hi
>> 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)
>      [...];
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: doing a comparison in python
  2010-08-17  0:35   ` Mathew Yeates
@ 2010-08-17  1:40     ` Thiago Jung Bauermann
  2010-08-17 10:59       ` Paul Koning
  2010-08-17 16:24       ` Tom Tromey
  0 siblings, 2 replies; 6+ messages in thread
From: Thiago Jung Bauermann @ 2010-08-17  1:40 UTC (permalink / raw)
  To: Mathew Yeates; +Cc: Michael Snyder, gdb

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: doing a comparison in python
  2010-08-17  1:40     ` Thiago Jung Bauermann
@ 2010-08-17 10:59       ` Paul Koning
  2010-08-17 16:24       ` Tom Tromey
  1 sibling, 0 replies; 6+ messages in thread
From: Paul Koning @ 2010-08-17 10:59 UTC (permalink / raw)
  To: Thiago Jung Bauermann; +Cc: Mathew Yeates, Michael Snyder, gdb


On Aug 16, 2010, at 9:40 PM, Thiago Jung Bauermann wrote:

> 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'
> -- 

That's a bit redundant, just as it would be in C.  I would write:

foo = gdb.parse_and_eval ("foo")
if foo:
   print 'hooray'
--
	paul

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: doing a comparison in python
  2010-08-17  1:40     ` Thiago Jung Bauermann
  2010-08-17 10:59       ` Paul Koning
@ 2010-08-17 16:24       ` Tom Tromey
  1 sibling, 0 replies; 6+ messages in thread
From: Tom Tromey @ 2010-08-17 16:24 UTC (permalink / raw)
  To: Thiago Jung Bauermann; +Cc: Mathew Yeates, Michael Snyder, gdb

>>>>> "Thiago" == Thiago Jung Bauermann <bauerman@br.ibm.com> writes:

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

In addition to what Thiago said, if the documentation (specifically the
node "Values From Inferior") is unclear, we'd appreciate comments on how
to improve it.

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-08-17 16:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-17  0:19 doing a comparison in python Mathew Yeates
2010-08-17  0:26 ` Michael Snyder
2010-08-17  0:35   ` Mathew Yeates
2010-08-17  1:40     ` Thiago Jung Bauermann
2010-08-17 10:59       ` Paul Koning
2010-08-17 16:24       ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).