Implement -C option to combine regular and -c output
* defs.h (cflag_t): New enum.
* strace.1: Document -C option.
* strace.c (cflag): Update type.
(main): Handle -C option.
(trace): Update use of cflag.
* count.c (count_syscall): Move clearing of TCB_INSYSCALL to ...
* syscall.c (trace_syscall): ... here. Update use of cflag.
Based on patch by Adrien Kunysz.
diff --git a/syscall.c b/syscall.c
index a56d7df..6a6fad8 100644
--- a/syscall.c
+++ b/syscall.c
@@ -2369,7 +2369,7 @@
long u_error;
/* Measure the exit time as early as possible to avoid errors. */
- if (dtime)
+ if (dtime || cflag)
gettimeofday(&tv, NULL);
/* BTW, why we don't just memorize syscall no. on entry
@@ -2407,8 +2407,15 @@
tprintf(" resumed> ");
}
- if (cflag)
- return count_syscall(tcp, &tv);
+ if (cflag) {
+ struct timeval t = tv;
+ int rc = count_syscall(tcp, &t);
+ if (cflag == CFLAG_ONLY_STATS)
+ {
+ tcp->flags &= ~TCB_INSYSCALL;
+ return rc;
+ }
+ }
if (res != 1) {
tprintf(") ");
@@ -2647,9 +2654,9 @@
return 0;
}
- if (cflag) {
- gettimeofday(&tcp->etime, NULL);
+ if (cflag == CFLAG_ONLY_STATS) {
tcp->flags |= TCB_INSYSCALL;
+ gettimeofday(&tcp->etime, NULL);
return 0;
}
@@ -2669,7 +2676,7 @@
return -1;
tcp->flags |= TCB_INSYSCALL;
/* Measure the entrance time as late as possible to avoid errors. */
- if (dtime)
+ if (dtime || cflag)
gettimeofday(&tcp->etime, NULL);
return sys_res;
}