1
Software Component Protocol Inference
Tao Xie General Examination Presentation
- Dept. of Computer Science and Engineering
University of Washington 6 June 2003
Software Component Protocol Inference Tao Xie General Examination - - PowerPoint PPT Presentation
Software Component Protocol Inference Tao Xie General Examination Presentation Dept. of Computer Science and Engineering University of Washington 6 June 2003 1 Outline Background Overview of protocol inference Dynamic protocol
1
University of Washington 6 June 2003
2
3
4
Example: java.util.zip.zipOutputStream
public class ZipOutputStream extends DeflaterOutputStream implements ZipConstants { public ZipOutputStream(OutputStream out); public static final int DEFLATED; public static final int STORED; public void close() throw IOException; public void closeEntry() throw IOException; public void finish () throws IOException; public void putNextEntry(ZipEntry e) throws IOException; public void setComment(String comment); public void setLevel(int level); public void setMethod(int method); public synchronized void write(byte[] b, int off, int len) throws IOException; }
5
you can write the contents of that entry with the write() methods. you can also specify the compression speed/strength tradeoff bypassing a number from 1 to 9 to setLevel(). If you use DEFLATED [for setMethod()],
The constants DEFLATED and STORED are the two legal values for setMethod(). If you use STORED, the entry is stored in the ZIP file without any compression.
you can set the compression method and level with setMethod() and setLevel(). Before beginning an entry with putNextEntry(), you can begin a new one by calling putNextEntry() again, or you can close the current entry with closeEntry(), or you can close the stream itself with close(). When you reach the end of an entry, Once you have begun an entry with putNextEntry(),
6
S
DEFLATED STORED
setMethod(m) [m=STORED] setMethod(m) [m= DEFLATED] setLevel setMethod(m) [m=STORED] close setMethod(m) [m=DEFLATED] close write closeEntry putNextEntry putNextEntry write
E
putNextEntry putNextEntry write write closeEntry
(FSA)
<DEFLATED> putNextEntry, write*, closeEntry? <DEFLATED>
7
8
9
10
FSA-like models to a model checker
Static C protocol code Lie et al. [LCED01]
Frequently recurring usage patterns
Dynamic Interactive system El-Ramly et al. [ESS02] FSA Dynamic Software process Cook et al. [CW98] FSA Dynamic C Ammons et al. [ABL02] FSA Dynamic Java, C++, and C Reiss et al. [RR01] FSA Static and Dynamic Java Whaley et al. [WML02]
11
–e.g. DEFLATED and STORED groups
Interface:a,b,c,d,e
–e.g. Concurrent FSAs –e.g. setMethod(DEFLATED),setMethod(STORED) –e.g. pop() when currentSize>0 –Illegal sequences in traces or client code –Method calls without any sequencing constraints
12
13
Scenarios Protocols Traces
14
Scenarios Protocols Traces
15
Scenarios Protocols Traces
16
setMethod putNextEntry write closeEntry close setMethod putNextEntry write write closeEntry close
Object1 Object2
setMethod putNextEntry write closeEntry close setMethod putNextEntry write write closeEntry close
Object1 Object2
17
Object1 Object2
The method field: setMethod, putNextEntry The entry field: putNextEntry, write, closeEntry
setMethod putNextEntry write closeEntry close
setMethod putNextEntry write write closeEntry close
18
19
fopen():return=0x40,fprintf(fp=0x40),fscanf(fp=0x40),fclose(fp=0x40)
fopen():return=0x40 fprintf(fp=0x40) fscanf(fp=0x40) fclose(fp=0x40)
20
fopen():return=0x40 fprintf(fp=0x40) fscanf(fp=0x40) fclose(fp=0x40)
21
Scenarios Protocols Traces
22
23
24
closeEntry,close
s
E S
cl c w w w p cl c w w p c w w p s
Initial FSA
putNextEntry
E S
close
closeEntry closeEntry
write
setMethod
Noise:
[Cook et al.]
[Ammons et al.] Merge 2-tail of p, w
S
c w c c w w p s
E
cl cl
Merge 2-tail of w, w
25
[Whaley et al.]
26
setMethod,putNextEntry,write,write,closeEntry,putNextEntry,write,write,cl
Last state-modifying method history Method call
setMethod(),putNextEntry(),write(),write(),write(),closeEntry(),close() START putNextEntry() putNextEntry() write() putNextEntry() write() putNextEntry() write() putNextEntry() closeEntry() closeEntry() END
Last state-modifying method Method call
putNextEntry() putNextEntry() write() putNextEntry() closeEntry()
putNextEntry
putNextEntry() putNextEntry() putNextEntry() write() write() putNextEntry() closeEntry() closeEntry() START S
putNextEntry
putNextEntry()
closeEntry
closeEntry() write write() END
E
27 write write
putNextEntry
putNextEntry
write
closeEntry
S E Submodel for the entry field
putNextEntry close closeEntry
E Submodel for the closed field
closeEntry
S E Submodel for the crc field write
putNextEntry putNextEntry
write
closeEntry
S E Submodel for the written field
putNextEntry
E S
close
closeEntry closeEntry
write
setMethod
A single FSA model by 2-tails algorithm write S
28
–e.g. DEFLATED and STORED groups
Interface:a,b,c,d,e
–e.g. Concurrent FSAs –e.g. setMethod(DEFLATED),setMethod(STORED) –e.g. pop() when currentSize>0 –Illegal sequences in traces or client code –Method calls without any sequencing constraints
29
Submodel for the closed field Submodel for the entry field
Removing states with low frequency Removing edges with low frequency
Handling unrelated methods by separation
robustness to noise
Composition
Cook et al.
Composition
Ammons et al.
Composition
Reiss et al.
Separation
Whaley et al.
data-dependent transitions separation/ composition of constraints
Previous work
S
DEFLATED STORED
setMethod(m) [m=STORED] setMethod(m) [m= DEFLATED] setLevel setMethod(m) [m=STORED] close setMethod(m) [m=DEFLATED] close write closeEntry putNextEntry putNextEntry write
E
putNextEntry putNextEntry write write closeEntry
putNextEntry
E
S
close closeEntry closeEntry write setMethod putNextEntry putNextEntry write closeEntry
S E
putNextEntry close E write
……
closeEntry
<DEFLATED> putNextEntry, write*, closeEntry? <DEFLATED>
A single FSA model by 2-tails algorithm S
30
Traces
Scenarios Protocols
31
Ammons et al. Cook et al. Reiss et al. Whaley et al.
32
[Ammons 03]
33
34
Trace Collection Scenario Extraction Protocol Inference Protocol Usage
Scenarios Protocols Traces
35
public void closeEntry() throws IOException { …… entry = null; } public synchronized void write(byte[] b, int off, int len) throws IOException { ……(no writes of entry) if (entry == null) { throw new ZipException("no current ZIP entry"); } …… }
36
37
putNextEntry, write, closeEntry
putNextEntry, write √ write, putNextEntry × putNextEntry, closeEntry √ closeEntry, putNextEntry √ write, closeEntry × closeEntry, write ×
38
putNextEntry
E S
close
closeEntry closeEntry
write
setMethod
A single FSA model by 2-tails algorithm
Dynamic spec inference Spec-based test generation
Tests
39
W R W entry W names W R method W R R R closed setMethod close R R W locoff W W W written W W crc W entries closeEntry write putnextEntry
c0 c1 c2
closed method written
c3
entry
c4 c5
locoff crc names
∅
c0=all methods c1={putnextEntry,setMethod} c2={close,closeEntry,putnextEntry,write} c3={closeEntry,putnextEntry,write} c4={closeEntry,write} c5={putnextEntry}
entries methods fields
40
{ case DEFLATED:… case STORED:… }
–e.g. setMethod(DEFLATED),setMethod(STORED) –e.g. pop() when currentSize>0
41
Trace Collection Scenario Extraction Protocol Inference Protocol Usage
Scenarios Protocols Traces
42
43
44
45
N/A N/A N/A
El-Ramly et al.
N/A N/A N/A
Cook et al. √ (client code) Ammons et al. √ (JVMPI) Reiss et al. √ (component code) Whaley et al. Execution environment Bytecode/executable instrumentation Source code instrumentation Previous work
46
+ does it once for all (clients) + without requiring the availability of the client code
+ better control of the instrumentation scope + without requiring the availability of the component code
+ Combine the above two
47
public void putNextEntry(ZipEntry e) throws IOException { ensureOpen(); if (entry != null) { closeEntry();// close previous entry } …… }
48
– Performed while the system is running
– Performed after the system has terminated
49
50
51
Legacy system reengineering Process validation Trace verification, Specification debugging Alg parameter tuning Test suite characterization, Software auditing
Protocol usage
IPM2 algorithm Interaction-based Screen Ids El-Ramly et al. k-tails algorithm, Markov algorithm n/a Process events Cook et al. sk-strings algorithm Flow dependence, Simplification, Standardization Method calls, Argument/return values Ammons et al. k-tails algorithm Object-based Method calls, Class/Object Ids Reiss et al. Separation of state modifying and state preserving methods Object-based, Slicing by member fields Method calls, Class/Object Ids Whaley et al.
Protocol inference Scenario extraction Trace collection Previous work
52
program slicing [Lie et al. 01].
et al. 01].