Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'strace/master' into HEAD
Browse files Browse the repository at this point in the history
Change-Id: I71324955ac973323aa790485c240e553272ff266
  • Loading branch information
enh-google committed Apr 7, 2015
2 parents c3d4308 + 79c5c5d commit afaea3d
Show file tree
Hide file tree
Showing 273 changed files with 2,886 additions and 4,999 deletions.
197 changes: 183 additions & 14 deletions Makefile.am

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion capability.c
Expand Up @@ -103,7 +103,7 @@ print_cap_data(struct tcb *tcp, unsigned long addr, const cap_user_header_t h)
else
len = 1;

if (umoven(tcp, addr, len * sizeof(data[0]), (char *) data) < 0) {
if (umoven(tcp, addr, len * sizeof(data[0]), data) < 0) {
tprintf("%#lx", addr);
return;
}
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Expand Up @@ -228,6 +228,7 @@ AC_CHECK_FUNCS(m4_normalize([
fputs_unlocked
if_indextoname
inet_ntop
pipe2
prctl
preadv
process_vm_readv
Expand Down
89 changes: 66 additions & 23 deletions defs.h
Expand Up @@ -67,8 +67,46 @@ const char *strerror(int);
extern char *stpcpy(char *dst, const char *src);
#endif

#if !defined __GNUC__
# define __attribute__(x) /*nothing*/
#if defined __GNUC__ && defined __GNUC_MINOR__
# define GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#else
# define __attribute__(x) /* empty */
# define GNUC_PREREQ(maj, min) 0
#endif

#if GNUC_PREREQ(2, 5)
# define ATTRIBUTE_NORETURN __attribute__((__noreturn__))
#else
# define ATTRIBUTE_NORETURN /* empty */
#endif

#if GNUC_PREREQ(2, 7)
# define ATTRIBUTE_FORMAT(args) __attribute__((__format__ args))
# define ATTRIBUTE_ALIGNED(arg) __attribute__((__aligned__(arg)))
# define ATTRIBUTE_PACKED __attribute__((__packed__))
#else
# define ATTRIBUTE_FORMAT(args) /* empty */
# define ATTRIBUTE_ALIGNED(arg) /* empty */
# define ATTRIBUTE_PACKED /* empty */
#endif

#if GNUC_PREREQ(3, 0)
# define ATTRIBUTE_MALLOC __attribute__((__malloc__))
#else
# define ATTRIBUTE_MALLOC /* empty */
#endif

#if GNUC_PREREQ(3, 1)
# define ATTRIBUTE_NOINLINE __attribute__((__noinline__))
#else
# define ATTRIBUTE_NOINLINE /* empty */
#endif

#if GNUC_PREREQ(4, 3)
# define ATTRIBUTE_ALLOC_SIZE(args) __attribute__((__alloc_size__ args))
#else
# define ATTRIBUTE_ALLOC_SIZE(args) /* empty */
#endif

#ifndef offsetof
Expand Down Expand Up @@ -152,14 +190,11 @@ extern char *stpcpy(char *dst, const char *src);

#if defined(SPARC) || defined(SPARC64)
# define PERSONALITY0_WORDSIZE 4
# define PERSONALITY1_WORDSIZE 4
# if defined(SPARC64)
# define SUPPORTED_PERSONALITIES 3
# define PERSONALITY2_WORDSIZE 8
# else
# define SUPPORTED_PERSONALITIES 2
# endif /* SPARC64 */
#endif /* SPARC[64] */
# define PERSONALITY1_WORDSIZE 8
# endif
#endif

#ifdef X86_64
# define SUPPORTED_PERSONALITIES 3
Expand Down Expand Up @@ -243,11 +278,10 @@ struct tcb {
FILE *outf; /* Output file for this process */
const char *auxstr; /* Auxiliary info from syscall (see RVAL_STR) */
const struct_sysent *s_ent; /* sysent[scno] or dummy struct for bad scno */
const struct_sysent *s_prev_ent; /* for "resuming interrupted SYSCALL" msg */
struct timeval stime; /* System time usage as of last process wait */
struct timeval dtime; /* Delta for system time usage */
struct timeval etime; /* Syscall entry time */
/* Support for tracing forked processes: */
long inst[2]; /* Saved clone args (badly named) */

#ifdef USE_LIBUNWIND
struct UPT_info* libunwind_ui;
Expand Down Expand Up @@ -392,11 +426,13 @@ extern unsigned os_release;

enum bitness_t { BITNESS_CURRENT = 0, BITNESS_32 };

void error_msg(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
void perror_msg(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
void error_msg_and_die(const char *fmt, ...) __attribute__ ((noreturn, format(printf, 1, 2)));
void perror_msg_and_die(const char *fmt, ...) __attribute__ ((noreturn, format(printf, 1, 2)));
void die_out_of_memory(void) __attribute__ ((noreturn));
void error_msg(const char *fmt, ...) ATTRIBUTE_FORMAT((printf, 1, 2));
void perror_msg(const char *fmt, ...) ATTRIBUTE_FORMAT((printf, 1, 2));
void error_msg_and_die(const char *fmt, ...)
ATTRIBUTE_FORMAT((printf, 1, 2)) ATTRIBUTE_NORETURN;
void perror_msg_and_die(const char *fmt, ...)
ATTRIBUTE_FORMAT((printf, 1, 2)) ATTRIBUTE_NORETURN;
void die_out_of_memory(void) ATTRIBUTE_NORETURN;

#if USE_CUSTOM_PRINTF
/*
Expand All @@ -418,14 +454,20 @@ extern void call_summary(FILE *);

extern void clear_regs(void);
extern void get_regs(pid_t pid);
extern int get_scno(struct tcb *tcp);

extern int umoven(struct tcb *, long, unsigned int, char *);
extern int umoven(struct tcb *, long, unsigned int, void *);
#define umove(pid, addr, objp) \
umoven((pid), (addr), sizeof(*(objp)), (char *) (objp))
umoven((pid), (addr), sizeof(*(objp)), (void *) (objp))
extern int umovestr(struct tcb *, long, unsigned int, char *);
extern int upeek(int pid, long, long *);
#if defined(SPARC) || defined(SPARC64) || defined(IA64) || defined(SH)

#if defined ALPHA || defined IA64 || defined MIPS \
|| defined SH || defined SPARC || defined SPARC64
# define HAVE_GETRVAL2
extern long getrval2(struct tcb *);
#else
# undef HAVE_GETRVAL2
#endif

extern const char *signame(const int);
Expand All @@ -436,6 +478,7 @@ extern int getfdpath(struct tcb *, int, char *, unsigned);
extern const char *xlookup(const struct xlat *, const unsigned int);
extern const char *xlat_search(const struct xlat *, const size_t, const unsigned int);

extern unsigned long get_pagesize(void);
extern int string_to_uint(const char *str);
extern int next_set_bit(const void *bit_array, unsigned cur_bit, unsigned size_bits);

Expand All @@ -456,7 +499,7 @@ extern int print_quoted_string(const char *, unsigned int, unsigned int);
#endif
extern int getllval(struct tcb *, unsigned long long *, int);
extern int printllval(struct tcb *, const char *, int)
__attribute__ ((format (printf, 2, 0)));
ATTRIBUTE_FORMAT((printf, 2, 0));

extern void printxval(const struct xlat *, const unsigned int, const char *);
extern int printargs(struct tcb *);
Expand All @@ -473,9 +516,9 @@ extern void dumpiov(struct tcb *, int, long);
extern void dumpstr(struct tcb *, long, int);
extern void printstr(struct tcb *, long, long);
extern void printnum_int(struct tcb *, long, const char *)
__attribute__ ((format (printf, 3, 0)));
ATTRIBUTE_FORMAT((printf, 3, 0));
extern void printnum_long(struct tcb *, long, const char *)
__attribute__ ((format (printf, 3, 0)));
ATTRIBUTE_FORMAT((printf, 3, 0));
extern void printpath(struct tcb *, long);
extern void printpathn(struct tcb *, long, unsigned int);
#define TIMESPEC_TEXT_BUFSIZE (sizeof(long)*3 * 2 + sizeof("{%u, %u}"))
Expand All @@ -488,7 +531,7 @@ extern void printtv_bitness(struct tcb *, long, enum bitness_t, int);
extern char *sprinttv(char *, struct tcb *, long, enum bitness_t, int special);
extern void print_timespec(struct tcb *, long);
extern void sprint_timespec(char *, struct tcb *, long);
extern void printsiginfo(const siginfo_t *, int);
extern void printsiginfo(const siginfo_t *, bool);
extern void printsiginfo_at(struct tcb *tcp, long addr);
extern void printfd(struct tcb *, int);
extern bool print_sockaddr_by_inode(const unsigned long, const char *);
Expand Down Expand Up @@ -567,7 +610,7 @@ extern struct tcb *printing_tcp;
extern void printleader(struct tcb *);
extern void line_ended(void);
extern void tabto(void);
extern void tprintf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
extern void tprintf(const char *fmt, ...) ATTRIBUTE_FORMAT((printf, 1, 2));
extern void tprints(const char *str);

#if SUPPORTED_PERSONALITIES > 1
Expand Down
6 changes: 3 additions & 3 deletions desc.c
Expand Up @@ -353,7 +353,7 @@ decode_select(struct tcb *tcp, long *args, enum bitness_t bitness)
tprintf(", %#lx", arg);
continue;
}
if (umoven(tcp, arg, fdsize, (char *) fds) < 0) {
if (umoven(tcp, arg, fdsize, fds) < 0) {
tprints(", [?]");
continue;
}
Expand Down Expand Up @@ -397,7 +397,7 @@ decode_select(struct tcb *tcp, long *args, enum bitness_t bitness)
int first = 1;

arg = args[i+1];
if (!arg || umoven(tcp, arg, fdsize, (char *) fds) < 0)
if (!arg || umoven(tcp, arg, fdsize, fds) < 0)
continue;
for (j = 0;; j++) {
j = next_set_bit(fds, j, nfds);
Expand Down Expand Up @@ -445,7 +445,7 @@ sys_oldselect(struct tcb *tcp)
{
long args[5];

if (umoven(tcp, tcp->u_arg[0], sizeof args, (char *) args) < 0) {
if (umoven(tcp, tcp->u_arg[0], sizeof args, args) < 0) {
tprints("[...]");
return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions evdev.c
Expand Up @@ -28,6 +28,8 @@

#include "defs.h"

#include <linux/ioctl.h>

#ifdef HAVE_LINUX_INPUT_H
#include <linux/input.h>
#include "xlat/evdev_abs.h"
Expand Down
3 changes: 1 addition & 2 deletions file.c
Expand Up @@ -305,7 +305,6 @@ sys_fstat(struct tcb *tcp)
* Linux x86_64 and x32 have unified `struct stat' but their i386 personality
* needs `struct stat64'.
* linux/arch/x86/include/uapi/asm/stat.h defines `struct stat64' only for i386.
* __GNUC__ is needed for the required __attribute__ below.
*
* Similarly, aarch64 has a unified `struct stat' but its arm personality
* needs `struct stat64' (unlike x86, it shouldn't be packed).
Expand All @@ -332,7 +331,7 @@ struct stat64 {
unsigned long long st_ino;
}
# if defined X86_64 || defined X32
__attribute__((packed))
ATTRIBUTE_PACKED
# define STAT64_SIZE 96
# else
# define STAT64_SIZE 104
Expand Down
2 changes: 1 addition & 1 deletion io.c
Expand Up @@ -112,7 +112,7 @@ tprint_iov_upto(struct tcb *tcp, unsigned long len, unsigned long addr, int deco
tprints("...");
break;
}
if (umoven(tcp, cur, sizeof_iov, (char *) &iov) < 0) {
if (umoven(tcp, cur, sizeof_iov, &iov) < 0) {
tprints("?");
failed = 1;
break;
Expand Down
2 changes: 1 addition & 1 deletion ioctl.c
Expand Up @@ -29,7 +29,7 @@
*/

#include "defs.h"
#include <asm/ioctl.h>
#include <linux/ioctl.h>
#include "xlat/ioctl_dirs.h"

#ifdef HAVE_LINUX_INPUT_H
Expand Down
2 changes: 1 addition & 1 deletion ioctlsort.c
Expand Up @@ -33,7 +33,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <asm/ioctl.h>
#include <linux/ioctl.h>

struct ioctlent {
const char *info;
Expand Down
3 changes: 1 addition & 2 deletions kexec.c
Expand Up @@ -58,8 +58,7 @@ print_kexec_segments(struct tcb *tcp, unsigned long addr, unsigned long len)
for (i = 0; i < len; ++i) {
if (i)
tprints(", ");
if (umoven(tcp, addr + i * sizeof_seg, sizeof_seg,
(char *) &seg) < 0) {
if (umoven(tcp, addr + i * sizeof_seg, sizeof_seg, &seg) < 0) {
tprints("?");
failed = 1;
break;
Expand Down
37 changes: 37 additions & 0 deletions linux/aarch64/arch_regs.c
@@ -0,0 +1,37 @@
struct arm_pt_regs {
int uregs[18];
};
#define ARM_cpsr uregs[16]
#define ARM_pc uregs[15]
#define ARM_lr uregs[14]
#define ARM_sp uregs[13]
#define ARM_ip uregs[12]
#define ARM_fp uregs[11]
#define ARM_r10 uregs[10]
#define ARM_r9 uregs[9]
#define ARM_r8 uregs[8]
#define ARM_r7 uregs[7]
#define ARM_r6 uregs[6]
#define ARM_r5 uregs[5]
#define ARM_r4 uregs[4]
#define ARM_r3 uregs[3]
#define ARM_r2 uregs[2]
#define ARM_r1 uregs[1]
#define ARM_r0 uregs[0]
#define ARM_ORIG_r0 uregs[17]

static union {
struct user_pt_regs aarch64_r;
struct arm_pt_regs arm_r;
} arm_regs_union;
#define aarch64_regs arm_regs_union.aarch64_r
#define arm_regs arm_regs_union.arm_r

uint64_t *const aarch64_sp_ptr = (uint64_t *) &aarch64_regs.sp;
uint32_t *const arm_sp_ptr = (uint32_t *) &arm_regs.ARM_sp;
static struct iovec aarch64_io = {
.iov_base = &arm_regs_union
};

#define ARCH_REGS_FOR_GETREGSET arm_regs_union
#define ARCH_IOVEC_FOR_GETREGSET aarch64_io
1 change: 1 addition & 0 deletions linux/aarch64/arch_sigreturn.c
@@ -0,0 +1 @@
#include "arm/arch_sigreturn.c"
10 changes: 10 additions & 0 deletions linux/aarch64/get_error.c
@@ -0,0 +1,10 @@
if (tcp->currpers == 1) {
if (check_errno && is_negated_errno(aarch64_regs.regs[0])) {
tcp->u_rval = -1;
tcp->u_error = -aarch64_regs.regs[0];
} else {
tcp->u_rval = aarch64_regs.regs[0];
}
} else {
#include "arm/get_error.c"
}
14 changes: 14 additions & 0 deletions linux/aarch64/get_scno.c
@@ -0,0 +1,14 @@
switch (aarch64_io.iov_len) {
case sizeof(aarch64_regs):
/* We are in 64-bit mode */
scno = aarch64_regs.regs[8];
update_personality(tcp, 1);
break;
case sizeof(arm_regs):
/* We are in 32-bit mode */
/* Note: we don't support OABI, unlike 32-bit ARM build */
scno = arm_regs.ARM_r7;
scno = shuffle_scno(scno);
update_personality(tcp, 0);
break;
}
10 changes: 10 additions & 0 deletions linux/aarch64/get_syscall_args.c
@@ -0,0 +1,10 @@
if (tcp->currpers == 1) {
tcp->u_arg[0] = aarch64_regs.regs[0];
tcp->u_arg[1] = aarch64_regs.regs[1];
tcp->u_arg[2] = aarch64_regs.regs[2];
tcp->u_arg[3] = aarch64_regs.regs[3];
tcp->u_arg[4] = aarch64_regs.regs[4];
tcp->u_arg[5] = aarch64_regs.regs[5];
} else {
#include "arm/get_syscall_args.c"
}
4 changes: 4 additions & 0 deletions linux/aarch64/print_pc.c
@@ -0,0 +1,4 @@
if (aarch64_io.iov_len == sizeof(arm_regs))
tprintf(fmt, (unsigned long) arm_regs.ARM_pc);
else
tprintf(fmt, (unsigned long) aarch64_regs.pc);
8 changes: 8 additions & 0 deletions linux/alpha/arch_getrval2.c
@@ -0,0 +1,8 @@
long
getrval2(struct tcb *tcp)
{
long r20;
if (upeek(tcp->pid, 20, &r20) < 0)
return -1;
return r20;
}
2 changes: 2 additions & 0 deletions linux/alpha/arch_regs.c
@@ -0,0 +1,2 @@
static long alpha_r0;
static long alpha_a3;
9 changes: 9 additions & 0 deletions linux/alpha/arch_sigreturn.c
@@ -0,0 +1,9 @@
long addr;

if (upeek(tcp->pid, REG_FP, &addr) < 0)
return 0;
addr += offsetof(struct sigcontext, sc_mask);

tprints("{mask=");
print_sigset_addr_len(tcp, addr, NSIG / 8);
tprints("}");
6 changes: 6 additions & 0 deletions linux/alpha/get_error.c
@@ -0,0 +1,6 @@
if (check_errno && alpha_a3) {
tcp->u_rval = -1;
tcp->u_error = alpha_r0;
} else {
tcp->u_rval = alpha_r0;
}

0 comments on commit afaea3d

Please sign in to comment.