]> granicus.if.org Git - strace/commitdiff
Fix -O option handling
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 20 Mar 2018 02:30:24 +0000 (02:30 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 20 Mar 2018 02:30:24 +0000 (02:30 +0000)
Fast syscalls usually take less than a microsecond of system cpu time
nowadays, making -O option almost useless.

* count.c (call_summary_pers): Avoid negative time counts.
* tests/count.test: Check it.
* NEWS: Mention it.

NEWS
count.c
tests/count.test

diff --git a/NEWS b/NEWS
index 002af1072f2921ecd8282866ebae97ef99787fa7..ee9e2457c9549e525d8fda96336e7d880bc4f1b4 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,7 @@ Noteworthy changes in release ?.?? (????-??-??)
 * Bug fixes
   * Fixed build on m68k.
   * Fixed v4l2 pixelformat decoding on big-endian architectures.
+  * Fixed -O option.
 
 Noteworthy changes in release 4.21 (2018-02-13)
 ===============================================
diff --git a/count.c b/count.c
index b414536498f788ad22c4a02e101e31508e0618cb..5d93371d0373f55f96aa7d9e98aa26dbb53f0ea8 100644 (file)
--- a/count.c
+++ b/count.c
@@ -150,6 +150,8 @@ call_summary_pers(FILE *outf)
                        continue;
                tv_mul(&dtv, &overhead, counts[i].calls);
                tv_sub(&counts[i].time, &counts[i].time, &dtv);
+               if (counts[i].time.tv_sec < 0 || counts[i].time.tv_usec < 0)
+                       counts[i].time.tv_sec = counts[i].time.tv_usec = 0;
                call_cum += counts[i].calls;
                error_cum += counts[i].errors;
                tv_add(&tv_cum, &tv_cum, &counts[i].time);
index a9752c09e51925b27ff7d12cf19531d192bea28b..39332a9ac12ed85bd370be40dcc3157fc07d263b 100755 (executable)
@@ -50,8 +50,12 @@ grep_log()
 }
 
 grep_log ' *[^ ]+ +0\.0[^n]*nanosleep'         -c
+grep_log ' *[^ ]+ +0\.0[^n]*nanosleep'         -c -O1
 grep_log ' *[^ ]+ +0\.0[^n]*nanosleep'         -c -enanosleep
+grep_log ' *[^ ]+ +0\.0[^n]*nanosleep'         -c -O1 -enanosleep
 grep_log ' *[^ ]+ +(1\.[01]|0\.99)[^n]*nanosleep'      -cw
+grep_log ' *[^ ]+ +(1\.[01]|0\.99)[^n]*nanosleep'      -cw -O1
 grep_log '100\.00 +(1\.[01]|0\.99)[^n]*nanosleep'      -cw -enanosleep
+grep_log '100\.00 +(1\.[01]|0\.99)[^n]*nanosleep'      -cw -O1 -enanosleep
 
 exit 0