From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13225 invoked by alias); 11 May 2009 20:30:28 -0000 Received: (qmail 13179 invoked by uid 22791); 11 May 2009 20:30:24 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_31,RCVD_IN_DNSWL_LOW,RCVD_NUMERIC_HELO,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 May 2009 20:30:16 +0000 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1M3c8d-0001PQ-31 for insight@sources.redhat.com; Mon, 11 May 2009 20:30:15 +0000 Received: from 75.139.7.185 ([75.139.7.185]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 11 May 2009 20:30:15 +0000 Received: from gds by 75.139.7.185 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 11 May 2009 20:30:15 +0000 To: insight@sources.redhat.com From: Gene Smith Subject: Re: functions returning double or float inspection Date: Mon, 11 May 2009 20:30:00 -0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) In-Reply-To: X-IsSubscribed: yes Mailing-List: contact insight-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: insight-owner@sourceware.org X-SW-Source: 2009-q2/txt/msg00055.txt.bz2 Gene Smith wrote: > I have been experimenting with function that return doubles in gcc such > as c = pow(x,y). They work OK and I can inspect the float/double c > return value (as a pop-up or as a watch) and it is ok. But if I inspect > pow(x,y) itself (highlighting the function call with the mouse or > evaluating in a watch window or print /f pow(x,y) in the console) I see > usually an integer value with no decimal or an incorrect real value. Is > this a bug or am I doing something wrong when letting insight/gdb > calculate a float/double function value? > > -gene Well, to quickly answer my own question see http://sourceware.org/gdb/wiki/FAQ . GDB reports a nonsensical return value from an inferior function call. What's going on? * GDB doesn't know the return type nor the type of the arguments for that function call, because there's no debug information available for it. Either provide debuginfo for the program or library which contains the function, or cast the function to a function pointer of the appropriate signature. For example, to call fabs, which takes a double and returns a double, use: (gdb) print ((double (*) (double)) fabs) ( -1.25 ) In my case print ((double (*) (double,double) pow(x,y) works for in the console. Pop-up and watch would require the libary built with debug info to see the correct values I think.