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-28 15:20:21 +03:00
# include "regs.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"
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
} ;
2015-04-07 04:36:50 +03:00
SYS_FUNC ( ptrace )
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 )
2015-07-18 00:12:05 +03:00
printaddr ( addr ) ;
1999-02-19 03:21:36 +03:00
else if ( x - > val > addr & & x ! = struct_user_offsets ) {
x - - ;
2015-07-18 00:12:05 +03:00
tprintf ( " %s + %ld " , x - > str , addr - x - > val ) ;
1999-02-19 03:21:36 +03:00
}
else
2015-07-18 00:12:05 +03:00
tprints ( 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
2015-07-18 00:12:05 +03:00
| | tcp - > u_arg [ 0 ] = = PTRACE_SETREGSET )
2013-03-18 04:52:29 +04:00
printxval ( nt_descriptor_types , tcp - > u_arg [ 2 ] , " NT_??? " ) ;
2015-07-18 00:12:05 +03:00
else
printaddr ( addr ) ;
tprints ( " , " ) ;
2013-02-13 19:10:10 +04:00
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 : {
2015-09-16 00:51:15 +03: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 :
2015-07-18 00:12:05 +03:00
printaddr ( tcp - > u_arg [ 3 ] ) ;
1999-02-19 03:21:36 +03:00
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
Fix printing tracee's long integers
Replace ambiguous printnum_long that used to fetch native long integers
from tracee's memory with printnum_ptr, printnum_slong, and printnum_ulong
that fetch tracee's pointer, signed long, and unsigned long integers.
* defs.h (printnum_long, printpair_long): Remove prototypes.
(printnum_int64, printpair_int64): Remove macros, declare functions
unconditionally.
[SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4] (printnum_long_int):
New prototype.
(printnum_ptr, printnum_slong, printnum_ulong): New macros.
* aio.c (sys_io_setup): Use printnum_ulong.
* block.c (block_ioctl): Use printnum_slong and printnum_ulong.
* get_robust_list.c (sys_get_robust_list): Use printnum_ptr
and printnum_ulong.
* io.c (print_off_t): Remove.
(sys_sendfile): Use printnum_ulong.
* ipc.c (sys_semctl): Use printnum_ptr.
* prctl.c (sys_prctl): Likewise.
* process.c (sys_ptrace): Likewise.
* rtc.c (rtc_ioctl): Use printnum_ulong.
* util.c (printnum_long, printpair_long): Remove.
(printnum_int64, printpair_int64): Define unconditionally.
[SUPPORTED_PERSONALITIES > 1 && SIZEOF_LONG > 4] (printnum_long_int):
New function.
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Elvira Khabirova <lineprinter0@gmail.com>
2015-08-18 17:58:27 +03:00
printnum_ptr ( tcp , tcp - > u_arg [ 3 ] ) ;
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 : {
2015-09-16 00:51:15 +03: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 ;
}