File tree 6 files changed +65
-0
lines changed
6 files changed +65
-0
lines changed Original file line number Diff line number Diff line change
1
+ # download and extract intel pin
2
+ pushd .
3
+ cd ..
4
+ wget https://software.intel.com/sites/landingpage/pintool/downloads/pin-3.27-98718-gbeaa5d51e-gcc-linux.tar.gz
5
+ tar xf pin-3.27-98718-gbeaa5d51e-gcc-linux.tar.gz
6
+ popd
7
+
8
+ # build CodeCoverage(this repository code)
9
+ ./build.sh
10
+
11
+ # build code coverage target example
12
+ pushd .
13
+ cd examples/c_function_call
14
+ make
15
+ popd
16
+
17
+ # run code coverage tool
18
+
Original file line number Diff line number Diff line change
1
+ ../pin-3.27-98718-gbeaa5d51e-gcc-linux/pin -t ./obj-intel64/CodeCoverage.so -- examples/c_function_call/cov_sample 1 2
Original file line number Diff line number Diff line change
1
+ make PIN_ROOT=../pin-3.27-98718-gbeaa5d51e-gcc-linux
2
+
Original file line number Diff line number Diff line change
1
+ all :
2
+ ${CC} -g -gdwarf-4 main.c calc.c -o cov_sample
3
+
4
+ clean :
5
+ rm -f cov_sample
6
+
Original file line number Diff line number Diff line change
1
+ int add (int a , int b )
2
+ {
3
+ return a + b ;
4
+ }
Original file line number Diff line number Diff line change
1
+ #include <stdio.h>
2
+ #include <stdlib.h>
3
+
4
+ extern int add (int , int );
5
+
6
+ int main (int argc , char * * argv )
7
+ {
8
+ /*
9
+ * With command line arg example, call function implemented in onother file(calc.c)
10
+ * Comment lines are not count as executable lines.
11
+ */
12
+ int a , b ;
13
+ int result = 0 ;
14
+
15
+ if (argc < 3 ) {
16
+ // must input 2 number args
17
+ fprintf (stderr , "input 2 numbers for calc add.\n" );
18
+ fprintf (stderr , "Usage) ./a.out 1 2\n" );
19
+ return -1 ;
20
+ }
21
+
22
+ a = atoi (argv [1 ]);
23
+ b = atoi (argv [2 ]);
24
+
25
+ result = add (a , b );
26
+
27
+ if (result < 10 ) {
28
+ printf ("a + b = %d, the answer is smaller than 10!\n" , result );
29
+ } else {
30
+ printf ("a + b = %d, the answer is greater than or equal to 10!\n" , result );
31
+ }
32
+
33
+ return 0 ;
34
+ }
You can’t perform that action at this time.
0 commit comments