Discussion:
[Bug build/21500] New: gdb sizeof(long int)=4 but gcc sizeof(long int)=8 on x86_64-pc-cygwin
jrose.manila at gmail dot com
2017-05-18 10:28:09 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21500

Bug ID: 21500
Summary: gdb sizeof(long int)=4 but gcc sizeof(long int)=8 on
x86_64-pc-cygwin
Product: gdb
Version: 7.10.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: build
Assignee: unassigned at sourceware dot org
Reporter: jrose.manila at gmail dot com
Target Milestone: ---
Host: CYGWIN_NT-10.0 Caroline-2 2.8.0(0.309/5/3) 2017-04-01
20:47 x86_64 Cygwin
Target: x86_64 Cygwin

gcc sizeof(long)=8 but gdb sizeof(long)=4 on current x86_64-pc-cygwin.
Consistency between gdb and gcc is required for any given platform.

The gdb build appears to be incorrect for x86_64-pc-cygwin. Tested with gcc
5.4.0 and gdb 7.10.1 (current cygwin versions) on x86_64-pc-cygwin running
under Windows 10.


Please refer to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80777 for
discussion whether gcc or gdb is incorrectly configured. In particular
comment-8 there.

Also refer to https://bugzilla.redhat.com/show_bug.cgi?id=518712 which
describes the same issue under Linux. Repeating the same test described in
comment-1 there when run under x86_64-pc-cygwin gets the wrong answer:

$ gdb
GNU gdb (GDB) (Cygwin 7.10.1-1) 7.10.1
Copyright (C) 2015 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-pc-cygwin".
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) show arch
The target architecture is set automatically (currently i386)
(gdb) set arch
Requires an argument. Valid arguments are i386, i386:x86-64, i386:x64-32,
i8086, i386:intel, i386:x86-64:intel, i386:x64-32:intel, i386:nacl,
i386:x86-64:nacl, i386:x64-32:nacl, auto.
(gdb) set arch i386:x86-64
The target architecture is assumed to be i386:x86-64
(gdb) print sizeof(long)
$1 = 4
(gdb) print sizeof(long long)
$2 = 8
(gdb) print sizeof(long*)
$3 = 8
(gdb) q
--
You are receiving this mail because:
You are on the CC list for the bug.
palves at redhat dot com
2017-05-18 12:29:15 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21500

Pedro Alves <palves at redhat dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |palves at redhat dot com

--- Comment #1 from Pedro Alves <palves at redhat dot com> ---
The problem is that while Cygwin and MinGW ABIs are different, GDB assumes
they're the same.

amd64-windows-tdep.c has:

/* On Windows, "long"s are only 32bit. */
set_gdbarch_long_bit (gdbarch, 32);

and this gdbarch is used by both Cygwin and MinGW.

We need a new "show osabi" value for "Windows" (MinGW), and then come up with
some way to figure out automatically from the program binary which of the ABIs
is in effect. Looking at the dll import list for the cygwin dll may be a good
enough approximation. (And add a hardcoded case for the cygwin dll itself.)
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-04-19 15:19:59 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21500

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org
Component|build |tdep
--
You are receiving this mail because:
You are on the CC list for the bug.
palves at redhat dot com
2018-04-19 15:21:52 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=21500

Pedro Alves <palves at redhat dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Keywords| |good-first-bug
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...