1 legacy system evolution through model-driven program transformation funded by the darpa...

17
1 Legacy System Evolution through Model-Driven Program Transformation Funded by the DARPA Information Exploitation Office (DARPA/IXO), under the Program Composition for Embedded Systems (PCES) program Jing Zhang and Jeff Gray {zhangj, gray} @ cis.uab.edu http://www.cis.uab.edu/zhangj http://www.cis.uab.edu/gray

Upload: james-garrett

Post on 26-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Legacy System Evolution through Model-Driven Program Transformation Funded by the DARPA Information Exploitation Office (DARPA/IXO), under the Program

1

Legacy System Evolution through Model-Driven

Program Transformation

Funded by the DARPA Information Exploitation Office (DARPA/IXO), under theProgram Composition for Embedded Systems (PCES) program

Jing Zhang and Jeff Gray{zhangj, gray} @ cis.uab.eduhttp://www.cis.uab.edu/zhangjhttp://www.cis.uab.edu/gray

Page 2: 1 Legacy System Evolution through Model-Driven Program Transformation Funded by the DARPA Information Exploitation Office (DARPA/IXO), under the Program

2

Contents

Motivation & Challenges Overview of Model-Driven Program

Transformation (MDPT) Case Study and Demo Conclusions & Future work

Page 3: 1 Legacy System Evolution through Model-Driven Program Transformation Funded by the DARPA Information Exploitation Office (DARPA/IXO), under the Program

3

Two-Dimensions of Transformation/Translation

Horizontal transformation Transformation within the same

level of abstraction E.g., Model transformation, code

refactoring

Vertical translation Translation, or synthesis, between

layers of abstraction E.g., MIC interpreters, reverse

engineering

ComputePositionC++

ComputePositionwith Locking

C++

NavDisplayC++

Vertical transformation needed!!!

Page 4: 1 Legacy System Evolution through Model-Driven Program Transformation Funded by the DARPA Information Exploitation Office (DARPA/IXO), under the Program

4

Legacy Source

Legacy Models

Legacy Models’

Meta-model

Defines

Legacy Source’

Defines

Describe

∆M

∆S

Describe

The evolution of the legacy system in terms of models and source code

∆M: The changes made to the legacy models∆S: The changes reflected in the legacy source

Page 5: 1 Legacy System Evolution through Model-Driven Program Transformation Funded by the DARPA Information Exploitation Office (DARPA/IXO), under the Program

5

Code Transformation from Models

Goal: Maintain the fidelity between the mapping of the model properties and the legacy source code

Challenges: Parsing and invasively transforming legacy source code from higher-level models

Solution: Model-Driven Program Transformation (MDPT)

Based on the unification of a mature program transformation system with a meta-modeling environment

Page 6: 1 Legacy System Evolution through Model-Driven Program Transformation Funded by the DARPA Information Exploitation Office (DARPA/IXO), under the Program

04/19/23

Supporting Technologies:The DMS "Software Reengineering Toolkit"

Lexer/Parser

DomainDefinition

TransformationEngine

Transforms

Analyzers

Procedures

Unparser definitions

ParserDefinition

SourceFiles(DomainNotation)

AST(Graph)

LanguageDescriptions

Viewer

UnparserRevisedSourceFiles

Debug Text

AttributeEvaluator

Sequencing;Transforms

SymbolTable

Declarations

Reader

AST(Graph)

Analysis + Transform Descriptions= Tool definition

Coded in PARLANSE

Slide borrowed with permission from Semantic Designs (www.semdesigns.com)

Page 7: 1 Legacy System Evolution through Model-Driven Program Transformation Funded by the DARPA Information Exploitation Office (DARPA/IXO), under the Program

7

Supporting Technologies:Model-Integrated Computing (MIC)

Generic Modeling Environment (GME) Embedded Systems Modeling Language (ESML)

ModelInterpretatio

n

Model Interpreters

Models

Modeling Environment

ApplicationDomain

App1

App2

App3

Application Evolution

Environment Evolution

Meta-LevelTranslation

MetaprogrammingInterface

Formal Specifications

Model Builder

Page 8: 1 Legacy System Evolution through Model-Driven Program Transformation Funded by the DARPA Information Exploitation Office (DARPA/IXO), under the Program

8

Legacy System:Bold Stroke Product Line

Mission-control software for Boeing military aircraft, e.g., F-18 E/F, Harrier, UCAV

CORBA event-based systems Thousands of components

implemented in over a million lines of C++ code

Page 9: 1 Legacy System Evolution through Model-Driven Program Transformation Funded by the DARPA Information Exploitation Office (DARPA/IXO), under the Program

9

Model-Driven Program Transformation (MDPT)

DMS Transformation Rules

Interpreter

UpdatedESML models

Common/Project Library of BoldStroke C++

Source Code

void BM__PushPullComponentImpl::Update (const UUEventSet& events)

{ BM__ComponentInstrumentation::EventConsumer(GetId(), "Update", events);

unsigned int tempData1 = GetId().GetGroupId();

unsigned int tempData2 = GetId().GetItemId();

std::vector<BM__ClosedComponent*>::iterator devIter = devices_.begin();

std::vector<BM__ClosedComponent*>::iterator endIter = devices_.end();

for (; devIter != endIter; ++devIter) {

BM__ClosedComponent* component = *devIter;

const UUIdentifier& id = component->GetId();

if (idInEventSet(id, events))

{ const BM__ClosedFunctionalFacet& facet = component->ProvideClosedFunctionalFacet();

BM__ComponentInstrumentation::SendDirectCall(GetId(), "Update", component->GetId(), "GetData1");

tempData1 += facet.GetData1();

BM__ComponentInstrumentation::SendDirectCall(GetId(), "Update", component->GetId(), "GetData2");

tempData2 += facet.GetData2();

} } data1_ = tempData1; data2_ = tempData2;}

TransformedBoldStroke C++ Code

void BM__PushPullComponentImpl::Update (const UUEventSet& events)

{ UM__GUARD_EXTERNAL_REGION(GetExternalPushLock());

BM__ComponentInstrumentation::EventConsumer(GetId(), "Update", events); 

unsigned int tempData1 = GetId().GetGroupId(); unsigned int tempData2 = GetId().GetItemId(); 

std::vector<BM__ClosedComponent*>::iterator devIter = devices_.begin();

std::vector<BM__ClosedComponent*>::iterator endIter = devices_.end(); 

for (; devIter != endIter; ++devIter) {

BM__ClosedComponent* component = *devIter; const UUIdentifier& id = component->GetId(); 

if (idInEventSet(id, events))

{ const BM__ClosedFunctionalFacet& facet = component->ProvideClosedFunctionalFacet();

BM__ComponentInstrumentation::SendDirectCall(GetId(), "Update", component->GetId(), "GetData1");

tempData1 += facet.GetData1();

BM__ComponentInstrumentation::SendDirectCall(GetId(), "Update", component->GetId(), "GetData2");

tempData2 += facet.GetData2();

} } UM__GUARD_INTERNAL_REGION; log.add(“data1_=”+data1_);

data1_ = tempData1; data2_ = tempData2; log.add(“data2_=”+data2_); }

Page 10: 1 Legacy System Evolution through Model-Driven Program Transformation Funded by the DARPA Information Exploitation Office (DARPA/IXO), under the Program

10

Benefits

Ensures causal connection between model changes and the underlying source code of the legacy system

Assists in legacy evolution from new properties specified in models

Model interpreters generate transformation rules to modify source

Page 11: 1 Legacy System Evolution through Model-Driven Program Transformation Funded by the DARPA Information Exploitation Office (DARPA/IXO), under the Program

11

Case Study :a black box data recorder

default base domain Cpp~VisualCpp6. pattern LogStmt() : statement = "log.add(\"data1_=\" + data1_); ". pattern LogOnMethodAspect(s:statement_seq): statement_seq = " { \s } \LogStmt\(\) ". pattern Update(id:identifier): qualified_id = "\id :: Update". rule log_on_Update(ret:decl_specifier_seq, id:identifier, p:parameter_declaration_clause, s: statement_seq): function_definition -> function_definition = "\ret \Update\(\id\) (\p) { \s } " -> "\ret \Update\(\id\) (\p) { \LogOnMethodAspect\(\s\) }" if ~[modsList:statement_seq .s matches "\:statement_seq \LogOnMethodAspect\(\modsList\)"]. rule log_on_Update_cv(ret:decl_specifier_seq, id:identifier, p:parameter_declaration_clause, s: statement_seq, cv: cv_qualifier_seq): function_definition -> function_definition = "\ret \Update\(\id\) (\p) \cv { \s } " -> "\ret \Update\(\id\) (\p) \cv { \LogOnMethodAspect\(\s\) }" if ~[modsList:statement_seq .s matches "\:statement_seq \LogOnMethodAspect\(\modsList\)"]. pattern getData1_(id:identifier): qualified_id = "\id :: getData1_". rule log_on_getData1_(ret:decl_specifier_seq, id:identifier, p:parameter_declaration_clause, s: statement_seq): function_definition -> function_definition = "\ret \getData1_\(\id\) (\p) { \s } " -> "\ret \getData1_\(\id\) (\p) { \LogOnMethodAspect\(\s\) }" if ~[modsList:statement_seq .s matches "\:statement_seq \LogOnMethodAspect\(\modsList\)"]. rule log_on_getData1__cv(ret:decl_specifier_seq, id:identifier, p:parameter_declaration_clause, s: statement_seq, cv: cv_qualifier_seq): function_definition -> function_definition = "\ret \getData1_\(\id\) (\p) \cv { \s } " -> "\ret \getData1_\(\id\) (\p) \cv { \LogOnMethodAspect\(\s\) }" if ~[modsList:statement_seq .s matches "\:statement_seq \LogOnMethodAspect\(\modsList\)"]. public ruleset applyrules = { log_on_Update, log_on_Update_cv, log_on_getData1_, log_on_getData1__cv }.

Page 12: 1 Legacy System Evolution through Model-Driven Program Transformation Funded by the DARPA Information Exploitation Office (DARPA/IXO), under the Program

12

Transformed code fragment 1 unsigned int BM__ClosedEDComponentImpl::getData1_ () const

2 { 3 4 5 UM__GUARD_INTERNAL_REGION; 6 BM__ComponentInstrumentation::ReceiveDirectCall(GetId(), "GetData1"); 7 8 9 return data1_;10 } 11 12 void BM__ClosedEDComponentImpl::Update (const UUEventSet& events)13 { 14 15 16 UM__GUARD_EXTERNAL_REGION(GetExternalPushLock()); 17 BM__ComponentInstrumentation::EventConsumer(GetId(), "Update", events);18 unsigned int tempData1 = GetId().GetGroupId();19 unsigned int tempData2 = GetId().GetItemId();20 21 //*** REMOVED: code for implementing Real-time Event Channel22 23 24 data1_ = tempData1; //*** REMOVED: actual variable names (proprietary)25 data2_ = tempData2;26 }

Addlog("data1_=" + data1_);

Addlog("data1_=" + data1_);

Addlog("data1_=" + data1_);

Addlog("data1_=" + data1_);

Log on getData1_() method entry

Log on reading data1_

Log on Update() method entry

Log on writing data1_

Page 13: 1 Legacy System Evolution through Model-Driven Program Transformation Funded by the DARPA Information Exploitation Office (DARPA/IXO), under the Program

13

Video DEMO

Case study: a black box data recorder

Constraint-Specification Aspect Weaver (C-SAW) is utilized to weave the "LogOnWrite" strategy across multiple components

Page 14: 1 Legacy System Evolution through Model-Driven Program Transformation Funded by the DARPA Information Exploitation Office (DARPA/IXO), under the Program

14

Generalization of the control flow for the MDPT process

Page 15: 1 Legacy System Evolution through Model-Driven Program Transformation Funded by the DARPA Information Exploitation Office (DARPA/IXO), under the Program

15

Conclusion

The model-driven program transformation technique is a novel approach for transforming large legacy systems from domain-specific models.

It provides widespread adaptations across multiple source files according to the evolving model features.

http://www.gray-area.org/Research/C-SAW/

Page 16: 1 Legacy System Evolution through Model-Driven Program Transformation Funded by the DARPA Information Exploitation Office (DARPA/IXO), under the Program

16

Future Work

Support other concerns (e.g. QoS) for transforming Bold Stroke

Generalization of the process for supporting legacy system evolution using MDPT

Experimental evaluation Productivity Correctness

Page 17: 1 Legacy System Evolution through Model-Driven Program Transformation Funded by the DARPA Information Exploitation Office (DARPA/IXO), under the Program

17