public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: "Brian Desany" <brian@desany.com>
To: "'Andrew Cagney'" <cagney@gnu.org>
Cc: "'Peter Barada'" <peter@the-baradas.com>, <gdb@sources.redhat.com>
Subject: RE: Quick question about "print EXPR"
Date: Tue, 04 Jan 2005 23:06:00 -0000	[thread overview]
Message-ID: <20050104230600.rSmfMEU3_vxpdMyUzoi_CO2YN_W2t0pysSerjrHHLi8@z> (raw)
In-Reply-To: <41DAFBF3.2060704@gnu.org>

 
> Brian Desany wrote:
> >>Did you include <math.h> in your program? 
> > 
> > 
> > Yep, I did (the program itself works properly).
> > 
> > FWIW the only lines of the program that aren't listed in my 
> original post are:
> > #include <stdio.h>
> > #include <math.h>
> > 
> > And just in case it matters, I compiled using the command 
> "cc -lm -g test.c".
> > If I compile with "gcc -lm -g test.c", "p floor(whatever)" 
> is always 
> > 16 (rather than 1 as in the original post).
> 
> Wonder if GDB can see this.  What does:
> 
> (gdb) ptype floor
> 
> print?

type = int ()

I was wrong about "p floor(whatever)" always returning a constant value. It
returns a different value depending apparently on what line of the program
I'm currently stopped on:

Breakpoint 1, main (argc=1, argv=0xbfffcf54) at test.c:9
9                        yada = 2.5;
(gdb) p floor(123.456)
$1 = 0
(gdb) n
10                       haha = floor(yada);
(gdb) p floor(123.456)
$2 = 0
(gdb) n
11                       printf("%0.1f %0.1f\n",yada, haha);
(gdb) p floor(123.456)
$3 = 3199
(gdb) n
2.5 -0.0
12                       return 0;
(gdb) p floor(123.456)
$4 = 9
(gdb) 

> 
> Andrew
> 
> > [bdesany]$ cc -v
> > Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
> > gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-81) 
> [bdesany]$ gcc 
> > -v Reading specs from 
> > /home/bdesany/sys/lib/gcc/i686-pc-linux-gnu/3.4.2/specs
> > Configured with: ./configure --prefix=/home/bdesany/sys 
> Thread model: 
> > posix gcc version 3.4.2
> > 
> > Thanks-
> > -Brian.

  reply	other threads:[~2005-01-04 23:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1103746608.31531.ezmlm@sources.redhat.com>
2004-12-22 20:25 ` Brian Desany
2004-12-22 20:40   ` Peter Barada
2004-12-22 20:47     ` Brian Desany
2005-01-04 20:26       ` Andrew Cagney
2005-01-04 23:06         ` Brian Desany [this message]
     [not found] <E1ClxlM-0003ME-7B@monty-python.gnu.org>
2005-02-08 16:42 ` Andrew Cagney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050104230600.rSmfMEU3_vxpdMyUzoi_CO2YN_W2t0pysSerjrHHLi8@z \
    --to=brian@desany.com \
    --cc=cagney@gnu.org \
    --cc=gdb@sources.redhat.com \
    --cc=peter@the-baradas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).