mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-21 01:12:32 +08:00
gdb/
Fix memory access from signed 32bit inferior registers on 64bit GDB. * linux-nat.c (linux_xfer_partial <TARGET_OBJECT_MEMORY>): New variable addr_bit. Mask OFFSET by the ADDR_BIT width. gdb/testsuite/ * gdb.arch/amd64-i386-address.exp, gdb.arch/amd64-i386-address.S: New.
This commit is contained in:
parent
4662c76e91
commit
8f31392312
@ -1,3 +1,9 @@
|
||||
2009-07-13 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
Fix memory access from signed 32bit inferior registers on 64bit GDB.
|
||||
* linux-nat.c (linux_xfer_partial <TARGET_OBJECT_MEMORY>): New variable
|
||||
addr_bit. Mask OFFSET by the ADDR_BIT width.
|
||||
|
||||
2009-07-13 Anthony Green <green@moxielogic.com>
|
||||
|
||||
* moxie-tdep.c (moxie_gdbarch_init): Call
|
||||
|
@ -4260,6 +4260,20 @@ linux_xfer_partial (struct target_ops *ops, enum target_object object,
|
||||
return linux_nat_xfer_osdata (ops, object, annex, readbuf, writebuf,
|
||||
offset, len);
|
||||
|
||||
/* GDB calculates all the addresses in possibly larget width of the address.
|
||||
Address width needs to be masked before its final use - either by
|
||||
linux_proc_xfer_partial or inf_ptrace_xfer_partial.
|
||||
|
||||
Compare ADDR_BIT first to avoid a compiler warning on shift overflow. */
|
||||
|
||||
if (object == TARGET_OBJECT_MEMORY)
|
||||
{
|
||||
int addr_bit = gdbarch_addr_bit (target_gdbarch);
|
||||
|
||||
if (addr_bit < (sizeof (ULONGEST) * HOST_CHAR_BIT))
|
||||
offset &= ((ULONGEST) 1 << addr_bit) - 1;
|
||||
}
|
||||
|
||||
xfer = linux_proc_xfer_partial (ops, object, annex, readbuf, writebuf,
|
||||
offset, len);
|
||||
if (xfer != 0)
|
||||
|
@ -1,3 +1,7 @@
|
||||
2009-07-13 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
* gdb.arch/amd64-i386-address.exp, gdb.arch/amd64-i386-address.S: New.
|
||||
|
||||
2009-07-13 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||
|
||||
Fix gdb.base/macscp.exp when using custom inputrc.
|
||||
|
24
gdb/testsuite/gdb.arch/amd64-i386-address.S
Normal file
24
gdb/testsuite/gdb.arch/amd64-i386-address.S
Normal file
@ -0,0 +1,24 @@
|
||||
/* Copyright 2009 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/>.
|
||||
|
||||
This file is part of the gdb testsuite. */
|
||||
|
||||
_start: .globl _start
|
||||
movl $0xdeadf00d, %eax
|
||||
pushl %eax
|
||||
movl %esp, %ebx
|
||||
int3
|
||||
nop
|
||||
nop
|
43
gdb/testsuite/gdb.arch/amd64-i386-address.exp
Normal file
43
gdb/testsuite/gdb.arch/amd64-i386-address.exp
Normal file
@ -0,0 +1,43 @@
|
||||
# Copyright 2009 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/>.
|
||||
|
||||
# This file is part of the gdb testsuite.
|
||||
|
||||
# Test UNsigned extension of the 32-bit inferior address on a 64-bit host.
|
||||
# On native 32-bit host the test always PASSed.
|
||||
|
||||
if {![istarget "x86_64-*-*"] && ![istarget "i?86-*-*"]} then {
|
||||
verbose "Skipping amd64->i386 adress test."
|
||||
return
|
||||
}
|
||||
|
||||
if [prepare_for_testing amd64-i386-address.exp amd64-i386-address amd64-i386-address.S [list debug "additional_flags=-m32 -nostdlib"]] {
|
||||
return -1
|
||||
}
|
||||
|
||||
gdb_run_cmd
|
||||
|
||||
set test "trap stop"
|
||||
gdb_test_multiple "" $test {
|
||||
-re "Program received signal SIGTRAP,.*_start .*$gdb_prompt $" {
|
||||
pass $test
|
||||
}
|
||||
}
|
||||
|
||||
gdb_test "x/wx \$esp" "0x\[0-9a-f\]*:\t0xdeadf00d"
|
||||
|
||||
# Failure case would be:
|
||||
# 0xff8d7f00: Cannot access memory at address 0xff8d7f00
|
||||
gdb_test "x/wx \$ebx" "0x\[0-9a-f\]*:\t0xdeadf00d"
|
Loading…
Reference in New Issue
Block a user