[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
GDB bug report: display of value in a register of type unsigned long lon
From: |
Steven Augart |
Subject: |
GDB bug report: display of value in a register of type unsigned long long |
Date: |
Sun, 13 Oct 2002 14:17:21 -0700 (PDT) |
I am using this GDB version:
(gdb) show version
GNU gdb 20010316
Copyright 2001 Free Software Foundation, Inc.
When I compile this tiny program with the GCC 2.95.3 command line:
cc -std=gnu9x -pipe -ggdb3 -W -Wall -Wbad-function-cast -Wcast-align
-Wpointer-arith -Wcast-qual -Wshadow -Wstrict-prototypes -Wmissing-prototypes
-Wmissing-declarations -fkeep-static-consts -fkeep-inline-functions -Wundef
-Wwrite-strings -Waggregate-return -Wmissing-noreturn -Wredundant-decls
-Wnested-externs -Wtrigraphs teeny-show-bug.c -o teeny-show-bug
#include <stdio.h>
int
main(int argc, char **argv)
{
unsigned long long c=0x78c50cef9bd3d85;
register unsigned long long divisor = 3;
unsigned long long divisor2 = 3;
printf("( c = %llu ) / (divisor = %llu) = %llu\n",
c, divisor, c / divisor );
printf("( c = %llu ) / (divisor2 = %llu) = %llu\n",
c, divisor2, c / divisor2 );
return 0;
}
I get this incorrect output (divisor should appear as 3, just as
divisor2 does, but GDB displays it incorrectly). The program,
however, does give correct output.
Starting program: /home/swa/Primes/teeny-show-bug
Breakpoint 1, main (argc=1, argv=0xbffff134) at teeny-show-bug.c:6
(gdb) n
(gdb) n
(gdb) n
(gdb) print divisor
$1 = 13835041167470755843
(gdb) print divisor2
$2 = 3
(gdb) show version
GNU gdb 20010316
Copyright 2001 Free Software Foundation, Inc. [...]
This GDB was configured as "i386-suse-linux".
(gdb) c
Continuing.
( c = 543898504888401285 ) / (divisor = 3) = 181299501629467095
( c = 543898504888401285 ) / (divisor2 = 3) = 181299501629467095
Program exited normally.
(gdb)
The hex values of divisor2 may be a bit more enlightening. It appears
to me that GDB is not displaying the high 32 bits of divisor2 correctly,
but is doing fine on the low 32 bits. (I also changed the printf()
formats in this second example):
(gdb) set output 16
Output radix now set to decimal 16, hex 10, octal 20.
(gdb) run
Starting program: /home/swa/Primes/teeny-show-bug
Breakpoint 1, main (argc=0x1, argv=0xbffff134) at teeny-show-bug.c:6
(gdb) n
(gdb) n
(gdb) print divisor
$3 = 0xbffff0a400000003
(gdb) c
Continuing.
( c = 0x78c50cef9bd3d85 ) / (divisor = 0x3) = 0x2841aefa89469d7
( c = 0x78c50cef9bd3d85 ) / (divisor2 = 0x3) = 0x2841aefa89469d7
Program exited normally.
(gdb)
Thanks,
--Steven Augart
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- GDB bug report: display of value in a register of type unsigned long long,
Steven Augart <=