From ff8e066b3c4559be637a4dcccf6a6808d94aa20a Mon Sep 17 00:00:00 2001 From: Nikolay Marchuk Date: Thu, 24 Aug 2017 18:19:40 +0700 Subject: [PATCH] Add macros for testing QUAL_* flags * defs.h (traced, raw, inject): Add macros for testing QUAL_TRACE, QUAL_RAW, and QUAL_INJECT flags. * syscall.c (syscall_entering_trace, syscall_exiting_trace): Use them. --- defs.h | 3 +++ syscall.c | 13 +++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/defs.h b/defs.h index 4aa34a88..f82eef15 100644 --- a/defs.h +++ b/defs.h @@ -259,8 +259,11 @@ struct tcb { #define entering(tcp) (!((tcp)->flags & TCB_INSYSCALL)) #define exiting(tcp) ((tcp)->flags & TCB_INSYSCALL) #define syserror(tcp) ((tcp)->u_error != 0) +#define traced(tcp) ((tcp)->qual_flg & QUAL_TRACE) #define verbose(tcp) ((tcp)->qual_flg & QUAL_VERBOSE) #define abbrev(tcp) ((tcp)->qual_flg & QUAL_ABBREV) +#define raw(tcp) ((tcp)->qual_flg & QUAL_RAW) +#define inject(tcp) ((tcp)->qual_flg & QUAL_INJECT) #define filtered(tcp) ((tcp)->flags & TCB_FILTERED) #define hide_log(tcp) ((tcp)->flags & TCB_HIDE_LOG) diff --git a/syscall.c b/syscall.c index d5aeabf0..6b1d2dcd 100644 --- a/syscall.c +++ b/syscall.c @@ -681,9 +681,7 @@ syscall_entering_trace(struct tcb *tcp, unsigned int *sig) break; } - if (!(tcp->qual_flg & QUAL_TRACE) - || (tracing_paths && !pathtrace_match(tcp)) - ) { + if (!traced(tcp) || (tracing_paths && !pathtrace_match(tcp))) { tcp->flags |= TCB_FILTERED; return 0; } @@ -694,7 +692,7 @@ syscall_entering_trace(struct tcb *tcp, unsigned int *sig) return 0; } - if (tcp->qual_flg & QUAL_INJECT) + if (inject(tcp)) tamper_with_syscall_entering(tcp, sig); if (cflag == CFLAG_ONLY_STATS) { @@ -710,8 +708,7 @@ syscall_entering_trace(struct tcb *tcp, unsigned int *sig) printleader(tcp); tprintf("%s(", tcp->s_ent->sys_name); - int res = (tcp->qual_flg & QUAL_RAW) - ? printargs(tcp) : tcp->s_ent->sys_func(tcp); + int res = raw(tcp) ? printargs(tcp) : tcp->s_ent->sys_func(tcp); fflush(tcp->outf); return res; } @@ -805,7 +802,7 @@ syscall_exiting_trace(struct tcb *tcp, struct timeval tv, int res) tcp->s_prev_ent = tcp->s_ent; int sys_res = 0; - if (tcp->qual_flg & QUAL_RAW) { + if (raw(tcp)) { /* sys_res = printargs(tcp); - but it's nop on sysexit */ } else { /* FIXME: not_failing_only (IOW, option -z) is broken: @@ -828,7 +825,7 @@ syscall_exiting_trace(struct tcb *tcp, struct timeval tv, int res) tabto(); unsigned long u_error = tcp->u_error; - if (tcp->qual_flg & QUAL_RAW) { + if (raw(tcp)) { if (u_error) { tprintf("= -1 (errno %lu)", u_error); } else { -- 2.40.0