]> granicus.if.org Git - strace/commitdiff
Add macros for testing QUAL_* flags
authorNikolay Marchuk <marchuk.nikolay.a@gmail.com>
Thu, 24 Aug 2017 11:19:40 +0000 (18:19 +0700)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 24 Aug 2017 18:24:16 +0000 (18:24 +0000)
* 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
syscall.c

diff --git a/defs.h b/defs.h
index 4aa34a88d11bce5163d38eb1043be78e78dfeb62..f82eef15eeacf1f5e95a6bf1240e2ab94e6770f1 100644 (file)
--- 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)
 
index d5aeabf05b535047f6d8de682491de7767fa97a4..6b1d2dcd91cbb297821848b923b408081b4a83de 100644 (file)
--- 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 {