Visualizing Memory Graphs by Thomas Zimmermann and Andreas Zeller Presented by Giannakaras Giorgos University of Konstanz Department of Computer and Information.

Slides:



Advertisements
Similar presentations
Chapter 10, Section 10.3 Tree Traversal
Advertisements

CH4.1 Type Checking Md. Fahim Computer Engineering Department Jamia Millia Islamia (A Central University) New Delhi –
Chapter 19 Vectors, templates, and exceptions Bjarne Stroustrup
Introduction to C Programming
Tintu David Joy. Agenda Motivation Better Verification Through Symmetry-basic idea Structural Symmetry and Multiprocessor Systems Mur ϕ verification system.
Pointer Lesson 2 CS1313 Spring Pointer Lesson 2 Outline 1.Pointer Lesson 2 Outline 2.Pass by Reference Bad Example 3.Pass by Reference Good Example.
General algorithmic techniques: Balanced binary tree technique Doubling technique: List Ranking Problem Divide and concur Lecture 6.
Question Bank. Explain the syntax of if else statement? Define Union Define global and local variables with example Concept of recursion with example.
CSC211 Data Structures Lecture 9 Linked Lists Instructor: Prof. Xiaoyan Li Department of Computer Science Mount Holyoke College.
Section 2.5: Graphs and Trees
January 23 rd, Document classification task We are interested to solve a task of Text Classification, i.e. to automatically assign a given document.
User Defined Functions
C Language.
Introduction to Algorithms Lecture 12 Prof. Constantinos Daskalakis CLRS
Pointers Pointer is a variable that contains the address of a variable Here P is sahd to point to the variable C C 7 34……
Data Structures Using C++ 2E
Advanced Topics in Algorithms and Data Structures
1 Programming Languages (CS 550) Mini Language Interpreter Jeremy R. Johnson.
Constructor. 2 constructor The main use of constructors is to initialize objects. A constructor is a special member function, whose name is same as class.
Chapter 6 Type Checking. The compiler should report an error if an operator is applied to an incompatible operand. Type checking can be performed without.
CPSC 388 – Compiler Design and Construction Parameter Passing.
CS 261 – Recitation 9 & 10 Graphs & Final review
Copyright © 2012 Pearson Education, Inc. Chapter 9: Pointers.
CS2420: Lecture 37 Vladimir Kulyukin Computer Science Department Utah State University.
Declaring Arrays Declare an array of 10 elements: int nums[10]; Best practice: #define SIZE 10 int nums[SIZE]; // cannot be int[SIZE] nums; C99: int nums[someVariable]
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 9 Pointers and Dynamic Arrays.
1 Type Type system for a programming language = –set of types AND – rules that specify how a typed program is allowed to behave Why? –to generate better.
CS 225 Lab #2 - Pointers, Copy Constructors, Destructors, and DDD.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 9: Pointers.
Self Referential Structure. A structure may not contain a member of its own type. struct check { int item; struct check n; // Invalid };
1/25 Pointer Logic Changki PSWLAB Pointer Logic Daniel Kroening and Ofer Strichman Decision Procedure.
KNURE, Software department, Ph , N.V. Bilous Faculty of computer sciences Software department, KNURE The trees.
Trees and Tree Traversals Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Chapter TwelveModern Programming Languages1 Memory Locations For Variables.
Feudal C Automatic memory management with zero runtime overhead CS263 - Spring 1999 Scott McPeak Dan Bonachea Carol Hurwitz C.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 13 Pointers and Linked Lists.
Values, variables and types © Allan C. Milne v
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9: Pointers.
Copyright © Cengage Learning. All rights reserved. CHAPTER 10 GRAPHS AND TREES.
CSCI 115 Chapter 7 Trees. CSCI 115 §7.1 Trees §7.1 – Trees TREE –Let T be a relation on a set A. T is a tree if there exists a vertex v 0 in A s.t. there.
Programming Languages by Ravi Sethi Chapter 6: Groupings of Data and Operations.
1 Jeff Edmonds York University COSC 2011 Lecture 2 Abstract Positions/Pointers Positions in an Array Pointers in C References in Java Implementing Positions.
Chapter 16 – Data Structures and Recursion. Data Structures u Built-in –Array –struct u User developed –linked list –stack –queue –tree Lesson 16.1.
C Programming Lecture 16 Pointers. Pointers b A pointer is simply a variable that, like other variables, provides a name for a location (address) in memory.
Principles of programming languages 6: Types Isao Sasano Department of Information Science and Engineering.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Pointers and Dynamic Arrays.
Modelling of Ecosystems by Tools from Computer Science Summer School at Czech University of Life Sciences, Prague, September, 2013 Winfried Kurth.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 9 Pointers and Dynamic Arrays.
1  Lecture 12 – Pointer FTMK, UTeM – Sem /2014.
A FIRST BOOK OF C++ CHAPTER 8 ARRAYS AND POINTERS.
What do I need to Know For My Assignment?. C Pointer Review To declare a pointer, we use the * operator. This is similar to but different from using *
©2004 Joel Jones 1 CS 403: Programming Languages Lecture 3 Fall 2004 Department of Computer Science University of Alabama Joel Jones.
C++ for Engineers and Scientists Second Edition Chapter 12 Pointers.
Pointers Lecture: 5. Topics 1 Pointers and the Address Operator 2 Pointer Variables 3 The Relationship Between Arrays and Pointers 4 Pointer Arithmetic.
Pointers Data Structures CSI 312 CSI Dept. Dr. Yousef Qawqzeh.
Design issues for Object-Oriented Languages
STACKS & QUEUES for CLASS XII ( C++).
Pointers and Dynamic Arrays
Pointers and Linked Lists
Pointers and Linked Lists
Principles of programming languages 8: Types
Stack Lesson xx   This module shows you the basic elements of a type of linked list called a stack.
Pointers and References
FP Foundations, Scheme In Text: Chapter 14.
Pointer & Memory Allocation Review
CS410 – Software Engineering Lecture #5: C++ Basics III
A simple function.
C# Language & .NET Platform 10th Lecture
Presentation transcript:

Visualizing Memory Graphs by Thomas Zimmermann and Andreas Zeller Presented by Giannakaras Giorgos University of Konstanz Department of Computer and Information Science Prof. Dr Stefan Leue, Wei Wei Software Visualization SS 2006

2 Outline Motivation Structure of Memory Graphs Obtaining Memory Graphs Conclusion

3 Motivation GNU debugger GDB Values are shown as texts. Problem A user will never notice if 2 pointers point to the same address – except by thoroughly checking and comparing pointer values.

4 Motivation GNU DDD debugger Models memory as a graph. Each value in memory becomes a vertex and references between values become edges between these vertices (i.e. pointers). Drawback Each and every pointer of a data structure must be dereferenced manually.

5 Motivation Memory graphs A memory graph captures the program state as a graph. The graph is extracted automatically from a program. Usefulness Checking if there are pointers pointing to a specific address. Checking the number of elements a data structure has. Checking if an allocated memory block is reachable from within a module. Checking if the tree changed during the last function call.

6 Example Graph

7 Structure of Memory Graphs Graph Notation  G = (V, E, root) V : set of vertices E : set of edges root : dedicated vertex root Vertices  v = (val, tp, addr) val : value tp : type addr : memory address Edges  e = (v 1, v 2, op) v 1, v 2 : related vertices op : operation which takes the expression of v 1 to construct the expression of v 2.

8 Structure of Memory Graphs Edge Operations Construct the name of the descendants from their parent’s name. Operations on edges leading from root to base variables initially set the name. We denote functions by λx.B – a function that has a formal parameter x and a body B. In our graph visualizations the operation body is shown as edge label with the formal parameter replaced by “()“. Root References all base variables of the program. Each vertex in the graph is accessible from the root.

9 Structure of Memory Graphs Example 1.C declaration of a struct f : struct foo { int val; } f = {47}; 2.Results in 2 vertices and an edge :  V f = ({…}, struct foo, 0x5678)  V f.val = (47, int, 0x9abc)  e f.val = (v f, v f.val, op f.val ) 3.Corresponding Memory Graph

10 Obtaining Memory Graphs

11 Obtaining Memory Graphs To obtain a memory graph G = (V, E, root) : Let unfold(parent, op, G) be a procedure that takes the name of a parent expression parent and an operation op and unfolds the element op(parent), adding new edges and vertices to the memory graph. Initialize V = {root} and E = Invoke unfold(root, λx.“name“) for each base variable name in the program. The expression expr = op(parent) that will be unfolded depends on the structure of the expr :

12 Obtaining Memory Graphs Aliases : if V already has a vertex v΄at the same address and with the same type, do not unfold expr again. However insert an edge (parent, v΄, op) to the existing vertex. Records : if expr is a record containing n members m 1, m 2,...m n, add a vertex v = ({...}, tp, addr) to V, and an edge (parent, v, op) to E. For each m i {m 1, m 2, m n } invoke unfold(expr, λx.“x.m i “, G), unfolding the record members. Arrays : if expr is an array containing n members m[0], m[1],..., m[n-1], add a vertex v = ([...], tp, addr) to V and an edge (parent, v, op) to E. For each i {0, 1,..., n} invoke unfold(expr, λx.“x[i]“, G), unfolding the array elements. Pointers : if expr is a pointer with address value val, add a vertex v = (val, tp, addr) to V and an edge (parent, v, op) to E. Invoke unfold(expr, λx.“*(x)“, G), unfolding the element that expr points to. Atomic values : if expr contains an atomic value val, add a vertex v = (val, tp, addr) to V and an edge (parent, v, op) to E.

13 Obtaining Memory Graphs Example 1.#include 2.#include 3.#define M 3 4.#define N 2 5.// _break is used to set the breakpoint 6.void _break() {} 7.main() { 8. int dim2[M][N]; 9. int i, j; for (i=0; i<M; i++) 12. for (j=0; j<N; j++) 13. dim2[i][j]=i*N+j; 14. _break(); }

14 Graph Differences Comparing program states In an alternate program run, all pointers can have different values, but still the same semantics. Comparing program states using a graph is a simple operation, since we try to detect the greatest common sub graph. Usefulness Comparing memory graphs gives us the ability to detect exactly where a failure has occurred.

15 Graph Differences Maximum common subgraph 1.Create the set of all pairs of vertices (v 1, v 2 ) with the same value and the same type, one from each graph. 2.Form the correspondence graph C whose nodes are the pairs from (1). 3.The maximal common sub graph then corresponds to the complete sub graph of C that is not contained to any other complete sub graph.  Any vertex that is not on the clique indicates a difference between G 1 and G 2.

16 Drawing Memory Graphs DOT graph layouter Layouts are nice and descriptive. They do not scale to large memory graphs (1000 vertices and more).

17 Drawing Memory Graphs h3viewer Interactive graph rendering tool that allows the user to navigate along the graph. Clicking on any vertex brings it on the front, showing detailed information. By dragging and rotating the view, the user can quickly follow and examine data structures.

18 Conclusion – Future Work Applications Visualization of all data structures in memory and capturing the entire program state. Detection of common sub graphs to isolate differences between program states – especially differences that cause failure. Limitations – Drawbacks Limitation in visualization : lack of capability to depict graphs which contain more than vertices. Not easily task to detect cycles in very large graphs which might cause endless recursions and eventually eating up all available heap space.

19 Conclusion – Future Work Enhancements - Improvements Summarizing parts of the graph – Instead of showing all n elements of a list it might suffice to present only the basic shape of the list. Reducing the graph size : pruning the graph at a certain depth in order to restrict the view to a particular module or variable. Development of graph algorithms for the detection of specific trouble spots or invariant violations.

END OF PRESENTATION