SlideShare a Scribd company logo
Topic S
Program Analysis and Transformation
SEG 4110: Advanced Software Design and
Reengineering
SEG4110 - Topic S - Program Analysis 2
Copyright Note
These slides are derived from work by
Bil Tzerpos a faculty member at York University
SEG4110 - Topic S - Program Analysis 3
Program Analysis
Extracting information, in order to present abstractions
of, or answer questions about, a software system
Static Analysis
• Examines the source code
Dynamic Analysis
• Examines the system as it is executing
SEG4110 - Topic S - Program Analysis 4
What are we looking for when performing
program analysis?
Depends on our goals and the system
• In almost any language, we can find out information about variable
usage
• In an OO environment, we can find out which classes use other
classes, what is the inheritance structure, etc.
• We can also find potential blocks of code that can never be executed
in running the program (dead code)
• Typically, the information extracted is in terms of entities and
relationships
—Can be metamodelled in a class diagram
SEG4110 - Topic S - Program Analysis 5
Entities
Entities are individuals that live in the system, and
attributes associated with them.
Some examples:
• Classes, along with information about their superclass,
their scope, and ‘where’ in the code they exist.
• Methods/functions and what their return type or
parameter list is, etc.
• Variables and what their types are, and whether or not
they are static, etc.
SEG4110 - Topic S - Program Analysis 6
Relationships
Relationships are interactions between the entities in the
system
Relationships include
• Classes inheriting from one another.
• Methods in one class calling the methods of another
class, and methods within the same class calling one
another.
• A method referencing an attribute.
SEG4110 - Topic S - Program Analysis 7
Information format for data extracted during
program analysis
Many different formats in use
• Simple but effective: RSF (Rigi Standard Format)
inherit TRIANGLE SHAPE
• TA (Tuple Attribute) is an extension of RSF that includes
a schema
$INSTANCE SHAPE Class
• GXL is a XML-based extension of TA
—Blow-up factor of 10 or more makes it rather
cumbersome
• New formats based on YAML being developed
SEG4110 - Topic S - Program Analysis 8
Representation of extracted information
A fundamental issue in re-engineering
• Provides
—means to generate abstractions
—input to a computational model for analyzing and
reasoning about programs
—means for translation and normalization of programs
SEG4110 - Topic S - Program Analysis 9
Key questions regarding representations of
extracted information
What are the strengths and weaknesses of each
representations of programs?
What levels of abstraction are useful?
SEG4110 - Topic S - Program Analysis 10
Abstract Syntax Trees
A translation of the source text in terms of operands and
operators
Omits superficial details, such as comments, whitespace
All necessary information to generate further
abstractions is maintained
SEG4110 - Topic S - Program Analysis 11
AST production
Four necessary elements to produce an AST:
• Lexical analyzer (turn input strings into tokens)
• Grammar (turn tokens into a parse tree)
• Domain Model (defines the nodes and arcs allowable in
the AST)
• Linker (annotates the AST with global information, e.g.
data types, scoping etc.)
SEG4110 - Topic S - Program Analysis 12
AST example
Input string: 1 + /* two */ 2
Parse Tree:
AST (without
global info) 2
1
+
int
int
Add
1 2
arg1 arg2
SEG4110 - Topic S - Program Analysis 13
Static Analysis
Involves parsing the source code
Usually creates an Abstract Syntax Tree
Borrows heavily from compiler technology
• but stops before code generation
Requires a grammar for the programming language
Can be very difficult to get right
SEG4110 - Topic S - Program Analysis 14
CppETS
CppETS is a benchmark for C++ extractors
A collection of C++ programs that pose various
problems commonly found in parsing and reverse
engineering
Static analysis research tools typically get about 60%
of the problems right
SEG4110 - Topic S - Program Analysis 15
Example program
#include <iostream.h>
class Hello {
public: Hello(); ~Hello();
};
Hello::Hello()
{ cout << "Hello, world.n"; }
Hello::~Hello()
{ cout << "Goodbye, cruel world.n"; }
main() {
Hello h;
return 0;
}
SEG4110 - Topic S - Program Analysis 16
Example Q&A
How many member methods are in the Hello
class?
Where are these member methods used?
Answer: Two, the constructor (Hello::Hello()) and
destructor (Hello::~Hello())
Answer: The constructor is called implicitly when
an instance of the class is created. The destructor
is called implicitly when the execution leaves the
scope of the instance.
SEG4110 - Topic S - Program Analysis 17
Static analysis in IDEs
High-level languages lend themselves better to static analysis
needs
• Rational Software Modeler does this with UML and Java
Unfortunately, most legacy systems are not written in either of
these languages
SEG4110 - Topic S - Program Analysis 18
Static analysis pipeline
Source code Parser Abstract Syntax Tree
Fact base
Fact extractor
Applications
Metrics tool
Visualizer
SEG4110 - Topic S - Program Analysis 19
Dynamic Analysis
Provides information about the run-time behaviour of
software systems, e.g.
• Component interactions
• Event traces
• Concurrent behaviour
• Code coverage
• Memory management
Can be done with a debugger
SEG4110 - Topic S - Program Analysis 20
Instrumentation
Augments the subject program with code that
• transmits events to a monitoring application
• or writes relevant information to an output file
A profiler tool can be used to examine the output file and
extract relevant facts from it
Instrumentation affects the execution speed and storage
space requirements of the system
SEG4110 - Topic S - Program Analysis 21
Instrumentation process
Source code Annotator Annotated program
Instrumented
executable
Compiler
Annotation
script
SEG4110 - Topic S - Program Analysis 22
Dynamic analysis pipeline
Instrumented
executable
CPU Dynamic analysis data
Fact base
Profiler
Applications
Metrics tool
Visualizer
SEG4110 - Topic S - Program Analysis 23
Non-instrumented approach
One can also use debugger log files to obtain dynamic information
• Disadvantage: Limited amount of information provided
• Advantages: Less intrusive, more accurate performance
measurements
SEG4110 - Topic S - Program Analysis 24
Dynamic analysis issues
Ensuring good code coverage is a key concern
A comprehensive test suite is required to ensure that all paths in the
code will be exercised
Results may not generalize to future executions
The size of run-time information is extraordinary large
SEG4110 - Topic S - Program Analysis 25
Summary: Static vs. Dynamic Analysis
Static Analysis
Reasons over all possible
behaviours (general results)
Conservative and sound
Challenge: Choose good
abstractions
Dynamic Analysis
Observes a small number of
behaviours (specific results)
Precise and fast
Challenge: Select representative
test cases
SEG4110 - Topic S - Program Analysis 26
Program Transformation
The act of changing one program into another
• from a source language to a target language
This is possible because of a program’s well-defined structure
• But for validity, we have to be aware of the semantics of each
structure
Used in many areas of software engineering:
• Compiler construction
• Software visualization
• Documentation generation
• Automatic software renovation
SEG4110 - Topic S - Program Analysis 27
Program transformation application
examples
Converting to a new language dialect
Migrating from a procedural language to an object-oriented one,
e.g. C to C++
Adding code comments
Requirement upgrading
• e.g. using 4 digits for years instead of 2 (Y2K)
Structural improvements
• e.g. changing GOTOs to control structures
Pretty printing
SEG4110 - Topic S - Program Analysis 28
Simple program transformation
Modify all arithmetic expressions to reduce the number
of parentheses using the formula: (a+b)*c = a*c + b*c
x := (2+5)*3
becomes
x := 2*3 + 5*3
SEG4110 - Topic S - Program Analysis 29
Two types of transformations
Translation
• Source and target language are different
• Semantics remain the same
Rephrasing
• Source and target language are the same
• Goal is to improve some aspect of the program such as
its understandability or performance
• Semantics might change
SEG4110 - Topic S - Program Analysis 30
Transformation tools
There are many transformation tools
Program-Transformation.org lists 90 of them
• http://www.program-transformation.org/
• TXL is one of the best
Most are based on ‘term rewriting’
• Other solutions use functional programming, lambda
calculus, etc.

More Related Content

Similar to reverse engineering.ppt

LIFT: A Legacy InFormation retrieval Tool
LIFT: A Legacy InFormation retrieval ToolLIFT: A Legacy InFormation retrieval Tool
LIFT: A Legacy InFormation retrieval Tool
Kellyton Brito
 
Se
SeSe
Probe Debugging
Probe DebuggingProbe Debugging
Probe Debugging
ESUG
 
Bse 3105 lecture 4-software re-engineering
Bse 3105  lecture 4-software re-engineeringBse 3105  lecture 4-software re-engineering
Bse 3105 lecture 4-software re-engineering
Alonzee Tash
 
CS2006Ch02A.ppt dfxgbfdcgbhfcdhbfdcbfdcgfdg
CS2006Ch02A.ppt dfxgbfdcgbhfcdhbfdcbfdcgfdgCS2006Ch02A.ppt dfxgbfdcgbhfcdhbfdcbfdcgfdg
CS2006Ch02A.ppt dfxgbfdcgbhfcdhbfdcbfdcgfdg
RahithAhsan1
 
Software Analytics - Achievements and Challenges
Software Analytics - Achievements and ChallengesSoftware Analytics - Achievements and Challenges
Software Analytics - Achievements and Challenges
Tao Xie
 
Pressman ch-11-component-level-design
Pressman ch-11-component-level-designPressman ch-11-component-level-design
Pressman ch-11-component-level-designOliver Cheng
 
Software maintenance
Software maintenanceSoftware maintenance
Software maintenance
NancyBeaulah_R
 
CommonKADS design and implementation
CommonKADS design and implementationCommonKADS design and implementation
CommonKADS design and implementation
Guus Schreiber
 
Scaling Application on High Performance Computing Clusters and Analysis of th...
Scaling Application on High Performance Computing Clusters and Analysis of th...Scaling Application on High Performance Computing Clusters and Analysis of th...
Scaling Application on High Performance Computing Clusters and Analysis of th...
Rusif Eyvazli
 
3 Software Estmation.ppt
3 Software Estmation.ppt3 Software Estmation.ppt
3 Software Estmation.ppt
Soham De
 
Msr2021 tutorial-di penta
Msr2021 tutorial-di pentaMsr2021 tutorial-di penta
Msr2021 tutorial-di penta
Massimiliano Di Penta
 
Spm project planning
Spm project planning Spm project planning
Spm project planning
Kanchana Devi
 
lecture_29.pptx
lecture_29.pptxlecture_29.pptx
lecture_29.pptx
MNumanZafar1
 
Triantafyllia Voulibasi
Triantafyllia VoulibasiTriantafyllia Voulibasi
Triantafyllia Voulibasi
ISSEL
 
Design & Implementation.pptx
Design & Implementation.pptxDesign & Implementation.pptx
Design & Implementation.pptx
SalmaItagi2
 
The Magic Of Application Lifecycle Management In Vs Public
The Magic Of Application Lifecycle Management In Vs PublicThe Magic Of Application Lifecycle Management In Vs Public
The Magic Of Application Lifecycle Management In Vs Public
David Solivan
 
Cocomo
CocomoCocomo
Cocomo
Yunis Lone
 
Software estimation techniques
Software estimation techniquesSoftware estimation techniques
Software estimation techniquesTan Tran
 
DITEC - Software Engineering
DITEC - Software EngineeringDITEC - Software Engineering
DITEC - Software Engineering
Rasan Samarasinghe
 

Similar to reverse engineering.ppt (20)

LIFT: A Legacy InFormation retrieval Tool
LIFT: A Legacy InFormation retrieval ToolLIFT: A Legacy InFormation retrieval Tool
LIFT: A Legacy InFormation retrieval Tool
 
Se
SeSe
Se
 
Probe Debugging
Probe DebuggingProbe Debugging
Probe Debugging
 
Bse 3105 lecture 4-software re-engineering
Bse 3105  lecture 4-software re-engineeringBse 3105  lecture 4-software re-engineering
Bse 3105 lecture 4-software re-engineering
 
CS2006Ch02A.ppt dfxgbfdcgbhfcdhbfdcbfdcgfdg
CS2006Ch02A.ppt dfxgbfdcgbhfcdhbfdcbfdcgfdgCS2006Ch02A.ppt dfxgbfdcgbhfcdhbfdcbfdcgfdg
CS2006Ch02A.ppt dfxgbfdcgbhfcdhbfdcbfdcgfdg
 
Software Analytics - Achievements and Challenges
Software Analytics - Achievements and ChallengesSoftware Analytics - Achievements and Challenges
Software Analytics - Achievements and Challenges
 
Pressman ch-11-component-level-design
Pressman ch-11-component-level-designPressman ch-11-component-level-design
Pressman ch-11-component-level-design
 
Software maintenance
Software maintenanceSoftware maintenance
Software maintenance
 
CommonKADS design and implementation
CommonKADS design and implementationCommonKADS design and implementation
CommonKADS design and implementation
 
Scaling Application on High Performance Computing Clusters and Analysis of th...
Scaling Application on High Performance Computing Clusters and Analysis of th...Scaling Application on High Performance Computing Clusters and Analysis of th...
Scaling Application on High Performance Computing Clusters and Analysis of th...
 
3 Software Estmation.ppt
3 Software Estmation.ppt3 Software Estmation.ppt
3 Software Estmation.ppt
 
Msr2021 tutorial-di penta
Msr2021 tutorial-di pentaMsr2021 tutorial-di penta
Msr2021 tutorial-di penta
 
Spm project planning
Spm project planning Spm project planning
Spm project planning
 
lecture_29.pptx
lecture_29.pptxlecture_29.pptx
lecture_29.pptx
 
Triantafyllia Voulibasi
Triantafyllia VoulibasiTriantafyllia Voulibasi
Triantafyllia Voulibasi
 
Design & Implementation.pptx
Design & Implementation.pptxDesign & Implementation.pptx
Design & Implementation.pptx
 
The Magic Of Application Lifecycle Management In Vs Public
The Magic Of Application Lifecycle Management In Vs PublicThe Magic Of Application Lifecycle Management In Vs Public
The Magic Of Application Lifecycle Management In Vs Public
 
Cocomo
CocomoCocomo
Cocomo
 
Software estimation techniques
Software estimation techniquesSoftware estimation techniques
Software estimation techniques
 
DITEC - Software Engineering
DITEC - Software EngineeringDITEC - Software Engineering
DITEC - Software Engineering
 

More from NaglaaFathy42

introduction to web engineering.pptx
introduction to web engineering.pptxintroduction to web engineering.pptx
introduction to web engineering.pptx
NaglaaFathy42
 
introduction to web engineering.pdf
introduction to web engineering.pdfintroduction to web engineering.pdf
introduction to web engineering.pdf
NaglaaFathy42
 
understanding computers.ppt
understanding computers.pptunderstanding computers.ppt
understanding computers.ppt
NaglaaFathy42
 
semantic integration.ppt
semantic integration.pptsemantic integration.ppt
semantic integration.ppt
NaglaaFathy42
 
semantic web tech.ppt
semantic web tech.pptsemantic web tech.ppt
semantic web tech.ppt
NaglaaFathy42
 
Bioinformatic_Databases_2.ppt
Bioinformatic_Databases_2.pptBioinformatic_Databases_2.ppt
Bioinformatic_Databases_2.ppt
NaglaaFathy42
 
Lec2_Information Integration.ppt
 Lec2_Information Integration.ppt Lec2_Information Integration.ppt
Lec2_Information Integration.ppt
NaglaaFathy42
 
Web Mining .ppt
Web Mining .pptWeb Mining .ppt
Web Mining .ppt
NaglaaFathy42
 
ch5-georeferencing.ppt
ch5-georeferencing.pptch5-georeferencing.ppt
ch5-georeferencing.ppt
NaglaaFathy42
 
intro to gis
intro to gisintro to gis
intro to gis
NaglaaFathy42
 

More from NaglaaFathy42 (10)

introduction to web engineering.pptx
introduction to web engineering.pptxintroduction to web engineering.pptx
introduction to web engineering.pptx
 
introduction to web engineering.pdf
introduction to web engineering.pdfintroduction to web engineering.pdf
introduction to web engineering.pdf
 
understanding computers.ppt
understanding computers.pptunderstanding computers.ppt
understanding computers.ppt
 
semantic integration.ppt
semantic integration.pptsemantic integration.ppt
semantic integration.ppt
 
semantic web tech.ppt
semantic web tech.pptsemantic web tech.ppt
semantic web tech.ppt
 
Bioinformatic_Databases_2.ppt
Bioinformatic_Databases_2.pptBioinformatic_Databases_2.ppt
Bioinformatic_Databases_2.ppt
 
Lec2_Information Integration.ppt
 Lec2_Information Integration.ppt Lec2_Information Integration.ppt
Lec2_Information Integration.ppt
 
Web Mining .ppt
Web Mining .pptWeb Mining .ppt
Web Mining .ppt
 
ch5-georeferencing.ppt
ch5-georeferencing.pptch5-georeferencing.ppt
ch5-georeferencing.ppt
 
intro to gis
intro to gisintro to gis
intro to gis
 

Recently uploaded

一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
ahzuo
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
yhkoc
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
vcaxypu
 
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
pchutichetpong
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
ewymefz
 
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
AbhimanyuSinha9
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
John Andrews
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
axoqas
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
axoqas
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
ewymefz
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
ArpitMalhotra16
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
Opendatabay
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
nscud
 
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
Tiktokethiodaily
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
ocavb
 
Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
Subhajit Sahu
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
ukgaet
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
v3tuleee
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
ewymefz
 

Recently uploaded (20)

一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
一比一原版(UIUC毕业证)伊利诺伊大学|厄巴纳-香槟分校毕业证如何办理
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
 
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
一比一原版(RUG毕业证)格罗宁根大学毕业证成绩单
 
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
Data Centers - Striving Within A Narrow Range - Research Report - MCG - May 2...
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
 
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...Best best suvichar in gujarati english meaning of this sentence as Silk road ...
Best best suvichar in gujarati english meaning of this sentence as Silk road ...
 
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...
 
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
哪里卖(usq毕业证书)南昆士兰大学毕业证研究生文凭证书托福证书原版一模一样
 
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
做(mqu毕业证书)麦考瑞大学毕业证硕士文凭证书学费发票原版一模一样
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
 
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
1.Seydhcuxhxyxhccuuxuxyxyxmisolids 2019.pptx
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
 
Adjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTESAdjusting primitives for graph : SHORT REPORT / NOTES
Adjusting primitives for graph : SHORT REPORT / NOTES
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
 
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理一比一原版(UofS毕业证书)萨省大学毕业证如何办理
一比一原版(UofS毕业证书)萨省大学毕业证如何办理
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
 

reverse engineering.ppt

  • 1. Topic S Program Analysis and Transformation SEG 4110: Advanced Software Design and Reengineering
  • 2. SEG4110 - Topic S - Program Analysis 2 Copyright Note These slides are derived from work by Bil Tzerpos a faculty member at York University
  • 3. SEG4110 - Topic S - Program Analysis 3 Program Analysis Extracting information, in order to present abstractions of, or answer questions about, a software system Static Analysis • Examines the source code Dynamic Analysis • Examines the system as it is executing
  • 4. SEG4110 - Topic S - Program Analysis 4 What are we looking for when performing program analysis? Depends on our goals and the system • In almost any language, we can find out information about variable usage • In an OO environment, we can find out which classes use other classes, what is the inheritance structure, etc. • We can also find potential blocks of code that can never be executed in running the program (dead code) • Typically, the information extracted is in terms of entities and relationships —Can be metamodelled in a class diagram
  • 5. SEG4110 - Topic S - Program Analysis 5 Entities Entities are individuals that live in the system, and attributes associated with them. Some examples: • Classes, along with information about their superclass, their scope, and ‘where’ in the code they exist. • Methods/functions and what their return type or parameter list is, etc. • Variables and what their types are, and whether or not they are static, etc.
  • 6. SEG4110 - Topic S - Program Analysis 6 Relationships Relationships are interactions between the entities in the system Relationships include • Classes inheriting from one another. • Methods in one class calling the methods of another class, and methods within the same class calling one another. • A method referencing an attribute.
  • 7. SEG4110 - Topic S - Program Analysis 7 Information format for data extracted during program analysis Many different formats in use • Simple but effective: RSF (Rigi Standard Format) inherit TRIANGLE SHAPE • TA (Tuple Attribute) is an extension of RSF that includes a schema $INSTANCE SHAPE Class • GXL is a XML-based extension of TA —Blow-up factor of 10 or more makes it rather cumbersome • New formats based on YAML being developed
  • 8. SEG4110 - Topic S - Program Analysis 8 Representation of extracted information A fundamental issue in re-engineering • Provides —means to generate abstractions —input to a computational model for analyzing and reasoning about programs —means for translation and normalization of programs
  • 9. SEG4110 - Topic S - Program Analysis 9 Key questions regarding representations of extracted information What are the strengths and weaknesses of each representations of programs? What levels of abstraction are useful?
  • 10. SEG4110 - Topic S - Program Analysis 10 Abstract Syntax Trees A translation of the source text in terms of operands and operators Omits superficial details, such as comments, whitespace All necessary information to generate further abstractions is maintained
  • 11. SEG4110 - Topic S - Program Analysis 11 AST production Four necessary elements to produce an AST: • Lexical analyzer (turn input strings into tokens) • Grammar (turn tokens into a parse tree) • Domain Model (defines the nodes and arcs allowable in the AST) • Linker (annotates the AST with global information, e.g. data types, scoping etc.)
  • 12. SEG4110 - Topic S - Program Analysis 12 AST example Input string: 1 + /* two */ 2 Parse Tree: AST (without global info) 2 1 + int int Add 1 2 arg1 arg2
  • 13. SEG4110 - Topic S - Program Analysis 13 Static Analysis Involves parsing the source code Usually creates an Abstract Syntax Tree Borrows heavily from compiler technology • but stops before code generation Requires a grammar for the programming language Can be very difficult to get right
  • 14. SEG4110 - Topic S - Program Analysis 14 CppETS CppETS is a benchmark for C++ extractors A collection of C++ programs that pose various problems commonly found in parsing and reverse engineering Static analysis research tools typically get about 60% of the problems right
  • 15. SEG4110 - Topic S - Program Analysis 15 Example program #include <iostream.h> class Hello { public: Hello(); ~Hello(); }; Hello::Hello() { cout << "Hello, world.n"; } Hello::~Hello() { cout << "Goodbye, cruel world.n"; } main() { Hello h; return 0; }
  • 16. SEG4110 - Topic S - Program Analysis 16 Example Q&A How many member methods are in the Hello class? Where are these member methods used? Answer: Two, the constructor (Hello::Hello()) and destructor (Hello::~Hello()) Answer: The constructor is called implicitly when an instance of the class is created. The destructor is called implicitly when the execution leaves the scope of the instance.
  • 17. SEG4110 - Topic S - Program Analysis 17 Static analysis in IDEs High-level languages lend themselves better to static analysis needs • Rational Software Modeler does this with UML and Java Unfortunately, most legacy systems are not written in either of these languages
  • 18. SEG4110 - Topic S - Program Analysis 18 Static analysis pipeline Source code Parser Abstract Syntax Tree Fact base Fact extractor Applications Metrics tool Visualizer
  • 19. SEG4110 - Topic S - Program Analysis 19 Dynamic Analysis Provides information about the run-time behaviour of software systems, e.g. • Component interactions • Event traces • Concurrent behaviour • Code coverage • Memory management Can be done with a debugger
  • 20. SEG4110 - Topic S - Program Analysis 20 Instrumentation Augments the subject program with code that • transmits events to a monitoring application • or writes relevant information to an output file A profiler tool can be used to examine the output file and extract relevant facts from it Instrumentation affects the execution speed and storage space requirements of the system
  • 21. SEG4110 - Topic S - Program Analysis 21 Instrumentation process Source code Annotator Annotated program Instrumented executable Compiler Annotation script
  • 22. SEG4110 - Topic S - Program Analysis 22 Dynamic analysis pipeline Instrumented executable CPU Dynamic analysis data Fact base Profiler Applications Metrics tool Visualizer
  • 23. SEG4110 - Topic S - Program Analysis 23 Non-instrumented approach One can also use debugger log files to obtain dynamic information • Disadvantage: Limited amount of information provided • Advantages: Less intrusive, more accurate performance measurements
  • 24. SEG4110 - Topic S - Program Analysis 24 Dynamic analysis issues Ensuring good code coverage is a key concern A comprehensive test suite is required to ensure that all paths in the code will be exercised Results may not generalize to future executions The size of run-time information is extraordinary large
  • 25. SEG4110 - Topic S - Program Analysis 25 Summary: Static vs. Dynamic Analysis Static Analysis Reasons over all possible behaviours (general results) Conservative and sound Challenge: Choose good abstractions Dynamic Analysis Observes a small number of behaviours (specific results) Precise and fast Challenge: Select representative test cases
  • 26. SEG4110 - Topic S - Program Analysis 26 Program Transformation The act of changing one program into another • from a source language to a target language This is possible because of a program’s well-defined structure • But for validity, we have to be aware of the semantics of each structure Used in many areas of software engineering: • Compiler construction • Software visualization • Documentation generation • Automatic software renovation
  • 27. SEG4110 - Topic S - Program Analysis 27 Program transformation application examples Converting to a new language dialect Migrating from a procedural language to an object-oriented one, e.g. C to C++ Adding code comments Requirement upgrading • e.g. using 4 digits for years instead of 2 (Y2K) Structural improvements • e.g. changing GOTOs to control structures Pretty printing
  • 28. SEG4110 - Topic S - Program Analysis 28 Simple program transformation Modify all arithmetic expressions to reduce the number of parentheses using the formula: (a+b)*c = a*c + b*c x := (2+5)*3 becomes x := 2*3 + 5*3
  • 29. SEG4110 - Topic S - Program Analysis 29 Two types of transformations Translation • Source and target language are different • Semantics remain the same Rephrasing • Source and target language are the same • Goal is to improve some aspect of the program such as its understandability or performance • Semantics might change
  • 30. SEG4110 - Topic S - Program Analysis 30 Transformation tools There are many transformation tools Program-Transformation.org lists 90 of them • http://www.program-transformation.org/ • TXL is one of the best Most are based on ‘term rewriting’ • Other solutions use functional programming, lambda calculus, etc.