From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20201 invoked by alias); 18 Oct 2007 21:54:54 -0000 Received: (qmail 20192 invoked by uid 22791); 18 Oct 2007 21:54:53 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 18 Oct 2007 21:54:51 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 6DF24982CA; Thu, 18 Oct 2007 21:54:49 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id 1BED1981F1; Thu, 18 Oct 2007 21:54:49 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.68) (envelope-from ) id 1IidKK-0003FS-4f; Thu, 18 Oct 2007 17:54:48 -0400 Date: Thu, 18 Oct 2007 21:54:00 -0000 From: Daniel Jacobowitz To: Thiago Jung Bauermann Cc: Grzegorz Cieslewski , gdb@sourceware.org Subject: Re: Setting a floating point register to raw hex value Message-ID: <20071018215448.GA12140@caradoc.them.org> Mail-Followup-To: Thiago Jung Bauermann , Grzegorz Cieslewski , gdb@sourceware.org References: <7aa837f80710120829y33db4c3cya21f6ead14ca56f3@mail.gmail.com> <7aa837f80710181238o4aa3e19djffe5324df65e5928@mail.gmail.com> <1192738560.5787.86.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1192738560.5787.86.camel@localhost.localdomain> User-Agent: Mutt/1.5.15 (2007-04-09) X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-10/txt/msg00160.txt.bz2 On Thu, Oct 18, 2007 at 06:16:00PM -0200, Thiago Jung Bauermann wrote: > Hi, > > Yes, that's indeed crazy. :-) > > Just found out that this works: > > (gdb) set (void *) $f1 = 0x1 > (gdb) info reg f1 > f1 4.9406564584124654e-324 (raw 0x0000000000000001) I think this only works by an accident involving gdbarch_convert_register_p on PowerPC. We should find some proper way to do it, document that, and then make this not work :-) > On Thu, 2007-10-18 at 15:38 -0400, Grzegorz Cieslewski wrote: > > I have figured out a workaround but it is really ugly. > > > > Step 1: Create shared object containing a union as follows > > union longlong2double > > { > > long long int hexNum; > > double floatNum; > > } temp; > > > > Step 2: Force load the library at runtime into your program using > > LD_PRELOAD environmental variable > > > > Step 3: When debugging the program store 0x1 into temp.hexNum; > > (one would think that I could use the following now 'set $f0 = > > temp.floatNum; but that yields incorrect result) > > > > Step4: Overwrite the current instruction with 'load float' > > > > Step5: Using stepping command 'stepi 1' to write the value to the $f0 > > > > Step6: Undo all the changes required by steps 4 and 5 > > > > Does any one know of a simpler way because this workaround is crazy? Sure, here's a much easier way that ought to work: (gdb) set {long long} ($sp - 8) = 1 (gdb) set $f0 = {double} ($sp - 8) Doesn't have to be $sp - 8, any memory address will do. Oddly, this does not work on PowerPC. I can't figure out why not. It certainly ought to work; perhaps it requires a current version of GDB, since 0x1 is a denormal. It does work for normals, though, so I know the approach is sound. -- Daniel Jacobowitz CodeSourcery