Software Debugging for High-altitude Balloons

22
Debugging John Graham-Cumming September 2013

description

A talk I gave at the UKHAS 2013 conference on software debugging.

Transcript of Software Debugging for High-altitude Balloons

Page 1: Software Debugging for High-altitude Balloons

DebuggingJohn Graham-CummingSeptember 2013

Page 2: Software Debugging for High-altitude Balloons

Ada Lovelace (1840s)

Page 3: Software Debugging for High-altitude Balloons

Maurice Wilkes (1950s)As soon as we started

programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs.

Page 4: Software Debugging for High-altitude Balloons

Writing code is hardBut writing bugs is easy!Everyone does it all the time

without even thinking about it.

Estimates in GOOD code there are 2 to 4 defects per 1,000 lines

You’re not that goodYou will spend many hours

debugging

Page 5: Software Debugging for High-altitude Balloons

ProgrammerIf a person who debugs code is a

debugger than a person who writes the bugs must be a... bugger?

Page 6: Software Debugging for High-altitude Balloons

Always have a fighter pilot in your presentation

Page 7: Software Debugging for High-altitude Balloons

Colonel John Boyd

Page 8: Software Debugging for High-altitude Balloons

OODA Loop

Page 9: Software Debugging for High-altitude Balloons

THE GREATEST DEBUGGER YOU WILL EVER USE IS IN YOUR HEAD

Ignore your tools!

Page 10: Software Debugging for High-altitude Balloons

ESSENTIAL SKILL: RUN CODE IN YOUR HEAD

Page 11: Software Debugging for High-altitude Balloons

RISEReproduceIsolateTargetExcise

Page 12: Software Debugging for High-altitude Balloons

Reproduce

Page 13: Software Debugging for High-altitude Balloons

IsolateTighten the OODA loop

◦The smallest◦Fastest◦Most easily repeated

And automate itThen turn it into a test case

Page 14: Software Debugging for High-altitude Balloons

Target

Page 15: Software Debugging for High-altitude Balloons

ESSENTIAL SKILL: ALWAYS BE ASKING WHY

Page 16: Software Debugging for High-altitude Balloons

Debugging Christmas Lights

Page 17: Software Debugging for High-altitude Balloons

ESSENTIAL SKILL: DOUBTING

Page 18: Software Debugging for High-altitude Balloons

ExciseFix the bugDon’t introduce new bugs!

You can check this with the test case that you made earlier

Page 19: Software Debugging for High-altitude Balloons

Talk to the teddy

Page 20: Software Debugging for High-altitude Balloons

Look Around DebuggingWhere there’s smoke...... research shows that bugs tend

to cluster

When you fix a bug look for more in the same spot.

Page 21: Software Debugging for High-altitude Balloons

5 bugs in a single linedir.permissions = 666; // Make the file writable

Bug 1: updates permissions without asking

Bug 2: doesn’t make the file writable

Bug 3: creates security holeBug 4: used decimal not octalBug 5: comment is incorrect

Page 22: Software Debugging for High-altitude Balloons

Remember This One Thing!The most effective debugging

tools are: your brain, a unit test, and the print statement.