namhyung / uftrace

Function graph tracer for C/C++/Rust/Python
https://uftrace.github.io/slide/
GNU General Public License v2.0
3.07k stars 474 forks source link

clang compiled uftrace test result #1116

Open honggyukim opened 4 years ago

honggyukim commented 4 years ago

I've compiled uftrace with clang-9.0.1 and run tests in x86_64. The result is as follows:

Test case                 pg             finstrument-fu
------------------------: O0 O1 O2 O3 Os O0 O1 O2 O3 Os
015 longjmp             : OK NG NG NG NG OK OK OK OK OK
051 return              : NG NG NG NG NG NG OK OK OK OK
052 nested_func         : BI BI BI BI BI BI BI BI BI BI
062 arg_char            : OK NG NG NG NG SK SK SK SK SK
082 arg_many            : NG OK OK OK OK SK SK SK SK SK
083 arg_float           : NG NG NG NG NG SK SK SK SK SK
084 arg_mixed           : NG NG NG NG NG SK SK SK SK SK
085 arg_reg             : NG NG NG NG NG SK SK SK SK SK
087 arg_variadic        : NG NG NG NG NG SK SK SK SK SK
090 report_recursive    : OK NG NG NG NG OK OK OK OK OK
124 exception           : OK OK OK OK OK NG NG NG NG NG
125 report_range        : OK NG OK OK OK OK OK OK OK OK
136 dynamic             : BI BI BI BI BI BI BI BI BI BI
151 recv_runcmd         : NG NG NG NG NG NG NG NG NG NG
162 pltbind_now_pie     : BI BI BI BI BI BI BI BI BI BI
181 graph_full          : NG NG NG NG NG NG NG NG NG NG
182 thread_exit         : SG OK OK NG OK SG OK NG NG NG
184 arg_enum            : NG NG NG NG NG NG NG NG NG NG
185 exception2          : OK OK OK OK OK NG NG NG NG NG
186 exception3          : OK OK OK OK OK NG NG NG NG NG
191 posix_spawn         : NG OK OK OK OK NG OK OK OK OK
198 lib_arg_float       : NG NG NG NG NG SK SK SK SK SK
201 arg_dwarf1          : NG NG NG NG NG SK SK SK SK SK
202 arg_dwarf2          : NG OK OK OK OK SK SK SK SK SK
203 arg_dwarf3          : NG NG NG NG NG SK SK SK SK SK
222 external_data       : OK OK OK OK OK OK OK NG OK OK
225 dynamic_size        : NG OK OK OK NG NG OK OK OK NG
228 read_pmu_cycle3     : OK NG NG NG NG OK OK NG OK OK
231 arg_bound           : NG OK OK OK OK SK SK SK SK SK
232 dynamic_unpatch     : BI BI BI BI BI BI BI BI BI BI

The tests are executed after changing as follows:

$ diff -u a/.config b/.config
--- a/.config   2020-02-09 09:24:00.711544768 +0900
+++ b/.config   2020-02-09 09:23:48.635330333 +0900
@@ -6,7 +6,7 @@
 override etcdir := /home/honggyu/usr/etc

 override ARCH   := x86_64
-override CC     := gcc
+override CC     := clang-9
 override LD     := ld
 override CFLAGS  =
 override LDFLAGS =
diff --git a/tests/runtest.py b/tests/runtest.py
index 1ddc8b7..b3a35f3 100755
--- a/tests/runtest.py
+++ b/tests/runtest.py
@@ -10,8 +10,8 @@ import time

 class TestBase:
     supported_lang = {
-        'C':   { 'cc': 'gcc', 'flags': 'CFLAGS',   'ext': '.c' },
-        'C++': { 'cc': 'g++', 'flags': 'CXXFLAGS', 'ext': '.cpp' },
+        'C':   { 'cc': 'clang', 'flags': 'CFLAGS',   'ext': '.c' },
+        'C++': { 'cc': 'clang++', 'flags': 'CXXFLAGS', 'ext': '.cpp' },
     }

     TEST_SUCCESS = 0
honggyukim commented 4 years ago

Here are the brief diff output of failed tests.

t015_longjmp: diff result of -pg -O1
--- expect      2020-02-09 09:18:24.736757759 +0900
+++ result      2020-02-09 09:18:24.736757759 +0900
@@ -5,3 +5,2 @@
    } /* _setjmp */
-   bar();
  } /* main */

015 longjmp             : NG
t051_return: diff result of -pg -O0
--- expect      2020-02-09 09:18:47.677287048 +0900
+++ result      2020-02-09 09:18:47.677287048 +0900
@@ -1,3 +1,6 @@
 main() {
-   return_large();
+   return_large() {
+     memset();
+   } /* return_large */
+   memcpy();
    return_small();

051 return              : NG
t083_arg_float: diff result of -pg -O0
--- expect      2020-02-09 09:17:26.339354642 +0900
+++ result      2020-02-09 09:17:26.339354642 +0900
@@ -1,6 +1,6 @@
 main() {
-   float_add(-0.100000, 0.200000) = 0.100000;
-   float_sub(0.100000, 0.200000) = -0.100000;
-   float_mul(300.000000, 400.000000) = 120000.000000;
-   float_div(40000000000.000000, -0.020000) = -2000000000000.000000;
+   float_add(0.000000, 0.000000) = 0.000000;
+   float_sub(0.000000, 0.000000) = 0.000000;
+   float_mul(0.000000, 0.000000) = 0.000000;
+   float_div(0.000000, 0.000000) = 0.000000;
  } /* main */

083 arg_float           : NG
t191_posix_spawn: diff result of -pg -O0
--- expect      2020-02-09 09:19:47.294609847 +0900
+++ result      2020-02-09 09:19:47.294609847 +0900
@@ -1,2 +1,3 @@
 main() {
+   memset();
    posix_spawn();

191 posix_spawn         : NG
t198_lib_arg_float: diff result of -pg -O0
--- expect      2020-02-09 09:20:44.631816472 +0900
+++ result      2020-02-09 09:20:44.631816472 +0900
@@ -1,4 +1,4 @@
 main() {
-   expf(1.000000) = 2.718282;
-   log(2.718282) = 1.000000;
+   expf(0.000000) = 0.000000;
+   log(0.000000) = 0.000000;
  } /* main */

198 lib_arg_float       : NG
t201_arg_dwarf1: diff result of -pg -O0
--- expect      2020-02-09 09:21:06.084252828 +0900
+++ result      2020-02-09 09:21:06.084252828 +0900
@@ -2,5 +2,5 @@
    foo(-1, 32768) = 32767;
-   bar("string argument", 'c', 0.000010, &null) {
+   bar("string argument", 'c', 0.000000, &null) {
      null("NULL");
-   } = -1.000000; /* bar */
+   } = 0.000000; /* bar */
    baz(ONE) {

201 arg_dwarf1          : NG
t225_dynamic_size: diff result of -pg -O0
--- expect      2020-02-09 09:21:42.168969609 +0900
+++ result      2020-02-09 09:21:42.168969609 +0900
@@ -1,3 +1,6 @@
 main() {
-   big();
+   memcpy();
+   big() {
+     memcpy();
+   } /* big */
  } /* main */

225 dynamic_size        : NG
t231_arg_bound: diff result of -pg -O0
--- expect      2020-02-09 09:22:01.921353279 +0900
+++ result      2020-02-09 09:22:01.921353279 +0900
@@ -12,3 +12,3 @@
    } /* foo */
-   many(12, 0, 1, 0);
+   many(1, 0, 1, 0);
    pass() {

231 arg_bound           : NG
honggyukim commented 4 years ago

It seems that -fno-inline option doesn't actually ignore function inlining in clang-9 so t015_longjmp fails.

Here is the result that clang compiled uftrace runs gcc compiled test programs.

063 retval              : OK SG SG SG SG SK SK SK SK SK
083 arg_float           : NG NG NG NG NG SK SK SK SK SK
084 arg_mixed           : NG NG NG NG NG SK SK SK SK SK
085 arg_reg             : NG NG NG NG NG SK SK SK SK SK
087 arg_variadic        : NG NG NG NG NG SK SK SK SK SK
125 report_range        : NG OK OK OK OK OK OK NG OK OK
136 dynamic             : OK OK OK OK OK NG NG NG NG NG
151 recv_runcmd         : NG NG NG NG NG NG NG NG NG NG
182 thread_exit         : NG NG NG OK OK OK OK OK OK OK
198 lib_arg_float       : NG NG NG NG NG SK SK SK SK SK
201 arg_dwarf1          : SG NG NG NG NG SK SK SK SK SK
203 arg_dwarf3          : NG NG NG NG NG SK SK SK SK SK
204 arg_dwarf4          : OK OK NG NG OK SK SK SK SK SK
222 external_data       : OK OK OK NG OK OK OK OK OK OK
228 read_pmu_cycle3     : OK OK NG NG NG OK OK OK OK OK
232 dynamic_unpatch     : OK OK OK OK OK NG NG NG NG NG

It shows less failures than clang compiled test programs.

honggyukim commented 4 years ago

Regarding t083_arg_float. it can be simply reproduced as follows.

$ gcc -pg -g s-exp-float.c

$ uftrace -a a.out
# DURATION     TID     FUNCTION
   0.660 us [ 10295] | __monstartup();
   0.407 us [ 10295] | __cxa_atexit();
            [ 10295] | main(1, 0x7ffc95ba3e78) {
   0.315 us [ 10295] |   float_add(0.000000, 0.000000) = 0.000000;
   0.280 us [ 10295] |   float_sub(0.000000, 0.000000) = 0.000000;
   0.124 us [ 10295] |   float_mul(0.000000, 0.000000) = 0.000000;
   0.096 us [ 10295] |   float_div(0.000000, 0.000000) = 0.000000;
   3.141 us [ 10295] | } = 0; /* main */