From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 80B8F3959CA8 for ; Mon, 16 Mar 2020 17:08:54 +0000 (GMT) X-ASG-Debug-ID: 1584378532-0c856e098a1287e30001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id D7dYin0INdYl4jQy (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 16 Mar 2020 13:08:52 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.lan (unknown [192.222.164.54]) by smtp.ebox.ca (Postfix) with ESMTP id 61C55441B21; Mon, 16 Mar 2020 13:08:52 -0400 (EDT) From: Simon Marchi X-Barracuda-Effective-Source-IP: 192-222-164-54.qc.cable.ebox.net[192.222.164.54] X-Barracuda-Apparent-Source-IP: 192.222.164.54 X-Barracuda-RBL-IP: 192.222.164.54 To: gdb-patches@sourceware.org Cc: Eli Zaretskii , Jon Turney , Simon Marchi Subject: [PATCH 7/7] gdb: define builtin long type to be 64 bits on amd64 Cygwin Date: Mon, 16 Mar 2020 13:08:45 -0400 X-ASG-Orig-Subj: [PATCH 7/7] gdb: define builtin long type to be 64 bits on amd64 Cygwin Message-Id: <20200316170845.184386-8-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200316170845.184386-1-simon.marchi@polymtl.ca> References: <20200316170845.184386-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1584378532 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 4468 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.80637 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-23.5 required=5.0 tests=GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_QUARANTINE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Mar 2020 17:08:55 -0000 From: Simon Marchi On Windows x86-64 (when building with MinGW), the size of the "long" type is 32 bits. amd64_windows_init_abi therefore does: set_gdbarch_long_bit (gdbarch, 32); This is also used when the chosen OS ABI is Cygwin, where the "long" type is 64 bits. GDB therefore gets sizeof(long) wrong when using the builtin long type: $ ./gdb -nx --data-directory=data-directory -batch -ex "set architecture i386:x86-64" -ex "set osabi Cygwin" -ex "print sizeof(long)" The target architecture is assumed to be i386:x86-64 $1 = 4 This patch makes GDB avoid setting the size of the long type to 32 bits when using the Cygwin OS ABI. it will inherit the value set in amd64_init_abi. With this patch, I get: $ ./gdb -nx --data-directory=data-directory -batch -ex "set architecture i386:x86-64" -ex "set osabi Cygwin" -ex "print sizeof(long)" The target architecture is assumed to be i386:x86-64 $1 = 8 gdb/ChangeLog: PR gdb/21500 * amd64-windows-tdep.c (amd64_windows_init_abi): Rename to... (amd64_windows_init_abi_common): ... this. Don't set size of long type. (amd64_windows_init_abi): New function. (amd64_cygwin_init_abi): New function. (_initialize_amd64_windows_tdep): Use amd64_cygwin_init_abi for the Cygwin OS ABI. * i386-windows-tdep.c (_initialize_i386_windows_tdep): Clarify comment. --- gdb/amd64-windows-tdep.c | 23 +++++++++++++++++------ gdb/i386-windows-tdep.c | 2 +- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c index e0346f8628fe..6d5076d1c437 100644 --- a/gdb/amd64-windows-tdep.c +++ b/gdb/amd64-windows-tdep.c @@ -1209,7 +1209,7 @@ amd64_windows_auto_wide_charset (void) } static void -amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +amd64_windows_init_abi_common (gdbarch_info info, struct gdbarch *gdbarch) { /* The dwarf2 unwinder (appended very early by i386_gdbarch_init) is preferred over the SEH one. The reasons are: @@ -1229,9 +1229,6 @@ amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) windows_init_abi (info, gdbarch); - /* On Windows, "long"s are only 32bit. */ - set_gdbarch_long_bit (gdbarch, 32); - /* Function calls. */ set_gdbarch_push_dummy_call (gdbarch, amd64_windows_push_dummy_call); set_gdbarch_return_value (gdbarch, amd64_windows_return_value); @@ -1244,6 +1241,21 @@ amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) set_gdbarch_auto_wide_charset (gdbarch, amd64_windows_auto_wide_charset); } +static void +amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +{ + amd64_windows_init_abi_common (info, gdbarch); + + /* On Windows, "long"s are only 32bit. */ + set_gdbarch_long_bit (gdbarch, 32); +} + +static void +amd64_cygwin_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +{ + amd64_windows_init_abi_common (info, gdbarch); +} + static gdb_osabi amd64_windows_osabi_sniffer (bfd *abfd) { @@ -1262,11 +1274,10 @@ void _initialize_amd64_windows_tdep (); void _initialize_amd64_windows_tdep () { - /* The Cygwin and Windows OS ABIs are currently equivalent. */ gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, GDB_OSABI_WINDOWS, amd64_windows_init_abi); gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, GDB_OSABI_CYGWIN, - amd64_windows_init_abi); + amd64_cygwin_init_abi); gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_coff_flavour, amd64_windows_osabi_sniffer); diff --git a/gdb/i386-windows-tdep.c b/gdb/i386-windows-tdep.c index bd6107b02f1f..b26731c6bf28 100644 --- a/gdb/i386-windows-tdep.c +++ b/gdb/i386-windows-tdep.c @@ -270,7 +270,7 @@ _initialize_i386_windows_tdep () gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour, i386_cygwin_core_osabi_sniffer); - /* The Windows and Cygwin OS ABIs are currently equivalent. */ + /* The Windows and Cygwin OS ABIs are currently equivalent on i386. */ gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_WINDOWS, i386_windows_init_abi); gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_CYGWIN, -- 2.25.1