Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Aug 2016 18:47:51 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r305012 - in head/lib/libc: amd64/sys arm/sys i386/sys include mips/sys powerpc/sys powerpc64/sys sparc64/sys sys
Message-ID:  <201608291847.u7TIlpkS056969@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Mon Aug 29 18:47:51 2016
New Revision: 305012
URL: https://svnweb.freebsd.org/changeset/base/305012

Log:
  Rewrite ptrace(2) wrappers in C.
  Besides removing hand-translation to assembler, this also adds missing
  wrappers for arm64 and risc-v.
  
  Reviewed by:	emaste, jhb
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week
  Differential revision:	https://reviews.freebsd.org/D7694

Added:
  head/lib/libc/sys/ptrace.c   (contents, props changed)
Deleted:
  head/lib/libc/amd64/sys/ptrace.S
  head/lib/libc/arm/sys/ptrace.S
  head/lib/libc/i386/sys/ptrace.S
  head/lib/libc/mips/sys/ptrace.S
  head/lib/libc/powerpc/sys/ptrace.S
  head/lib/libc/powerpc64/sys/ptrace.S
  head/lib/libc/sparc64/sys/ptrace.S
Modified:
  head/lib/libc/amd64/sys/Makefile.inc
  head/lib/libc/arm/sys/Makefile.inc
  head/lib/libc/i386/sys/Makefile.inc
  head/lib/libc/include/libc_private.h
  head/lib/libc/mips/sys/Makefile.inc
  head/lib/libc/powerpc/sys/Makefile.inc
  head/lib/libc/powerpc64/sys/Makefile.inc
  head/lib/libc/sparc64/sys/Makefile.inc
  head/lib/libc/sys/Makefile.inc

Modified: head/lib/libc/amd64/sys/Makefile.inc
==============================================================================
--- head/lib/libc/amd64/sys/Makefile.inc	Mon Aug 29 18:46:04 2016	(r305011)
+++ head/lib/libc/amd64/sys/Makefile.inc	Mon Aug 29 18:47:51 2016	(r305012)
@@ -4,7 +4,7 @@
 SRCS+=	amd64_get_fsbase.c amd64_get_gsbase.c amd64_set_fsbase.c \
 	amd64_set_gsbase.c
 
-MDASM=	vfork.S brk.S cerror.S exect.S getcontext.S ptrace.S \
+MDASM=	vfork.S brk.S cerror.S exect.S getcontext.S \
 	sbrk.S setlogin.S sigreturn.S
 
 # Don't generate default code for these syscalls:

Modified: head/lib/libc/arm/sys/Makefile.inc
==============================================================================
--- head/lib/libc/arm/sys/Makefile.inc	Mon Aug 29 18:46:04 2016	(r305011)
+++ head/lib/libc/arm/sys/Makefile.inc	Mon Aug 29 18:47:51 2016	(r305012)
@@ -2,7 +2,7 @@
 
 SRCS+=	__vdso_gettc.c
 
-MDASM= Ovfork.S brk.S cerror.S ptrace.S sbrk.S shmat.S sigreturn.S syscall.S
+MDASM= Ovfork.S brk.S cerror.S sbrk.S shmat.S sigreturn.S syscall.S
 
 # Don't generate default code for these syscalls:
 NOASM=	break.o exit.o getlogin.o sstk.o vfork.o yield.o

Modified: head/lib/libc/i386/sys/Makefile.inc
==============================================================================
--- head/lib/libc/i386/sys/Makefile.inc	Mon Aug 29 18:46:04 2016	(r305011)
+++ head/lib/libc/i386/sys/Makefile.inc	Mon Aug 29 18:47:51 2016	(r305012)
@@ -7,7 +7,7 @@ SRCS+=	i386_clr_watch.c i386_set_watch.c
 SRCS+=	i386_get_fsbase.c i386_get_gsbase.c i386_get_ioperm.c i386_get_ldt.c \
 	i386_set_fsbase.c i386_set_gsbase.c i386_set_ioperm.c i386_set_ldt.c
 
-MDASM=	Ovfork.S brk.S cerror.S exect.S getcontext.S ptrace.S \
+MDASM=	Ovfork.S brk.S cerror.S exect.S getcontext.S \
 	sbrk.S setlogin.S sigreturn.S syscall.S
 
 # Don't generate default code for these syscalls:

Modified: head/lib/libc/include/libc_private.h
==============================================================================
--- head/lib/libc/include/libc_private.h	Mon Aug 29 18:46:04 2016	(r305011)
+++ head/lib/libc/include/libc_private.h	Mon Aug 29 18:47:51 2016	(r305012)
@@ -335,6 +335,7 @@ int		__sys_openat(int, const char *, int
 int		__sys_pselect(int, struct fd_set *, struct fd_set *,
 		    struct fd_set *, const struct timespec *,
 		    const __sigset_t *);
+int		__sys_ptrace(int, __pid_t, char *, int);
 int		__sys_poll(struct pollfd *, unsigned, int);
 int		__sys_ppoll(struct pollfd *, unsigned, const struct timespec *,
 		    const __sigset_t *);

Modified: head/lib/libc/mips/sys/Makefile.inc
==============================================================================
--- head/lib/libc/mips/sys/Makefile.inc	Mon Aug 29 18:46:04 2016	(r305011)
+++ head/lib/libc/mips/sys/Makefile.inc	Mon Aug 29 18:47:51 2016	(r305012)
@@ -3,7 +3,7 @@
 SRCS+=	trivial-vdso_tc.c
 
 MDASM=  Ovfork.S brk.S cerror.S exect.S \
-	ptrace.S sbrk.S syscall.S
+	sbrk.S syscall.S
 
 # Don't generate default code for these syscalls:
 NOASM=	break.o exit.o getlogin.o sstk.o vfork.o yield.o

Modified: head/lib/libc/powerpc/sys/Makefile.inc
==============================================================================
--- head/lib/libc/powerpc/sys/Makefile.inc	Mon Aug 29 18:46:04 2016	(r305011)
+++ head/lib/libc/powerpc/sys/Makefile.inc	Mon Aug 29 18:47:51 2016	(r305012)
@@ -1,6 +1,6 @@
 # $FreeBSD$
 
-MDASM+=	brk.S cerror.S exect.S ptrace.S sbrk.S setlogin.S
+MDASM+=	brk.S cerror.S exect.S sbrk.S setlogin.S
 
 # Don't generate default code for these syscalls:
 NOASM=	break.o exit.o getlogin.o sstk.o yield.o

Modified: head/lib/libc/powerpc64/sys/Makefile.inc
==============================================================================
--- head/lib/libc/powerpc64/sys/Makefile.inc	Mon Aug 29 18:46:04 2016	(r305011)
+++ head/lib/libc/powerpc64/sys/Makefile.inc	Mon Aug 29 18:47:51 2016	(r305012)
@@ -1,6 +1,6 @@
 # $FreeBSD$
 
-MDASM+=	brk.S cerror.S exect.S ptrace.S sbrk.S setlogin.S
+MDASM+=	brk.S cerror.S exect.S sbrk.S setlogin.S
 
 # Don't generate default code for these syscalls:
 NOASM=	break.o exit.o getlogin.o sstk.o yield.o

Modified: head/lib/libc/sparc64/sys/Makefile.inc
==============================================================================
--- head/lib/libc/sparc64/sys/Makefile.inc	Mon Aug 29 18:46:04 2016	(r305011)
+++ head/lib/libc/sparc64/sys/Makefile.inc	Mon Aug 29 18:47:51 2016	(r305012)
@@ -12,7 +12,7 @@ SRCS+=	__sparc_sigtramp_setup.c \
 
 CFLAGS+= -I${LIBC_SRCTOP}/sparc64/fpu
 
-MDASM+=	brk.S cerror.S exect.S ptrace.S sbrk.S setlogin.S sigaction1.S
+MDASM+=	brk.S cerror.S exect.S sbrk.S setlogin.S sigaction1.S
 
 # Don't generate default code for these syscalls:
 NOASM=	break.o exit.o getlogin.o sstk.o yield.o

Modified: head/lib/libc/sys/Makefile.inc
==============================================================================
--- head/lib/libc/sys/Makefile.inc	Mon Aug 29 18:46:04 2016	(r305011)
+++ head/lib/libc/sys/Makefile.inc	Mon Aug 29 18:47:51 2016	(r305012)
@@ -48,6 +48,7 @@ INTERPOSED = \
 	poll \
 	ppoll \
 	pselect \
+	ptrace \
 	read \
 	readv \
 	recvfrom \

Added: head/lib/libc/sys/ptrace.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lib/libc/sys/ptrace.c	Mon Aug 29 18:47:51 2016	(r305012)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2016 The FreeBSD Foundation.
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice(s), this list of conditions and the following disclaimer as
+ *    the first lines of this file unmodified other than the possible
+ *    addition of one or more copyright notices.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice(s), this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/ptrace.h>
+#include <errno.h>
+#include "libc_private.h"
+
+__weak_reference(_ptrace, ptrace);
+
+int
+_ptrace(int request, pid_t pid, caddr_t addr, int data)
+{
+
+	errno = 0;
+	return (__sys_ptrace(request, pid, addr, data));
+}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201608291847.u7TIlpkS056969>