Dynamic Analysis. The job of the reverse engineer is similar to the one of the doctor, as they both need to reason about an unknown complex system.

Similar documents
How To Understand And Understand Smalltalk

Exploiting Dynamic Information in IDEs Eases Software Maintenance

Understanding Software Static and Dynamic Aspects

IMPROVING JAVA SOFTWARE THROUGH PACKAGE STRUCTURE ANALYSIS

The Class Blueprint A Visualization of the Internal Structure of Classes

CodeCrawler An Extensible and Language Independent 2D and 3D Software Visualization Tool

Software visualization. Why visualization?

Software Visualization and Model Generation

Stéphane Ducasse. 43 years INRIA Lille Nord Europe- LIFL/USTL - CNRS UMR8022

BugMaps-Granger: A Tool for Causality Analysis between Source Code Metrics and Bugs

Software Analysis Visualization

Gadget: A Tool for Extracting the Dynamic Structure of Java Programs

Program Understanding with Code Visualization

A Thread Monitoring System for Multithreaded Java Programs

Verifying Business Processes Extracted from E-Commerce Systems Using Dynamic Analysis

Génie Logiciel et Gestion de Projets. Evolution

Software Bugs and Evolution: A Visual Approach to Uncover Their Relationship

Java Wiretap. Extracting Feature Execution Models for Reverse Engineering

Representing Code History with Development Environment Events

Using Recovered Views to Track Architectural Evolution

Online Construction of Dynamic Object Process Graphs

A Framework of Model-Driven Web Application Testing

Using Library Dependencies for Clustering

VISUALIZATION APPROACH FOR SOFTWARE PROJECTS

Strategies for Program Inspection and Visualization

Securing PHP Based Web Application Using Vulnerability Injection

Enterprise Navigator: A System for Visualizing and Analyzing Software Infrastructures

Resource Management and Containment for Active Services

VisCG: Creating an Eclipse Call Graph Visualization Plug-in. Kenta Hasui, Undergraduate Student at Vassar College Class of 2015

Supporting Software Development Process Using Evolution Analysis : a Brief Survey

Monitoring, Tracing, Debugging (Under Construction)

Visualizing the Execution of Java Programs

Advanced compiler construction. General course information. Teacher & assistant. Course goals. Evaluation. Grading scheme. Michel Schinz

An Eclipse Plug-In for Visualizing Java Code Dependencies on Relational Databases

EvoSpaces: 3D Visualization of Software Architecture

Program Understanding in Software Engineering

Towards Lightweight Logging and Replay of Embedded, Distributed Systems

SAPM Overview. Semester Summary. Project management. Tools (1) Dr. James A. Bednar

Software Visualization

A Visualization Technique for Monitoring of Network Flow Data

BugMaps-Granger: a tool for visualizing and predicting bugs using Granger causality tests

Software Engineering & Architecture

Component visualization methods for large legacy software in C/C++

Performance Measurement of Dynamically Compiled Java Executions

An Exception Monitoring System for Java

Visualizing Information Flow through C Programs

Glossary of Object Oriented Terms

A Linux Kernel Auditing Tool for Host-Based Intrusion Detection

SAPM Overview Semester Summary

International Journal of Computer Engineering and Applications, Volume V, Issue III, March 14

International Workshop on Field Programmable Logic and Applications, FPL '99

Compiling Object Oriented Languages. What is an Object-Oriented Programming Language? Implementation: Dynamic Binding

HAVING a good mental model of how a

Tudumi: Information Visualization System for Monitoring and Auditing Computer Logs

How To Trace

Using Clang to Visualize Large Codebases. Nathan Hawes and Ben Barham Oracle Labs Australia October 2014

Performance Analysis and Optimization Tool

Eclipse A Case Study in Software Visualization Based on Static Analysis

Génie Logiciel et Gestion de Projets. Patterns

The Basics of Graphical Models

Visual Analysis Tool for Bipartite Networks

Software Visualization Tools for Component Reuse

Comprensione del software - principi base e pratica reale 5

Malware Detection in Android by Network Traffic Analysis

GSPIM: Graphical Visualization Tool for MIPS Assembly

What is LOG Storm and what is it useful for?

Coordinated Visualization of Aspect-Oriented Programs

A Tool for Visual Understanding of Source Code Dependencies

Managing and Tracing the Traversal of Process Clouds with Templates, Agendas and Artifacts

DESIGN AND VERIFICATION OF LSR OF THE MPLS NETWORK USING VHDL

Visualization. Program visualization

On the value of hybrid security testing

Visualization methods for patent data

A Comparison of General Approaches to Multiprocessor Scheduling

Chapter 12 Programming Concepts and Languages

Integration of the OCM-G Monitoring System into the MonALISA Infrastructure

Visual Data Mining: A Review

Visualizing Software Architecture Evolution using Change-sets

A COLLABORATIVE BACHELOR'S DEGREE IN SOFTWARE ENGINEERING

A Strategy to Perform Coverage Testing of Mobile Applications

A Categorization of Classes based on the Visualization of their Internal Structure: the Class Blueprint

Animating Programs and Students in the Laboratory

GBIL: Generic Binary Instrumentation Language. Andrew Calvano. September 24 th, 2015

Database Application Developer Tools Using Static Analysis and Dynamic Profiling

Combining Static and Dynamic Impact Analysis for Large-scale Enterprise Systems

Image Compression through DCT and Huffman Coding Technique

JSquash: Source Code Analysis of Embedded Database Applications for Determining SQL Statements

Visualizing Software Projects in JavaScript

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters

Intellect Platform - The Workflow Engine Basic HelpDesk Troubleticket System - A102

find model parameters, to validate models, and to develop inputs for models. c 1994 Raj Jain 7.1

Baseline Code Analysis Using McCabe IQ

A Visualization Approach for Bug Reports in Software Systems

A Comparison of Dictionary Implementations

COMPARING MATRIX-BASED AND GRAPH-BASED REPRESENTATIONS FOR PRODUCT DESIGN

P ERFORMANCE M ONITORING AND A NALYSIS S ERVICES - S TABLE S OFTWARE

What Questions Developers Ask During Software Evolution? An Academic Perspective

DocAve 4.1 Backup User Guide

Persistent Binary Search Trees

Topology-based network security

Transcription:

Dynamic Analysis Tudor Gîrba www.tudorgirba.com The job of the reverse engineer is similar to the one of the doctor, as they both need to reason about an unknown complex system. One way to gain insights is to see the system in action. The first thing doctors do in an emergency room is to attach various instruments to the patient to follow the evolution of his condition.

Watching a system run, can reveal a great deal of information about the problem. For example, some reverse engineering patterns mentioned before are related to observing the system run: - Interview during demo - Step through the execution - Tests, your life insurance Dynamic analysis is the analysis of the properties of a running program What properties? Thomas Ball, The Concept of Dynamic Analysis, Proceedings of the European Software Engineering Conference and ACM SIGSOFT International Symposium on the Foundations of Software Engineering (ESEC/FSC'99), LNCS, no. 687, Springer Verlag, Heidelberg, September 999, pp. 26 234. Ball 999 First letʼs see what makes the dynamic analysis space. It all starts from the first execution. main()

The main method calls a method. method() and so on. After a method returns, another method is called. Thus, the totality of method executions can be seen as a tree.

Dynamic information offers detailed information about the communication in the system. Dynamic analysis offers precise information Still, the problem is that the dynamic space offers too many details. Thus, we have to know what data to gather and for what purpose. We need to know how to model that data. And we need to know how to obtain the data. How to instrument What to capture and why How to model What to execute How to instrument

The most primitive way of debugging is to print the state of the system at a certain moment. Letʼs call this the the poor manʼs debugging. public class BankAccount { private Money balance; public void deposit(money amount) { System.out.println( deposit ); this.balance += money; } } import org.apache.log4j.logger; public class BankAccount { private Money balance; Using a logging framework improves the situation by being able to customize what happens with the data. Still, we have to add the hooks by hand directly in the code. We also do not keep information about the control flow. public void deposit(money amount) { logger.info( deposit ); this.balance += money; } } Method Wrappers and Aspects intervene before and after each interesting method Another possibility is to insert the instrumentation code around the methods of interests. Two solutions are Aspects and Method Wrappers. With Aspects we can inject the instrumentation in the code. Method Wrappers wrap the original methods and thus can be used to control the instrumentation.

Profilers probe the system Yet another possibility is to run the original program in a process and in another process of higher priority to run a loop that probes the original process. 3 + 4 And yet another possibility is to insert the instrumentation code directly in the bytecode. This example shows the bytecode of a Smalltalk method returning 3+4. pushconstant: 3 pushconstant: 4 popintotemp: 0 put argument in temp 0 popintotemp: put receiver in temp send: + perform addition returntop 3 + 4 insertbefore: 'Transcript show: <meta: #receiver>' pushconstant: 3 pushconstant: 4 popintotemp: 0 "put argument in temp 0" popintotemp: "put receiver in temp " pushlit: ##Transcript "start of inserted code" pushtemp: "push receiver for printing" send: asstring send: show: pop "end of inserted code" pushtemp: "rebuild the stack" pushtemp: 0 send: + returntop Denker 2008 Marcus Denker, Stéphane Ducasse and Éric Tanter, Runtime Bytecode Transformation for Smalltalk, Journal of Computer Languages, Systems and Structures, vol. 32, no. 2-3, July 2006, pp. 25-39. When we want to insert before this method execution a printout of the receiver, the code can look like in the picture. The main benefit here is that we have no intermediary code that needs to be executed (like for example in the case of Method Wrappers). Still, the problem is that

3 + 4 Marcus Denker, Stéphane Ducasse, Adrian Lienhard and Philippe Marschall, Sub- Method Reflection, Journal of Object Technology, Special Issue. Proceedings of TOOLS Europe 2007, vol. 6/9, ETH, October 2007, pp. 23 25. Message (+) Receiver (3) Arguments (4) Denker etal 2007 3 + 4 insertbefore: 'Transcript show: <meta: #receiver>' Marcus Denker, Stéphane Ducasse, Adrian Lienhard and Philippe Marschall, Sub- Method Reflection, Journal of Object Technology, Special Issue. Proceedings of TOOLS Europe 2007, vol. 6/9, ETH, October 2007, pp. 23 25. before Transcript show: <meta: #receiver> Message (+) Receiver (3) Arguments (4) Denker etal 2007 How to instrument What to capture and why

One common use of dynamic analysis is profiling. Targets can be: - CPU and memory usage (top) - Network usage (netstat, tcpdump) - Open files, pipes, sockets (lsof) Collecting Garbage is a Dynamic Analysis Possible implementations are: - reference counter: it counts the number of references for each object and the objects with 0 references are discarded (rarely used now) - traverse, mark and clean: another solution is to traverse the memory and mark each objects as they are reached. Those that are not reached get cleaned. The Control Flow is the most common focus Dynamic analysis comes from procedural programming, that is why many dynamic analyses focus on the control flow.

Wim De Pauw, David Lorenz, John Vlissides and Mark Wegman, Execution Patterns in Object-Oriented Visualization, Proceedings of Conference on Object-Oriented Technologies and Systems (COOTS'98), USENIX, 998, pp. 29 234. The runtime of a system contains tons of data. We need effective means to distill relevant information from this data. De Pauw etal 998 This picture shows a compressed view an execution trace. The orange line at the bottom represents the root of the tree, and the dots from on top represent the leaves of the tree. The colors denote various activation types and reveal repeating patterns. De Pauw etal 998 Trace Signals reveal similar execution traces Adrian Kuhn and Orla Greevy, Exploiting the Analogy Between Traces and Signal Processing, Proceedings IEEE International Conference on Software Maintainance (ICSM 2006), IEEE Computer Society Press, Los Alamitos CA, September 2006, pp. 320-329. Another approach summarizes traces into signals (each dot represents an activation) and orders several traces to reveal similarities. Kuhn, Greevy 2006

Wim De Pauw, David Lorenz, John Vlissides and Mark Wegman, Execution Patterns in Object-Oriented Visualization, Proceedings of Conference on Object-Oriented Technologies and Systems (COOTS'98), USENIX, 998, pp. 29 234. Another use case for dynamic analysis is the recovery of sequence diagrams. In this case, activations are related to instances. Such a visualization is only useful when fine grained details are needed. De Pauw etal 998 Inter Class Call Matrix shows how classes collaborate at runtime Wim De Pauw, Richard Helm, Doug Kimelman and John Vlissides, Visualizing the Behavior of Object-Oriented Systems, Proceedings of International Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA'93), October 993, pp. 326 337. A more coarse grained view is to relate instances to their classes and to recover the runtime communication between classes. De Pauw etal 993 Communication Interaction shows how classes collaborate at runtime Stéphane Ducasse, Michele Lanza and Roland Bertuli, High-Level Polymetric Views of Condensed Run-Time Information, Proceedings of 8th European Conference on Software Maintenance and Reengineering (CSMR'04), IEEE Computer Society Press, Los Alamitos CA, 2004, pp. 309 38. Another example of class runtime communication. Classes are shown as nodes, and method executions as edges. The graph is arranged according to a spring layout. Ducasse etal 2004

A meta-model guides the way we think of a problem domain. What is a good metamodel for dynamic analysis? How to instrument What to capture and why How to model This is the space that needs to be modeled. Each node in the trace is called an Activation. sender 0.. Activation

It represents an Activation of a Method. The relationship between Activation and Method allows us to link dynamic information with static information. sender 0.. Activation Class Method While engineers see internal structure, users see features. One particular opportunity offered by dynamic analysis is to bridge the two worlds by recovering the mapping between features and the code parts that implement them. A feature is an observable unit of behavior of a system triggered by the user Eisenbarth etal 2003 We can manually pick the start and end of a feature while we instrument the system. Feature Feature 2... Feature n

Thus, a Feature is a set of activations. sender 0.. Activation Class Method Feature Software Reconnaissance identifies where features are implemented Norman Wilde and Michael Scully, Software Reconnaisance: Mapping Program Features to Code, Journal on Software Maintenance: Research and Practice, vol. 7, no., 995, pp. 49 62. Software Reconnaisance is a technique to recover the mapping between code parts and features. First, the program is ran by exercising the feature (blue classes), and then it is ran without exercising the feature (red classes). Thus, candidates for most specific classes for a feature are those that appear in the first run, but do not appear in the second one. Wilde, Scully 995 Andy Zaidman and Serge Demeyer, Managing trace data volume through a heuristical clustering process based on event execution frequency, Proceedings IEEE European Conference on Software Maintenance and Reengineering (CSMR'04), IEEE Computer Society Press, Los Alamitos CA, March 2004, pp. 329 338. In this approach, to identify where to start implementing a new feature is to first identify the most specific part of a similar feature. Shown in the graph is a signal of an execution trace. The signal shows repeating patterns in the execution of the similar feature that can be good starting points. Zaidman, Demeyer 2004

Feature Views show how features cover classes Orla Greevy, Stéphane Ducasse and Tudor Gîrba, Analyzing Software Evolution through Feature Views, Journal of Software Maintenance and Evolution: Research and Practice (JSME), vol. 8, no. 6, 2006, pp. 425 456. In this case, boxes are features and squares are classes. The color of a class is given by the degree of class participation in features: - cyan denotes classes that only appear in this feature - yellow denotes classes that appear in less than 50% of features - orange denotes classes that appear in more than 50% of features - red denotes classes that appear in all features addfolder addpage Greevy etal 2006 Here we show an example of how we can combine two analyses (namely, ownership map and feature views) to obtain identify how developers work on features. addfolder addpage Team Collaboration shows how authors develop features Orla Greevy, Tudor Gîrba and Stéphane Ducasse, How Developers Develop Features, Proceedings of th European Conference on Software Maintenance and Reengineering (CSMR 2007), IEEE Computer Society, Los Alamitos CA, 2007, pp. 256 274. In this view, each box represents a feature, and each square represents a class. This time, the color of a class is given by the owner of that class. Thus, the totality of colors in a box represents the team that develops it. The boxes are arranged according to a partial order (the features on top have a large team than those on the bottom). Greevy etal 2007

How to instrument What to capture and why How to model Method execution traces do not reveal how objects refer to each other object references evolve The runtime is more than method activations The Smalltalk inspector allows us to check the state of objects at runtime.

Because of side effects (storing values in instance variables), the way an object gets into a specific state is not obvious. return field-write return field-read parameter field-read allocation Object Flow captures object aliases Adrian Lienhard and Stéphane Ducasse and Tudor Gîrba. Taking an Object-Centric View on Dynamic Information with Object Flow Analysis. In Journal of Computer Languages, Systems and Structures 35() p. 63--79, 2009. In this example, the gray tree represents the control flow, while the red tree represents the flow of one object. The object flow intertwines the control flow and tells a complementary story. Lienhard 2009 sender 0.. Activation Class Method Feature

To model how objects flow, we first model instances. Instance sender 0.. Activation Class Method Feature Aliases model a reference to an Instance. An alias is obtained from a possible parent Alias. Thus, Aliases form a tree. 0.. parent subject Alias Instance receiver creator sender 0.. Activation Class Method Both the receiver of an Activation and its creator are not represented directly by Instances but by Aliases. As such, we can know exactly where an alias was used. Feature 0.. parent subject Alias Instance receiver creator sender 0.. Activation Feature Class Method Attribute There can be several types of creating an alias: - by passing it via an argument - by returning it from a method - by storing in/reading from a temp variable - by storing in/reading from a field The field alias is shown as linked to its static counter part, Attribute. Similar relationships exist for ArgumentAliases and TemoAliases. ArgumentAlias ReturnAlias TempAlias FieldAlias

Inter Unit Flow shows how objects move Adrian Lienhard, Stéphane Ducasse and Tudor Gîrba, Object Flow Analysis Taking an Object-Centric View on Dynamic Analysis, Proceedings of the 2007 International Conference on Dynamic Languages (ICDL'07), ACM Digital Library, New York, NY, USA, 2007, pp. 2 40. The view shows modules or units as nodes and the amount of objects transmitted as edges. The system under study is an compiler: the objects flow from the Scanner to the Parser, then to the Intermediate Representation Builder and finally to the ByteCodeGenerator. Lienhard etal 2007 Object Dependencies reveal features dependencies drian Lienhard, Orla Greevy and Oscar Nierstrasz, Tracking Objects to detect Feature Dependencies, Proceedings of International Conference on Program Comprehension (ICPC'07), IEEE Computer Society, Washington, DC, USA, June 2007, pp. 59 68. This view shows objects and references. The color denotes the moment of the creation of the object. The scale of gray is given by the different features exercised. In this example, the system is an IRC client and the features are executed in order: open, connect, join channel, send message to the channel. Open Connect Join Channel Send Message Lienhard etal 2007 In 50% of the cases the execution stack contains essentially no information about the bug s cause Ben Liblit, Mayur Naik, Alice X. Zheng, Alex Aiken and Michael I. Jordan, Scalable statistical bug isolation, Proceedings of the 2005 ACM SIGPLAN conference on Programming language design and implementation (PLDI'05), ACM, New York, NY, USA, 2005, pp. 5 26. Liblit etal 2005

Back in time debuggers remember more than the current stack The screenshot is taken from the Compass prototype developed by Julien Fierz. Fierz 2008 To interpret the result of a dynamic analysis, you have to control what is executed. How to instrument What to capture and why How to model What to execute The runtime is more than method activations Tudor Gîrba www.tudorgirba.com creativecommons.org/licenses/by/3.0/