[PATCH v9 02/15] Add macros for checking QUAL_* flags
Nikolay Marchuk
marchuk.nikolay.a at gmail.com
Thu Aug 24 11:19:40 UTC 2017
* defs.h (QUAL_READ, QUAL_WRITE): Change description.
(traced, raw, inject, dump_read, dump_write): Add macros for checking
QUAL_TRACE, QUAL_RAW, QUAL_INJECT, QUAL_READ, QUAL_WRITE.
* syscall.c (syscall_entering_trace, syscall_exiting_trace): Use new macros.
---
defs.h | 9 +++++++--
syscall.c | 13 +++++--------
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/defs.h b/defs.h
index 92cde26e..87f831f1 100644
--- a/defs.h
+++ b/defs.h
@@ -254,16 +254,21 @@ struct tcb {
#define QUAL_RAW 0x008 /* print all args in hex for this syscall */
#define QUAL_INJECT 0x010 /* tamper with this system call on purpose */
#define QUAL_SIGNAL 0x100 /* report events with this signal */
-#define QUAL_READ 0x200 /* dump data read from this file descriptor */
-#define QUAL_WRITE 0x400 /* dump data written to this file descriptor */
+#define QUAL_READ 0x200 /* dump data read in this syscall */
+#define QUAL_WRITE 0x400 /* dump data written in this syscall */
#define DEFAULT_QUAL_FLAGS (QUAL_TRACE | QUAL_ABBREV | QUAL_VERBOSE)
#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 dump_read(tcp) ((tcp)->qual_flg & QUAL_READ)
+#define dump_write(tcp) ((tcp)->qual_flg & QUAL_WRITE)
#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.11.0
More information about the Strace-devel
mailing list