logo资料库

Debugging - The 9 Indispensable Rules for Finding Even the Most ....pdf

第1页 / 共106页
第2页 / 共106页
第3页 / 共106页
第4页 / 共106页
第5页 / 共106页
第6页 / 共106页
第7页 / 共106页
第8页 / 共106页
资料共106页,剩余部分请下载后查看
Header
Table of Contents
DebuggingŠThe Nine Indispensable Rules for Finding Even the Most Elusive Software and Hardware Problems
Chapter 1: Introduction
Overview
How Can That Work?
Isn't It Obvious?
Anyone Can Use It
It'll Debug Anything
But It Won't Prevent, Certify, or Triage Anything
More Than Just Troubleshooting
A Word About War Stories
Stay Tuned
Chapter 2: The Rules-Suitable for Framing
Chapter 3: Understand the System
Overview
Read the Manual
Read Everything, Cover to Cover
Know What's Reasonable
Know the Road Map
Know Your Tools
Look It Up
Remember
Understand the System
Chapter 4: Make it Fail
Overview
Do It Again
Start at the Beginning
Stimulate the Failure
Don't Simulate the Failure
What If It's Intermittent?
What If I've Tried Everything and It's Still Intermittent?
A Hard Look at Bad Luck
Lies, Damn Lies, and Statistics
Did You Fix It, or Did You Get Lucky?
"But That Can't Happen"
Never Throw Away a Debugging Tool
Remember
Make It Fail
Chapter 5: Quit Thinking and Look
Overview
See the Failure
See the Details
Now You See It, Now You Don't
Instrument the System
Design Instrumentation In
Build Instrumentation In Later
Don't Be Afraid to Dive In
Add Instrumentation On
Instrumentation in Daily Life
The Heisenberg Uncertainty Principle
Guess Only to Focus the Search
Remember
Quit Thinking and Look
Chapter 6: Divide and Conquer
Overview
Narrow the Search
In the Ballpark
Which Side Are You On?
Inject Easy-to-Spot Patterns
Start with the Bad
Fix the Bugs You Know About
Fix the Noise First
Remember
Divide and Conquer
Chapter 7: Change One Thing at a Time
Overview
Use a Rifle, Not a Shotgun
Grab the Brass Bar with Both Hands
Change One Test at a Time
Compare with a Good One
What Did You Change Since the Last Time It Worked?
Remember
Change One Thing at a Time
Chapter 8: Keep an Audit Trail
Overview
Write Down What You Did, in What Order, and What Happened
The Devil Is in the Details
Correlate
Audit Trails for Design Are Also Good for Testing
The Shortest Pencil Is Longer Than the Longest Memory
Remember
Keep an Audit Trail
Chapter 9: Check the Plug
Overview
Question Your Assumptions
Don't Start at Square Three
Test the Tool
Remember
Check the Plug
Chapter 10: Get a Fresh View
Overview
Ask for Help
A Breath of Fresh Insight
Ask an Expert
The Voice of Experience
Where to Get Help
Don't Be Proud
Report Symptoms, Not Theories
You Don't Have to Be Sure
Remember
Get a Fresh View
Chapter 11: If You Didn't Fix it, It Ain't Fixed
Overview
Check That It's Really Fixed
Check That It's Really Your Fix That Fixed It
It Never Just Goes Away by Itself
Fix the Cause
Fix the Process
Remember
If You Didn't Fix It, It Ain't Fixed
Chapter 12: All the Rules in One Story
Chapter 13: Easy Exercises for the Reader
Overview
A Light Vacuuming Job
A Flock of Bugs
A Loose Restriction
The Jig Is Up
Chapter 14: The View From the Help Desk
Overview
Help Desk Constraints
The Rules, Help Desk Style
Understand the System
Make It Fail
Quit Thinking and Look
Divide and Conquer
Change One Thing at a Time
Keep an Audit Trail
Check the Plug
Get a Fresh View
If You Didn't Fix It, It Ain't Fixed
Remember
The View From the Help Desk Is Murky
Chapter 15: The Bottom Line
Overview
The Debugging Rules Web Site
If You're an Engineer
If You're a Manager
If You're a Teacher
Remember
List of Figures
List of Sidebars
Current
Debugging
Table of Contents Debugging—The Nine Indispensable Rules for Finding Even the Most Elusive Software and Hardware Problems...................................................................................................................1 Chapter 1: Introduction.....................................................................................................................4 Overview..................................................................................................................................4 How Can That Work?...............................................................................................................4 Isn't It Obvious?.......................................................................................................................4 Anyone Can Use It...................................................................................................................5 It'll Debug Anything..................................................................................................................5 But It Won't Prevent, Certify, or Triage Anything.....................................................................6 More Than Just Troubleshooting.............................................................................................6 A Word About War Stories.......................................................................................................7 Stay Tuned...............................................................................................................................7 Chapter 2: The Rules−Suitable for Framing....................................................................................9 Chapter 3: Understand the System................................................................................................10 Overview................................................................................................................................10 Read the Manual....................................................................................................................11 Read Everything, Cover to Cover..........................................................................................12 Know What's Reasonable......................................................................................................13 Know the Road Map..............................................................................................................14 Know Your Tools....................................................................................................................14 Look It Up...............................................................................................................................15 Remember.............................................................................................................................16 Understand the System....................................................................................................16 Chapter 4: Make it Fail.....................................................................................................................17 Overview................................................................................................................................17 Do It Again.............................................................................................................................19 Start at the Beginning............................................................................................................19 Stimulate the Failure..............................................................................................................19 Don't Simulate the Failure......................................................................................................20 What If It's Intermittent?.........................................................................................................21 What If I've Tried Everything and It's Still Intermittent?..........................................................22 A Hard Look at Bad Luck.................................................................................................22 Lies, Damn Lies, and Statistics........................................................................................23 Did You Fix It, or Did You Get Lucky?.............................................................................23 "But That Can't Happen"........................................................................................................24 Never Throw Away a Debugging Tool...................................................................................25 Remember.............................................................................................................................26 Make It Fail.......................................................................................................................26 Chapter 5: Quit Thinking and Look................................................................................................27 Overview................................................................................................................................27 See the Failure.......................................................................................................................29 See the Details.......................................................................................................................31 Now You See It, Now You Don't............................................................................................33 Instrument the System...........................................................................................................33 Design Instrumentation In................................................................................................33 i
Table of Contents Chapter 5: Quit Thinking and Look Build Instrumentation In Later..........................................................................................35 Don't Be Afraid to Dive In.................................................................................................36 Add Instrumentation On...................................................................................................36 Instrumentation in Daily Life.............................................................................................37 The Heisenberg Uncertainty Principle...................................................................................37 Guess Only to Focus the Search...........................................................................................38 Remember.............................................................................................................................38 Quit Thinking and Look....................................................................................................38 Chapter 6: Divide and Conquer......................................................................................................40 Overview................................................................................................................................40 Narrow the Search.................................................................................................................42 In the Ballpark..................................................................................................................43 Which Side Are You On?.................................................................................................44 Inject Easy−to−Spot Patterns................................................................................................44 Start with the Bad...................................................................................................................45 Fix the Bugs You Know About...............................................................................................46 Fix the Noise First..................................................................................................................46 Remember.............................................................................................................................47 Divide and Conquer.........................................................................................................47 Chapter 7: Change One Thing at a Time.......................................................................................48 Overview................................................................................................................................48 Use a Rifle, Not a Shotgun....................................................................................................49 Grab the Brass Bar with Both Hands.....................................................................................50 Change One Test at a Time...................................................................................................51 Compare with a Good One....................................................................................................51 What Did You Change Since the Last Time It Worked?........................................................52 Remember.............................................................................................................................54 Change One Thing at a Time...........................................................................................54 Chapter 8: Keep an Audit Trail.......................................................................................................55 Overview................................................................................................................................55 Write Down What You Did, in What Order, and What Happened..........................................56 The Devil Is in the Details......................................................................................................57 Correlate................................................................................................................................58 Audit Trails for Design Are Also Good for Testing.................................................................58 The Shortest Pencil Is Longer Than the Longest Memory.....................................................59 Remember.............................................................................................................................59 Keep an Audit Trail...........................................................................................................59 Chapter 9: Check the Plug..............................................................................................................61 Overview................................................................................................................................61 Question Your Assumptions..................................................................................................62 Don't Start at Square Three...................................................................................................63 Test the Tool..........................................................................................................................63 Remember.............................................................................................................................65 Check the Plug.................................................................................................................65 ii
Table of Contents Chapter 10: Get a Fresh View.........................................................................................................66 Overview................................................................................................................................66 Ask for Help...........................................................................................................................66 A Breath of Fresh Insight.................................................................................................66 Ask an Expert...................................................................................................................67 The Voice of Experience..................................................................................................67 Where to Get Help.................................................................................................................68 Don't Be Proud.......................................................................................................................69 Report Symptoms, Not Theories............................................................................................69 You Don't Have to Be Sure..............................................................................................70 Remember.............................................................................................................................70 Get a Fresh View.............................................................................................................70 Chapter 11: If You Didn't Fix it, It Ain't Fixed................................................................................71 Overview................................................................................................................................71 Check That It's Really Fixed..................................................................................................72 Check That It's Really Your Fix That Fixed It.........................................................................72 It Never Just Goes Away by Itself..........................................................................................73 Fix the Cause.........................................................................................................................73 Fix the Process......................................................................................................................74 Remember.............................................................................................................................75 If You Didn't Fix It, It Ain't Fixed.......................................................................................75 Chapter 12: All the Rules in One Story..........................................................................................76 Chapter 13: Easy Exercises for the Reader..................................................................................78 Overview................................................................................................................................78 A Light Vacuuming Job..........................................................................................................78 A Flock of Bugs......................................................................................................................79 A Loose Restriction................................................................................................................81 The Jig Is Up..........................................................................................................................85 Chapter 14: The View From the Help Desk....................................................................................88 Overview................................................................................................................................88 Help Desk Constraints...........................................................................................................89 The Rules, Help Desk Style...................................................................................................89 Understand the System....................................................................................................90 Make It Fail.......................................................................................................................91 Quit Thinking and Look....................................................................................................91 Divide and Conquer.........................................................................................................92 Change One Thing at a Time...........................................................................................92 Keep an Audit Trail...........................................................................................................92 Check the Plug.................................................................................................................93 Get a Fresh View.............................................................................................................93 If You Didn't Fix It, It Ain't Fixed.......................................................................................94 Remember.............................................................................................................................94 The View From the Help Desk Is Murky...........................................................................94 iii
Table of Contents Chapter 15: The Bottom Line..........................................................................................................95 Overview................................................................................................................................95 The Debugging Rules Web Site.............................................................................................95 If You're an Engineer.............................................................................................................95 If You're a Manager................................................................................................................95 If You're a Teacher.................................................................................................................96 Remember.............................................................................................................................96 List of Figures..................................................................................................................................98 List of Sidebars..............................................................................................................................100 iv
Debugging—The Nine Indispensable Rules for Finding Even the Most Elusive Software and Hardware Problems David J. Agans American Management Association New York • Atlanta • Brussels • Buenos Aires • Chicago • London • Mexico City San Francisco • Shanghai • Tokyo • Toronto • Washington , D.C. Special discounts on bulk quantities of AMACOM books are available to corporations, professional associations, and other organizations. For details, contact Special Sales Department, AMACOM, a division of American Management Association, 1601 Broadway, New York, NY 10019. Tel.: 212−903−8316. Fax: 212−903−8083. Web site: http://www.amacombooks.org/ This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional service. If legal advice or other expert assistance is required, the services of a competent professional person should be sought. Library of Congress Cataloging−in−Publication Data Agans, David J., 1954− Debugging: the 9 indispensable rules for finding even the most elusive software and hardware problems / David J. Agans. p. cm. Includes index. ISBN 0−8144−7168−4 1. Debugging in computer science. 2. Computer software—Quality control. I. Title. QA76.9.D43 A35 2002 005.1 4—dc21 2002007990 Copyright © 2002 David J. Agans. All rights reserved. Printed in the United States of America. This publication may not be reproduced, stored in a retrieval system, 1
or transmitted in whole or in part, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of AMACOM, a division of American Management Association, 1601 Broadway, New York, NY 10019. Printing number 10 9 8 7 6 5 4 3 2 1 To my mom, Ruth (Worsley) Agans, who debugged Fortran listings by hand at our dining room table, fueled by endless cups of strong coffee. And to my dad, John Agans, who taught me to think, to use my common sense, and to laugh. Your spirits are with me in all my endeavors. Acknowledgments This book was born in 1981 when a group of test technicians at Gould asked me if I could write a document on how to troubleshoot our hardware products. I was at a loss—the products were boards with hundreds of chips on them, several microprocessors, and numerous communications buses. I knew there was no magical recipe; they would just have to learn how to debug things. I discussed this with Mike Bromberg, a long time mentor of mine, and we decided the least we could do was write up some general rules of debugging. The Ten Debugging Commandments were the result, a single sheet of brief rules for debugging which quickly appeared on the wall above the test benches. Over the years, this list was compressed by one rule and generalized to software and systems, but it remains the core of this book. So to Mike, and to the floor techs who expressed the need, thanks. Over the years, I've had the pleasure of working for and with a number of inspirational people who helped me develop both my debugging skills and my sense of humor. I'd like to recognize Doug Currie, Scott Ross, Glen Dash, Dick Morley, Mike Greenberg, Cos Fricano, John Aylesworth (one of the original techs), Bob DeSimone, and Warren Bayek for making challenging work a lot of fun. I should also mention three teachers who expected excellence and made learning enjoyable: Nick Menutti (it ain't the Nobel Prize, but here's your good word), Ray Fields, and Professor Francis F. Lee. And while I never met them, their books have made a huge difference in my writing career: William Strunk Jr. and E. B. White (The Elements of Style), and Jeff Herman and Deborah Adams (Write the Perfect Book Proposal). To the Delt Dawgs, my summer softball team of 28 years and counting, thanks for the reviews and networking help. I'm indebted to Charlie Seddon, who gave me a detailed review with many helpful comments, and to Bob Siedensticker, who did that and also gave me war stories, topic suggestions, and advice on the publishing biz. Several people, most of whom I did not know personally at the time, reviewed the book and sent me nice letters of endorsement, which helped get it published. Warren Bayek and Charlie Seddon (mentioned above), Dick Riley, Bob Oakes, Dave Miller, and Professor Terry Simkin: thank you for your time and words of encouragement. I'm grateful to the Sesame Workshop, Tom and Ray Magliozzi (Click and Clack of Car Talk—or is it Clack and Click?), and Steve Martin for giving me permission to use their stories and jokes; to Sir Arthur Conan Doyle for creating Sherlock Holmes and having him make so many apropos comments; and to Seymour Friedel, Bob McIlvaine, and my brother Tom Agans for relating 2
分享到:
收藏