1999-02-19 03:21:36 +03:00
/*
* Copyright ( c ) 1991 , 1992 Paul Kranenburg < pk @ cs . few . eur . nl >
* Copyright ( c ) 1993 Branko Lankester < branko @ hacktic . nl >
* Copyright ( c ) 1993 , 1994 , 1995 , 1996 Rick Sladkey < jrs @ world . std . com >
1999-12-23 17:20:14 +03:00
* Copyright ( c ) 1996 - 1999 Wichert Akkerman < wichert @ cistron . nl >
* Copyright ( c ) 1999 IBM Deutschland Entwicklung GmbH , IBM Corporation
* Linux for s390 port by D . J . Barrow
* < barrow_dj @ mail . yahoo . com , djbarrow @ de . ibm . com >
2002-05-01 20:39:22 +04:00
* Copyright ( c ) 2000 PocketPenguins Inc . Linux for Hitachi SuperH
* port by Greg Banks < gbanks @ pocketpenguins . com >
1999-12-23 17:20:14 +03:00
*
1999-02-19 03:21:36 +03:00
* All rights reserved .
*
* 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 , this list of conditions and the following disclaimer .
* 2. Redistributions in binary form must reproduce the above copyright
* notice , this list of conditions and the following disclaimer in the
* documentation and / or other materials provided with the distribution .
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission .
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ` ` 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 AUTHOR 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 "defs.h"
2014-12-11 22:25:02 +03:00
2013-03-18 04:52:29 +04:00
# ifdef HAVE_ELF_H
# include <elf.h>
# endif
1999-02-19 03:21:36 +03:00
2014-12-11 22:25:02 +03:00
# include "xlat/nt_descriptor_types.h"
2015-02-13 03:26:38 +03:00
# include "ptrace.h"
2014-12-11 22:25:02 +03:00
# include "xlat/ptrace_cmds.h"
# include "xlat/ptrace_setoptions_flags.h"
2015-02-13 05:12:14 +03:00
# include "regs.h"
2000-02-04 00:58:30 +03:00
2012-03-21 17:39:22 +04:00
# define uoff(member) offsetof(struct user, member)
2014-12-11 22:25:02 +03:00
# define XLAT_UOFF(member) { uoff(member), "offsetof(struct user, " #member ")" }
2012-03-21 17:39:22 +04:00
2014-12-11 22:25:02 +03:00
static const struct xlat struct_user_offsets [ ] = {
process.c: split struct_user_offsets into architecture-specific include files
* Makefile.am (EXTRA_DIST): Add linux/alpha/userent.h,
linux/arm/userent.h, linux/avr32/userent.h, linux/bfin/userent.h,
linux/crisv10/userent.h, linux/crisv32/userent.h,
linux/i386/userent.h, linux/i386/userent0.h, linux/ia64/userent.h,
linux/m68k/userent.h, linux/microblaze/userent.h,
linux/mips/userent.h, linux/or1k/userent.h, linux/powerpc/userent.h,
linux/s390/userent.h, linux/s390/userent0.h, linux/s390/userent1.h,
linux/s390x/userent.h, linux/sh/userent.h, linux/sh/userent0.h,
linux/sh64/userent.h, linux/sparc/userent.h, linux/sparc64/userent.h,
linux/tile/userent.h, linux/userent.h, linux/userent0.h,
linux/x32/userent.h, linux/x86_64/userent.h, and
linux/xtensa/userent.h.
* process.c (struct_user_offsets): Split into architecture-specific
include files, inculde userent.h.
2014-12-11 22:25:02 +03:00
# include "userent.h"
2014-02-05 06:20:51 +04:00
XLAT_END
1999-02-19 03:21:36 +03:00
} ;
int
2009-02-24 15:59:47 +03:00
sys_ptrace ( struct tcb * tcp )
1999-02-19 03:21:36 +03:00
{
2004-09-04 07:39:20 +04:00
const struct xlat * x ;
2014-09-10 17:46:04 +04:00
unsigned long addr ;
1999-02-19 03:21:36 +03:00
2003-01-14 12:46:21 +03:00
if ( entering ( tcp ) ) {
2012-03-20 19:48:35 +04:00
printxval ( ptrace_cmds , tcp - > u_arg [ 0 ] , " PTRACE_??? " ) ;
2003-01-14 12:46:21 +03:00
tprintf ( " , %lu, " , tcp - > u_arg [ 1 ] ) ;
2013-02-13 19:10:10 +04:00
1999-02-19 03:21:36 +03:00
addr = tcp - > u_arg [ 2 ] ;
if ( tcp - > u_arg [ 0 ] = = PTRACE_PEEKUSER
2013-02-13 19:10:10 +04:00
| | tcp - > u_arg [ 0 ] = = PTRACE_POKEUSER
) {
1999-02-19 03:21:36 +03:00
for ( x = struct_user_offsets ; x - > str ; x + + ) {
if ( x - > val > = addr )
break ;
}
if ( ! x - > str )
tprintf ( " %#lx, " , addr ) ;
else if ( x - > val > addr & & x ! = struct_user_offsets ) {
x - - ;
tprintf ( " %s + %ld, " , x - > str , addr - x - > val ) ;
}
else
tprintf ( " %s, " , x - > str ) ;
2013-02-13 19:10:10 +04:00
} else
2013-03-18 04:52:29 +04:00
if ( tcp - > u_arg [ 0 ] = = PTRACE_GETREGSET
| | tcp - > u_arg [ 0 ] = = PTRACE_SETREGSET
) {
printxval ( nt_descriptor_types , tcp - > u_arg [ 2 ] , " NT_??? " ) ;
tprints ( " , " ) ;
} else
2013-02-13 19:10:10 +04:00
tprintf ( " %#lx, " , addr ) ;
1999-02-19 03:21:36 +03:00
switch ( tcp - > u_arg [ 0 ] ) {
2012-03-17 04:27:37 +04:00
# ifndef IA64
1999-02-19 03:21:36 +03:00
case PTRACE_PEEKDATA :
case PTRACE_PEEKTEXT :
case PTRACE_PEEKUSER :
break ;
2012-03-17 04:27:37 +04:00
# endif
1999-02-19 03:21:36 +03:00
case PTRACE_CONT :
case PTRACE_SINGLESTEP :
case PTRACE_SYSCALL :
case PTRACE_DETACH :
printsignal ( tcp - > u_arg [ 3 ] ) ;
break ;
2009-01-13 21:30:55 +03:00
case PTRACE_SETOPTIONS :
printflags ( ptrace_setoptions_flags , tcp - > u_arg [ 3 ] , " PTRACE_O_??? " ) ;
break ;
case PTRACE_SETSIGINFO : {
2013-02-13 19:31:32 +04:00
printsiginfo_at ( tcp , tcp - > u_arg [ 3 ] ) ;
2009-01-13 21:30:55 +03:00
break ;
}
2013-02-13 19:10:10 +04:00
case PTRACE_SETREGSET :
tprint_iov ( tcp , /*len:*/ 1 , tcp - > u_arg [ 3 ] , /*as string:*/ 0 ) ;
break ;
2015-02-13 03:26:38 +03:00
case PTRACE_GETSIGINFO :
case PTRACE_GETREGSET :
/* Don't print anything, do it at syscall return. */
break ;
1999-02-19 03:21:36 +03:00
default :
tprintf ( " %#lx " , tcp - > u_arg [ 3 ] ) ;
break ;
}
} else {
switch ( tcp - > u_arg [ 0 ] ) {
case PTRACE_PEEKDATA :
case PTRACE_PEEKTEXT :
case PTRACE_PEEKUSER :
2012-03-17 04:27:37 +04:00
# ifdef IA64
2007-11-20 01:11:45 +03:00
return RVAL_HEX ;
2012-03-17 04:27:37 +04:00
# else
2003-01-14 12:59:00 +03:00
printnum ( tcp , tcp - > u_arg [ 3 ] , " %#lx " ) ;
1999-02-19 03:21:36 +03:00
break ;
2012-03-17 04:27:37 +04:00
# endif
2009-01-13 21:30:55 +03:00
case PTRACE_GETSIGINFO : {
2013-02-13 19:31:32 +04:00
printsiginfo_at ( tcp , tcp - > u_arg [ 3 ] ) ;
2009-01-13 21:30:55 +03:00
break ;
}
2013-02-13 19:10:10 +04:00
case PTRACE_GETREGSET :
tprint_iov ( tcp , /*len:*/ 1 , tcp - > u_arg [ 3 ] , /*as string:*/ 0 ) ;
break ;
1999-02-19 03:21:36 +03:00
}
}
return 0 ;
}