2010 01 lecture sig um mfes 3 - reverse engineering

23
91 I 112 Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010. Structure of the lecture Analysis Static Analysis Dynamic Analysis testing metrics models patterns

Upload: jstvssr

Post on 27-Jan-2015

112 views

Category:

Education


3 download

DESCRIPTION

 

TRANSCRIPT

Page 1: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

91 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

Structure of the lecture

Analysis

StaticAnalysis

DynamicAnalysis

testingmetrics modelspatterns

Page 2: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

92 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

REVERSE ENGINEERING

Page 3: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

93 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

abstractconcrete

Models / SpecificationsUML, ER, VDM, …

ProgramsJava, SQL, Perl, …

Reverseengineering

Re-engineering

Terminology

Page 4: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

94 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

Reverse engineering

Dependencies and graphs• Extraction, manipulation, presentation• Graph metrics• Slicing

Advanced• Type reconstruction• Concept analysis• Programmatic join extraction

Page 5: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

95 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

Extraction

From program sources, extract basic information into an initialsource model.

Manipulation

Combine, condense, aggregate, or otherwise process the basicinformation to obtain a derived source model.

Presentation

Visualize or otherwise present source models to a user.

Reverse engineering trinity

Page 6: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

96 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

Green oval = moduleBlue oval = table

Purple arrow = select operationYellow arrow = insert/update operationBrown arrow = delete operation

Example

Page 7: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

97 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

Example

Tables used by multiple modules. Tables used by a single module.

Page 8: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

98 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

Relation

type Rel a b = Set (a,b) set of pairs

Graph

type Gph a = Rel a a endo-relation

Labeled relation

type LRel a b l = Map (a,b) l map from pairs

Note

Rel a b = Set(a,b)= Map(a,b)()= LRel a b ()

Relations and graphs

Page 9: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

99 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

Slicing (forward)

Page 10: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

100 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

Slicing (backward)

Page 11: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

101 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

Chop = Forward ∩ Backward

Page 12: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

102 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

abstractconcrete

Javaprogram Excel

spreadsheet Systemarchitecture

slice(interactive)

Graph(control flow,

data flow,structure, …)

extract

new program/ spreadsheet/ architecture

transform

Generic slicing

Page 13: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

103 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

SeeArun Lakhotia.Graph theoretic foundations of program slicing and integration.The Center for Advanced Computer Studies, University of Southwestern Louisiana.Technical Report CACS TR-91-5-5, 1991.

Further reading

Page 14: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

104 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

See• Arie van Deursen and Leon Moonen. An empirical Study Into Cobol Type

Inferencing. Science of Computer Programming 40(2-3):189-211, July 2001

Basic idea

1. Extract basic relations (entities are variables)- assign: ex. a := b- expression: ex. a <= b- arrayIndex: ex. A[i ]

2. Compute derived relations- typeEquiv: variables belong to the same type- subtypeOf: variables belong to super/subtype- extensional notion of type: set of variables

Type reconstruction(from type-less legacy code)

Page 15: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

105 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

Pseudo code from paper

Type reconstruction(from type-less legacy code)

Page 16: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

106 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

Type reconstruction(from type-less legacy code)

Datatype VariableGraph v array = (Rel v v, Rel v array, Rel v v)

type TypeGraph x = (Rel x x, Rel x x) -- subtypes and type equiv

OperationtypeInference :: (Ord v, Ord array) => VariableGraph v array -> TypeGraph v

Page 17: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

107 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

See• Christian Lindig. Fast Concept Analysis. In Gerhard Stumme, editors, Working

with Conceptual Structures - Contributions to ICCS 2000, Shaker Verlag,Aachen, Germany, 2000.

Basic idea

1. Given formal context - matrix of objects vs. properties

2. Compute concept lattice - a concept = (extent,intent) - ordering is by sub/super set relation on intent/extent

Used in many fields, including program understanding.

Formal concept analysis

Page 18: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

108 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

Note that _’ operation denotes computation of intent from extent, orvice versa, implicitly given a context.

Formal concept analysispseudo-code (1/2)

Page 19: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

109 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

Transposition to Haskell?

Formal concept analysispseudo-code (2/2)

Page 20: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

110 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

Representation

type Context g m = Rel g mtype Concept g m = (Set g, Set m)type ConceptLattice g m

= Rel (Concept g m) (Concept g m)

Algorithmneighbors :: (Ord g, Ord m) => Set g -- extent of concept -> Context g m -- formal context -> [Concept g m] -- list of neighbors

lattice :: (Ord g, Ord m) => Context g m -- formal context -> ConceptLattice g m -- concept lattice

Formal concept analysis

Page 21: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

111 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

Ongoing projects at SIG

Repository mining• Analyze relationships between code/commits/issues through time• Clustering and decision trees• Popularity index for programming languages, frameworks, …

Quality and metrics• Generalized method for derivation of quality profiles• Metrics for architectural quality and evolution• Quality models for BPEL, SAP, Sharepoint, …

Large-scale source code analysis• Detection of “events” in data streams• Using the Amazon cloud• Metrics warehouse

Page 22: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

112 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

Possible MFES projects at SIG

Massively parallel source code analysis• Use Hadoop framework for Map-Reduce• Put algebraic API on top• Construct example analyses

Java library binary relational algebra• Extend to “labeled” relations (matrix algebra)• Extend with advanced algorithms (e.g. concept analysis)

Randomized testing for Java• Study existing approaches• Build / extend tool

Page 23: 2010 01 lecture SIG UM MFES 3 - Reverse engineering

113 I 112

Software Analysis and Testing, MFES Universidade do Minho by Joost Visser, Software Improvement Group © 2010.

More info? Feel free to contact…

Dr. ir. Joost Visser E: [email protected] W: www.sig.nl T: +31 20 3140950