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-design
Oliver 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
 
Software testing presentation for engineering students of computer science
Software testing presentation for engineering students of computer scienceSoftware testing presentation for engineering students of computer science
Software testing presentation for engineering students of computer science
AmaanAli86
 
Cocomo
CocomoCocomo
Cocomo
Yunis Lone
 
Software estimation techniques
Software estimation techniquesSoftware estimation techniques
Software estimation techniques
Tan Tran
 

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
 
Software testing presentation for engineering students of computer science
Software testing presentation for engineering students of computer scienceSoftware testing presentation for engineering students of computer science
Software testing presentation for engineering students of computer science
 
Cocomo
CocomoCocomo
Cocomo
 
Software estimation techniques
Software estimation techniquesSoftware estimation techniques
Software estimation techniques
 

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

History and Application of LLM Leveraging Big Data
History and Application of LLM Leveraging Big DataHistory and Application of LLM Leveraging Big Data
History and Application of LLM Leveraging Big Data
Jongwook Woo
 
BDSM Girls Call Mumbai 👀 9820252231 👀 Cash Payment With Room DeliveryDelivery
BDSM Girls Call Mumbai 👀 9820252231 👀 Cash Payment With Room DeliveryDeliveryBDSM Girls Call Mumbai 👀 9820252231 👀 Cash Payment With Room DeliveryDelivery
BDSM Girls Call Mumbai 👀 9820252231 👀 Cash Payment With Room DeliveryDelivery
erynsouthern
 
Where to order Frederick Community College diploma?
Where to order Frederick Community College diploma?Where to order Frederick Community College diploma?
Where to order Frederick Community College diploma?
SomalyEng
 
Female Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service A...
Female Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service A...Female Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service A...
Female Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service A...
45unexpected
 
VIP Kolkata Girls Call Kolkata 0X0000000X Doorstep High-Profile Girl Service ...
VIP Kolkata Girls Call Kolkata 0X0000000X Doorstep High-Profile Girl Service ...VIP Kolkata Girls Call Kolkata 0X0000000X Doorstep High-Profile Girl Service ...
VIP Kolkata Girls Call Kolkata 0X0000000X Doorstep High-Profile Girl Service ...
sukaniyasunnu
 
Cyber Insurance Mathematical Model & Pricing 2
Cyber Insurance Mathematical Model & Pricing 2Cyber Insurance Mathematical Model & Pricing 2
Cyber Insurance Mathematical Model & Pricing 2
BaraDaniel1
 
AWS re:Invent 2023 - Deep dive into Amazon Aurora and its innovations DAT408
AWS re:Invent 2023 - Deep dive into Amazon Aurora and its innovations DAT408AWS re:Invent 2023 - Deep dive into Amazon Aurora and its innovations DAT408
AWS re:Invent 2023 - Deep dive into Amazon Aurora and its innovations DAT408
Grant McAlister
 
CMO MRM_May 2024 WITH BREAKDOWN AND IMPROVEMENTDATA.pdf
CMO MRM_May 2024 WITH BREAKDOWN AND IMPROVEMENTDATA.pdfCMO MRM_May 2024 WITH BREAKDOWN AND IMPROVEMENTDATA.pdf
CMO MRM_May 2024 WITH BREAKDOWN AND IMPROVEMENTDATA.pdf
IndranilDasgupta19
 
Self-healing Security Systems - CloudIOTEnterpriseSystems-Group5.pptx
Self-healing Security Systems - CloudIOTEnterpriseSystems-Group5.pptxSelf-healing Security Systems - CloudIOTEnterpriseSystems-Group5.pptx
Self-healing Security Systems - CloudIOTEnterpriseSystems-Group5.pptx
BiplabRoy71
 
Verified Girls Call Andheri 9930245274 Unlimited Short Providing Girls Servic...
Verified Girls Call Andheri 9930245274 Unlimited Short Providing Girls Servic...Verified Girls Call Andheri 9930245274 Unlimited Short Providing Girls Servic...
Verified Girls Call Andheri 9930245274 Unlimited Short Providing Girls Servic...
revolutionary575
 
Female Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service An...
Female Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service An...Female Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service An...
Female Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service An...
sheetal singh$A17
 
Solution Manual for First Course in Abstract Algebra A, 8th Edition by John B...
Solution Manual for First Course in Abstract Algebra A, 8th Edition by John B...Solution Manual for First Course in Abstract Algebra A, 8th Edition by John B...
Solution Manual for First Course in Abstract Algebra A, 8th Edition by John B...
rightmanforbloodline
 
PTT of AI Bots, Avatar, business continuity software.
PTT of AI Bots, Avatar, business continuity software.PTT of AI Bots, Avatar, business continuity software.
PTT of AI Bots, Avatar, business continuity software.
arash8484
 
Practical Research for grade 12 students
Practical Research for grade 12 studentsPractical Research for grade 12 students
Practical Research for grade 12 students
juliaaaaana10
 
High Profile Girls Call Mumbai 9910780858 Provide Best And Top Girl Service A...
High Profile Girls Call Mumbai 9910780858 Provide Best And Top Girl Service A...High Profile Girls Call Mumbai 9910780858 Provide Best And Top Girl Service A...
High Profile Girls Call Mumbai 9910780858 Provide Best And Top Girl Service A...
shardda patel
 
Exclusive Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service...
Exclusive Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service...Exclusive Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service...
Exclusive Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service...
sheetal singh$A17
 
The Rise of Python in Finance,Automating Trading Strategies: _.pdf
The Rise of Python in Finance,Automating Trading Strategies: _.pdfThe Rise of Python in Finance,Automating Trading Strategies: _.pdf
The Rise of Python in Finance,Automating Trading Strategies: _.pdf
Riya Sen
 
Water bodies of India - Shubham 8 b.pptx
Water bodies of India - Shubham 8 b.pptxWater bodies of India - Shubham 8 b.pptx
Water bodies of India - Shubham 8 b.pptx
manshinain08
 
Celebrity Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service...
Celebrity Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service...Celebrity Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service...
Celebrity Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service...
arti singh$A17
 
Semantic Web and organizational data .pptx
Semantic Web and organizational data .pptxSemantic Web and organizational data .pptx
Semantic Web and organizational data .pptx
Kanchana Weerasinghe
 

Recently uploaded (20)

History and Application of LLM Leveraging Big Data
History and Application of LLM Leveraging Big DataHistory and Application of LLM Leveraging Big Data
History and Application of LLM Leveraging Big Data
 
BDSM Girls Call Mumbai 👀 9820252231 👀 Cash Payment With Room DeliveryDelivery
BDSM Girls Call Mumbai 👀 9820252231 👀 Cash Payment With Room DeliveryDeliveryBDSM Girls Call Mumbai 👀 9820252231 👀 Cash Payment With Room DeliveryDelivery
BDSM Girls Call Mumbai 👀 9820252231 👀 Cash Payment With Room DeliveryDelivery
 
Where to order Frederick Community College diploma?
Where to order Frederick Community College diploma?Where to order Frederick Community College diploma?
Where to order Frederick Community College diploma?
 
Female Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service A...
Female Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service A...Female Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service A...
Female Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Service A...
 
VIP Kolkata Girls Call Kolkata 0X0000000X Doorstep High-Profile Girl Service ...
VIP Kolkata Girls Call Kolkata 0X0000000X Doorstep High-Profile Girl Service ...VIP Kolkata Girls Call Kolkata 0X0000000X Doorstep High-Profile Girl Service ...
VIP Kolkata Girls Call Kolkata 0X0000000X Doorstep High-Profile Girl Service ...
 
Cyber Insurance Mathematical Model & Pricing 2
Cyber Insurance Mathematical Model & Pricing 2Cyber Insurance Mathematical Model & Pricing 2
Cyber Insurance Mathematical Model & Pricing 2
 
AWS re:Invent 2023 - Deep dive into Amazon Aurora and its innovations DAT408
AWS re:Invent 2023 - Deep dive into Amazon Aurora and its innovations DAT408AWS re:Invent 2023 - Deep dive into Amazon Aurora and its innovations DAT408
AWS re:Invent 2023 - Deep dive into Amazon Aurora and its innovations DAT408
 
CMO MRM_May 2024 WITH BREAKDOWN AND IMPROVEMENTDATA.pdf
CMO MRM_May 2024 WITH BREAKDOWN AND IMPROVEMENTDATA.pdfCMO MRM_May 2024 WITH BREAKDOWN AND IMPROVEMENTDATA.pdf
CMO MRM_May 2024 WITH BREAKDOWN AND IMPROVEMENTDATA.pdf
 
Self-healing Security Systems - CloudIOTEnterpriseSystems-Group5.pptx
Self-healing Security Systems - CloudIOTEnterpriseSystems-Group5.pptxSelf-healing Security Systems - CloudIOTEnterpriseSystems-Group5.pptx
Self-healing Security Systems - CloudIOTEnterpriseSystems-Group5.pptx
 
Verified Girls Call Andheri 9930245274 Unlimited Short Providing Girls Servic...
Verified Girls Call Andheri 9930245274 Unlimited Short Providing Girls Servic...Verified Girls Call Andheri 9930245274 Unlimited Short Providing Girls Servic...
Verified Girls Call Andheri 9930245274 Unlimited Short Providing Girls Servic...
 
Female Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service An...
Female Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service An...Female Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service An...
Female Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service An...
 
Solution Manual for First Course in Abstract Algebra A, 8th Edition by John B...
Solution Manual for First Course in Abstract Algebra A, 8th Edition by John B...Solution Manual for First Course in Abstract Algebra A, 8th Edition by John B...
Solution Manual for First Course in Abstract Algebra A, 8th Edition by John B...
 
PTT of AI Bots, Avatar, business continuity software.
PTT of AI Bots, Avatar, business continuity software.PTT of AI Bots, Avatar, business continuity software.
PTT of AI Bots, Avatar, business continuity software.
 
Practical Research for grade 12 students
Practical Research for grade 12 studentsPractical Research for grade 12 students
Practical Research for grade 12 students
 
High Profile Girls Call Mumbai 9910780858 Provide Best And Top Girl Service A...
High Profile Girls Call Mumbai 9910780858 Provide Best And Top Girl Service A...High Profile Girls Call Mumbai 9910780858 Provide Best And Top Girl Service A...
High Profile Girls Call Mumbai 9910780858 Provide Best And Top Girl Service A...
 
Exclusive Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service...
Exclusive Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service...Exclusive Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service...
Exclusive Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service...
 
The Rise of Python in Finance,Automating Trading Strategies: _.pdf
The Rise of Python in Finance,Automating Trading Strategies: _.pdfThe Rise of Python in Finance,Automating Trading Strategies: _.pdf
The Rise of Python in Finance,Automating Trading Strategies: _.pdf
 
Water bodies of India - Shubham 8 b.pptx
Water bodies of India - Shubham 8 b.pptxWater bodies of India - Shubham 8 b.pptx
Water bodies of India - Shubham 8 b.pptx
 
Celebrity Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service...
Celebrity Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service...Celebrity Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service...
Celebrity Girls Call Noida 🎈🔥9873940964 🔥💋🎈 Provide Best And Top Girl Service...
 
Semantic Web and organizational data .pptx
Semantic Web and organizational data .pptxSemantic Web and organizational data .pptx
Semantic Web and organizational data .pptx
 

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.