• No results found

CiaoPP Demo. Pedro López-García 1, Edison Mera 2 and Teresa Trigo 1. ES PASS Barcelona Jun. 26, 2008

N/A
N/A
Protected

Academic year: 2021

Share "CiaoPP Demo. Pedro López-García 1, Edison Mera 2 and Teresa Trigo 1. ES PASS Barcelona Jun. 26, 2008"

Copied!
19
0
0

Loading.... (view fulltext now)

Full text

(1)

CiaoPP Demo

Pedro L ´opez-Garc´ıa

1

, Edison Mera

2

and Teresa Trigo

1

(with Manuel Hermenegildo, 1,3,4 J. Navas 3 and M. M ´endez 3)

CLIP Group 1

Fac. Inform ´atica, U. Polit ´ecnica de Madrid 2Fac. Inform ´atica, U. Complutense de Madrid 3

CS and EECE Depts., U. of New Mexico, USA 4IMDEA SW Development Technology Institute

(2)

Index

ES PASS

Introduction to CiaoPP

O.S. and development environments Input & Output

CiaoPP under Emacs Graphic interface Examples

1. Fact.java & Fib.java 2. Files.java

3. CellPhone.java

(3)

ES PASS Staff

PhD:

Manuel Hermenegildo Salinas Pedro L ´opez-Garc´ıa

Francisco Bueno Carrillo Manuel Carro Linares Student:

Mar´ıa Teresa Trigo de la Vega Collaborator:

(4)

ES PASS Roadmap WP3

Main milestones:

T0 + 3 [Finished] D301 UPM Tool survey CiaoPP (initial description of CiaoPP capabilities and limitations).

T0 + 9 [Finished] D3.10.1 Report on the extension of the CiaoPP assertion language to express user-defined resources.

T0 + 15 [Ongoing] D3.10.2 Report on the extension of CiaoPP to infer functions which yield (upper and lower bounds on) execution times of procedures in a program as a function of input data size.

T0 + 15 [Ongoing] D3.10.3 Extended CiaoPP analyzer prototype.

T0 + 21 [Ongoing] D3.10.4 Report on the adaptation of the CiaoPP analyzers to infer both upper and lower bounds on usage of user-defined resources. [Ongoing]

(5)

ES PASS Roadmap WP5

Main milestones:

T0 + 24 [Ongoing] D5.1.1 Knowledge database on new static analysis tools and techniques.

T0 + 24 D5.1.2 Calendar of academic and industrial events.

T0 + 12 D5.6.1 b First version of the training material and documentation.

(6)

Introduction to CiaoPP

A preprocessor integrated in development environments (emacs, eclipse) Performs error detection, verification, and source-to-source transformations:

Input: program (optionally w/assertions) and libraries (interfaces) Output: error/warning messages + transformed program, with

Results of static checking of assertions / verification (and certificates for Abstraction Carrying Code)

Assertion run-time checking code

High-level optimizations (specialization, slicing, parallelization)

Results of analysis (as assertions): used for low-level optimizations Language support:

Ciao (our CLP-based multiparadigm language) + Java and Java bytecode Underlying technology:

Modular polyvariant abstract interpretation Modular abstract multiple specialization

(7)

Introduction. CiaoPP ES PASS Property Coverage

P1: Safe removal of unreachable code

Via (abstract) partial evaluation and slicing

P2: Absence of run-time errors

Null pointer detection Array bounds checking Type inference / checking

P4: Safe estimation for worst-case execution times (WCET)

Upper and lower bound on number of execution steps Upper and lower bounds on execution time

as functions of input data sizes

P6: User-defined functional or safety properties

Upper and lower bounds on usage of a wide class of user-defined resources E.g., bytes sent/received over the Internet, SMSs sent or received, monetary units spent, memory, stack usage, etc

(8)

O.S. & development environments

Operating Systems

Distributions for Linux / Unix (32 bits) Windows compatible (32 bits)

64 bits

32 bits Operating System Virtual Machine

• Virtual appliance with Ciao Development environments

Emacs

emacs21

(9)

Input & Output

Fibonacci:

Fib.java Fib.pl

package examples: :- module( fib, [ fib/2 ], [ assertions, regtypes, predefres( res arith ), res arith( res arith comp ) ] ).

import soot.resources.Resource;

import soot.resources.annotations.Resources;

@Resources(Resource.STEPS) :- entry fib( X, Y ) : num * var. public class Fib{ fib( 0, 0 ) :- !.

public int fib(int n){ fib( 1, 1 ) :- !. if (n == 0){ fib( M, N ) :-return 0; M1 is M-1, } M2 is M-2, else if (n == 1){ fib( M1, N1 ), return 1; fib( M2, N2 ), } N is N1 + N2 else{

return fib(n - 1) + fib(n - 2);

} } }

(10)

Input & Output

Input: program (optionally w/assertions) and libraries (interfaces) Examples of input assertions:

Ciao:

:- entry fib( X, Y ) : num * var. In general:

:- Status pred PredDesc [:PrecC] [=>PostC] [+Comp] Status = [check|true/false|trust|checked|entry]

Java:

import soot.resources.Resource;

import soot.resources.annotations.Resources; @Resources({Resource.STEPS})

Resources: ACCESSES_DB, BYTES_RECEIVED, CLOSED_FILES,

COST_IN_DOLLARS, DATA_STORED, ENERGY_CONSUMED, HEAP_USAGE, OPENED_FILES, SCREEN_WIDTH, SIZE, STACK_USAGE, STEPS

(11)

Input & Output

Output: transformed program Examples of output assertions:

Ciao:

:- true pred fib(X,Y) : ( num(X), var(Y) ) => ( num(X), int(Y), size(ub,X,int(X)), size(ub,Y,0.4472135954999579*exp(1.618033988749895,int(X)) -0.4472135954999579*exp(-0.6180339887498949,int(X))) ) + steps_ub(1.447213595499958*exp(1.618033988749895,int(X)) +0.5527864045000421*exp(-0.6180339887498949,int(X))-1.0). Java: /** * true

* if (arg(1)/top && this/top && ret/top) { * arg(1)/top && this/top && ret/top &&

* size(ub,ret,0.4472135954999579*exp(1.618033988749895, * int(arg(1)))-0.4472135954999579*exp(-0.6180339887498949, * int(arg(1)))) && size(ub,this,size(this)) &&

* size(ub,arg(1),int(arg(1))) * } * && cost(ub,STEPS,7.683281572999747*exp(1.618033988749895, * int(arg(1)))+2.316718427000253* * exp(-0.6180339887498949,int(arg(1)))-8.0) */

(12)

Input & Output

Input (Fib.java) Output (Fib resources co.java) package examples: package examples:

import soot.resources.Resource; import soot.resources.Resource;

import soot.resources.annotations.Resources; import soot.resources.annotations.Resources; @Resources(Resource.STEPS) @Resources(Resource.STEPS)

public class Fib{ public class Fib{

/** * true

* if (arg(1)/top1&& this/top && ret/top){

* arg(1)/top && this/top && ret/top &&

* size(ub,ret,0.4472135954999579*exp(1.618033988749895,int(arg(1))) * -0.4472135954999579*exp(-0.6180339887498949, int(arg(1)))) * && size(ub,this,size(this)) && size(ub,arg(1),int(arg(1)))

*}

* && cost(ub,STEPS,7.683281572999747*exp(1.618033988749895, int(arg(1))) * +2.316718427000253* exp(-0.6180339887498949,int(arg(1)))-8.0)

*/

public int fib(int n){ public int fib(int n){

if (n == 0){ if (n == 0){ return 0; return 0; } } else if (n == 1){ else if (n == 1){ return 1; return 1; } } else{ else{

return fib(n - 1) + fib(n - 2); return fib(n - 1) + fib(n - 2);

} }

} }

} }

(13)

CiaoPP under Emacs. Graphic interface

1. C-c M in the program’s buffer. It loads the graphic interface

2. Menu options:

Select Menu Level: [naive] (naive) ?

Select Action Group: [analyze] (analyze) ?

Select Aliasing-Mode Analysis: [none, java_nullity] (none) ? Select Shape-Type Analysis: [none, java_cha] (none) ?

Select Resource Analysis: [none, resources] (resources) ? Multivariant Success: [off, on] (off) ?

Print Program Point Info: [off, on] (off) ?

Collapse AI Info: [off, on] (on) ?

Note: Current Saved Menu Configurations: [] Menu Configuration Name: (none) ?

(14)

Examples: 1. Fact.java & Fib.java

Targets:

To illustrate the functioning of the analyzer To check the correctness of the results Complete modules (without interfaces) Resources: steps of execution

(15)

Examples: 2. Files.java

Targets:

To observe how the results depends on the program (change the program and take a look at the new output)

To discover another uses of the resources analysis Complete modules (without interfaces)

Resources: data stored, opened files and closed files

(16)

Examples: 3. CellPhone.java

Targets:

To illustrate the behaviour of the analyzer with a commercial example (which is also more complex)

To observe the use of user-defined resources Complete modules (with imported elements) Resources: cost in dollars

(17)

Examples: 3. CellPhone.java. Equations

Size: sizeret(Sr0, Sr1, Sr2, Sr3) ≤      0 if Sr1 = 0 7× Sr1 − 6 + sizeret(Sr0, Sr1 − 1, Sr2, Sr3) if Sr1 > 0 sizeret(Sr0, Sr1, Sr2, Sr3) ≤ 3.5× S 2 r1 − 2.5 × Sr1 Resources: costsendSms(Sr0, Sr1, Sr2, Sr3) ≤      0 if Sr1 = 0 12 × Sr1 − 12 + costsendSms(Sr0, Sr1 − 1, Sr2, Sr3) if Sr1 > 0 costsendSms(Sr0, Sr1, Sr2, Sr3) ≤ 6× S 2 r1 − 6 ×Sr1

(18)

Examples: 4. SensorNetworkLoop.java

Targets:

To illustrate the behaviour of the analyzer with an incomplete example (a simple example)

Incomplete modules (with interfaces)

Sizes and costs that can’t be inferred by means of assertions Resources: energy consumed

(19)

References

Related documents

Make measurements on timeslot 0 [FREQUENCY] {Timeslot Off} [Enter] Activate the ORFS measurement (figure 25) [MEASURE] {GMSK Output RF The default setting measures spectrum

investment advice (for the relevant information requirement, see Article 24(3) of the MiFID II draft). Only then is it actually possible for banks to offer this service without

— Sutural angle of elytra without small tooth; head, antennae, scutellum, legs, and venter (except abdominal sterna laterally) black; pronotum yellow with disc black from base to

It is the (education that will empower biology graduates for the application of biology knowledge and skills acquired in solving the problem of unemployment for oneself and others

As shown in this study, loyalty to the organization resulting from merger or acquisition has different intensity level for employees in different hierarchical

Itron wideband systems operate across 120 channels and are designed to receive up to 120 separate transmissions simultaneously, each at 37.5 kbps (kbps = kilo bits per second)

PerformanceIN grants you permission to store and print from this material for your own personal and commercial use.. No part of this publication may be reproduced without