From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11211 invoked by alias); 13 Jul 2009 20:20:49 -0000 Received: (qmail 11200 invoked by uid 22791); 13 Jul 2009 20:20:48 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 13 Jul 2009 20:20:37 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n6DKKVeZ007634; Mon, 13 Jul 2009 16:20:31 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n6DKKUob003938; Mon, 13 Jul 2009 16:20:30 -0400 Received: from host0.dyn.jankratochvil.net (sebastian-int.corp.redhat.com [172.16.52.221]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n6DKKRtA016928; Mon, 13 Jul 2009 16:20:28 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id n6DKKQ3C020765; Mon, 13 Jul 2009 22:20:26 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id n6DKKMSF020737; Mon, 13 Jul 2009 22:20:22 +0200 Date: Mon, 13 Jul 2009 20:32:00 -0000 From: Jan Kratochvil To: Ulrich Weigand Cc: Mark Kettenis , drow@false.org, Tom Tromey , gdb-patches@sourceware.org Subject: Re: [patch] Fix i386 memory-by-register access on amd64 Message-ID: <20090713202022.GA18371@host0.dyn.jankratochvil.net> References: <20090708144136.GA6490@host0.dyn.jankratochvil.net> <200907131708.n6DH896H016447@d12av02.megacenter.de.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200907131708.n6DH896H016447@d12av02.megacenter.de.ibm.com> User-Agent: Mutt/1.5.19 (2009-01-05) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-07/txt/msg00373.txt.bz2 On Mon, 13 Jul 2009 19:08:09 +0200, Ulrich Weigand wrote: > I've looked at a couple of ptrace implementations in the Linux kernel, and > it seems this fix should be correct on all bi-arch Linux platforms. Extended now the kernel ptrace testcase / tested besides x86_64 now also s390x and ppc64: http://sources.redhat.com/cgi-bin/cvsweb.cgi/~checkout~/tests/ptrace-tests/tests/highmem-debugger.c?cvsroot=systemtap http://sources.redhat.com/cgi-bin/cvsweb.cgi/~checkout~/tests/ptrace-tests/tests/highmem-debuggee.c?cvsroot=systemtap > > 2009-07-08 Jan Kratochvil > > > > Fix memory access from signed 32bit inferior registers on 64bit GDB. > > * inf-ptrace.c (inf_ptrace_xfer_partial ): New > > variable addr_bit. Mask OFFSET by the ADDR_BIT width. > > * linux-nat.c (linux_xfer_partial ): Likewise. > > > > 2009-07-08 Jan Kratochvil > > > > * gdb.arch/amd64-i386-address.exp, gdb.arch/amd64-i386-address.S: New. > > The linux-nat.c change and the test case are OK. Checked-in: http://sourceware.org/ml/gdb-cvs/2009-07/msg00102.html Thanks, Jan --- src/gdb/ChangeLog 2009/07/13 04:56:12 1.10713 +++ src/gdb/ChangeLog 2009/07/13 20:16:46 1.10714 @@ -1,3 +1,9 @@ +2009-07-13 Jan Kratochvil + + Fix memory access from signed 32bit inferior registers on 64bit GDB. + * linux-nat.c (linux_xfer_partial ): New variable + addr_bit. Mask OFFSET by the ADDR_BIT width. + 2009-07-13 Anthony Green * moxie-tdep.c (moxie_gdbarch_init): Call --- src/gdb/linux-nat.c 2009/07/02 21:57:27 1.144 +++ src/gdb/linux-nat.c 2009/07/13 20:16:47 1.145 @@ -4260,6 +4260,20 @@ 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) --- src/gdb/testsuite/ChangeLog 2009/07/13 19:24:17 1.1925 +++ src/gdb/testsuite/ChangeLog 2009/07/13 20:16:47 1.1926 @@ -1,5 +1,9 @@ 2009-07-13 Jan Kratochvil + * gdb.arch/amd64-i386-address.exp, gdb.arch/amd64-i386-address.S: New. + +2009-07-13 Jan Kratochvil + Fix gdb.base/macscp.exp when using custom inputrc. * gdb.base/completion.exp: Remove env(INPUTRC) set and restore. * gdb.base/readline.exp: Remove env(INPUTRC) set and restore. Remove --- src/gdb/testsuite/gdb.arch/amd64-i386-address.S +++ src/gdb/testsuite/gdb.arch/amd64-i386-address.S 2009-07-13 20:17:35.179465000 +0000 @@ -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 . + + This file is part of the gdb testsuite. */ + +_start: .globl _start + movl $0xdeadf00d, %eax + pushl %eax + movl %esp, %ebx + int3 + nop + nop --- src/gdb/testsuite/gdb.arch/amd64-i386-address.exp +++ src/gdb/testsuite/gdb.arch/amd64-i386-address.exp 2009-07-13 20:17:36.993238000 +0000 @@ -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 . + +# 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"