CS 520 Theory and Practice of Software Engineering Fall 2018

Similar documents
Steps for project success. git status. Milestones. Deliverables. Homework 1 submitted Homework 2 will be posted October 26.

Regression testing. Whenever you find a bug. Why is this a good idea?

CSE 331 Software Design & Implementation

CSE 331 Software Design & Implementation. Hal Perkins Fall 2016 Debugging

CSE 331 Software Design and Implementation. Lecture 16 Debugging

Reasoning about programs

Last time. Reasoning about programs. Coming up. Project Final Presentations. This Thursday, Nov 30: 4 th in-class exercise

Exceptions and assertions

CSE 143. Programming is... Principles of Programming and Software Engineering. The Software Lifecycle. Software Lifecycle in HW

Assertions. Assertions - Example

Lecture 15 Software Testing

Testing. Prof. Clarkson Fall Today s music: Wrecking Ball by Miley Cyrus

DESIGN AS RISK MINIMIZATION

Software Engineering Testing and Debugging Testing

Program Correctness and Efficiency. Chapter 2

INTRODUCTION TO SOFTWARE ENGINEERING

CSE 331 Software Design & Implementation

CSE 374 Programming Concepts & Tools

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

Chapter01.fm Page 1 Monday, August 23, :52 PM. Part I of Change. The Mechanics. of Change

Testing. ECE/CS 5780/6780: Embedded System Design. Why is testing so hard? Why do testing?

Thread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections

CS 520 Theory and Practice of Software Engineering Fall 2017

Introduction to Assurance

CSE 374 Programming Concepts & Tools. Hal Perkins Fall 2015 Lecture 15 Testing

Representation Invariants and Abstraction Functions

Programming Project 4: COOL Code Generation

Finding Firmware Defects Class T-18 Sean M. Beatty

Testing. UW CSE 160 Winter 2016

CS 3 Introduction to Software Engineering. 3: Exceptions

Why testing and analysis. Software Testing. A framework for software testing. Outline. Software Qualities. Dependability Properties

Project Compiler. CS031 TA Help Session November 28, 2011

CS 161 Computer Security. Security Throughout the Software Development Process

CS 370 The Pseudocode Programming Process D R. M I C H A E L J. R E A L E F A L L

CS112 Lecture: Exceptions and Assertions

Software Engineering

Boot Camp. Dave Eckhardt Bruce Maggs

Chapter 8 Software Testing. Chapter 8 Software testing

CS112 Lecture: Exceptions. Objectives: 1. Introduce the concepts of program robustness and reliability 2. Introduce exceptions

Programming Assignment IV Due Thursday, November 18th, 2010 at 11:59 PM

CSE 331 Midterm Exam Sample Solution 2/13/12

Software Testing CS 408

MITOCW watch?v=9h6muyzjms0

Three General Principles of QA. COMP 4004 Fall Notes Adapted from Dr. A. Williams

Creating an Intranet using Lotus Web Content Management. Part 2 Project Planning

CSE 403: Software Engineering, Fall courses.cs.washington.edu/courses/cse403/16au/ Unit Testing. Emina Torlak

Main concepts to be covered. Testing and Debugging. Code snippet of the day. Results. Testing Debugging Test automation Writing for maintainability

Compiling with Multiple Files The Importance of Debugging CS 16: Solving Problems with Computers I Lecture #7

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

Verification, Testing, and Bugs

Lecture 4 Specifications

CS 215 Software Design Homework 3 Due: February 28, 11:30 PM

Northeastern University - Seattle. Computer and Information Sciences

Memory Safety (cont d) Software Security

SOFTWARE LIFE-CYCLE MODELS 2.1

Principles of Software Construction: Objects, Design, and Concurrency (Part 2: Designing (Sub )Systems)

Announcements. Testing. Announcements. Announcements

Abstraction and Specification

Write for your audience

When Trouble Comes: The Basics of Debugging

Lecture 5 Representation Invariants

CS 3110 Lecture 1 Course Overview

CS 307: Software Engineering. Lecture 10: Software Design and Architecture

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

High Reliability Systems. Lloyd Moore, President

From designing to coding

ESC/Java2 extended static checking for Java Erik Poll Radboud University Nijmegen

Who are we? Andre Platzer Out of town the first week GHC TAs Alex Crichton, senior in CS and ECE Ian Gillis, senior in CS

Assertions, pre/postconditions

9 th CA 2E/CA Plex Worldwide Developer Conference 1

Promoting Component Architectures in a Dysfunctional Organization

CSE331 Winter 2014, Midterm Examination February 12, 2014

Testing. Topics. Types of Testing. Types of Testing

Software Engineering Testing and Debugging Debugging

Software Engineering

Today s Topic. Software Engineering Testing and Debugging Debugging. Today s Topic. The Main Steps in Systematic Debugging

Secure Programming I. Steven M. Bellovin September 28,

17. Assertions. Outline. Built-in tests. Built-in tests 3/29/11. Jelle Slowack, Bart Smets, Glenn Van Loon, Tom Verheyen

Assertions and Exceptions Lecture 11 Fall 2005

So far, we know: Wednesday, October 4, Thread_Programming Page 1

Part 5. Verification and Validation

Data Structures. Subodh Kumar. Dept of Computer Sc. & Engg. IIT Delhi

17. Assertions. Jelle Slowack, Bart Smets, Glenn Van Loon, Tom Verheyen

6.830 Problem Set 3: SimpleDB Transactions

Specifications. CSE 331 Spring 2010

Verification and Validation

Verification and Validation

Object Oriented Software Design - I

Advanced Memory Allocation

Jtest Tutorial. Tutorial

Verification and Validation

Bridge Course On Software Testing

Object Oriented Programming. Week 7 Part 1 Exceptions

Improving Software Testability

Day 8. COMP1006/1406 Summer M. Jason Hinek Carleton University

Testing and Debugging

Programming Assignment IV Due Monday, November 8 (with an automatic extension until Friday, November 12, noon)

UC Santa Barbara. CS189A - Capstone. Christopher Kruegel Department of Computer Science UC Santa Barbara

CSCI 8530 Advanced Operating Systems

Who is our rival? Upcoming. Testing. Ariane 5 rocket (1996) Ariane 5 rocket 3/8/18. Real programmers need no testing!

Transcription:

CS 520 Theory and Practice of Software Engineering Fall 2018 Nediyana Daskalova Monday, 4PM CS 151 Debugging October 30, 2018 Personalized Behavior-Powered Systems for Guiding Self-Experiments Help me improve the class Coming up Homework 2 posted, due November 15 Mid-final-project report details This Thursday, in-class 3 (on debugging) sign up for a team on moodle https://people.cs.umass.edu/~brun/class/2018fall/cs520/ Let s talk projects 1 st project deliverables Steps for project success 1-page problem statement / design (due Nov 13) Short in-class meeting with Prof or TA (Nov 13) Come in ready to present a project proposal. Be able to describe to us what you will produce. timeline team member roles and responsibilities Likely useful to bring in a prototype. Research-focused projects: having your research questions figured out know how you will answer them System-building project Formulate what you re going to do Design the system you will build Develop a plan (assign team members jobs) Specify your system Create a testing plan Implement (prototype) Test Document Research-centered project Formulate what you re going to do Design the experiment you will perform Identify the necessary artifacts to perform the experiment Develop a plan (assign team members jobs) Learn state-of-the-art Prototype the experiment Build necessary infrastructure 1

Final Deliverables git repository code tests documentation final poster presentation with demo final report, if appropriate Debugging Ways to get your code right A bug September 9, 1947 US Navy Admiral Grace Murray Hopper, working on Mark I at Harvard Validation Purpose is to uncover problems and increase confidence Combination of reasoning and test Debugging Finding out why a program is not functioning as intended Defensive programming Programming with validation and debugging in mind Testing debugging test: reveals existence of problem debug: pinpoint location + cause of problem A Bug s Life Defect mistake committed by a human Error incorrect computation Failure visible error: program violates its specification Debugging starts when a failure is observed Unit testing Integration testing In the field Defense in depth 1. Make errors impossible Java makes memory overwrite bugs impossible 2. Don t introduce defects Correctness: get things right the first time 3. Make errors immediately visible Local visibility of errors: best to fail immediately Example: checkrep() routine to check representation invariants 4. Last resort is debugging Needed when effect of bug is distant from cause Design experiments to gain information about bug Fairly easy in a program with good modularity, representation hiding, specs, unit tests etc. Much harder and more painstaking with a poor design, e.g., with rampant rep exposure 2

First defense: Impossible by design In the language Java makes memory overwrite bugs impossible In the protocols/libraries/modules TCP/IP will guarantee that data is not reordered BigInteger will guarantee that there will be no overflow In self-imposed conventions Hierarchical locking makes deadlock bugs impossible Banning the use of recursion will make infinite recursion/insufficient stack bugs go away Immutable data structures will guarantee behavioral equality Caution: You must maintain the discipline Second defense: correctness Get things right the first time Don t code before you think! Think before you code. If you're making lots of easy-to-find bugs, you're also making hard-to-find bugs don't use compiler as crutch Especially true, when debugging is going to be hard Concurrency Difficult test and instrument environments Program must meet timing deadlines Simplicity is key Modularity Divide program into chunks that are easy to understand Use abstract data types with well-defined interfaces Use defensive programming; avoid rep exposure Specification Write specs for all modules, so that an explicit, well-defined contract exists between each module and its clients Third defense: immediate visibility If we can't prevent bugs, we can try to localize them to a small part of the program Assertions: catch bugs early, before failure has a chance to contaminate (and be obscured by) further computation Unit testing: when you test a module in isolation, you can be confident that any bug you find is in that unit (unless it's in the test driver) Regression testing: run tests as often as possible when changing code. If there is a failure, chances are there's a mistake in the code you just changed When localized to a single method or small module, bugs can be found simply by studying the program text Benefits of immediate visibility Key difficulty of debugging is to find the code fragment responsible for an observed problem A method may return an erroneous result, but be itself error free, if there is prior corruption of representation The earlier a problem is observed, the easier it is to fix For example, frequently checking the rep invariant helps the above problem General approach: fail-fast Check invariants, don't just assume them Don't try to recover from bugs this just obscures them How to debug a compiler Program Multiple passes Each operate on a complex IR Lot of information passing Very complex Rep Invariant Code generation at the end Bug types: Compiler crashes Generated program is buggy J L Front End Optimization Optimization rray a while (true) { This code fragment searches an array a for a value k. Value is guaranteed to be in the array If that guarantee is broken (by a bug), the code throws an exception and dies. Temptation: make code more robust by not failing RUN Executable Code Generation 3

Now at least the loop will always terminate But no longer guarantees that a[i]==k If rest of code relies on this, then problems arise later All we've done is obscure the link between the bug's origin and the eventual erroneous behavior it causes. assert (i<a.length) : "key not found"; Assertions let us document and check invariants Abort program as soon as problem is detected Inserting Checks Insert checks galore with an intelligent checking strategy Precondition checks Consistency checks Bug-specific checks Goal: stop the program as close to bug as possible Use debugger to see where you are, explore program a bit Checking For Preconditions assert (i<a.length) : "key not found"; Precondition violated? Get an assertion! Downside of Assertions static int sum(integer a[], List<Integer> index) { int s = 0; assert(e < a.length, Precondition violated ); s = s + a[e]; return s; Assertion not checked until we use the data Fault occurs when bad index inserted into list May be a long distance between fault activation and error detection checkrep: Data Structure Consistency Checks static void checkrep(integer a[], List<Integer> index) { assert(e < a.length, Inconsistent Data Structure ); Perform check after all updates to minimize distance between bug occurrence and bug detection Can also write a single procedure to check ALL data structures, then scatter calls to this procedure throughout code 4

Bug-Specific Checks static void check(integer a[], List<Integer> index) { assert(e!= 1234, Inconsistent Data Structure ); Bug shows up as 1234 in list Check for that specific condition Checks In Production Code Should you include assertions and checks in production code? Yes: stop program if check fails don t want to take chance program will do something wrong No: may need program to keep going, maybe bug does not have such bad consequences Correct answer depends on context! Ariane 5 program halted because of overflow in unused value, exception thrown but not handled until top level, rocket crashes Ariane 5 rocket (1996) Coming up Homework 2 posted, due November 15 This Thursday, in-class 3 (on debugging) sign up for a team on moodle 5