DEBUGGING CS2110.

Slides:



Advertisements
Similar presentations
VCE SD Theory Slideshows By Mark Kelly Vceit.com Debugging Techniques.
Advertisements

Why care about debugging? How many of you have written a program that worked perfectly the first time? No one (including me!) writes a program that works.
Debugging tutorial. Outline Brief refresher on debugging using Eclipse Logging with log4j – Logging levels – log4j.properties Debugging strategically.
General Computer Science for Engineers CISC 106 Lecture 21 Dr. John Cavazos Computer and Information Sciences 04/10/2009.
Building Secure Software Chapter 9 Race Conditions.
27-Jun-15 Profiling code, Timing Methods. Optimization Optimization is the process of making a program as fast (or as small) as possible Here’s what the.
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
Programming Fundamentals (750113) Ch1. Problem Solving
DEBUGGERS For CS302 Data Structures Course Slides prepared by TALHA OZ (most of the text is from
P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Compilers, Interpreters and Debuggers Ruibin Bai (Room AB326) Division of Computer Science.
Chapter 8 – Software Testing Lecture 1 1Chapter 8 Software testing The bearing of a child takes nine months, no matter how many women are assigned. Many.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
Program Errors and Debugging Week 10, Thursday Lab.
Debugging Strategies from Software Carpentry. Agan's Rules Many people make debugging harder than it needs to be by: Using inadequate tools Not going.
Making Good Code AKA: So, You Wrote Some Code. Now What? Ray Haggerty July 23, 2015.
Debugging and Profiling With some help from Software Carpentry resources.
CS 3500 L Performance l Code Complete 2 – Chapters 25/26 and Chapter 7 of K&P l Compare today to 44 years ago – The Burroughs B1700 – circa 1974.
Debuggers in Python. The Debugger Every programming IDE has a tool called a debugger. This application does NOT locate or fix your bugs for you! It slows.
Design - programming Cmpe 450 Fall Dynamic Analysis Software quality Design carefully from the start Simple and clean Fewer errors Finding errors.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Debugging COMP T1.
CS 177 Week 10 Recitation Slides 1 1 Debugging. Announcements 2 2.
Harvard Mark I Howard Aiken was a pioneer in computing and a creator of conceptual design for IBM in the 1940s. He envisioned an electro-mechanical computing.
Debugging and Testing Hussein Suleman March 2007 UCT Department of Computer Science Computer Science 1015F.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
Maximal D-segments Maximal-scoring No subsegment has higher score No segment properly containing the segment satisfies the above No supersegment has higher.
ImageJ2. Who Develops ImageJ2? And anyone who wants to contribute!
Institute of Radio Physics and Electronics ILug-Cal Introduction to GDB Institute of Radio Physics and Electronics and Indian GNU/Linux Users Group Kolkata.
Pragmatic Drupal Development John Fiala Developer.
Software Testing. Software Quality Assurance Overarching term Time consuming (40% to 90% of dev effort) Includes –Verification: Building the product right,
CSC 108H: Introduction to Computer Programming
Wrapper Classes Debugging Interlude 1
Lecture 5: Test-Driven Development Basics
CS 241 – Computer Programming II Lab
Programming and Debugging with the Dragon and JTAG
14 Compilers, Interpreters and Debuggers
YAHMD - Yet Another Heap Memory Debugger
CSE 374 Programming Concepts & Tools
Software Testing An Introduction.
Testing and Debugging.
Verification and Testing
1. Welcome to Software Construction
G7 programing language Teacher / Shamsa Hassan Alhassouni.
Profiling for Performance in C++
September 27 – Course introductions; Adts; Stacks and Queues
Pseudo-ops, Debugging, etc.
Which slows more? Java or C++?
Chapter 15 Debugging.
Common C Programming Errors, GDB Debugging
Debugging 9/22/15 & 9/23/15 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
DEBUGGING JAVA PROGRAMS USING ECLIPSE DEBUGGER
Debugging CSCE 121 J. Michael Moore.
Debugging at Scale.
Using a Debugger 1-Jan-19.
Debugging Taken from notes by Dr. Neil Moore
Chapter 15 Debugging.
EECS150 Fall 2007 – Lab Lecture #4 Shah Bawany
Debugging EECS150 Fall Lab Lecture #4 Sarah Swisher
Debugging “Why you were up till 2AM”
Programming Fundamentals (750113) Ch1. Problem Solving
Debugging Taken from notes by Dr. Neil Moore
Debugging EECS150 Fall Lab Lecture #4 Sarah Swisher
IDE’s and Debugging.
Programming Fundamentals (750113) Ch1. Problem Solving
Asymptotic complexity
Unit 1 Programming - Assignment 3
C. M. Overstreet Old Dominion University Fall 2005
Debugging CSCE 121.
Presentation transcript:

DEBUGGING CS2110

Announcements Lunch with Professors – sign up, including today! Prelim 2 Regrade Requests due tonight at 11:59PM

Context 2110 teaches you how to write code with care. Use: meaningful comments meaningful variable names loop invariants preconditions asserts testing (lots and lots of testing!) clean style a structure that is easy to reason about What not to do: https://www.ioccc.org

Correctness first, then Performance "Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%.” —Donald Knuth Correctness first, then speed. If speed really matters, use a profiler.

Sometimes… …despite your best efforts, your code will not work Now what?

The 1st Bug On September 9, 1947, U.S. Navy officers found a moth between the relays on the Harvard Mark II computer they were working on. In those days computers filled rooms and the warmth of the internal components attracted moths, flies and other flying creatures. Those creatures then shortened circuits and caused the computer to malfunction. https://thenextweb.com/shareables/2013/09/18/the-very-first-computer-bug/ https://thenextweb.com/shareables/2013/09/18/the-very-first-computer-bug/

Debugging is twice as hard as writing the code in the first place Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. —BRIAN KERNIGHAN If debugging is the process of removing software bugs, then programming must be the process of putting them in. —E. W. DIJKSTRA Deleted code is debugged code. —JEFF SICKEL

Debugging 101 Step 1: know what the correct behavior is Step 2: find a single, reproducible* case where your code is incorrect Step 3: figure out what your code is doing NOT: why your code isn’t doing what it should (your code is doing exactly what you told it to) *if your code (or code you call) generates a random # anywhere you need to stop (or seed) that

Inspecting your code… Several approaches. Look at: + the last thing you touched + the part you feel the least sure of + the code most associated with the error you’re observing – every single line of code

Step through your code Print statements Use a debugger!

How to start the Eclipse debugger OR

Under the Run Menu The controls of your debugger How you navigate through the execution of your code in debug mode. Lines or variables of interest

2 days ago on piazza

Breakpoints, Watchpoints, etc. Some basic functionality common to all debuggers Breakpoint a line you want to see get executed Conditional Breakpoint a line you sometimes want to see get executed Warning: can make your code super slow Watchpoint a global variable you want to track When read When written to

Breakpoints & Watchpoints: https://help.eclipse.org/photon/index.jsp?topic=%2F org.eclipse.cdt.doc.user%2Ftasks%2Fcdt_o_brkpnts_w atch.htm