mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-27 04:52:05 +08:00
c912f608be
When a 64-bits (x86-64) gdbarch is created, it is first born as a 32-bits gdbarch in i386_gdbarch_init. The call gdbarch_init_osabi will call the handler register for the selected (arch, osabi) pair, such as amd64_linux_init_abi. The various amd64 handlers call amd64_init_abi, which turns the gdbarch into a 64-bits one. When selecting the i386:x86-64 architecture with no osabi, no such handler is ever called, so the gdbarch stays (wrongfully) a 32-bits one. My first idea was to manually call amd64_init_abi & al in i386_gdbarch_init when the osabi is GDB_OSABI_NONE. However, this doesn't work in a build of GDB where i386 is included as a target but not amd64. My next option (implemented in this patch), is to allow registering handlers for GDB_OSABI_NONE. I added two such handlers in amd64-tdep.c, so now it works the same as for the "normal" osabis. It required re-ordering things in gdbarch_init_osabi to allow running handlers for GDB_OSABI_NONE. Without this patch applied (but with the previous one*) : (gdb) set osabi none (gdb) set architecture i386:x86-64 The target architecture is assumed to be i386:x86-64 (gdb) p sizeof(void*) $1 = 4 and now: (gdb) set osabi none (gdb) set architecture i386:x86-64 The target architecture is assumed to be i386:x86-64 (gdb) p sizeof(void*) $1 = 8 * Before the previous patch, which fixed "set osabi none", this bug was hidden because we didn't actually try to generate a gdbarch for no osabi, it would always fall back on Linux. Generating the gdbarch for amd64/linux did work. gdb/ChangeLog: PR gdb/22979 * amd64-tdep.c (amd64_none_init_abi): New function. (amd64_x32_none_init_abi): New function. (_initialize_amd64_tdep): Register handlers for x86-64 and x64_32 with GDB_OSABI_NONE. * osabi.c (gdbarch_init_osabi): Allow running handlers for the GDB_OSABI_NONE osabi. gdb/testsuite/ChangeLog: PR gdb/22979 * gdb.arch/amd64-osabi.exp: New file.
44 lines
1.4 KiB
Plaintext
44 lines
1.4 KiB
Plaintext
# Copyright 2018 Free Software Foundation, Inc.
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# Verify that gdbarches for i386 variants and osabi none are properly created.
|
|
|
|
if { ![istarget x86_64-*-* ] } {
|
|
untested "skipping x86-64 specific test"
|
|
return
|
|
}
|
|
|
|
|
|
proc test_osabi_none { arch void_ptr_size long_double_size } {
|
|
clean_restart
|
|
|
|
gdb_test "set architecture i386:x86-64" "The target architecture is assumed to be i386:x86-64"
|
|
gdb_test_no_output "set osabi none" "set osabi none"
|
|
gdb_test "print sizeof (void*)" " = 8"
|
|
gdb_test "print sizeof (long double)" " = 16"
|
|
}
|
|
|
|
set infos { \
|
|
{ "i386:x86-64" 8 16 } \
|
|
{ "i386:x64-32" 4 16 } \
|
|
{ "i386" 4 12 } }
|
|
|
|
foreach info $infos {
|
|
lassign $info arch void_ptr_size long_double_size
|
|
with_test_prefix "arch=$arch" {
|
|
test_osabi_none $arch $void_ptr_size $long_double_size
|
|
}
|
|
}
|