summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--count.c2
-rw-r--r--defs.h13
-rw-r--r--desc.c6
-rw-r--r--file.c2
-rw-r--r--io.c9
-rw-r--r--process.c2
-rw-r--r--resource.c2
-rw-r--r--signal.c5
-rw-r--r--syscall.c42
-rw-r--r--time.c10
-rw-r--r--util.c17
11 files changed, 53 insertions, 57 deletions
diff --git a/count.c b/count.c
index 2977353..d05ec60 100644
--- a/count.c
+++ b/count.c
@@ -220,7 +220,7 @@ call_summary(FILE *outf)
if (i)
fprintf(outf,
"System call usage summary for %u bit mode:\n",
- personality_wordsize[current_personality] * 8);
+ current_wordsize * 8);
call_summary_pers(outf);
}
diff --git a/defs.h b/defs.h
index 8750322..d327128 100644
--- a/defs.h
+++ b/defs.h
@@ -228,6 +228,10 @@ extern long ptrace(int, int, char *, long);
# define PERSONALITY1_WORDSIZE 4
#endif
+#ifndef PERSONALITY0_WORDSIZE
+# define PERSONALITY0_WORDSIZE sizeof(long)
+#endif
+
#if !HAVE_DECL_PTRACE_SETOPTIONS
# define PTRACE_SETOPTIONS 0x4200
#endif
@@ -450,7 +454,6 @@ void error_msg_and_die(const char *fmt, ...) __attribute__ ((noreturn, format(pr
void perror_msg_and_die(const char *fmt, ...) __attribute__ ((noreturn, format(printf, 1, 2)));
void die_out_of_memory(void) __attribute__ ((noreturn));
-extern void set_personality(int personality);
extern const char *xlookup(const struct xlat *, int);
extern void set_sortby(const char *);
@@ -570,8 +573,16 @@ extern void tprints(const char *str);
#define printtv_special(tcp, addr) \
printtv_bitness((tcp), (addr), BITNESS_CURRENT, 1)
+#if SUPPORTED_PERSONALITIES > 1
+extern void set_personality(int personality);
extern int current_personality;
extern const int personality_wordsize[];
+# define current_wordsize (personality_wordsize[current_personality])
+#else
+# define set_personality(personality) ((void)0)
+# define current_personality 0
+# define current_wordsize PERSONALITY0_WORDSIZE
+#endif
struct sysent {
unsigned nargs;
diff --git a/desc.c b/desc.c
index be4d2a9..884f143 100644
--- a/desc.c
+++ b/desc.c
@@ -230,8 +230,8 @@ printflock(struct tcb *tcp, long addr, int getlk)
struct flock fl;
#if SUPPORTED_PERSONALITIES > 1
- if (personality_wordsize[current_personality] != sizeof(fl.l_start)) {
- if (personality_wordsize[current_personality] == 4) {
+ if (current_wordsize != sizeof(fl.l_start)) {
+ if (current_wordsize == 4) {
/* 32-bit x86 app on x86_64 and similar cases */
struct {
short int l_type;
@@ -252,7 +252,7 @@ printflock(struct tcb *tcp, long addr, int getlk)
} else {
/* let people know we have a problem here */
tprintf("{ <decode error: unsupported wordsize %d> }",
- personality_wordsize[current_personality]);
+ current_wordsize);
return;
}
} else
diff --git a/file.c b/file.c
index 32d2122..1a448cd 100644
--- a/file.c
+++ b/file.c
@@ -2059,7 +2059,7 @@ sys_utime(struct tcb *tcp)
long utl[2];
int uti[2];
} u;
- unsigned wordsize = personality_wordsize[current_personality];
+ unsigned wordsize = current_wordsize;
if (entering(tcp)) {
printpath(tcp, tcp->u_arg[0]);
diff --git a/io.c b/io.c
index b483c49..a7f6c29 100644
--- a/io.c
+++ b/io.c
@@ -72,14 +72,11 @@ tprint_iov(struct tcb *tcp, unsigned long len, unsigned long addr, int decode_io
struct { u_int64_t base; u_int64_t len; } iov64;
} iov;
#define sizeof_iov \
- (personality_wordsize[current_personality] == 4 \
- ? sizeof(iov.iov32) : sizeof(iov.iov64))
+ (current_wordsize == 4 ? sizeof(iov.iov32) : sizeof(iov.iov64))
#define iov_iov_base \
- (personality_wordsize[current_personality] == 4 \
- ? (u_int64_t) iov.iov32.base : iov.iov64.base)
+ (current_wordsize == 4 ? (uint64_t) iov.iov32.base : iov.iov64.base)
#define iov_iov_len \
- (personality_wordsize[current_personality] == 4 \
- ? (u_int64_t) iov.iov32.len : iov.iov64.len)
+ (current_wordsize == 4 ? (uint64_t) iov.iov32.len : iov.iov64.len)
#else
struct iovec iov;
#define sizeof_iov sizeof(iov)
diff --git a/process.c b/process.c
index 2239d4a..7035c2e 100644
--- a/process.c
+++ b/process.c
@@ -858,7 +858,7 @@ printargv(struct tcb *tcp, long addr)
} cp;
const char *sep;
int n = 0;
- unsigned wordsize = personality_wordsize[current_personality];
+ unsigned wordsize = current_wordsize;
cp.p64 = 1;
for (sep = ""; !abbrev(tcp) || n < max_strlen / 2; sep = ", ", ++n) {
diff --git a/resource.c b/resource.c
index 77a94a2..d7a34ef 100644
--- a/resource.c
+++ b/resource.c
@@ -180,7 +180,7 @@ decode_rlimit(struct tcb *tcp, unsigned long addr)
# if SIZEOF_RLIM_T == 4
print_rlimit32(tcp, addr);
# else
- if (personality_wordsize[current_personality] == 4)
+ if (current_wordsize == 4)
print_rlimit32(tcp, addr);
else
print_rlimit64(tcp, addr);
diff --git a/signal.c b/signal.c
index 11b133d..ab7ae56 100644
--- a/signal.c
+++ b/signal.c
@@ -1226,7 +1226,7 @@ sys_kill(struct tcb *tcp)
long pid = tcp->u_arg[0];
#if SUPPORTED_PERSONALITIES > 1
/* Sign-extend a 32-bit value when that's what it is. */
- if (personality_wordsize[current_personality] < sizeof pid)
+ if (current_wordsize < sizeof pid)
pid = (long) (int) pid;
#endif
tprintf("%ld, %s", pid, signame(tcp->u_arg[1]));
@@ -1335,8 +1335,7 @@ sys_rt_sigaction(struct tcb *tcp)
}
#if SUPPORTED_PERSONALITIES > 1
#if SIZEOF_LONG > 4
- if (personality_wordsize[current_personality] != sizeof(sa.sa_flags)
- && personality_wordsize[current_personality] == 4) {
+ if (current_wordsize != sizeof(sa.sa_flags) && current_wordsize == 4) {
struct new_sigaction32 sa32;
r = umove(tcp, addr, &sa32);
if (r >= 0) {
diff --git a/syscall.c b/syscall.c
index 3f157b2..3ee4417 100644
--- a/syscall.c
+++ b/syscall.c
@@ -183,29 +183,25 @@ enum { nioctlents2 = ARRAY_SIZE(ioctlent2) };
int qual_flags2[MAX_QUALS];
#endif
-const struct sysent *sysent;
-const char *const *errnoent;
-const char *const *signalent;
-const struct ioctlent *ioctlent;
-unsigned nsyscalls;
-unsigned nerrnos;
-unsigned nsignals;
-unsigned nioctlents;
-int *qual_flags;
+const struct sysent *sysent = sysent0;
+const char *const *errnoent = errnoent0;
+const char *const *signalent = signalent0;
+const struct ioctlent *ioctlent = ioctlent0;
+unsigned nsyscalls = nsyscalls0;
+unsigned nerrnos = nerrnos0;
+unsigned nsignals = nsignals0;
+unsigned nioctlents = nioctlents0;
+int *qual_flags = qual_flags0;
+#if SUPPORTED_PERSONALITIES > 1
int current_personality;
-#ifndef PERSONALITY0_WORDSIZE
-# define PERSONALITY0_WORDSIZE sizeof(long)
-#endif
const int personality_wordsize[SUPPORTED_PERSONALITIES] = {
PERSONALITY0_WORDSIZE,
-#if SUPPORTED_PERSONALITIES > 1
PERSONALITY1_WORDSIZE,
-#endif
-#if SUPPORTED_PERSONALITIES > 2
+# if SUPPORTED_PERSONALITIES > 2
PERSONALITY2_WORDSIZE,
-#endif
+# endif
};
void
@@ -224,7 +220,6 @@ set_personality(int personality)
qual_flags = qual_flags0;
break;
-#if SUPPORTED_PERSONALITIES >= 2
case 1:
errnoent = errnoent1;
nerrnos = nerrnos1;
@@ -236,9 +231,8 @@ set_personality(int personality)
nsignals = nsignals1;
qual_flags = qual_flags1;
break;
-#endif
-#if SUPPORTED_PERSONALITIES >= 3
+# if SUPPORTED_PERSONALITIES >= 3
case 2:
errnoent = errnoent2;
nerrnos = nerrnos2;
@@ -250,13 +244,12 @@ set_personality(int personality)
nsignals = nsignals2;
qual_flags = qual_flags2;
break;
-#endif
+# endif
}
current_personality = personality;
}
-#if SUPPORTED_PERSONALITIES > 1
static void
update_personality(struct tcb *tcp, int personality)
{
@@ -521,7 +514,7 @@ decode_socket_subcall(struct tcb *tcp)
tcp->scno = SYS_socket_subcall + tcp->u_arg[0];
addr = tcp->u_arg[1];
tcp->u_nargs = sysent[tcp->scno].nargs;
- size = personality_wordsize[current_personality];
+ size = current_wordsize;
for (i = 0; i < tcp->u_nargs; ++i) {
if (size == sizeof(int)) {
unsigned int arg;
@@ -685,8 +678,7 @@ static long r3;
* other: error, trace_syscall() should print error indicator
* ("????" etc) and bail out.
*/
-static
-int
+static int
get_scno(struct tcb *tcp)
{
long scno = 0;
@@ -1682,7 +1674,7 @@ is_negated_errno(unsigned long int val)
{
unsigned long int max = -(long int) nerrnos;
#if SUPPORTED_PERSONALITIES > 1
- if (personality_wordsize[current_personality] < sizeof(val)) {
+ if (current_wordsize < sizeof(val)) {
val = (unsigned int) val;
max = (unsigned int) max;
}
diff --git a/time.c b/time.c
index 09d0f07..537265e 100644
--- a/time.c
+++ b/time.c
@@ -79,7 +79,7 @@ sprinttv(char *buf, struct tcb *tcp, long addr, enum bitness_t bitness, int spec
if (bitness == BITNESS_32
#if SUPPORTED_PERSONALITIES > 1
- || personality_wordsize[current_personality] == 4
+ || current_wordsize == 4
#endif
)
{
@@ -135,7 +135,7 @@ sprint_timespec(char *buf, struct tcb *tcp, long addr)
int rc;
#if SUPPORTED_PERSONALITIES > 1
- if (personality_wordsize[current_personality] == 4) {
+ if (current_wordsize == 4) {
struct timeval32 tv;
rc = umove(tcp, addr, &tv);
@@ -288,7 +288,7 @@ printitv_bitness(struct tcb *tcp, long addr, enum bitness_t bitness)
if (bitness == BITNESS_32
#if SUPPORTED_PERSONALITIES > 1
- || personality_wordsize[current_personality] == 4
+ || current_wordsize == 4
#endif
)
{
@@ -542,7 +542,7 @@ tprint_timex(struct tcb *tcp, long addr)
struct timex tx;
#if SUPPORTED_PERSONALITIES > 1
- if (personality_wordsize[current_personality] == 4)
+ if (current_wordsize == 4)
return tprint_timex32(tcp, addr);
#endif
if (umove(tcp, addr, &tx) < 0)
@@ -746,7 +746,7 @@ printsigevent(struct tcb *tcp, long arg)
struct sigevent sev;
#if SUPPORTED_PERSONALITIES > 1
- if (personality_wordsize[current_personality] == 4) {
+ if (current_wordsize == 4) {
printsigevent32(tcp, arg);
return;
}
diff --git a/util.c b/util.c
index 4066bcb..9a77705 100644
--- a/util.c
+++ b/util.c
@@ -631,14 +631,11 @@ dumpiov(struct tcb *tcp, int len, long addr)
} iovu;
#define iov iovu.iov64
#define sizeof_iov \
- (personality_wordsize[current_personality] == 4 \
- ? sizeof(*iovu.iov32) : sizeof(*iovu.iov64))
+ (current_wordsize == 4 ? sizeof(*iovu.iov32) : sizeof(*iovu.iov64))
#define iov_iov_base(i) \
- (personality_wordsize[current_personality] == 4 \
- ? (u_int64_t) iovu.iov32[i].base : iovu.iov64[i].base)
+ (current_wordsize == 4 ? (uint64_t) iovu.iov32[i].base : iovu.iov64[i].base)
#define iov_iov_len(i) \
- (personality_wordsize[current_personality] == 4 \
- ? (u_int64_t) iovu.iov32[i].len : iovu.iov64[i].len)
+ (current_wordsize == 4 ? (uint64_t) iovu.iov32[i].len : iovu.iov64[i].len)
#else
struct iovec *iov;
#define sizeof_iov sizeof(*iov)
@@ -783,8 +780,8 @@ umoven(struct tcb *tcp, long addr, int len, char *laddr)
} u;
#if SUPPORTED_PERSONALITIES > 1
- if (personality_wordsize[current_personality] < sizeof(addr))
- addr &= (1ul << 8 * personality_wordsize[current_personality]) - 1;
+ if (current_wordsize < sizeof(addr))
+ addr &= (1ul << 8 * current_wordsize) - 1;
#endif
if (!process_vm_readv_not_supported) {
@@ -874,8 +871,8 @@ umovestr(struct tcb *tcp, long addr, int len, char *laddr)
} u;
#if SUPPORTED_PERSONALITIES > 1
- if (personality_wordsize[current_personality] < sizeof(addr))
- addr &= (1ul << 8 * personality_wordsize[current_personality]) - 1;
+ if (current_wordsize < sizeof(addr))
+ addr &= (1ul << 8 * current_wordsize) - 1;
#endif
if (!process_vm_readv_not_supported) {