From patchwork Tue Jan 31 14:23:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 138788 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 48BDA1007D1 for ; Wed, 1 Feb 2012 01:23:43 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1328624625; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:From:To:Subject:Date:Message-ID:User-Agent: MIME-Version:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=WI850ElnFCQHwGof/zIdkcpKNlA=; b=WLfZDGu5KNQe+iN eKIp4eIxqAqbezCJj29YfV03MqT1uXsPogB6kx8PDWEABr8mTgySWVQf2diDyqmZ GwnwzW5YhOw0Zy3l/G1+WPAuvVdHsrWo5TCe5DS/7/GnIIiONbFcrYBtEp+nHq9Y qK/xpYc6j7iIMFoTkx10ppqrjrXQ= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=uTqvU3LruydapuyaDBmiJ0vQpiyLlyP091++oofZovWpIYoPTuwy/RVI+/v4RC yVgtG8yNekXywkXxlde1AFI0Ey7zKEdYmBeX//MCy9gsjBd1ZX4B9QH/BncbK9mT iy2G6OoqfMOahz0CfskrHxBEPJQ2vihQKUFlfRBQTpqug=; Received: (qmail 21905 invoked by alias); 31 Jan 2012 14:23:36 -0000 Received: (qmail 21880 invoked by uid 22791); 31 Jan 2012 14:23:34 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mail-pz0-f47.google.com (HELO mail-pz0-f47.google.com) (209.85.210.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 31 Jan 2012 14:23:21 +0000 Received: by dakj40 with SMTP id j40so220540dak.20 for ; Tue, 31 Jan 2012 06:23:20 -0800 (PST) Received: by 10.68.213.38 with SMTP id np6mr50281291pbc.37.1328019800371; Tue, 31 Jan 2012 06:23:20 -0800 (PST) Received: by 10.68.213.38 with SMTP id np6mr50281266pbc.37.1328019800241; Tue, 31 Jan 2012 06:23:20 -0800 (PST) Received: from coign.google.com ([66.109.103.62]) by mx.google.com with ESMTPS id p9sm55771770pbb.9.2012.01.31.06.23.17 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 31 Jan 2012 06:23:19 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: libgo patch committed: Don't use PtraceRegs if not defined Date: Tue, 31 Jan 2012 06:23:11 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org The libgo library only defines PtraceRegs on a few systems. However, it was using PtraceRegs on every GNU/Linux system. This patch fix this taking the easy way out, by moving a copy of the two small functions which use PtraceRegs into the processor-specific files which define PtraceRegs. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 8942226864dd libgo/go/syscall/libcall_linux.go --- a/libgo/go/syscall/libcall_linux.go Mon Jan 30 15:51:16 2012 -0800 +++ b/libgo/go/syscall/libcall_linux.go Tue Jan 31 06:20:56 2012 -0800 @@ -139,14 +139,6 @@ return ptracePoke(PTRACE_POKEDATA, PTRACE_PEEKDATA, pid, addr, data) } -func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) { - return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) -} - -func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) { - return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) -} - func PtraceSetOptions(pid int, options int) (err error) { return ptrace(PTRACE_SETOPTIONS, pid, 0, uintptr(options)) } diff -r 8942226864dd libgo/go/syscall/syscall_linux_386.go --- a/libgo/go/syscall/syscall_linux_386.go Mon Jan 30 15:51:16 2012 -0800 +++ b/libgo/go/syscall/syscall_linux_386.go Tue Jan 31 06:20:56 2012 -0800 @@ -6,10 +6,20 @@ package syscall +import "unsafe" + func (r *PtraceRegs) PC() uint64 { - return uint64(uint32(r.Eip)); + return uint64(uint32(r.Eip)) } func (r *PtraceRegs) SetPC(pc uint64) { - r.Eip = int32(pc); + r.Eip = int32(pc) } + +func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) { + return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) +} + +func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) { + return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) +} diff -r 8942226864dd libgo/go/syscall/syscall_linux_alpha.go --- a/libgo/go/syscall/syscall_linux_alpha.go Mon Jan 30 15:51:16 2012 -0800 +++ b/libgo/go/syscall/syscall_linux_alpha.go Tue Jan 31 06:20:56 2012 -0800 @@ -6,42 +6,52 @@ package syscall +import "unsafe" + type PtraceRegs struct { - R0 uint64 - R1 uint64 - R2 uint64 - R3 uint64 - R4 uint64 - R5 uint64 - R6 uint64 - R7 uint64 - R8 uint64 - R19 uint64 - R20 uint64 - R21 uint64 - R22 uint64 - R23 uint64 - R24 uint64 - R25 uint64 - R26 uint64 - R27 uint64 - R28 uint64 - Hae uint64 + R0 uint64 + R1 uint64 + R2 uint64 + R3 uint64 + R4 uint64 + R5 uint64 + R6 uint64 + R7 uint64 + R8 uint64 + R19 uint64 + R20 uint64 + R21 uint64 + R22 uint64 + R23 uint64 + R24 uint64 + R25 uint64 + R26 uint64 + R27 uint64 + R28 uint64 + Hae uint64 Trap_a0 uint64 Trap_a1 uint64 Trap_a2 uint64 - Ps uint64 - Pc uint64 - Gp uint64 - R16 uint64 - R17 uint64 - R18 uint64 + Ps uint64 + Pc uint64 + Gp uint64 + R16 uint64 + R17 uint64 + R18 uint64 } func (r *PtraceRegs) PC() uint64 { - return r.Pc; + return r.Pc } func (r *PtraceRegs) SetPC(pc uint64) { - r.Pc = pc; + r.Pc = pc } + +func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) { + return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) +} + +func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) { + return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) +} diff -r 8942226864dd libgo/go/syscall/syscall_linux_amd64.go --- a/libgo/go/syscall/syscall_linux_amd64.go Mon Jan 30 15:51:16 2012 -0800 +++ b/libgo/go/syscall/syscall_linux_amd64.go Tue Jan 31 06:20:56 2012 -0800 @@ -6,10 +6,20 @@ package syscall +import "unsafe" + func (r *PtraceRegs) PC() uint64 { - return r.Rip; + return r.Rip } func (r *PtraceRegs) SetPC(pc uint64) { - r.Rip = pc; + r.Rip = pc } + +func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) { + return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) +} + +func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) { + return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) +}