2014-12-11 22:25:02 +03:00
# include "defs.h"
static void
printargv ( struct tcb * tcp , long addr )
{
union {
unsigned int p32 ;
unsigned long p64 ;
char data [ sizeof ( long ) ] ;
} cp ;
const char * sep ;
unsigned int n = 0 ;
2015-07-20 18:17:24 +03:00
const unsigned wordsize = current_wordsize ;
2014-12-11 22:25:02 +03:00
cp . p64 = 1 ;
for ( sep = " " ; ! abbrev ( tcp ) | | n < max_strlen / 2 ; sep = " , " , + + n ) {
2015-07-20 18:17:24 +03:00
if ( umoven_or_printaddr ( tcp , addr , wordsize , cp . data ) )
2014-12-11 22:25:02 +03:00
return ;
if ( wordsize = = 4 )
cp . p64 = cp . p32 ;
if ( cp . p64 = = 0 )
break ;
tprints ( sep ) ;
printstr ( tcp , cp . p64 , - 1 ) ;
addr + = wordsize ;
}
if ( cp . p64 )
tprintf ( " %s... " , sep ) ;
}
static void
printargc ( const char * fmt , struct tcb * tcp , long addr )
{
int count ;
2015-07-27 13:02:33 +03:00
char * cp = NULL ;
2014-12-11 22:25:02 +03:00
2015-07-27 13:02:33 +03:00
for ( count = 0 ; ! umoven ( tcp , addr , current_wordsize , & cp ) & & cp ; count + + ) {
addr + = current_wordsize ;
2014-12-11 22:25:02 +03:00
}
tprintf ( fmt , count , count = = 1 ? " " : " s " ) ;
}
2015-07-26 14:06:53 +03:00
static void
decode_execve ( struct tcb * tcp , const unsigned int index )
2014-12-11 22:25:02 +03:00
{
2015-07-26 14:06:53 +03:00
printpath ( tcp , tcp - > u_arg [ index + 0 ] ) ;
2015-07-20 18:20:46 +03:00
tprints ( " , " ) ;
2015-07-20 18:17:24 +03:00
2015-07-26 14:06:53 +03:00
if ( ! tcp - > u_arg [ index + 1 ] | | ! verbose ( tcp ) )
printaddr ( tcp - > u_arg [ index + 1 ] ) ;
2015-07-20 18:20:46 +03:00
else {
tprints ( " [ " ) ;
2015-07-26 14:06:53 +03:00
printargv ( tcp , tcp - > u_arg [ index + 1 ] ) ;
2015-07-20 18:20:46 +03:00
tprints ( " ] " ) ;
}
tprints ( " , " ) ;
2015-07-20 18:17:24 +03:00
2015-07-26 14:06:53 +03:00
if ( ! tcp - > u_arg [ index + 2 ] | | ! verbose ( tcp ) )
printaddr ( tcp - > u_arg [ index + 2 ] ) ;
2015-07-20 18:20:46 +03:00
else if ( abbrev ( tcp ) )
2015-07-26 14:06:53 +03:00
printargc ( " [/* %d var%s */] " , tcp , tcp - > u_arg [ index + 2 ] ) ;
2015-07-20 18:20:46 +03:00
else {
tprints ( " [ " ) ;
2015-07-26 14:06:53 +03:00
printargv ( tcp , tcp - > u_arg [ index + 2 ] ) ;
2015-07-20 18:20:46 +03:00
tprints ( " ] " ) ;
2014-12-11 22:25:02 +03:00
}
2015-07-26 14:06:53 +03:00
}
SYS_FUNC ( execve )
{
decode_execve ( tcp , 0 ) ;
return RVAL_DECODED ;
}
SYS_FUNC ( execveat )
{
print_dirfd ( tcp , tcp - > u_arg [ 0 ] ) ;
decode_execve ( tcp , 1 ) ;
tprints ( " , " ) ;
printflags ( at_flags , tcp - > u_arg [ 4 ] , " AT_??? " ) ;
2015-07-20 18:20:46 +03:00
return RVAL_DECODED ;
2014-12-11 22:25:02 +03:00
}
# if defined(SPARC) || defined(SPARC64)
2015-04-07 04:36:50 +03:00
SYS_FUNC ( execv )
2014-12-11 22:25:02 +03:00
{
2015-07-20 18:20:46 +03:00
printpath ( tcp , tcp - > u_arg [ 0 ] ) ;
tprints ( " , " ) ;
if ( ! tcp - > u_arg [ 1 ] | | ! verbose ( tcp ) )
printaddr ( tcp - > u_arg [ 1 ] ) ;
else {
tprints ( " [ " ) ;
printargv ( tcp , tcp - > u_arg [ 1 ] ) ;
tprints ( " ] " ) ;
2014-12-11 22:25:02 +03:00
}
2015-07-20 18:20:46 +03:00
return RVAL_DECODED ;
2014-12-11 22:25:02 +03:00
}
# endif /* SPARC || SPARC64 */