slide 1, presentation: reverse engineering state diagrams from c/c++ code, 29-10-2008 | dennie van...

of 24 /24
Slide 1, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland Masters Project Reverse Engineering state machine diagrams from C/C++ code Vanderlande Industries B.V. (Veghel) Dennie van Zeeland

Author: dale-norris

Post on 31-Dec-2015

213 views

Category:

Documents


0 download

Embed Size (px)

TRANSCRIPT

Graduation ProjectSlide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Masters Project
Vanderlande Industries B.V. (Veghel)
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Outline
Introduction
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Introduction (1)
FALCON project by ESI, VI, 3TU (SET)
baggage handling at airports
express parcel sortation facilities
*
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Introduction (2)
Flow System Controller (FSC)
Controls the product flows in conveyor systems for transport and sortation
Controls all motors, photocells and other active components
Send and receive control and status information
Realtime Control of equipment
*
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Introduction (3)
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Introduction (4)
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Introduction (5)
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Project goal (1)
Why:
V7 is being developed from scratch
Extracting dynamic behavior from source code for V7
Identifying requirements
What kind of documentation
Engineering manual
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Project goal (2)
Extracting State Machine diagrams from code (main focus)
Preprocessing source code
Parsing source code
Creating diagrams
*
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Tools
FSC is written in object oriented C
Current tools only work on C++
No tools are available for state machine extraction
current tool is very specific for FSC (thus not generally applicable for any software system)
No complete state machine can be extracted
Cpp2XMI
C++ to UML-diagrams
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
CPP2XMI
Class, Sequence, Activity Diagram in XML (XMI)-format
*
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
CPP2XMI
Store (internal datastructure) + Layout
Add Layout using Dot-Layout
UML model in XMI 1.1 (with layout)
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Approach
Find 1 specific pattern
Create 2nd parser for CPPML
Storage in internal data structures
State Machine organizer
Adding layout (position information)
XMI writer / DOT writer
Extending with extra patterns
*
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
CPP2XMI
Store (internal datastructure) + Layout
Add Layout using Dot-Layout
UML model in XMI 1.1 (with layout)
Second Parser for CPPML for Objective C
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Example
CPPML
static void obj_control(Obj *obj, ObjEvent event) {… switch (obj->state) { case State_A: switch (event) { case event1: … obj->state = State_B; break; case event2: … obj->state = State_C; … break;} break; case State_B: switch (event) { case event1: … obj->state = State_B; … break; case event3: … obj->state = State_C; … break;} break; default;}}
<struc:Function id='id109‘ name='OBJ_control'> <statm:Switch id='id110'> <statm:hasCondition> {obj->state} </statm:hasCondition> <statm:Block id='id118'> <statm:Switch id='id119'> {event} <statm:hasSubstatement> <statm:Block id='id121'> <expr:Assignment id='id122' kind='askAssignEql'> {obj->state} <expr:Id name='STATE_B' id='id127'/> </expr:Assignment> <statm:Break id='id128'/> </statm:Switch> <stat:Switch> … </stat:Switch> … <statm:CaseLabel id='id135'> <statm:hasCaseValue> <expr:Id name='EVENT1' id='id136'/> </statm:hasCaseValue> <statm:namesNextStatement ref='id122'/> </statm:CaseLabel> …
*
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Example
State Machine Diagram
*
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Extensions / Improvements to CPP2XMI
2nd parser for CPPML
Database storage
Improved command line options
*
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Examples extracted from FSC (V6)
*
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Examples extracted from FSC (V6)
*
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Examples extracted from FSC (V6)
*
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Extensions / Improvements to CPP2XMI
Find more false negatives and their corresponding patterns, implement those.
Add more information to state transitions (conditional state transitions)
Map overlapping states and transitions
Write documentation
*
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Extensions / Improvements to CPP2XMI
Further improvements to CPP2XMI
basic idea:
Find patterns
Based on this classification, determine the classes, methods and attributes
Make diagrams
XMI conversion
*
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Problems encountered
Preprocessing issues
CPPML should have a tree-structure (1 on 1 with AST)
However it’s a DAG, which makes pattern recognition is tricky
CPP2XMI doesn’t extract controlstatements (do, while, if, switch break, continue, etc.) correctly (for C)
Performance issues with CPPML parser
JDOM (Memory peak level: 1,8GB)
SAX (will not solve memory peaks)
Bug in XMI-part
Duplicate id’s, which raises errors when importing XMI into case-tools (Enterprise Architect)
Position information not part of XMI
Enterprise Architect doesn’t do anything with position information
*
Slide *, Presentation: Reverse Engineering state diagrams from C/C++ code, 29-10-2008 | Dennie van Zeeland
Questions?