• No results found

Debugging and all that for Master Software Engineering

N/A
N/A
Protected

Academic year: 2022

Share "Debugging and all that for Master Software Engineering"

Copied!
21
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

Software Analysis And Transformation

Debugging and all that

Software Construction 2012/2013 May 2nd

Jurgen Vinju

(2)

Read

“The Pragmatic Programmer” (Hunt & Thomas)

“Why Programs Fail, a guide to systematic debugging” (Zeller)

(3)

Today

Motivating debugging (attitude)

Terms and concepts (knowledge)

How to debug (skill)

Stories (fun)

(4)

Programmer Activities

Learning (API, domain, …)

Setting up (tools)

Designing

Explorative coding

Exploring code

Accidental coding (hacking)

Productive coding

Testing

Deploying

Documenting

Anything else?

All valid!

(5)

Continuous Go/No-Go

Different best practices with different goals and activities

know what you are doing and why and how

be able to switch activities and come back

step back, realize, plan ahead, take notes

Go or No-Go: continuously make the technical-debt trade-off

quickly estimate cost of activities (in time or in quality)

estimate return-on-investment (in time or in quality)

estimate available resources (in time)

Communicate

Learn to really listen to what your colleague is saying (and yourself)

Learn to explain better and faster what you are thinking

(6)

Debugging exists!

Plato versus Aristotle

Wishful thinking and the reality of software

Plato: better safe than sorry; “if only we had”

Aristotle: wake up in the real world!

What if you have a bug?

Blame somebody else!

Blame something else!

Give up! Start from scratch!

Or… be a professional programmer

Andreas Zeller

(7)

Debugging is search

Debugging is searching

a path from effect (“failure”)

to cause (“defect”)

Preventive (Plato, theoretical)

keeping the search space small

Curative (Aristotle, pragmatic)

making the search effective

Programmers are Researchers

(8)

Search space

LIMITATION: What do

immutability (FP), synchronization, asserts, design-by-contract, types,

etc. do to the search space?

Time

Memory

scan taken from “why programs fail”

POWER: What do pointers, inversion of control, parallelism,

concurrency, global variables, monads, implicits, AOP, interfaces, dynamic dispatch, etc. etc. do to the

search space?

Code staring is “useless”

because code does not describe the search space, it generates it!

(9)

Debugging is awesome

“a humbling experience”

(10)

Debugging is possible!

it takes guts and brains and perseverance

(11)

First Plato

Defensive coding

express assumptions (in asserts, types, tests)

minimize dependencies (locality of debugging)

what else?

Understand why it (should) work!

how can you understand a failure if you don’t know how to recognize success?

understand the relationship between requirements, specification and implementation (bug or feature)

What else can we do to prevent bugs? Or to make fixing them easier?

(12)

Then Aristotle

The scientific method

Observe (actually read the error message...)

Document (use an issue tracker; take notes)

Reproduce (automate a test)

Analyze

Simplify

Form hypotheses

Run a test

Fix and see if problem goes away, or go back, without forgetting what you have learned

Be conscious, and do stuff:

What are your (implicit) assumptions/claims/hypotheses?

How can you experiment/test/assert that they are true?

(13)

Thinking vs Reasoning

There is a difference

There are different valid ways of reasoning

Deductive (“consequentially”)

Inductive (generalizing, “so always/never”)

Abductive (guessing, hypothesizing)

Debugging paradox:

The dangerous forms of reasoning are most effective in debugging, making the search space smaller.

The safe form of reasoning can get you easily started on wild goose chase.

(14)

Deduction

Direction: from cause to effect

A deduction guarantees that the conclusion is true given that the premise is true

“programs only throw segmentation faults if

there is a bug in the program” and “this program throws a segmentation fault”, so “this program

has a bug

(15)

Induction

Making a general statement after seeing some specific examples

An induction is/should be made based on many similar observations

“the program fails every time I pressed the ESC button” (3 times), so “the ESC button must be causing the failure”.

(16)

Abduction

Direction: from effect to cause (!)

Finding an explanation that fits the facts

Abduction is guessing based on insight

“The program crashes on my clients machine which runs Windows” and “The program does

not crash on my machine which runs Linux”, so:

“The cause of the crash is due to some difference between the OS’s”

(17)

Delta debugging

How to make a search space smaller?

Analyze only the differences between what fails and what does not fail

A definition of “cause”: the minimal difference

between a world that shows the effect and a world that does not

Find the minimal difference, and you have found a cause of the defect.

Can be iterative, can be automated (Zeller, AskIgor)

(18)

Omniscient debugging

Log EVERYTHING

Apply delta debugging on the log

Omniscient debugging tools

can automate delta debugging

can look back in time, reverse run the program

(19)

Live coding

Debugging is the new programming

See the effect while you are causing it

Fixes the forward search, not the backward search

(20)

War stories!

Debugging is a skill of the mind

Skills are learned by practice and by example

Let’s learn from each other now.

(21)

STAR + SNOWBALL

STAR

What was the Situation?

What was your Task?

How did you Approach?

What was the Result?

SNOWBALL

first in pairs of 2

then groups of 4, 8, 16

each round 5 minutes

the method?

the best of two

First listen, then ask, then analyze, then choosereminiscent?

Referenties

GERELATEERDE DOCUMENTEN

3) Bereken het fosfaatquotum dat aangevoerd mag worden en vergelijk dit met de totale fosfaataanvoer. 4) Door de landbouwkundige adviesbasis te volgen is mogelijk minder nodig dan

Kennisverspreiding door lezingen en discussie-bijeenkomsten Naast telers worden stakeholders zoals toeleveranciers en overheden betrokken bij ontwikkeling en implementatie van

Voor alle duidelijkheid wordt er op gewezen dat dit niet een onderzoek behelste naar het functioneren van regionale en lokale over· heidssorganen, maar naar

Typically, three activity regions could be distin- guished (cf. However, for catalysts in which these crystallites were absent, or were decomposed into surface rhenium

Morbi luctus, wisi viverra faucibus pretium, nibh est placerat odio, nec commodo wisi enim eget quam.. Quisque libero justo, con- sectetuer a, feugiat vitae, porttitor

Either one's theory of emotions and of emotional reasoning does already conceptually imply a more developed notion of the self, which leads to the question whether there is

As the first part of a series investigating hydrological changes over the Sanjiangyuan region, this paper com- prehensively evaluated the newly developed CSSPv2 model by comparing

After these exploratory investigations of the numerical treatment of the nucleation burst, we proceed by inves- tigating the physical implications of changing the temperature level