From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8168 invoked by alias); 18 Apr 2013 00:51:56 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 8079 invoked by uid 89); 18 Apr 2013 00:51:56 -0000 X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE autolearn=ham version=3.3.1 Received: from mail-ia0-f177.google.com (HELO mail-ia0-f177.google.com) (209.85.210.177) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 18 Apr 2013 00:51:55 +0000 Received: by mail-ia0-f177.google.com with SMTP id w33so1934388iag.8 for ; Wed, 17 Apr 2013 17:51:54 -0700 (PDT) X-Received: by 10.50.192.165 with SMTP id hh5mr5604557igc.89.1366246314064; Wed, 17 Apr 2013 17:51:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.118.35 with HTTP; Wed, 17 Apr 2013 17:51:33 -0700 (PDT) From: Vladimir Kargov Date: Thu, 18 Apr 2013 15:40:00 -0000 Message-ID: Subject: =?windows-1252?Q?=5BPATCH=5D_Fix_the_x87_FP_register_printout_by_=93info_?= =?windows-1252?Q?float=94=2E?= To: gdb-patches@sourceware.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2013-04/txt/msg00558.txt.bz2 Hello, Please find attached a patch that fixes the x87 FP register printout when issuing the =93info float=94 command. Consider the following simple program: .globl _start .text _start: fldt val .data val: .byte 0x00,0x00,0x45,0x07,0x11,0x19,0x22,0xe9,0xfe,0xbf With the current gdb revision(7.6.50.20130417-cvs) on my x86-64 target machine after the moment the fldt command has been executed the register st(0) looks like this, according to the =93info regs=94 output (TOP=3D7): R7: Valid 0xffffffbffffffffeffffffe922191107450000 -0.910676542908976927 which is clearly wrong (just count its length). The problem is due to the printf() statement (see patch) printing a promoted integer value of a char argument "raw[i]", and, since char is signed on my machine, the erroneous =93ffffff=94 are printed for the first three bytes which turn out to be "negative". The fix adds the char length modifier that forces fprintf to treat the value as a char instead of int. After the fix the value will be printed correctly: R7: Valid 0xbffee922191107450000 -0.910676542908976927 Another way to fix this would be to replace the type in the definition of variable "raw" from "char" to "gdb_char" which is currently defined as "unsigned char", but I couldn't find any signs in the code that this typedef wouldn't be changed in the future to something else. 2013-04-18 Vladimir Kargov * i387-tdep.c (i387_print_float_info): Add the "hh" length modifier to the format string of fprintf_filtered(). Index: gdb/i387-tdep.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/i387-tdep.c,v retrieving revision 1.76 diff -u -p -r1.76 i387-tdep.c --- gdb/i387-tdep.c 1 Jan 2013 06:32:45 -0000 1.76 +++ gdb/i387-tdep.c 18 Apr 2013 00:23:27 -0000 @@ -302,7 +302,7 @@ i387_print_float_info (struct gdbarch *g fputs_filtered ("0x", file); for (i =3D 9; i >=3D 0; i--) - fprintf_filtered (file, "%02x", raw[i]); + fprintf_filtered (file, "%02hhx", raw[i]); if (tag !=3D -1 && tag !=3D 3) print_i387_ext (gdbarch, raw, file); Best regards, -- Vladimir