Legacy System Evolution through ModelDriven Program Transformation Jing

  • Slides: 17
Download presentation
Legacy System Evolution through Model-Driven Program Transformation Jing Zhang and Jeff Gray {zhangj, gray}

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

Contents n n Motivation & Challenges Overview of Model-Driven Program Transformation (MDPT) Case Study

Contents n n Motivation & Challenges Overview of Model-Driven Program Transformation (MDPT) Case Study and Demo Conclusions & Future work 2

Two-Dimensions of Transformation/Translation n Horizontal transformation n n Transformation within the same level of

Two-Dimensions of Transformation/Translation n Horizontal transformation n n Transformation within the same level of abstraction E. g. , Model transformation, code refactoring n Compute. Position with Locking C++ Compute. Position C++ Vertical translation n n Translation, or synthesis, between layers of abstraction E. g. , MIC interpreters, reverse engineering Vertical transformation needed!!! Nav. Display C++ 3

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

The evolution of the legacy system in terms of models and source code Meta-model Defines ∆M Legacy Models’ Describe ∆S Legacy Source’ ∆M: The changes made to the legacy models ∆S: The changes reflected in the legacy source 4

Code Transformation from Models n n n Goal: Maintain the fidelity between the mapping

Code Transformation from Models n n n 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) n Based on the unification of a mature program transformation system with a meta-modeling environment 5

Supporting Technologies: The DMS "Software Reengineering Toolkit" Source Files (Domain Notation) Lexer/ Parser Symbol

Supporting Technologies: The DMS "Software Reengineering Toolkit" Source Files (Domain Notation) Lexer/ Parser Symbol Table AST (Graph) Analyzers Declarations Attribute Evaluator AST (Graph) Unparser Revised Source Files Parser Definition Domain Definition Reader Transforms Procedures Language Descriptions Analysis + Transform Descriptions = Tool definition Transformation Engine Viewer Debug Text Sequencing; Transforms Unparser definitions Coded in PARLANSE Slide borrowed with permission from Semantic Designs (www. semdesigns. com)

Supporting Technologies: Model-Integrated Computing (MIC) Metaprogramming Interface Environment Evolution Application Domain Application Evolution App

Supporting Technologies: Model-Integrated Computing (MIC) Metaprogramming Interface Environment Evolution Application Domain Application Evolution App 1 Formal Specifications App 2 App 3 Modeling Environment Model Builder Meta-Level Translation Models Model Interpretatio n Model Interpreters n n Generic Modeling Environment (GME) Embedded Systems Modeling Language (ESML) 7

Legacy System: Bold Stroke Product Line n n n Mission-control software for Boeing military

Legacy System: Bold Stroke Product Line n n n 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 8

Model-Driven Program Transformation (MDPT) void BM__Push. Pull. Component. Impl: : Update (const UUEvent. Set&

Model-Driven Program Transformation (MDPT) void BM__Push. Pull. Component. Impl: : Update (const UUEvent. Set& events) Updated ESML models { BM__Component. Instrumentation: : Event. Consumer(Get. Id(), "Update", events); unsigned int temp. Data 1 = Get. Id(). Get. Group. Id(); unsigned int temp. Data 2 = Get. Id(). Get. Item. Id(); std: : vector<BM__Closed. Component*>: : iterator dev. Iter = devices_. begin(); std: : vector<BM__Closed. Component*>: : iterator end. Iter = devices_. end(); for (; dev. Iter != end. Iter; ++dev. Iter) { BM__Closed. Component* component = *dev. Iter; const UUIdentifier& id = component->Get. Id(); if (id. In. Event. Set(id, events)) { const BM__Closed. Functional. Facet& facet = component->Provide. Closed. Functional. Facet(); BM__Component. Instrumentation: : Send. Direct. Call(Get. Id(), "Update", component->Get. Id(), "Get. Data 1"); temp. Data 1 += facet. Get. Data 1(); BM__Component. Instrumentation: : Send. Direct. Call(Get. Id(), "Update", component->Get. Id(), "Get. Data 2"); temp. Data 2 += facet. Get. Data 2(); } } data 1_ = temp. Data 1; data 2_ = temp. Data 2; } Common/Project Library of Bold. Stroke C++ Source Code DMS Transformation Rules Interpreter void BM__Push. Pull. Component. Impl: : Update (const UUEvent. Set& events) { UM__GUARD_EXTERNAL_REGION(Get. External. Push. Lock()); BM__Component. Instrumentation: : Event. Consumer(Get. Id(), "Update", events); Transformed Bold. Stroke C++ Code unsigned int temp. Data 1 = Get. Id(). Get. Group. Id(); unsigned int temp. Data 2 = Get. Id(). Get. Item. Id(); std: : vector<BM__Closed. Component*>: : iterator dev. Iter = devices_. begin(); std: : vector<BM__Closed. Component*>: : iterator end. Iter = devices_. end(); for (; dev. Iter != end. Iter; ++dev. Iter) { BM__Closed. Component* component = *dev. Iter; const UUIdentifier& id = component->Get. Id(); if (id. In. Event. Set(id, events)) { const BM__Closed. Functional. Facet& facet = component->Provide. Closed. Functional. Facet(); BM__Component. Instrumentation: : Send. Direct. Call(Get. Id(), "Update", component->Get. Id(), "Get. Data 1"); temp. Data 1 += facet. Get. Data 1(); BM__Component. Instrumentation: : Send. Direct. Call(Get. Id(), "Update", component->Get. Id(), "Get. Data 2"); temp. Data 2 += facet. Get. Data 2(); } } UM__GUARD_INTERNAL_REGION; log. add(“data 1_=”+data 1_); data 1_ = temp. Data 1; data 2_ = temp. Data 2; log. add(“data 2_=”+data 2_); } 9

Benefits n n n Ensures causal connection between model changes and the underlying source

Benefits n n n 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 10

Case Study : a black box data recorder default base domain Cpp~Visual. Cpp 6.

Case Study : a black box data recorder default base domain Cpp~Visual. Cpp 6. pattern Log. Stmt() : statement = "log. add("data 1_=" + data 1_); ". pattern Log. On. Method. Aspect(s: statement_seq): statement_seq = " { s } Log. Stmt() ". 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) { Log. On. Method. Aspect(s) }" if ~[mods. List: statement_seq. s matches ": statement_seq Log. On. Method. Aspect(mods. List)"]. 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 { Log. On. Method. Aspect(s) }" if ~[mods. List: statement_seq. s matches ": statement_seq Log. On. Method. Aspect(mods. List)"]. pattern get. Data 1_(id: identifier): qualified_id = "id : : get. Data 1_". rule log_on_get. Data 1_(ret: decl_specifier_seq, id: identifier, p: parameter_declaration_clause , s: statement_seq): function_definition -> function_definition = "ret get. Data 1_(id) (p) { s } " -> "ret get. Data 1_(id) (p) { Log. On. Method. Aspect(s) }" if ~[mods. List: statement_seq. s matches ": statement_seq Log. On. Method. Aspect(mods. List)"]. rule log_on_get. Data 1__cv(ret: decl_specifier_seq, id: identifier, p: parameter_declaration_clause , s: statement_seq, cv: cv_qualifier_seq): function_definition > function_definition = "ret get. Data 1_(id) (p) cv { s } " -> "ret get. Data 1_(id) (p) cv { Log. On. Method. Aspect(s) }" if ~[mods. List: statement_seq. s matches ": statement_seq Log. On. Method. Aspect(mods. List)"]. public ruleset applyrules = { log_on_Update, log_on_Update_cv, log_on_get. Data 1__cv }. 11

Transformed code fragment 1 unsigned int BM__Closed. EDComponent. Impl: : get. Data 1_ ()

Transformed code fragment 1 unsigned int BM__Closed. EDComponent. Impl: : get. Data 1_ () const 2 { 3 Addlog("data 1_=" + data 1_); Log on get. Data 1_() method entry 4 5 UM__GUARD_INTERNAL_REGION; 6 BM__Component. Instrumentation: : Receive. Direct. Call(Get. Id(), "Get. Data 1"); 7 Addlog("data 1_=" + data 1_); 8 Log on reading data 1_ 9 return data 1_; 10 } 11 12 void BM__Closed. EDComponent. Impl: : Update (const UUEvent. Set& events) 13 { Addlog("data 1_=" + data 1_); 14 Log on Update() method entry 15 16 UM__GUARD_EXTERNAL_REGION(Get. External. Push. Lock()); 17 BM__Component. Instrumentation: : Event. Consumer(Get. Id(), "Update", events); 18 unsigned int temp. Data 1 = Get. Id(). Get. Group. Id(); 19 unsigned int temp. Data 2 = Get. Id(). Get. Item. Id(); 20 21 //*** REMOVED: code for implementing Real-time Event Channel 22 Log on writing data 1_ Addlog("data 1_=" + data 1_); 23 24 data 1_ = temp. Data 1; //*** REMOVED: actual variable names (proprietary) 25 data 2_ = temp. Data 2; 26 } 12

Video DEMO n n Case study: a black box data recorder Constraint-Specification Aspect Weaver

Video DEMO n n Case study: a black box data recorder Constraint-Specification Aspect Weaver (C-SAW) is utilized to weave the "Log. On. Write" strategy across multiple components 13

Generalization of the control flow for the MDPT process 14

Generalization of the control flow for the MDPT process 14

Conclusion n n The model-driven program transformation technique is a novel approach for transforming

Conclusion n n 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/ 15

Future Work n n n Support other concerns (e. g. Qo. S) for transforming

Future Work n n n Support other concerns (e. g. Qo. S) for transforming Bold Stroke Generalization of the process for supporting legacy system evolution using MDPT Experimental evaluation n n Productivity Correctness 16

17

17