SlideShare a Scribd company logo
KLEE
* a symbolic virtual machine, built on top of the LLVM compiler infrastructure
* used for generating automatic tests with high coverage
* successor of a similar tool, called EXE
* uses STP as a constraint solver
Official website:
https://klee.github.io/
Installation tutorial:
http://blog.opensecurityresearch.com/2014/07/klee-on-ubuntu-1404-lts-64bit.html
Paper:
http://www.doc.ic.ac.uk/~cristic/papers/klee-osdi-08.pdf
Extension:
Klee-multisolver http://srg.doc.ic.ac.uk/projects/klee-multisolver/
First example
* testing a simple function with Klee
* compile & run in cmd line
Results are in files test*.ktest
Test1: found a negative number
Test2: found 0 as a positive number
#include <klee/klee.h>
int get_sign(int x) {
if (x < 0)
return -1;
return 1;
}
int main() {
int a;
klee_make_symbolic(&a, sizeof(a), "a");
return get_sign(a);
}
> llvm-gcc -I ../../include --emit-llvm -c -g get_sign.c
> klee get_sign.o
> cd klee-last
> ktest-tool --write-ints test000001.ktest > test1.txt
Other examples
* the symbolic variable can be int, char, array of int/char, NO float allowed
* a nice example with Maze:
https://feliam.wordpress.com/2010/10/07/the-symbolic-maze/
* I extended the above example for the Missionaries & cannibals problem,
which runs rather slow and the timing depends a lot on the input data size (in
this case, on the max boat rides allowed to find a solution)
* data initialization:
int shore_left[2], shore_right[2];
shore_left[0] = 3; shore_left[1] = 3;
shore_right[0] = 0; shore_right[1] = 0;
char boat[MAX]; // pairs (m,c) of people transported in one turn
// Make the input symbolic.
klee_make_symbolic(boat, sizeof boat, "boat");
int turns = 0;
while (turns < MAX/2) {
int mboat = turns * 2, cboat = turns * 2 + 1;
klee_assume (boat[mboat] >= 0);
klee_assume (boat[cboat] >= 0);
klee_assume (boat[mboat]+boat[cboat] <= CAPACITY);
// klee_assume (boat[mboat] + boat[cboat] != 0);
turns++;
}
run(shore_left, shore_right, boat); // main function
Other examples – cont.
* for both examples, the acceptable input result is represented as bytes (arrays
of char are easier to read in hexa than arrays of int)
* one of the inputs found for the Missionaries problem:
> klee-stats klee-last run.stats
ICov = instruction coverage; BCov = branch coverage
Files generated
test*.ktest values found for the symbolic variables
info
explored paths, number of queries,
instructions, generated tests
warnings,
messages
generated by Klee
assembly.ll human readable LLVM bitcode
run.stats use klee-stats tool
Useful Klee functions
* klee_make_symbolic (void * addr, unsigned nbytes, const char * name);
* klee_assume ( condition ); // add a constraint and enforce it, avoid &&, ||
* klee_prefer_cex (void * object, unsigned condition ); // gives preference to a
constraint but without forcing it
* klee_assert ( expression ); // klee_assert(0) can be used to signal when a special place in
the code is reached
* klee_abort (); // abort current process
* klee_range ( int begin, int end, const char* name ); // construct a symbolic value in
the interval [begin, end)
* klee_set_forking (unsigned enabled); // 0 to discard other branches in favor of a random one
We can specify the search heuristics:
> klee --search=dfs demo.o
Others accepted are bfs, random-path, random-state, nurs... (non-uniform random search)
Useful Klee functions
* klee_make_symbolic (void * addr, unsigned nbytes, const char * name);
* klee_assume ( condition ); // add a constraint and enforce it, avoid &&, ||
* klee_prefer_cex (void * object, unsigned condition ); // gives preference to a
constraint but without forcing it
* klee_assert ( expression ); // klee_assert(0) can be used to signal when a special place in
the code is reached
* klee_abort (); // abort current process
* klee_range ( int begin, int end, const char* name ); // construct a symbolic value in
the interval [begin, end)
* klee_set_forking (unsigned enabled); // 0 to discard other branches in favor of a random one
We can specify the search heuristics:
> klee --search=dfs demo.o
Others accepted are bfs, random-path, random-state, nurs... (non-uniform random search)

More Related Content

What's hot

Use groovy & grails in your spring boot projects
Use groovy & grails in your spring boot projectsUse groovy & grails in your spring boot projects
Use groovy & grails in your spring boot projects
Fátima Casaú Pérez
 
[BASH] Shell Scripting [ITA]
[BASH] Shell Scripting [ITA][BASH] Shell Scripting [ITA]
[BASH] Shell Scripting [ITA]
Matteo Collica
 
BDD Approach with Karate Framework in Service Tests
BDD Approach with Karate Framework in Service TestsBDD Approach with Karate Framework in Service Tests
BDD Approach with Karate Framework in Service Tests
kloia
 
Java Memory Management Tricks
Java Memory Management Tricks Java Memory Management Tricks
Java Memory Management Tricks
GlobalLogic Ukraine
 
Smarter deployments with octopus deploy
Smarter deployments with octopus deploySmarter deployments with octopus deploy
Smarter deployments with octopus deploy
Thibaud Gravrand
 
MOPCON_2022.pdf
MOPCON_2022.pdfMOPCON_2022.pdf
MOPCON_2022.pdf
JohnLiu64754
 
Yale Jenkins Show and Tell
Yale Jenkins Show and TellYale Jenkins Show and Tell
Yale Jenkins Show and TellE. Camden Fisher
 
13 practical tips for writing secure golang applications
13 practical tips for writing secure golang applications13 practical tips for writing secure golang applications
13 practical tips for writing secure golang applications
Karthik Gaekwad
 
Painless JavaScript Testing with Jest
Painless JavaScript Testing with JestPainless JavaScript Testing with Jest
Painless JavaScript Testing with Jest
Michał Pierzchała
 
Designing with Capabilities
Designing with CapabilitiesDesigning with Capabilities
Designing with Capabilities
Scott Wlaschin
 
C++20 the small things - Timur Doumler
C++20 the small things - Timur DoumlerC++20 the small things - Timur Doumler
C++20 the small things - Timur Doumler
corehard_by
 
Why The Free Monad isn't Free
Why The Free Monad isn't FreeWhy The Free Monad isn't Free
Why The Free Monad isn't Free
Kelley Robinson
 
Kubernetes Basics
Kubernetes BasicsKubernetes Basics
Kubernetes Basics
Antonin Stoklasek
 
Monads do not Compose
Monads do not ComposeMonads do not Compose
Monads do not Compose
Philip Schwarz
 
¡Introducción a Cypress! - Globant Tech Insiders: Automatización de Pruebas
¡Introducción a Cypress! - Globant Tech Insiders: Automatización de Pruebas¡Introducción a Cypress! - Globant Tech Insiders: Automatización de Pruebas
¡Introducción a Cypress! - Globant Tech Insiders: Automatización de Pruebas
Globant
 
Algebraic Data Types for Data Oriented Programming - From Haskell and Scala t...
Algebraic Data Types forData Oriented Programming - From Haskell and Scala t...Algebraic Data Types forData Oriented Programming - From Haskell and Scala t...
Algebraic Data Types for Data Oriented Programming - From Haskell and Scala t...
Philip Schwarz
 
CI and CD with Jenkins
CI and CD with JenkinsCI and CD with Jenkins
CI and CD with Jenkins
Martin Málek
 
Sequence and Traverse - Part 2
Sequence and Traverse - Part 2Sequence and Traverse - Part 2
Sequence and Traverse - Part 2
Philip Schwarz
 
Conan a C/C++ Package Manager
Conan a C/C++ Package ManagerConan a C/C++ Package Manager
Conan a C/C++ Package Manager
Uilian Ries
 
Docker Container Security
Docker Container SecurityDocker Container Security
Docker Container Security
Suraj Khetani
 

What's hot (20)

Use groovy & grails in your spring boot projects
Use groovy & grails in your spring boot projectsUse groovy & grails in your spring boot projects
Use groovy & grails in your spring boot projects
 
[BASH] Shell Scripting [ITA]
[BASH] Shell Scripting [ITA][BASH] Shell Scripting [ITA]
[BASH] Shell Scripting [ITA]
 
BDD Approach with Karate Framework in Service Tests
BDD Approach with Karate Framework in Service TestsBDD Approach with Karate Framework in Service Tests
BDD Approach with Karate Framework in Service Tests
 
Java Memory Management Tricks
Java Memory Management Tricks Java Memory Management Tricks
Java Memory Management Tricks
 
Smarter deployments with octopus deploy
Smarter deployments with octopus deploySmarter deployments with octopus deploy
Smarter deployments with octopus deploy
 
MOPCON_2022.pdf
MOPCON_2022.pdfMOPCON_2022.pdf
MOPCON_2022.pdf
 
Yale Jenkins Show and Tell
Yale Jenkins Show and TellYale Jenkins Show and Tell
Yale Jenkins Show and Tell
 
13 practical tips for writing secure golang applications
13 practical tips for writing secure golang applications13 practical tips for writing secure golang applications
13 practical tips for writing secure golang applications
 
Painless JavaScript Testing with Jest
Painless JavaScript Testing with JestPainless JavaScript Testing with Jest
Painless JavaScript Testing with Jest
 
Designing with Capabilities
Designing with CapabilitiesDesigning with Capabilities
Designing with Capabilities
 
C++20 the small things - Timur Doumler
C++20 the small things - Timur DoumlerC++20 the small things - Timur Doumler
C++20 the small things - Timur Doumler
 
Why The Free Monad isn't Free
Why The Free Monad isn't FreeWhy The Free Monad isn't Free
Why The Free Monad isn't Free
 
Kubernetes Basics
Kubernetes BasicsKubernetes Basics
Kubernetes Basics
 
Monads do not Compose
Monads do not ComposeMonads do not Compose
Monads do not Compose
 
¡Introducción a Cypress! - Globant Tech Insiders: Automatización de Pruebas
¡Introducción a Cypress! - Globant Tech Insiders: Automatización de Pruebas¡Introducción a Cypress! - Globant Tech Insiders: Automatización de Pruebas
¡Introducción a Cypress! - Globant Tech Insiders: Automatización de Pruebas
 
Algebraic Data Types for Data Oriented Programming - From Haskell and Scala t...
Algebraic Data Types forData Oriented Programming - From Haskell and Scala t...Algebraic Data Types forData Oriented Programming - From Haskell and Scala t...
Algebraic Data Types for Data Oriented Programming - From Haskell and Scala t...
 
CI and CD with Jenkins
CI and CD with JenkinsCI and CD with Jenkins
CI and CD with Jenkins
 
Sequence and Traverse - Part 2
Sequence and Traverse - Part 2Sequence and Traverse - Part 2
Sequence and Traverse - Part 2
 
Conan a C/C++ Package Manager
Conan a C/C++ Package ManagerConan a C/C++ Package Manager
Conan a C/C++ Package Manager
 
Docker Container Security
Docker Container SecurityDocker Container Security
Docker Container Security
 

Viewers also liked

Merge sort paralel
Merge sort paralelMerge sort paralel
Merge sort paralel
Georgiana T.
 
BOD of L & T
BOD of L & TBOD of L & T
BOD of L & T
Jaldhi Rastogi
 
Cv mohammad eid 2016
Cv   mohammad eid 2016Cv   mohammad eid 2016
Cv mohammad eid 2016
Mohammad Eid
 
eXplorer: a dynamic statistical data visualization tool to support Italian de...
eXplorer: a dynamic statistical data visualization tool to support Italian de...eXplorer: a dynamic statistical data visualization tool to support Italian de...
eXplorer: a dynamic statistical data visualization tool to support Italian de...
carloamati
 
Ritonavir impurity l
Ritonavir impurity lRitonavir impurity l
Ritonavir impurity l
Naresh Kumar
 
Open Data Standards and Open Source Modeling Tools: The GPL'd Release of Wind...
Open Data Standards and Open Source Modeling Tools: The GPL'd Release of Wind...Open Data Standards and Open Source Modeling Tools: The GPL'd Release of Wind...
Open Data Standards and Open Source Modeling Tools: The GPL'd Release of Wind...
Steve Arnold
 
Startup Garden Lviv 2016 - Shut up & take my money
Startup Garden Lviv 2016 - Shut up & take my moneyStartup Garden Lviv 2016 - Shut up & take my money
Startup Garden Lviv 2016 - Shut up & take my money
Viacheslav Maiakin
 

Viewers also liked (10)

Merge sort paralel
Merge sort paralelMerge sort paralel
Merge sort paralel
 
Yuyos verdes
Yuyos verdesYuyos verdes
Yuyos verdes
 
BOD of L & T
BOD of L & TBOD of L & T
BOD of L & T
 
Cv mohammad eid 2016
Cv   mohammad eid 2016Cv   mohammad eid 2016
Cv mohammad eid 2016
 
Donald Thomas Resume Updated 2014
Donald Thomas Resume Updated 2014Donald Thomas Resume Updated 2014
Donald Thomas Resume Updated 2014
 
eXplorer: a dynamic statistical data visualization tool to support Italian de...
eXplorer: a dynamic statistical data visualization tool to support Italian de...eXplorer: a dynamic statistical data visualization tool to support Italian de...
eXplorer: a dynamic statistical data visualization tool to support Italian de...
 
Ritonavir impurity l
Ritonavir impurity lRitonavir impurity l
Ritonavir impurity l
 
Open Data Standards and Open Source Modeling Tools: The GPL'd Release of Wind...
Open Data Standards and Open Source Modeling Tools: The GPL'd Release of Wind...Open Data Standards and Open Source Modeling Tools: The GPL'd Release of Wind...
Open Data Standards and Open Source Modeling Tools: The GPL'd Release of Wind...
 
Tugas tambahan
Tugas tambahanTugas tambahan
Tugas tambahan
 
Startup Garden Lviv 2016 - Shut up & take my money
Startup Garden Lviv 2016 - Shut up & take my moneyStartup Garden Lviv 2016 - Shut up & take my money
Startup Garden Lviv 2016 - Shut up & take my money
 

Similar to Klee introduction

ESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. NowESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. Now
Krzysztof Szafranek
 
iOS Development with Blocks
iOS Development with BlocksiOS Development with Blocks
iOS Development with Blocks
Jeff Kelley
 
Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014
Béo Tú
 
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the bfinalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
ChereCheek752
 
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docxcase3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
tidwellveronique
 
Let's talk about the cache! - Mathilde Lemée - Codemotion Rome 2015
Let's talk about the cache! - Mathilde Lemée - Codemotion Rome 2015Let's talk about the cache! - Mathilde Lemée - Codemotion Rome 2015
Let's talk about the cache! - Mathilde Lemée - Codemotion Rome 2015Codemotion
 
Java tutorial PPT
Java tutorial  PPTJava tutorial  PPT
Java tutorial PPT
Intelligo Technologies
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
Intelligo Technologies
 
Ive posted 3 classes after the instruction that were given at star.pdf
Ive posted 3 classes after the instruction that were given at star.pdfIve posted 3 classes after the instruction that were given at star.pdf
Ive posted 3 classes after the instruction that were given at star.pdf
deepaarora22
 
Effecient javascript
Effecient javascriptEffecient javascript
Effecient javascript
mpnkhan
 
Better Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web ServicesBetter Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web Services
WSO2
 
Java tut1
Java tut1Java tut1
Java tut1
Ajmal Khan
 
Tutorial java
Tutorial javaTutorial java
Tutorial java
Abdul Aziz
 
Java Tut1
Java Tut1Java Tut1
Java Tut1
guest5c8bd1
 
Zabbix LLD from a C Module by Jan-Piet Mens
Zabbix LLD from a C Module by Jan-Piet MensZabbix LLD from a C Module by Jan-Piet Mens
Zabbix LLD from a C Module by Jan-Piet Mens
NETWAYS
 
Blocks & GCD
Blocks & GCDBlocks & GCD
Blocks & GCD
rsebbe
 
FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6
Dmitry Soshnikov
 
Introduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy CresineIntroduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy Cresine
Movel
 
start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()
Kiwamu Okabe
 

Similar to Klee introduction (20)

ESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. NowESCMAScript 6: Get Ready For The Future. Now
ESCMAScript 6: Get Ready For The Future. Now
 
iOS Development with Blocks
iOS Development with BlocksiOS Development with Blocks
iOS Development with Blocks
 
Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014
 
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the bfinalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
finalprojtemplatev5finalprojtemplate.gitignore# Ignore the b
 
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docxcase3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
 
Let's talk about the cache! - Mathilde Lemée - Codemotion Rome 2015
Let's talk about the cache! - Mathilde Lemée - Codemotion Rome 2015Let's talk about the cache! - Mathilde Lemée - Codemotion Rome 2015
Let's talk about the cache! - Mathilde Lemée - Codemotion Rome 2015
 
Java tutorial PPT
Java tutorial  PPTJava tutorial  PPT
Java tutorial PPT
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
Ive posted 3 classes after the instruction that were given at star.pdf
Ive posted 3 classes after the instruction that were given at star.pdfIve posted 3 classes after the instruction that were given at star.pdf
Ive posted 3 classes after the instruction that were given at star.pdf
 
Effecient javascript
Effecient javascriptEffecient javascript
Effecient javascript
 
Better Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web ServicesBetter Open Source Enterprise C++ Web Services
Better Open Source Enterprise C++ Web Services
 
Java tut1
Java tut1Java tut1
Java tut1
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
 
Tutorial java
Tutorial javaTutorial java
Tutorial java
 
Java Tut1
Java Tut1Java Tut1
Java Tut1
 
Zabbix LLD from a C Module by Jan-Piet Mens
Zabbix LLD from a C Module by Jan-Piet MensZabbix LLD from a C Module by Jan-Piet Mens
Zabbix LLD from a C Module by Jan-Piet Mens
 
Blocks & GCD
Blocks & GCDBlocks & GCD
Blocks & GCD
 
FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6
 
Introduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy CresineIntroduction to ES6 with Tommy Cresine
Introduction to ES6 with Tommy Cresine
 
start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()start_printf: dev/ic/com.c comstart()
start_printf: dev/ic/com.c comstart()
 

Recently uploaded

Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
mz5nrf0n
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
Roshan Dwivedi
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 

Recently uploaded (20)

Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 

Klee introduction

  • 1. KLEE * a symbolic virtual machine, built on top of the LLVM compiler infrastructure * used for generating automatic tests with high coverage * successor of a similar tool, called EXE * uses STP as a constraint solver Official website: https://klee.github.io/ Installation tutorial: http://blog.opensecurityresearch.com/2014/07/klee-on-ubuntu-1404-lts-64bit.html Paper: http://www.doc.ic.ac.uk/~cristic/papers/klee-osdi-08.pdf Extension: Klee-multisolver http://srg.doc.ic.ac.uk/projects/klee-multisolver/
  • 2. First example * testing a simple function with Klee * compile & run in cmd line Results are in files test*.ktest Test1: found a negative number Test2: found 0 as a positive number #include <klee/klee.h> int get_sign(int x) { if (x < 0) return -1; return 1; } int main() { int a; klee_make_symbolic(&a, sizeof(a), "a"); return get_sign(a); } > llvm-gcc -I ../../include --emit-llvm -c -g get_sign.c > klee get_sign.o > cd klee-last > ktest-tool --write-ints test000001.ktest > test1.txt
  • 3. Other examples * the symbolic variable can be int, char, array of int/char, NO float allowed * a nice example with Maze: https://feliam.wordpress.com/2010/10/07/the-symbolic-maze/ * I extended the above example for the Missionaries & cannibals problem, which runs rather slow and the timing depends a lot on the input data size (in this case, on the max boat rides allowed to find a solution) * data initialization: int shore_left[2], shore_right[2]; shore_left[0] = 3; shore_left[1] = 3; shore_right[0] = 0; shore_right[1] = 0; char boat[MAX]; // pairs (m,c) of people transported in one turn // Make the input symbolic. klee_make_symbolic(boat, sizeof boat, "boat"); int turns = 0; while (turns < MAX/2) { int mboat = turns * 2, cboat = turns * 2 + 1; klee_assume (boat[mboat] >= 0); klee_assume (boat[cboat] >= 0); klee_assume (boat[mboat]+boat[cboat] <= CAPACITY); // klee_assume (boat[mboat] + boat[cboat] != 0); turns++; } run(shore_left, shore_right, boat); // main function
  • 4. Other examples – cont. * for both examples, the acceptable input result is represented as bytes (arrays of char are easier to read in hexa than arrays of int) * one of the inputs found for the Missionaries problem: > klee-stats klee-last run.stats ICov = instruction coverage; BCov = branch coverage
  • 5. Files generated test*.ktest values found for the symbolic variables info explored paths, number of queries, instructions, generated tests warnings, messages generated by Klee assembly.ll human readable LLVM bitcode run.stats use klee-stats tool
  • 6. Useful Klee functions * klee_make_symbolic (void * addr, unsigned nbytes, const char * name); * klee_assume ( condition ); // add a constraint and enforce it, avoid &&, || * klee_prefer_cex (void * object, unsigned condition ); // gives preference to a constraint but without forcing it * klee_assert ( expression ); // klee_assert(0) can be used to signal when a special place in the code is reached * klee_abort (); // abort current process * klee_range ( int begin, int end, const char* name ); // construct a symbolic value in the interval [begin, end) * klee_set_forking (unsigned enabled); // 0 to discard other branches in favor of a random one We can specify the search heuristics: > klee --search=dfs demo.o Others accepted are bfs, random-path, random-state, nurs... (non-uniform random search)
  • 7. Useful Klee functions * klee_make_symbolic (void * addr, unsigned nbytes, const char * name); * klee_assume ( condition ); // add a constraint and enforce it, avoid &&, || * klee_prefer_cex (void * object, unsigned condition ); // gives preference to a constraint but without forcing it * klee_assert ( expression ); // klee_assert(0) can be used to signal when a special place in the code is reached * klee_abort (); // abort current process * klee_range ( int begin, int end, const char* name ); // construct a symbolic value in the interval [begin, end) * klee_set_forking (unsigned enabled); // 0 to discard other branches in favor of a random one We can specify the search heuristics: > klee --search=dfs demo.o Others accepted are bfs, random-path, random-state, nurs... (non-uniform random search)

Editor's Notes

  1. KLEE * a symbolic virtual machine, built on top of the LLVM compiler infrastructure * used for generating automatic tests with high coverage * successor of a similar tool, called EXE * uses STP as a constraint solver A better installation tutorial: http://blog.opensecurityresearch.com/2014/07/klee-on-ubuntu-1404-lts-64bit.html Examples: http://klee.github.io/tutorials/