Mining Operational Preconditions. Andrzej Wasylkowski Andreas Zeller Saarland University

Size: px
Start display at page:

Download "Mining Operational Preconditions. Andrzej Wasylkowski Andreas Zeller Saarland University"

Transcription

1 Mining Operational Preconditions Andrzej Wasylkowski Andreas Zeller Saarland University

2

3 @interface A {} bug.aj aspect Test { int var* : int var* interface Subject {} } public int Subject.vara; public int Subject.varb; class X implements Test.Subject {}

4

5

6 ajc Stack Trace java.util.nosuchelementexception at java.util.abstractlist$itr.next(abstractlist.java:427) at org.aspectj.weaver.bcel.bcelclassweaver.weaveatfieldrepeatedly (BcelClassWeaver.java:1016)

7 ajc Stack Trace java.util.nosuchelementexception at java.util.abstractlist$itr.next(abstractlist.java:427) at org.aspectj.weaver.bcel.bcelclassweaver.weaveatfieldrepeatedly (BcelClassWeaver.java:1016)

8 weaveatfieldrepeatedly for (Iterator iter = itdfields.iterator(); iter.hasnext();) {... for (Iterator iter2 = worthretrying.iterator(); iter.hasnext();) {... } }

9 weaveatfieldrepeatedly for (Iterator iter = itdfields.iterator(); iter.hasnext();) {... for (Iterator iter2 = worthretrying.iterator(); iter.hasnext();) {... } should be iter2 }

10 weaveatfieldrepeatedly for (Iterator iter = itdfields.iterator(); iter.hasnext();) {... for (Iterator iter2 = worthretrying.iterator(); iter.hasnext();) {... } should be iter2 } Invalid iterator usage: hasnext() should precede next()

11 Preconditions

12 Preconditions Invoking next() with no next element violates a precondition

13 Preconditions Invoking next() with no next element violates a precondition Traditional preconditions are axiomatic describing the state of the system

14 Preconditions Invoking next() with no next element violates a precondition Traditional preconditions are axiomatic describing the state of the system How do we reach this state?

15 Preconditions

16 Preconditions close(int fildes)

17 Preconditions close(int fildes) Axiomatic: fildes is a valid file descriptor

18 Preconditions close(int fildes) Axiomatic: fildes is a valid file descriptor Operational: fildes stems from a call to open() with read() and write() calls in between

19 Preconditions close(int fildes) Axiomatic: fildes is a valid file descriptor Operational: fildes stems from a call to open() with read() and write() calls in between Can we check operational preconditions?

20 OP-Miner

21 Program OP-Miner

22 OP-Miner Usage Models Program iter.hasnext () iter.next ()

23 OP-Miner Usage Models Temporal Properties Program iter.hasnext () iter.next () hasnext next hasnext hasnext next hasnext next next

24 OP-Miner Usage Models Temporal Properties Program iter.hasnext () iter.next () hasnext next hasnext hasnext next hasnext next next Patterns hasnext next hasnext hasnext

25 OP-Miner Usage Models Temporal Properties Program iter.hasnext () iter.next () hasnext next hasnext hasnext next hasnext next next Anomalies Patterns hasnext next hasnext hasnext hasnext next hasnext hasnext hasnext next hasnext hasnext

26 OP-Miner Usage Models Temporal Properties Program iter.hasnext () iter.next () hasnext next hasnext hasnext next hasnext next next Anomalies Patterns hasnext next hasnext hasnext hasnext next hasnext hasnext hasnext next hasnext hasnext

27 Method Models public Stack createstack () { Random r = new Random (); int n = r.nextint (); Stack s = new Stack (); int i = 0; while (i < n) { s.push (rand (r)); i++; } s.push (-1); return s; }

28 Method Models public Stack createstack () { Random r = new Random (); int n = r.nextint (); Stack s = new Stack (); int i = 0; while (i < n) { s.push (rand (r)); i++; } s.push (-1); return s; }

29 Method Models public Stack createstack () { Random r = new Random (); int n = r.nextint (); Stack s = new Stack (); int i = 0; while (i < n) { s.push (rand (r)); i++; } s.push (-1); return s; } Random r = new Random ();

30 Method Models public Stack createstack () { Random r = new Random (); int n = r.nextint (); Stack s = new Stack (); int i = 0; while (i < n) { s.push (rand (r)); i++; } s.push (-1); return s; } Random r = new Random (); int n = r.nextint (); Stack s = new Stack (); int i = 0;

31 Method Models public Stack createstack () { Random r = new Random (); int n = r.nextint (); Stack s = new Stack (); int i = 0; while (i < n) { s.push (rand (r)); i++; } s.push (-1); return s; } Random r = new Random (); int n = r.nextint (); Stack s = new Stack (); int i = 0; i < n i++; s.push (rand (r));

32 Method Models public Stack createstack () { Random r = new Random (); int n = r.nextint (); Stack s = new Stack (); int i = 0; while (i < n) { s.push (rand (r)); i++; } s.push (-1); i < n return s; } s.push (-1); Random r = new Random (); int n = r.nextint (); Stack s = new Stack (); int i = 0; i < n i++; s.push (rand (r));

33 Method Models public Stack createstack () { Random r = new Random (); int n = r.nextint (); Stack s = new Stack (); int i = 0; while (i < n) { s.push (rand (r)); i++; } s.push (-1); i < n return s; } s.push (-1); Random r = new Random (); int n = r.nextint (); Stack s = new Stack (); int i = 0; i < n i++; s.push (rand (r));

34 Usage Models Random r = new Random (); int n = r.nextint (); Stack s = new Stack (); int i = 0; i < n s.push (-1); i < n s.push (rand (r)); i++;

35 Usage Models Stack s = new Stack (); s.push (-1); s.push (rand (r));

36 Usage Models s.<init>() s.push (_) s.push (_)

37 Usage Models Random r = new Random (); int n = r.nextint (); Stack s = new Stack (); int i = 0; i < n s.push (-1); i < n s.push (rand (r)); i++;

38 Usage Models Random r = new Random (); int n = r.nextint (); s.push (rand (r));

39 Usage Models r.<init> () r.nextint () Utils.rand (r)

40 JPanel.add() panel.<init> () panel.<init> (...) panel.setlayout (...) panel.add (...,...) panel.add (...,...)

41 ASTNode.reapPropertyList() list.<init> ASTNode.createPropertyList (..., list) ASTNode.addProperty (..., list) ASTNode.reapPropertyList (list)

42 Resource.getFlags() resource.getresourceinfo (...,...) resource.getflags (...)

43 OP-Miner Usage Models Temporal Properties Program iter.hasnext () iter.next () hasnext next hasnext hasnext next hasnext next next Anomalies Patterns hasnext next hasnext hasnext hasnext next hasnext hasnext hasnext next hasnext hasnext

44 OP-Miner Usage Models Temporal Properties Program iter.hasnext () iter.next () hasnext next hasnext hasnext next hasnext next next Anomalies Patterns hasnext next hasnext hasnext hasnext next hasnext hasnext hasnext next hasnext hasnext

45 Methods vs. Properties Temporal Properties start stop lock unlock eof close Methods

46 Methods vs. Properties Temporal Properties start stop lock unlock eof close get() Methods

47 Methods vs. Properties Temporal Properties start stop lock unlock eof close get() Methods open()

48 Methods vs. Properties Temporal Properties start stop lock unlock eof close get() Methods open() hello()

49 Methods vs. Properties Temporal Properties start stop lock unlock eof close get() Methods open() hello() parse()

50 Methods vs. Properties Temporal Properties start stop lock unlock eof close get() Methods open() hello() parse()

51 Methods vs. Properties Temporal Properties start stop lock unlock eof close get() Methods open() hello() parse()

52 Methods vs. Properties Temporal Properties start stop lock unlock eof close Pattern get() Methods open() hello() parse()

53 Methods vs. Properties Temporal Properties start stop lock unlock eof close Pattern get() Methods open() hello() parse() Support

54 Discovering Anomalies Temporal Properties start stop lock unlock eof close get() Methods open() hello() parse()

55 Discovering Anomalies Temporal Properties start stop lock unlock eof close get() Methods open() hello() parse()

56 Discovering Anomalies Temporal Properties start stop lock unlock eof close get() Methods open() hello() parse()

57 Discovering Anomalies Temporal Properties start stop lock unlock eof close get() Methods open() hello() parse()

58 Discovering Anomalies Temporal Properties start stop lock unlock eof close get() Methods open() hello() parse()

59 Discovering Anomalies Temporal Properties start stop lock unlock eof close get() Methods open() hello() parse()

60 Case Study: AspectJ

61 Case Study: AspectJ 2,954 classes

62 Case Study: AspectJ 2,954 classes 36,045 methods

63 Case Study: AspectJ 2,954 classes 36,045 methods 1,154 methods with OP support 20

64 Case Study: AspectJ 2,954 classes 36,045 methods 1,154 methods with OP support violations found in 8 minutes

65 Case Study: AspectJ 2,954 classes 36,045 methods 1,154 methods with OP support violations found in 8 minutes Examined every single one

66 A Defect for (Iterator iter = itdfields.iterator(); iter.hasnext();) {... for (Iterator iter2 = worthretrying.iterator(); iter.hasnext();) {... } }

67 A Defect for (Iterator iter = itdfields.iterator(); iter.hasnext();) {... for (Iterator iter2 = worthretrying.iterator(); iter.hasnext();) {... should be iter2 } }

68 A Defect for (Iterator iter = itdfields.iterator(); iter.hasnext();) {... for (Iterator iter2 = worthretrying.iterator(); iter.hasnext();) {... should be iter2 } }

69 Another Defect public void visitnewarray (NEWARRAY o) { byte t = o.gettypecode (); if (!((t == Constants.T_BOOLEAN) (t == Constants.T_CHAR)... (t == Constants.T_LONG))) { constraintviolated (o, "(...) '+t+' (...)"); } }

70 Another Defect public void visitnewarray (NEWARRAY o) { byte t = o.gettypecode (); if (!((t == Constants.T_BOOLEAN) (t == Constants.T_CHAR)... (t == Constants.T_LONG))) { constraintviolated (o, "(...) '+t+' (...)"); } } should be double quotes

71 A False Positive Name internalnewname (String[] identifiers)... for (int i = 1; i < count; i++) { SimpleName name = new SimpleName(this); name.internalsetidentifier(identifiers[i]);... }... }

72 A False Positive Name internalnewname (String[] identifiers)... for (int i = 1; i < count; i++) { SimpleName name = new SimpleName(this); name.internalsetidentifier(identifiers[i]);... } should stay as is... }

73 A Code Smell public String getretentionpolicy () {... for (Iterator it =...; it.hasnext();) {... = it.next();... return retentionpolicy; }... }

74 A Code Smell public String getretentionpolicy () {... for (Iterator it =...; it.hasnext();) {... = it.next();... return retentionpolicy; }... should be fixed }

75 AspectJ Defects Code smells False positives

76 AspectJ Defects Code smells False positives

77 AspectJ Defects Code smells False positives

78 AspectJ Defects Code smells False positives

79 More Results # Violations Program Total Investigated # Defects # Code smells # False positives Efficiency ACT-RBOT % APACHE TOMCAT % ARGOUML % ASPECTJ % AZUREUS % COLUMBA % JEDIT % 1, %

80 Future Work

81 Future Work Procedural languages leveraging appropriate static analysis frameworks

82 Future Work Procedural languages leveraging appropriate static analysis frameworks Interprocedural analysis but does this make sense for learning usage?

83 Future Work Procedural languages leveraging appropriate static analysis frameworks Interprocedural analysis but does this make sense for learning usage? Ranking violations in particular in presence of low support

84 Future Work Procedural languages leveraging appropriate static analysis frameworks Interprocedural analysis but does this make sense for learning usage? Ranking violations in particular in presence of low support Early programmer support in terms of recommendations and documentation

85 OP-Miner

86 OP-Miner OP-Miner learns operational preconditions i.e., how to typically construct arguments

87 OP-Miner OP-Miner learns operational preconditions i.e., how to typically construct arguments Learns from normal argument usage for specific projects or across projects

88 OP-Miner OP-Miner learns operational preconditions i.e., how to typically construct arguments Learns from normal argument usage for specific projects or across projects Fully automatic

89 OP-Miner OP-Miner learns operational preconditions i.e., how to typically construct arguments Learns from normal argument usage for specific projects or across projects Fully automatic Found dozens of verified defects

Mining Temporal Specifications from Object Usage. Andrzej Wasylkowski Andreas Zeller Saarland University

Mining Temporal Specifications from Object Usage. Andrzej Wasylkowski Andreas Zeller Saarland University Mining Temporal Specifications from Object Usage Andrzej Wasylkowski Andreas Zeller Saarland University bug.aj @interface A { aspect Test { declare @field : @A int var* : @A; declare @field : int var*

More information

Automatic Defect Detection. Andrzej Wasylkowski

Automatic Defect Detection. Andrzej Wasylkowski Automatic Defect Detection Andrzej Wasylkowski Overview Automatic Defect Detection Horizontal Techniques Specification-checking Techniques Mining-based Techniques Mining Repositories Mining Traces Mining

More information

Leveraging Test Generation and Specification Mining for Automated Bug Detection without False Positives

Leveraging Test Generation and Specification Mining for Automated Bug Detection without False Positives Leveraging Test Generation and Specification Mining for Automated Bug Detection without False Positives Michael Pradel and Thomas R. Gross Department of Computer Science ETH Zurich 1 Motivation API usage

More information

Detecting Object Usage Anomalies

Detecting Object Usage Anomalies hasnext next next hasnext init push push push Detecting Object Usage Anomalies Andrzej Wasylkowski Dept. of Computer Science Saarland University Saarbrücken, Germany wasylkowski@cs.uni-sb.de Andreas Zeller

More information

Mining Operational Preconditions

Mining Operational Preconditions Mining Operational Preconditions Andrzej Wasylkowski Dept. of Computer Science Saarland University, Saarbrücken, Germany wasylkowski@cs.uni-sb.de Andreas Zeller Dept. of Computer Science Saarland University,

More information

Object Usage Models. Andrzej Wasylkowski Saarland University

Object Usage Models. Andrzej Wasylkowski Saarland University Object Usage Models Andrzej Wasylkowski Saarland University A bug in AspectJ 2 A bug in AspectJ /** * This method looks through the type hierarchy for some target type - it is attempting to * find an existing

More information

Mining Specifications

Mining Specifications Mining Specifications Andreas Zeller Saarland University zeller@acm.org WINNER OF JOLT PRODUCTIVITY AWARD ANDREAS ZELLER WHY PROGRAMS FAIL A GUIDE TO SYSTEMATIC DEBUGGING SECOND EDITION FOSE 10 FSE 10

More information

Replaying and Isolating Failing Multi-Object Interactions. Martin Burger Andreas Zeller Saarland University

Replaying and Isolating Failing Multi-Object Interactions. Martin Burger Andreas Zeller Saarland University Replaying and Isolating Failing Multi-Object Interactions Martin Burger Andreas Zeller Saarland University e-mail client written in Java 100,200 LOC ~ 1,600 Java classes 17 developers Actively developed

More information

NEGWeb: Detecting Neglected Conditions via Mining Programming Rules from Open Source Code

NEGWeb: Detecting Neglected Conditions via Mining Programming Rules from Open Source Code NEGWeb: Detecting Neglected Conditions via Mining Programming Rules from Open Source Code ABSTRACT Suresh Thummalapenta Department of Computer Science North Carolina State University Raleigh, USA sthumma@ncsu.edu

More information

Comparing Coverage. Andreas Zeller

Comparing Coverage. Andreas Zeller Comparing Coverage Andreas Zeller Tracing Infections For every infection, we must find the earlier infection that causes it. Which origin should we focus upon? 2 Tracing Infections 3 Focusing on Anomalies

More information

Active Learning: Streams

Active Learning: Streams Lecture 29 Active Learning: Streams The Logger Application 2 1 Goals Using the framework of the Logger application, we are going to explore three ways to read and write data using Java streams: 1. as text

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

7 April r0 SAS-2 SMP function result for incomplete descriptor lists

7 April r0 SAS-2 SMP function result for incomplete descriptor lists 7 April 2007 07-176r0 SAS-2 SMP function result for incomplete descriptor lists To: T10 Technical Committee From: Rob Elliott, HP (elliott@hp.com) Date: 7 April 2007 Subject: 07-176r0 SAS-2 SMP function

More information

CSE 143. Computer Programming II

CSE 143. Computer Programming II Adam Blank Lecture 15 Spring 2015 CSE 143 Computer Programming II CSE 143: Computer Programming II More Interfaces & Iterators Today s Goals 1 We begin with ArrayIntList & LinkedIntList. Our goals are:

More information

Algorithms & Data Structures

Algorithms & Data Structures GATE- 2016-17 Postal Correspondence 1 Algorithms & Data Structures Computer Science & Information Technology (CS) 20 Rank under AIR 100 Postal Correspondence Examination Oriented Theory, Practice Set Key

More information

Detecting Redundant Unit Tests for AspectJ Programs

Detecting Redundant Unit Tests for AspectJ Programs Detecting Redundant Unit Tests for AspectJ Programs Tao Xie 1 Jianjun Zhao 2 Darko Marinov 3 David Notkin 4 1 North Carolina State University 2 Shanghai Jiaotong University 3 University of Illinois at

More information

C++ Programming: From Problem Analysis to Program Design, Fourth Edition. Chapter 5: Control Structures II (Repetition)

C++ Programming: From Problem Analysis to Program Design, Fourth Edition. Chapter 5: Control Structures II (Repetition) C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 5: Control Structures II (Repetition) Objectives In this chapter, you will: Learn about repetition (looping) control structures

More information

Collections and Iterators. Collections

Collections and Iterators. Collections Collections and Iterators Based on the notes from David Fernandez-Baca and Steve Kautz Based on The Java Tutorial (http://docs.oracle.com/javase/tutorial/java/) Bryn Mawr College CS206 Intro to Data Structures

More information

Part 1: Excep-ons, part 2 Part 2: Iterator. Lecture 11 COMP 401, Spring /3/2015

Part 1: Excep-ons, part 2 Part 2: Iterator. Lecture 11 COMP 401, Spring /3/2015 Part 1: Excep-ons, part 2 Part 2: Iterator Lecture 11 COMP 401, Spring 2015 3/3/2015 The finally block Some-me we need some code to run no maker what happens. OMen this is the case in order to free up

More information

Object Usage: Patterns and Anomalies

Object Usage: Patterns and Anomalies Object Usage: Patterns and Anomalies Andrzej Wasylkowski Dissertation zur Erlangung des Grades des Doktors der Ingenieurwissenschaften der Naturwissenschaftlich-Technischen Fakultäten der Universität des

More information

Do not start the test until instructed to do so!

Do not start the test until instructed to do so! CS 1054: Programming in Java Page 1 of 6 Form A READ THIS NOW! Failure to read and follow the instructions below may result in severe penalties Failure to adhere to these directions will not constitute

More information

C++ Programming: From Problem Analysis to Program Design, Third Edition

C++ Programming: From Problem Analysis to Program Design, Third Edition C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 5: Control Structures II (Repetition) Why Is Repetition Needed? Repetition allows you to efficiently use variables Can input,

More information

[TAP:PMUHE] Stack vs Queue

[TAP:PMUHE] Stack vs Queue [TAP:PMUHE] Stack vs Queue A Singly Linked List can be used to implement which of the following A. List B. Stack C. Queue D. B and C E. Whatever 1 Administrative Details Midterm and lab scores (4 and 5)

More information

Java. Programming: Chapter Objectives. Why Is Repetition Needed? Chapter 5: Control Structures II. Program Design Including Data Structures

Java. Programming: Chapter Objectives. Why Is Repetition Needed? Chapter 5: Control Structures II. Program Design Including Data Structures Chapter 5: Control Structures II Java Programming: Program Design Including Data Structures Chapter Objectives Learn about repetition (looping) control structures Explore how to construct and use count-controlled,

More information

Chapter 5: Control Structures II (Repetition) Objectives (cont d.) Objectives. while Looping (Repetition) Structure. Why Is Repetition Needed?

Chapter 5: Control Structures II (Repetition) Objectives (cont d.) Objectives. while Looping (Repetition) Structure. Why Is Repetition Needed? Chapter 5: Control Structures II (Repetition) Objectives In this chapter, you will: Learn about repetition (looping) control structures Explore how to construct and use countercontrolled, sentinel-controlled,

More information

Introduction to C Language (M3-R )

Introduction to C Language (M3-R ) Introduction to C Language (M3-R4-01-18) 1. Each question below gives a multiple choice of answers. Choose the most appropriate one and enter in OMR answer sheet supplied with the question paper, following

More information

Automated Fixing of Programs with Contracts

Automated Fixing of Programs with Contracts Automated Fixing of Programs with Contracts Yi Wei, Yu Pei, Carlo A. Furia, Lucas S. Silva, Stefan Buchholz, Bertrand Meyer and Andreas Zeller Chair of Software Engineering, ETH Zürich Software Engineering

More information

CS1150 Principles of Computer Science Methods

CS1150 Principles of Computer Science Methods CS1150 Principles of Computer Science Methods Yanyan Zhuang Department of Computer Science http://www.cs.uccs.edu/~yzhuang CS1150 UC. Colorado Springs Opening Problem Find the sum of integers from 1 to

More information

Verification and Validation. Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 1

Verification and Validation. Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 1 Verification and Validation 1 Objectives To introduce software verification and validation and to discuss the distinction between them To describe the program inspection process and its role in V & V To

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

Program Representations

Program Representations Program Representations 17-654/17-765 Analysis of Software Artifacts Jonathan Aldrich Representing Programs To analyze software automatically, we must be able to represent it precisely Some representations

More information

CIS 120 Programming Languages and Techniques. Midterm II. November 12, Answer key

CIS 120 Programming Languages and Techniques. Midterm II. November 12, Answer key CIS 120 Programming Languages and Techniques Midterm II November 12, 2010 Answer key 1. (14 points) Pages 7 to 9 define a simplified version of the Java Collection interface (the SimpleCollection and SimpleIterator

More information

CS 3 Introduction to Software Engineering. 5: Iterators

CS 3 Introduction to Software Engineering. 5: Iterators CS 3 Introduction to Software Engineering 5: Iterators Questions? 2 PS1 Discussion Question You are to choose between two procedures, both of which compute the minimum value in an array of integers. One

More information

JAVA COLLECTION FRAMEWORK & SETS

JAVA COLLECTION FRAMEWORK & SETS JAVA COLLECTION FRAMEWORK & SETS Ch07.4-5 & Ch10.5 Presentation for use with the textbook 1. Data Structures and Algorithms in Java, 6 th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser,

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 28 March 30, 2018 Overriding Methods, Equality, Enums, Iterators Chapters 25 and 26 Method Overriding When a subclass replaces an inherited method

More information

Mutation-based Generation of Tests and Oracles. Gordon Fraser and Andreas Zeller Saarland University, Germany

Mutation-based Generation of Tests and Oracles. Gordon Fraser and Andreas Zeller Saarland University, Germany Mutation-based Generation of Tests and Oracles Gordon Fraser and Andreas Zeller Saarland University, Germany LocalDate date = new LocalDate(2010, 7, 15); date.plusyears(1); assertequals(date.getyear(),

More information

AP Computer Science A

AP Computer Science A 2017 AP Computer Science A Sample Student Responses and Scoring Commentary Inside: RR Free Response Question 3 RR Scoring Guideline RR Student Samples RR Scoring Commentary 2017 The College Board. College

More information

Mining API Popularity

Mining API Popularity Mining API Popularity 40 # projects using an API element 35 30 25 20 15 10 5 junit.framework.testsuite javax.swing.jscrollpane javax.swing.border.border junit.framework.assertionfailederror java.io.stringbufferinputstream

More information

ECEN 449 Microprocessor System Design. Review of C Programming

ECEN 449 Microprocessor System Design. Review of C Programming ECEN 449 Microprocessor System Design Review of C Programming 1 Objectives of this Lecture Unit Review C programming basics Refresh es programming g skills s 2 1 Basic C program structure # include

More information

An Activation Record for Simple Subprograms. Activation Record for a Language with Stack-Dynamic Local Variables

An Activation Record for Simple Subprograms. Activation Record for a Language with Stack-Dynamic Local Variables Activation Records The storage (for formals, local variables, function results etc.) needed for execution of a subprogram is organized as an activation record. An Activation Record for Simple Subprograms.

More information

Computer Science 62. Midterm Examination

Computer Science 62. Midterm Examination Computer Science 62 Bruce/Mawhorter Fall 16 Midterm Examination October 5, 2016 Question Points Score 1 15 2 10 3 10 4 8 5 9 TOTAL 52 Your name (Please print) 1. Suppose you are given a singly-linked list

More information

Largest Online Community of VU Students

Largest Online Community of VU Students WWW.VUPages.com http://forum.vupages.com WWW.VUTUBE.EDU.PK Largest Online Community of VU Students MIDTERM EXAMINATION SEMESTER FALL 2003 CS301-DATA STRUCTURE Total Marks:86 Duration: 60min Instructions

More information

C Programming Language (Chapter 2 of K&R) Variables and Constants

C Programming Language (Chapter 2 of K&R) Variables and Constants C Programming Language (Chapter 2 of K&R) Types, Operators and Expressions Variables and Constants Basic objects manipulated by programs Declare before use: type var1, var2, int x, y, _X, x11, buffer;

More information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1(c): Java Basics (II) Lecture Contents Java basics (part II) Conditions Loops Methods Conditions & Branching Conditional Statements A

More information

6.096 Introduction to C++

6.096 Introduction to C++ MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. 6.096 Lecture 3 Notes

More information

COMP-202. Recursion. COMP Recursion, 2011 Jörg Kienzle and others

COMP-202. Recursion. COMP Recursion, 2011 Jörg Kienzle and others COMP-202 Recursion Recursion Recursive Definitions Run-time Stacks Recursive Programming Recursion vs. Iteration Indirect Recursion Lecture Outline 2 Recursive Definitions (1) A recursive definition is

More information

FORM 2 (Please put your name and form # on the scantron!!!!)

FORM 2 (Please put your name and form # on the scantron!!!!) CS 161 Exam 2: FORM 2 (Please put your name and form # on the scantron!!!!) True (A)/False(B) (2 pts each): 1. Recursive algorithms tend to be less efficient than iterative algorithms. 2. A recursive function

More information

CS1150 Principles of Computer Science Methods

CS1150 Principles of Computer Science Methods CS1150 Principles of Computer Science Methods Yanyan Zhuang Department of Computer Science http://www.cs.uccs.edu/~yzhuang CS1150 UC. Colorado Springs Opening Problem Find the sum of integers from 1 to

More information

C++ Programming: From Problem Analysis to Program Design, Third Edition

C++ Programming: From Problem Analysis to Program Design, Third Edition C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 4: Control Structures I (Selection) Control Structures A computer can proceed: In sequence Selectively (branch) - making

More information

Large-Scale API Protocol Mining for Automated Bug Detection

Large-Scale API Protocol Mining for Automated Bug Detection Large-Scale API Protocol Mining for Automated Bug Detection Michael Pradel Department of Computer Science ETH Zurich 1 Motivation LinkedList pinconnections =...; Iterator i = pinconnections.iterator();

More information

References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 10/14/2004 1

References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 10/14/2004 1 References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 10/14/2004 1 Assertions Statements about input to a routine or state of a class Have two primary roles As documentation,

More information

Advanced Software Testing Testing Code with Static Analysis

Advanced Software Testing Testing Code with Static Analysis Advanced Software Testing Testing Code with Static Analysis Advanced Software Testing A series of webinars, this one excerpted from Advanced Software Testing: V3, a book for technical test analysts, programmers,

More information

CSci 4061 Introduction to Operating Systems. Programs in C/Unix

CSci 4061 Introduction to Operating Systems. Programs in C/Unix CSci 4061 Introduction to Operating Systems Programs in C/Unix Today Basic C programming Follow on to recitation Structure of a C program A C program consists of a collection of C functions, structs, arrays,

More information

JoeQ Framework CS243, Winter 20156

JoeQ Framework CS243, Winter 20156 Overview Java Intermediate representation JoeQ Framework CS243, Winter 20156 Bytecode JoeQ Framework Quads: Instruction set used in JoeQ JoeQ constructs Writing analysis in JoeQ HW 2 Typical Compiler Infrastructure

More information

CSE 331 Summer 2016 Final Exam. Please wait to turn the page until everyone is told to begin.

CSE 331 Summer 2016 Final Exam. Please wait to turn the page until everyone is told to begin. Name The exam is closed book, closed notes, and closed electronics. Please wait to turn the page until everyone is told to begin. Score / 54 1. / 12 2. / 12 3. / 10 4. / 10 5. / 10 Bonus: 1. / 6 2. / 4

More information

0/38. Detecting Invariants. Andreas Zeller + Andreas Gross. Lehrstuhl Softwaretechnik Universität des Saarlandes, Saarbrücken

0/38. Detecting Invariants. Andreas Zeller + Andreas Gross. Lehrstuhl Softwaretechnik Universität des Saarlandes, Saarbrücken 0/38 Detecting Invariants Andreas Zeller + Andreas Gross Lehrstuhl Softwaretechnik Universität des Saarlandes, Saarbrücken Exam 1/38 on Tuesday, 2003-02-18, 11:15 in lecture room 45/001 (here) Written

More information

n Data structures that reflect a temporal relationship q order of removal based on order of insertion n We will consider:

n Data structures that reflect a temporal relationship q order of removal based on order of insertion n We will consider: Linear, time-ordered structures CS00: Stacks n Prichard Ch 7 n Data structures that reflect a temporal relationship order of removal based on order of insertion n We will consider: first come,first serve

More information

2IP15 Programming Methods

2IP15 Programming Methods Lecture 5: Iteration Abstraction 2IP15 Programming Methods From Small to Large Programs Tom Verhoeff Eindhoven University of Technology Department of Mathematics & Computer Science Software Engineering

More information

ECEN 449 Microprocessor System Design. Review of C Programming. Texas A&M University

ECEN 449 Microprocessor System Design. Review of C Programming. Texas A&M University ECEN 449 Microprocessor System Design Review of C Programming 1 Objectives of this Lecture Unit Review C programming basics Refresh programming skills 2 Basic C program structure # include main()

More information

TACi: Three-Address Code Interpreter (version 1.0)

TACi: Three-Address Code Interpreter (version 1.0) TACi: Three-Address Code Interpreter (version 1.0) David Sinclair September 23, 2018 1 Introduction TACi is an interpreter for Three-Address Code, the common intermediate representation (IR) used in compilers.

More information

Computer Components. Software{ User Programs. Operating System. Hardware

Computer Components. Software{ User Programs. Operating System. Hardware Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point

More information

Highlights. - Making threads. - Waiting for threads. - Review (classes, pointers, inheritance)

Highlights. - Making threads. - Waiting for threads. - Review (classes, pointers, inheritance) Parallel processing Highlights - Making threads - Waiting for threads - Review (classes, pointers, inheritance) Review: CPUs Review: CPUs In the 2000s, computing too a major turn: multi-core processors

More information

COMP 202 Recursion. CONTENTS: Recursion. COMP Recursion 1

COMP 202 Recursion. CONTENTS: Recursion. COMP Recursion 1 COMP 202 Recursion CONTENTS: Recursion COMP 202 - Recursion 1 Recursive Thinking A recursive definition is one which uses the word or concept being defined in the definition itself COMP 202 - Recursion

More information

Complexity, General. Standard approach: count the number of primitive operations executed.

Complexity, General. Standard approach: count the number of primitive operations executed. Complexity, General Allmänt Find a function T(n), which behaves as the time it takes to execute the program for input of size n. Standard approach: count the number of primitive operations executed. Standard

More information

Parsing Scheme (+ (* 2 3) 1) * 1

Parsing Scheme (+ (* 2 3) 1) * 1 Parsing Scheme + (+ (* 2 3) 1) * 1 2 3 Compiling Scheme frame + frame halt * 1 3 2 3 2 refer 1 apply * refer apply + Compiling Scheme make-return START make-test make-close make-assign make- pair? yes

More information

Lecture 2 Tao Wang 1

Lecture 2 Tao Wang 1 Lecture 2 Tao Wang 1 Objectives In this chapter, you will learn about: Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common programming errors

More information

COMP 110/401 DOCUMENTATION: ASSERTIONS. Instructor: Prasun Dewan

COMP 110/401 DOCUMENTATION: ASSERTIONS. Instructor: Prasun Dewan COMP 110/401 DOCUMENTATION: ASSERTIONS Instructor: Prasun Dewan PREREQUISITE Documentation Annotations 2 INVALID BMI public double getbmi() { return weight/(height*height); getbmi() should really not have

More information

Tutorial 5. Call Stack and Stack Frames. Memory Addresses and Pointers. Content vs Address of Pointers. scanf() function. Perils of Pointers

Tutorial 5. Call Stack and Stack Frames. Memory Addresses and Pointers. Content vs Address of Pointers. scanf() function. Perils of Pointers Tutorial 5 Call Stack and Stack Frames Memory Addresses and Pointers Content vs Address of Pointers scanf() function Perils of Pointers Function Pointers CS 136 Winter 2018 Tutorial 5 1 Call Stack and

More information

Array. Array Declaration:

Array. Array Declaration: Array Arrays are continuous memory locations having fixed size. Where we require storing multiple data elements under single name, there we can use arrays. Arrays are homogenous in nature. It means and

More information

Conditionals & Control Flow

Conditionals & Control Flow CS 1110: Introduction to Computing Using Python Lecture 8 Conditionals & Control Flow [Andersen, Gries, Lee, Marschner, Van Loan, White] Announcements: Assignment 1 Due tonight at 11:59pm. Suggested early

More information

CSCE 110 PROGRAMMING FUNDAMENTALS

CSCE 110 PROGRAMMING FUNDAMENTALS CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 2. Overview of C++ Prof. Amr Goneid, AUC 1 Overview of C++ Prof. Amr Goneid, AUC 2 Overview of C++ Historical C++ Basics Some Library

More information

Recap. Juan Pablo Galeotti,Alessandra Gorla, Software Engineering Chair Computer Science Saarland University, Germany

Recap. Juan Pablo Galeotti,Alessandra Gorla, Software Engineering Chair Computer Science Saarland University, Germany Recap Juan Pablo Galeotti,Alessandra Gorla, Software Engineering Chair Computer Science Saarland University, Germany 30% projects (10% each) At least 50% threshold for exam admittance Groups of 2 70% final

More information

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor. 3.Constructors and Destructors Develop cpp program to implement constructor and destructor. Constructors A constructor is a special member function whose task is to initialize the objects of its class.

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Marcel Turcotte School of Information Technology and Engineering Iterator (part II) Inner class Implementation: fail-fast Version of March 20, 2011 Abstract These

More information

Type Conversion. and. Statements

Type Conversion. and. Statements and Statements Type conversion changing a value from one type to another Void Integral Floating Point Derived Boolean Character Integer Real Imaginary Complex no fractional part fractional part 2 tj Suppose

More information

CSC 1351: Quiz 6: Sort and Search

CSC 1351: Quiz 6: Sort and Search CSC 1351: Quiz 6: Sort and Search Name: 0.1 You want to implement combat within a role playing game on a computer. Specifically, the game rules for damage inflicted by a hit are: In order to figure out

More information

Introduction to Programming I COS1511 School of Computing Revision Notes

Introduction to Programming I COS1511 School of Computing Revision Notes Introduction to Programming I COS1511 School of Computing Revision Notes UNISA 2018 1 Introduction Some key basic principles to remember: Apply the BODMAS rules of Mathematics for all calculations; The

More information

CA4003 Compiler Construction Assignment Language Definition

CA4003 Compiler Construction Assignment Language Definition CA4003 Compiler Construction Assignment Language Definition David Sinclair 2017-2018 1 Overview The language is not case sensitive. A nonterminal, X, is represented by enclosing it in angle brackets, e.g.

More information

A First Program - Greeting.cpp

A First Program - Greeting.cpp C++ Basics A First Program - Greeting.cpp Preprocessor directives Function named main() indicates start of program // Program: Display greetings #include using namespace std; int main() { cout

More information

Final exam. Final exam will be 12 problems, drop any 2. Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers)

Final exam. Final exam will be 12 problems, drop any 2. Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers) Review Final exam Final exam will be 12 problems, drop any 2 Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers) 2 hours exam time, so 12 min per problem (midterm 2 had

More information

COMP6700/2140 Abstract Data Types: Lists and Iteration

COMP6700/2140 Abstract Data Types: Lists and Iteration COMP6700/2140 Abstract Data Types: Lists and Iteration Alexei B Khorev and Josh Milthorpe Research School of Computer Science, ANU 19 April 2017 Alexei B Khorev and Josh Milthorpe (RSCS, ANU) COMP6700/2140

More information

CMPS 105 Systems Programming. Prof. Darrell Long E2.371

CMPS 105 Systems Programming. Prof. Darrell Long E2.371 + CMPS 105 Systems Programming Prof. Darrell Long E2.371 darrell@ucsc.edu + Chapter 3: File I/O 2 + File I/O 3 n What attributes do files need? n Data storage n Byte stream n Named n Non-volatile n Shared

More information

Analysis of Coding Patterns over Software Versions

Analysis of Coding Patterns over Software Versions Information and Media Technologies 0(): - (05) reprinted from: Computer Software (): 0- (05) Analysis of Coding Patterns over Software Versions Hironori Date, Takashi Ishio, Makoto Matsushita, Katsuro

More information

No Source Code. EEC 521: Software Engineering. Specification-Based Testing. Advantages

No Source Code. EEC 521: Software Engineering. Specification-Based Testing. Advantages No Source Code : Software Testing Black-Box Testing Test-Driven Development No access to source code So test cases don t worry about structure Emphasis is only on ensuring that the contract is met Specification-Based

More information

Understanding the Program Run

Understanding the Program Run 0/45 Understanding the Program Run Andreas Zeller Lehrstuhl Softwaretechnik Universität des Saarlandes, Saarbrücken Isolating Failure Causes 1/45 So far, we have seen how to isolate causes in the environment

More information

CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall Office hours:

CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall Office hours: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu Office hours: Tuesday 10:00 AM 12:00 PM * Wednesday 4:00 PM 5:00 PM Friday 11:00 AM 12:00 PM OR

More information

CS171:Introduction to Computer Science II

CS171:Introduction to Computer Science II CS171:Introduction to Computer Science II Department of Mathematics and Computer Science Li Xiong 9/7/2012 1 Announcement Introductory/Eclipse Lab, Friday, Sep 7, 2-3pm (today) Hw1 to be assigned Monday,

More information

Strings. Strings and their methods. Mairead Meagher Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics

Strings. Strings and their methods. Mairead Meagher Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics Strings Strings and their methods Produced by: Mairead Meagher Dr. Siobhán Drohan Department of Computing and Mathematics http://www.wit.ie/ Topics list Primitive Types: char Object Types: String Primitive

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2010 Handout Decaf Language Tuesday, Feb 2 The project for the course is to write a compiler

More information

CS313D: ADVANCED PROGRAMMING LANGUAGE

CS313D: ADVANCED PROGRAMMING LANGUAGE CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science Department Lecture 3: C# language basics Lecture Contents 2 C# basics Conditions Loops Methods Arrays Dr. Amal Khalifa, Spr 2015 3 Conditions and

More information

CS 62 Practice Final SOLUTIONS

CS 62 Practice Final SOLUTIONS CS 62 Practice Final SOLUTIONS 2017-5-2 Please put your name on the back of the last page of the test. Note: This practice test may be a bit shorter than the actual exam. Part 1: Short Answer [32 points]

More information

A token is a sequence of characters not including any whitespace.

A token is a sequence of characters not including any whitespace. Scanner A Scanner object reads from an input source (keyboard, file, String, etc) next() returns the next token as a String nextint() returns the next token as an int nextdouble() returns the next token

More information

Computer Systems Lecture 9

Computer Systems Lecture 9 Computer Systems Lecture 9 CPU Registers in x86 CPU status flags EFLAG: The Flag register holds the CPU status flags The status flags are separate bits in EFLAG where information on important conditions

More information

COMP6771 Advanced C++ Programming

COMP6771 Advanced C++ Programming 1.... COMP6771 Advanced C++ Programming Week 5 Part One: Exception Handling 2016 www.cse.unsw.edu.au/ cs6771 2.... Memory Management & Exception Handling.1 Part I: Exception Handling Exception objects

More information

ECE 2035 Programming HW/SW Systems Fall problems, 5 pages Exam Three 28 November 2012

ECE 2035 Programming HW/SW Systems Fall problems, 5 pages Exam Three 28 November 2012 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

Program Analysis: A Hierarchy

Program Analysis: A Hierarchy 0/13 Workshop on Dynamic Analysis, Portland, Oregon, 2003 Program Analysis: A Hierarchy Andreas Zeller Lehrstuhl Softwaretechnik Universität des Saarlandes, Saarbrücken A Hierarchy of Reasoning 1/13 Experimentation

More information

Programming Languages

Programming Languages Programming Languages Tevfik Koşar Lecture - VIII February 9 th, 2006 1 Roadmap Allocation techniques Static Allocation Stack-based Allocation Heap-based Allocation Scope Rules Static Scopes Dynamic Scopes

More information

CSE 143 Au04 Midterm 2 Sample Solution Page 1 of 7

CSE 143 Au04 Midterm 2 Sample Solution Page 1 of 7 CSE 143 Au04 Midterm 2 Sample Solution Page 1 of 7 Reference information about some standard Java library classes appears on the last pages of the test. You can tear off these pages for easier reference

More information

Thrift specification - Remote Procedure Call

Thrift specification - Remote Procedure Call Erik van Oosten Revision History Revision 1.0 2016-09-27 EVO Initial version v1.1, 2016-10-05: Corrected integer type names. Small changes to section headers. Table of Contents 1.

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 29 Enums & Iterators Announcements Prof. Benjamin Pierce is lecturing today Will be teaching 120 again next Spring Enumerations Enumerations (a.k.a.

More information