Why Programs Fail
A Guide to Systematic DebuggingBy
- Andreas Zeller
This fully updated second edition includes 100+ pages of new material, including new chapters on Verifying Code, Predicting Errors, and Preventing Errors. Cutting-edge tools such as FindBUGS and AGITAR are explained, techniques from integrated environments like Jazz.net are highlighted, and all-new demos with ESC/Java and Spec#, Eclipse and Mozilla are included.
This complete and pragmatic overview of debugging is authored by Andreas Zeller, the talented researcher who developed the GNU Data Display Debugger(DDD), a tool that over 250,000 professionals use to visualize the data structures of programs while they are running. Unlike other books on debugging, Zeller's text is product agnostic, appropriate for all programming languages and skill levels.
Why Programs Fail explains best practices ranging from systematically tracking error reports, to observing symptoms, reproducing errors, and correcting defects. It covers a wide range of tools and techniques from hands-on observation to fully automated diagnoses, and also explores the author's innovative techniques for isolating minimal input to reproduce an error and for tracking cause and effect through a program. It even includes instructions on how to create automated debugging tools.
Computer programmers, software developers, analysts and testers
Paperback, 424 Pages
Published: June 2009
Imprint: Morgan Kaufmann
Praise from the experts for the first edition: "In this book, Andreas Zeller does an excellent job introducing useful debugging techniques and tools invented in both academia and industry. The book is easy to read and actually very fun as well. It will not only help you discover a new perspective on debugging, but it will also teach you some fundamental static and dynamic program analysis techniques in plain language." -Miryung Kim, Software Developer, Motorola Korea "Today every computer program written is also debugged, but debugging is not a widely studied or taught skill. Few books beyond this one present a systematic approach to finding and fixing programming errors." -James Larus, Microsoft Research "From the author of ODD, the famous data display debugger, now comes the definitive book on debugging. Zeller's book is chock-full with advice, insight, and tools to track down defects in programs, for all levels of experience and any programming language. The book is lucidly written, explaining the principles of every technique without boring the reader with minutiae. And best of all, at the end of each chapter it tells you where to download all those fancy tools. A great book for the software professional as well as the student interested in the frontiers of automated debugging." -Walter F. Tichy, Professor, University Karlsruhe, Germany "Andreas Zeller's Why Programs Fail lays an excellent foundation far practitioners, educators, and researchers alike. Using a disciplined approach based on the scientific method, Zeller provides deep insights, detailed approaches, and illustrative examples." -David Notkin, Professor Computer Science & Engineering, University of Washington
- 1 How Failures Come to Be 1.1 My Program Does Not Work! 1.2 From Defects to Failures 1.3 Lost in Time and Space1.4 From Failures to Fixes 1.5 Automated Debugging Techniques 1.6 Bugs, Faults, or Defects? 1.7 Concepts 1.8 Tools 1.9 Further Reading 1.10 Exercises2 Tracking Problems 2.1 Oh! All These Problems 2.2 Reporting Problems 2.3 Managing Problems 2.4 Classifying Problems 2.5 Processing Problems 2.6 Managing Problem Tracking 2.7 Requirements as Problems 2.8 Managing Duplicates 2.9 Relating Problems and Fixes 2.10 Relating Problems and Tests2.11 Concepts 2.12 Tools 2.13 Further Reading 2.14 Exercises 3 Making Programs Fail 3.1 Testing for Debugging 3.2 Controlling the Program 3.3 Testing at the Presentation Layer 3.4 Testing at the Functionality Layer 3.5 Testing at the Unit Layer 3.6 Isolating Units 3.7 Designing for Debugging 73.8 Preventing Unknown Problems 3.9 Concepts 3.10 Tools 3.11 Further Reading 3.12 Exercises 4 Reproducing Problems 4.1 The First Task in Debugging 4.2 Reproducing the Problem Environment 4.3 Reproducing Program Execution 4.4 Reproducing System Interaction 4.5 Focusing on Units 4.6 Concepts 4.7 Tools 4.8 Further Reading 4.9 Exercises 5 Simplifying Problems 5.1 Simplifying the Problem 5.2 The Gecko BugAThon 5.3 Manual Simpliﬁcation 5.4 Automatic Simpliﬁcation 5.5 A Simpliﬁcation Algorithm 5.6 Simplifying User Interaction 5.7 Random Input Simpliﬁed 5.8 Simplifying Faster 5.9 Concepts 5.10 Tools 5.11 Further Reading 5.12 Exercises 6 Scientiﬁc Debugging 6.1 How to Become a Debugging Guru 6.2 The Scientiﬁc Method 6.3 Applying the Scientiﬁc Method 6.4 Explicit Debugging 6.5 Keeping a Logbook 6.6 Debugging Quick-and-Dirty 6.7 Algorithmic Debugging 6.8 Deriving a Hypothesis 6.9 Reasoning About Programs 6.10 Concepts 6.11 Further Reading 6.12 Exercises 7 Deducing Errors 7.1 Isolating Value Origins 7.2 Understanding Control Flow 7.3 Tracking Dependences7.4 Slicing Programs 7.5 Deducing Code Smells 7.6 Limits of Static Analysis 7.7 Concepts 7.8 Tools 7.9 Further Reading 7.10 Exercises 8 Observing Facts 8.1 Observing State 8.2 Logging Execution 8.3 Using Debuggers 8.4 Querying Events 8.5 Visualizing State 8.6 Concepts 8.7 Tools 8.8 Further Reading 8.9 Exercises 9 Tracking Origins 9.1 Reasoning Backwards 9.2 Exploring Execution History 9.3 Dynamic Slicing 9.4 Leveraging Origins 9.5 Tracking Down Infections 9.6 Concepts 9.7 Tools 9.8 Further Reading 9.9 Exercises 10 Asserting Expectations 10.1 Automating Observation 10.2 Basic Assertions 10.3 Asserting Invariants 10.4 Asserting Correctness 10.5 Assertions as Speciﬁcations 10.6 From Assertions to Veriﬁcation 10.7 Reference Runs 10.8 System Assertions 10.9 Checking Production Code 10.10 Concepts 10.11 Tools 10.12 Further Reading 10.13 Exercises 11 Detecting Anomalies 11.1 Capturing Normal Behavior 11.2 Comparing Coverage 11.3 Statistical Debugging 11.4 Collecting Data in the Field11.5 Dynamic Invariants 11.6 Invariants on the Fly 11.7 From Anomalies to Defects11.8 Concepts 11.9 Tools 11.10 Further Reading 11.11 Exercises12 Causes and Eﬀects 12.1 Causes and Alternate Worlds12.2 Verifying Causes 12.3 Causality in Practice 12.4 Finding Actual Causes 12.5 Narrowing Down Causes 12.6 A Narrowing Example 12.7 The Common Context 12.8 Causes in Debugging 12.9 Concepts 12.10 Further Reading 12.11 Exercises 13 Isolating Failure Causes 13.1 Isolating Causes Automatically 13.2 Isolating versus Simplifying 13.3 An Isolation Algorithm 13.4 Implementing Isolation 13.5 Isolating Failure-inducing Input 13.6 Isolating Failure-inducing Schedules 13.7 Isolating Failure-inducing Changes 13.8 Problems and Limitations 13.9 Concepts 13.10 Tools 13.11 Further Reading 13.12 Exercises 14 Isolating Cause-Eﬀect Chains 14.1 Useless Causes 14.2 Capturing Program States 14.3 Comparing Program States 14.4 Isolating Relevant Program States 14.5 Isolating Cause-Eﬀect Chains 14.6 Isolating Failure-inducing Code 14.7 Issues and Risks 14.8 Concepts 14.9 Tools 14.10 Further Reading 14.11 Exercises 15 Fixing the Defect 15.1 Locating the Defect 15.2 Focusing on the Most Likely Errors 15.3 Validating the Defect 15.4 Correcting the Defect 15.5 Workarounds 15.6 Learning from Mistakes 15.7 Concepts 15.8 Further Reading 15.9 ExercisesAppendix: Formal Deﬁnitions A.1 Delta Debugging A.2 Memory Graphs A.3 Cause-Eﬀect Chains