GNU gcov (1/4) [from Wikipedia] gcov is a source code coverage analysis and statement- by-statement profiling tool. gcov generates exact counts of the.

Slides:



Advertisements
Similar presentations
CPSC 441 TUTORIAL – JANUARY 16, 2012 TA: MARYAM ELAHI INTRODUCTION TO C.
Advertisements

Computer Science 2212a/b - UWO1 Structural Testing Motivation The gcov Tool An example using gcov How does gcov do it gcov subtleties Further structural.
Review of Scientific Programming in C and Fortran Michael McLennan Software Architect HUBzero™ Platform for Scientific Collaboration.
C Programming Day 1 based upon Practical C Programming by Steve Oualline CS550 Operating Systems.
Coverage analysis using gcc (or g++) source code source code executable run results coverage gcc –ftest-coverage –fprofile-arcs myprogram.exe myprogram.cpp.
CS 202 Computer Science II Lab Fall 2009 September 17.
Unix Continuum of Tools Do something once: use the command line Do something many times: –Use an alias –Use a shell script Do something that is complex.
Using Set Operations on Code Coverage Data to Discover Program Properties by Nick Rutar.
Fork and Exec Unix Model Tutorial 3. Process Management Model The Unix process management model is split into two distinct operations : 1. The creation.
Command line arguments. – main can take two arguments conventionally called argc and argv. – Information regarding command line arguments are passed to.
An Introduction to C Programming Geb Thomas. Learning Objectives Learn how to write and compile a C program Learn what C libraries are Understand the.
Xin Liu Sep 16, Introduction Xin (Shane) Liu PhD Candidate in Computer Science Research Area: Computer Graphics Tutorial Page: pages.cpsc.ucalgary.ca/~liuxin/CPSC453.
Data Flow in Static Profiling Cathal Boogerd, Delft University, The Netherlands Leon Moonen, Simula Research Lab, Norway ?
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 15: Linked data structures.
Practical Session 4. Labels Definition - advanced label: (pseudo) instruction operands ; comment valid characters in labels are: letters, numbers, _,
Timing and Profiling ECE 454 Computer Systems Programming Topics: Measuring and Profiling Cristiana Amza.
Jul 1, CUnit & Coverage Larry Shi. Jul 1, Agenda  Aim  CUnit  Screenshots(Automated)  Demo  TO-DO list.
1 Components of the Virtual Memory System  Arrows indicate what happens on a lw virtual address data physical address TLB page table memory cache disk.
Shell (Addendum). Example r What if we want to support something like this: m ps –le | sort r One process should execute ps –le and another should execute.
/21 Clang Tutorial CS453 Automated Software Testing.
1 4-Development Environment Development processor  The processor on which we write and debug our programs Usually a PC Target processor  The processor.
Adv. UNIX: Profile/151 Advanced UNIX v Objectives –introduce profiling based on execution times and line counts Special Topics in Comp.
CS-1030 Dr. Mark L. Hornick 1 Java Review Interactive.
1 SEEM3460 Tutorial Compiling and Debugging C programs.
1 Announcements  Homework 4 out today  Dec 7 th is the last day you can turn in Lab 4 and HW4, so plan ahead.
WHITE BOX TESTING IS4500 Copyright © 2012 by The Cathris Group and Martin J. Schedlbauer. All Rights Reserved. Do Not Duplicate or Distribute Without Written.
OPERATING SYSTEMS 1 - HARDWARE PIETER HARTEL 1. Hardware 2.
C. C ? K & R C – The Kernighan and Richie classic ANCI C -- started 1983 – ANSI X and ISO/IEC 9899:1990 – Standard C, C89, C90 C90 –
The Problem If someone were to write a unit test with the goal of 90% coverage over the code, how is this 90% coverage verified? Not reaching test coverage.
C:\Temp\Templates 4 5 Use This Main Program 6.
Announcements You will receive your scores back for Assignment 2 this week. You will have an opportunity to correct your code and resubmit it for partial.
Int main( ) { x = a(); } int a() { y = b(); } int b() { z = c(); } int c() { } 1.
HW7: Due Dec 5th 23:59 1.Describe test cases to reach full path coverage of the triangle program by completing the path condition table below. Also, draw.
CSE 333 – SECTION 2 Memory Management. Questions, Comments, Concerns Do you have any? Exercises going ok? Lectures make sense? Homework 1 – START EARLY!
© Dr. A. Williams, Fall Present Software Quality Assurance – Clover Lab 1 Tutorial / lab 2: Code instrumentation Goals of this session: 1.Create.
White Box Testing. Agenda White-box vs Black-box Program Flow Controls White-box Test Methods Exercises Complexity Q&A.
Week 4 – Functions Coding Functions. Purpose of Coding Functions A function is written to perform a well-defined task; rather than having all logic in.
Using System Calls (Unix) Have to tell compiler (if C/C++) where to find the headers, etc. – i.e., the “include” files May have to tell compiler where.
July 10, 2016ISA's, Compilers, and Assembly1 CS232 roadmap In the first 3 quarters of the class, we have covered 1.Understanding the relationship between.
KYC - Know your compiler Introduction to GCC
Content Coverity Static Analysis Use cases of Coverity Examples
Lab 7 Control-Flow Testing
The Machine Model Memory
SPI Software Process & Infrastructure
Optimizing Compilers Background
Command line arguments
Agenda Make Utility Command Line Arguments in Unix
Command Line Arguments
White-Box Testing.
Command Line Arguments
Repetition Statements
Code Coverage David Inglis November 18, 2018.
An Introduction to Java – Part I, language basics
GNU gcov (1/4) [from Wikipedia]
CSc 352: Testing and Code Coverage
Command Line Parameters
Summary.
Copyright © – Curt Hill Bash Flow of Control Copyright © – Curt Hill.
Introduction to Static Analyzer
GNU gcov gcov is a test coverage program running with gcc.
Whitebox Testing.
GNU gcov (1/4) [from Wikipedia]
C. M. Overstreet Old Dominion University Spring 2006
White-Box Testing.
Whitebox Testing.
Testing grep.c (200 pts) For grep.c, generate 10,000 test cases through the (reverse) DFS search strategy. You are requested to modify grep.c to create.
C. M. Overstreet Old Dominion University Fall 2007
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2010.
HW#7 Describe test cases to reach full path coverage of the triangle program by completing the path condition table below. Also, draw the complete execution.
Software Testing.
Presentation transcript:

GNU gcov (1/4) [from Wikipedia] gcov is a source code coverage analysis and statement- by-statement profiling tool. gcov generates exact counts of the number of times each statement in a program has been executed gcov does not produce any time-based data (you should use gprof for this purpose) and works only on code compiled with the GCC suite.

GNU gcov (2/4) To use gcov, each source file should be compiled with -fprofile–arcs and –ftest-coverage, which generates a.gcno file that is a graph file of the source file. After the instrumented target program completes its execution, execution statistics is recorded in a.gcda file. gcov creates a human readable logfile.gcov from a binary.gcda file, which indicates how many times each line of a source file has executed. gcov [-b] [-c] [-v] [-n] [-l] [-f] [-o directory] sourcefile – -a: Write individual execution counts for every basic block. – -b: Write branch frequencies to the output file – -c: Write branch frequencies as the number of branches taken – -f: Output summaries for each function in addition to the file level summary. – -o The directory where the object files live. Gcov will search for `.bb', `.bbg', and `.da' files in this directory

GNU gcov (3/4) For example, if you measure coverage of example.c, gcov]$ l example.c gcov]$ gcc -fprofile-arcs -ftest-coverage example.c gcov]$ a.out 5 i=5 j=2 gcov]$ gcov -b example.c File 'example.c' Lines executed:78.57% of 14 Branches executed:100.00% of 10 Taken at least once:50.00% of 10 Calls executed:60.00% of 5 example.c:creating 'example.c.gcov' 1 #include 2 int main(int argc, char **argv){ 3 int i=0,j=0; 4 if (argc < 2) { 5 printf("Usage:…\n”);exit(-1);} 6 i = atoi(argv[1]); 7 printf("i=%d\n",i); 8 9 if( i == 0) 10 j=0; 11 else { 12 if (i == 1) 13 j=1; 14 if (i > 1 && i < 10) 15 j=2; 16 } 17 printf("j=%d\n",j); 18 }

GNU gcov (4/4) Not executed Non-executable statement Call info 1 #include 2 int main(int argc, char **argv){ 3 int i=0,j=0; 4 if (argc < 2) { 5 printf("Usage:…\n”);exit(-1);} 6 i = atoi(argv[1]); 7 printf("i=%d\n",i); 8 9 if( i == 0) 10 j=0; 11 else { 12 if (i == 1) 13 j=1; 14 if (i > 1 && i < 10) 15 j=2; 16 } 17 printf("j=%d\n",j); 18 } -: 0:Source:example.c -: 0:Graph:example.gcno -: 0:Data:example.gcda -: 0:Runs:1 -: 0:Programs:1 -: 1:#include function main called 1 returned 100% blocks executed 71% 1: 2:int main(int argc, char **argv){ 1: 3: int i=0,j=0; 1: 4: if (argc < 2) { branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 5: printf("Usage:…\n");exit(-1);} call 0 never executed call 1 never executed 1: 6: i=atoi(argv[1]); call 0 returned 100% 1: 7: printf("i=%d\n",i); call 0 returned 100% -: 8: 1: 9: if( i == 0) branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 10: j=0; -: 11: else { 1: 12: if (i == 1) branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 13: j=1; 1: 14: if(i>1&&i<10) branch 0 taken 100% (fallthrough) branch 1 taken 0% branch 2 taken 100% (fallthrough) branch 3 taken 0% 1: 15: j=2; -: 16: } 1: 17: printf("j=%d\n",j); call 0 returned 100% 1: 18:} Branch info for each condition Note that a "branch" for gcov is anything that causes the code to execute non-straight line Conditional statement with a compound condition (i.e., a Boolean formula containing && or ||) has more than 2 branches Executed function info