Software Testing and Verificaton (SWTV) group

Slides:



Advertisements
Similar presentations
1/20 Generalized Symbolic Execution for Model Checking and Testing Charngki PSWLAB Generalized Symbolic Execution for Model Checking and Testing.
Advertisements

Background for “KISS: Keep It Simple and Sequential” cs264 Ras Bodik spring 2005.
Automated creation of verification models for C-programs Yury Yusupov Saint-Petersburg State Polytechnic University The Second Spring Young Researchers.
Complexity Analysis (Part I)
Overview of program analysis Mooly Sagiv html://
Overview of program analysis Mooly Sagiv html://
1 The Problem o Fluid software cannot be trusted to behave as advertised unknown origin (must be assumed to be malicious) known origin (can be erroneous.
Regression testing Tor Stållhane. What is regression testing – 1 Regression testing is testing done to check that a system update does not re- introduce.
LLVM Developed by University of Illinois at Urbana-Champaign CIS dept Cisc 471 Matthew Warner.
Chapter 1 Algorithm Analysis
Prof. amr Goneid, AUC1 CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 10. Pointers & Dynamic Data Structures.
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
Proof Carrying Code Zhiwei Lin. Outline Proof-Carrying Code The Design and Implementation of a Certifying Compiler A Proof – Carrying Code Architecture.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 2.
Computer Science Detecting Memory Access Errors via Illegal Write Monitoring Ongoing Research by Emre Can Sezer.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
Basics of Java IMPORTANT: Read Chap 1-6 of How to think like a… Lecture 3.
Introduction to Software Testing Chapter 8.1 Building Testing Tools –Instrumentation Paul Ammann & Jeff Offutt
Java Basics Hussein Suleman March 2007 UCT Department of Computer Science Computer Science 1015F.
An Undergraduate Course on Software Bug Detection Tools and Techniques Eric Larson Seattle University March 3, 2006.
Operated by Los Alamos National Security, LLC for DOE/NNSA DC Reviewed by Kei Davis SKA – Static Kernel Analysis using LLVM IR Kartik Ramkrishnan and Ben.
Question of the Day  What three letter word completes the first word and starts the second one: DON???CAR.
LLVM Simone Campanoni
Dr. Hussien Sharaf Dr Emad Nabil. Dr. Hussien M. Sharaf 2 position := initial + rate * Lexical analyzer 2. Syntax analyzer id 1 := id 2 + id 3 *
LECTURE 10 Semantic Analysis. REVIEW So far, we’ve covered the following: Compilation methods: compilation vs. interpretation. The overall compilation.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Algorithm Analysis 1.
Complexity Analysis (Part I)
Simone Campanoni LLVM Simone Campanoni
Clang Plugins working group
Profile-Guided Optimization in the LDC D compiler
Context-Sensitive Analysis
Compiler Construction (CS-636)
Static Single Assignment
Testing and Debugging.
Compiler Chapter 9. Intermediate Languages
Optimization Code Optimization ©SoftMoore Consulting.
Simone Campanoni LLVM Simone Campanoni
MobiSys 2017 Symbolic Execution of Android Framework with Applications to Vulnerability Discovery and Exploit Generation Qiang Zeng joint work with Lannan.
Moonzoo Kim CS Dept. KAIST
CS453: Automated Software Testing
State your reasons or how to keep proofs while optimizing code
Volatiles Are Miscompiled, and What to Do about It
Moonzoo Kim CS Dept. KAIST
CS360 Windows Programming
LLVM Pass and Code Instrumentation
Java Byte Codes (0xCAFEBABE) cs205: engineering software
Algorithm design and Analysis
SUDS: An Infrastructure for Creating Bug Detection Tools
Security in Java Real or Decaf? cs205: engineering software
Generic Lightweight Druntime
Lecture 15 (Notes by P. N. Hilfinger and R. Bodik)
CSE401 Introduction to Compiler Construction
Coding Concepts (Sub- Programs)
Moonzoo Kim School of Computing KAIST
Analysis of Algorithms
Language-based Security
IntroductionToPHP Static vs. Dynamic websites
Moonzoo Kim School of Computing KAIST
Regression testing Tor Stållhane.
Introduction to Data Structure
Course Overview PART I: overview material PART II: inside a compiler
Paul Ammann & Jeff Offutt
Compiler Structures 1. Overview Objective
Complexity Analysis (Part I)
Can Embeddings Detect Heartbleed?
Complexity Analysis (Part I)
Procedures & Macros Introduction Syntax Difference.
Chapter 11 Introduction to Programming in C
Advanced Analysis of Algorithms
Presentation transcript:

Software Testing and Verificaton (SWTV) group Clang v.s. LLVM Moonzoo Kim Software Testing and Verificaton (SWTV) group CS Dept. KAIST 2019-05-12

Comparison of Clang and LLVM Pros Source code information (e.g., line/column number) is available Clang supports source-to-source transformation Complex high-level language semantics are lowered to relatively simple instructions An analysis tool using LLVM can be programming language independent Cons A user should handle complex C/C++ language semantics (e.g., side effect, various AST node types) Source code information is lost Application C’s undefined behavior checker Source code refactoring tool Source code browser (e.g., Source Insight) Static analyzer for bug detection Test generator Runtime monitoring tool 2019-05-12

An Example of Clang’s Use Cases You need to use Clang to develop a checker for C/C++’s undefined behaviors in source code Undefined behaviors in C code will be removed in transformed LLVM IR Line 4 of C code containing an undefined behavior is transformed into well-defined LLVM instructions LLVM bytecode (Simplified version) 1 define i32 @example() { 2 store i32 1, i32* %a 3 %1 = load i32* %a 4 %2 = add i32 %1, 1 5 store i32 %2, i32* %a 6 %3 = load i32* %a 7 %4 = add i32 %3, 1 8 store i32 %4, i32* %a 9 %5 = add i32 %1, %4 10 store i32 %5, i32* %b 11 %6 = load i32* %b 12 ret i32 %6 } C code 1 int example(){ 2 int a = 1, b; 3 // Undefined behavior 4 b = a++ + ++a; 5 return b;} 2019-05-12

An Example of LLVM’s Use Cases (1/3) Using LLVM to develop a run-time checker by inserting assertions is easier than using Clang When we use Clang for analyzing C source code, we need to handle C’s complex language semantics including side effects Suppose that we would like to do array bound checking by inserting assert() before array accesses One possible solution is to use Clang to insert assert() to check array subscription expression can be greater than the size of array Will it Okay? An example program 1 int example(int x){ 2 int a[10], b[10]; 3 … omitted code … 4 // Want to check array bound 5 b[++a[x++]]=0; 6 …} An instrumented program 1 int example(int *a,int x){ 2 int b[10]; 3 … omitted code … 4 assert(++a[x++]<10); 5 b[++a[x++]]=0; 6 …} 2019-05-12

An Example of LLVM’s Use Cases (2/3) The array subscription expression ++a[x++] has side effects Executing assert(++a[x++]) changes the value of x and a[x] We should execute the array subscription expression once and store the result to use both assert() and array access In addition, we should do array bound check for the array subscription expression ++a[x++] itself. If we choose Clang to develop a run-time checker to insert assert(), we should consider such complex semantics of C program code An instrumented program rev. 2 1 int example(int *a,int x){ 2 int b[10]; 3 … omitted code … 4 int tmp1=x++; 5 assert(tmp1<10); 6 int tmp2=++a[tmp1] 7 assert(tmp2<10); 9 b[tmp2]=0; 10 …} An example program 1 int example(int x){ 2 int a[10], b[10]; 3 … omitted code … 4 // Want to check array bound 5 b[++a[x++]]=0; 6 …} 2019-05-12

An Example of LLVM’s Use Cases (3/3) If we use LLVM to perform array bound check, we can simply instrument the getelementptr instruction (LLVM instruction for array accesses) to check the 3rd parameter (array index) of the instruction We do not suffer side effects because all side effects in C code are removed by LLVM front-end LLVM bytecode (Simplified version) 1 define i32 @example(i32 %x) { 2 %1 = alloca i32 3 %a = alloca [10 x i32] 4 %b = alloca [10 x i32] … omitted code … 9 %4 = sext i32 %2 to i64 10 %5 = getelementptr [10 x i32]* %a, i32 0, i64 %4 ; access to array a[10] 14 %8 = sext i32 %7 to i64 15 %9 = getelementptr [10 x i32]* %b, i32 0, i64 %8 ; access to array b[10] An example program 1 int example(int *a,int x){ 2 int b[10]; 3 // Want to check array bound 4 b[++a[x++]]=0; 5 …} 2019-05-12