2015-04-24 12 views
6

Non riesco a fare GDB stampa correcly alcuni numeri in virgola mobile in stile C esadecimali, si veda:GDB può analizzare correttamente i numeri esadecimali in virgola mobile in stile C?

GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1 
Copyright (C) 2014 Free Software Foundation, Inc. 
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 
This is free software: you are free to change and redistribute it. 
There is NO WARRANTY, to the extent permitted by law. Type "show copying" 
and "show warranty" for details. 
This GDB was configured as "x86_64-linux-gnu". 
Type "show configuration" for configuration details. 
For bug reporting instructions, please see: 
<http://www.gnu.org/software/gdb/bugs/>. 
Find the GDB manual and other documentation resources online at: 
<http://www.gnu.org/software/gdb/documentation/>. 
For help, type "help". 
Type "apropos word" to search for commands related to "word". 
(gdb) p 0xa.0p-4 
$1 = 6 

Qui $1 dovrebbe essere 0.625 ma il mio GDB sembra di vedere 0xa.0p come decimali 10 e fa un successiva aggiunta con -4. Cosa c'è di sbagliato in ciò che chiedo a GDB di stampare? Non sono riuscito a trovare alcuna documentazione pertinente su come GDB gestisce i float esadecimali.

risposta

3

Cosa c'è di sbagliato in ciò che chiedo a GDB di stampare?

Apparentemente è un bug con gdb.

Le costanti esadecimali in virgola mobile con un esponente negativo danno un risultato errato con gdb.

Ho provato con l'ultima gdb rilascio sorgente 7.9 (Feb 20, 2015) su costanti floating point Linux e esadecimali con un esponente positivo sono supportati:

(gdb) p/f 0x00.1p0 
$1 = 0.0625 
(gdb) p/f 0x00.1p1 
$2 = 0.125 

ma se l'esponente è negativo, allora il risultato è sbagliato:

(gdb) p/f 0x00.1p-1 
$3 = -0.9375 

Il diritto e il risultato atteso è 0.031250.

+0

@hdl Non riesco a trovare alcun bug aperto su gdb Bugzilla https://www.sourceware.org/bugzilla ti piacerebbe aprirne uno? Altrimenti posso salvarlo da solo. – ouah

+0

Per l'errore "Numero non valido", vedere http://stackoverflow.com/questions/24865689/change-decimal-separator-in-gdb#comment38649027_24865689 – hdl

+0

@hdl buon punto, rimuovo questo punto della mia risposta per evitare il rumore non necessario – ouah

Problemi correlati