From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14304 invoked by alias); 19 Oct 2007 19:48:20 -0000 Received: (qmail 14289 invoked by uid 22791); 19 Oct 2007 19:48:19 -0000 X-Spam-Check-By: sourceware.org Received: from igw2.br.ibm.com (HELO igw2.br.ibm.com) (32.104.18.25) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 19 Oct 2007 19:48:12 +0000 Received: from mailhub1.br.ibm.com (mailhub1 [9.18.232.109]) by igw2.br.ibm.com (Postfix) with ESMTP id 3FDC317F613 for ; Fri, 19 Oct 2007 17:45:44 -0200 (BRDT) Received: from d24av02.br.ibm.com (d24av02.br.ibm.com [9.18.232.47]) by mailhub1.br.ibm.com (8.13.8/8.13.8/NCO v8.5) with ESMTP id l9JJm6Nc2297990 for ; Fri, 19 Oct 2007 17:48:06 -0200 Received: from d24av02.br.ibm.com (loopback [127.0.0.1]) by d24av02.br.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id l9JJm5gL015328 for ; Fri, 19 Oct 2007 16:48:05 -0300 Received: from [9.18.238.251] ([9.18.238.251]) by d24av02.br.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id l9JJm5l7015325; Fri, 19 Oct 2007 16:48:05 -0300 Subject: Re: Setting a floating point register to raw hex value From: Thiago Jung Bauermann To: Daniel Jacobowitz Cc: Grzegorz Cieslewski , gdb@sourceware.org In-Reply-To: <20071018215448.GA12140@caradoc.them.org> References: <7aa837f80710120829y33db4c3cya21f6ead14ca56f3@mail.gmail.com> <7aa837f80710181238o4aa3e19djffe5324df65e5928@mail.gmail.com> <1192738560.5787.86.camel@localhost.localdomain> <20071018215448.GA12140@caradoc.them.org> Content-Type: text/plain Date: Fri, 19 Oct 2007 19:48:00 -0000 Message-Id: <1192823285.5787.122.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.12.0 Content-Transfer-Encoding: 7bit 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/msg00177.txt.bz2 On Thu, 2007-10-18 at 17:54 -0400, Daniel Jacobowitz wrote: > 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 :-) You're just spoiling the fun. :-) You mean that rs6000_convert_register_p should return true for every type that's not double, and then GDB would try to convert a void * to a double and fail? I see in value_assign that $f1 in the expression I gave above is being represented as a value struct in register $f1 with void * type. Wouldn't it be reasonable for value_assign to see that this register is being used with a type different than it's default (double) and figure that the user wants to use the register in a different way and just let him do that? > > 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. $sp - 8 will mess with the function's frame if he happens to be stepping through the prologue. Just telling to make sure Grzegorz is aware of it... > 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. It worked for me in GDB 6.7 but not in HEAD. -- []'s Thiago Jung Bauermann Software Engineer IBM Linux Technology Center