CSE3010: (Software Pattern Theory and Practice) - - PowerPoint PPT Presentation

cse3010
SMART_READER_LITE
LIVE PREVIEW

CSE3010: (Software Pattern Theory and Practice) - - PowerPoint PPT Presentation

CSE3010: (Software Pattern Theory and Practice) Yann-Gal Guhneuc The Be a Debugger process pattern This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 3.0 Unported


slide-1
SLIDE 1

Yann-Gaël Guéhéneuc

This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 3.0 Unported License

CSE3010: 소프트웨어패턴 이론및실험

(Software Pattern Theory and Practice)

The Be a Debugger process pattern

slide-2
SLIDE 2

2/40

Bug

slide-3
SLIDE 3

3/40

Bug

slide-4
SLIDE 4

4/40

Outline

 Definition  Method  Tools

– Logging – Debugger

 Conclusion

slide-5
SLIDE 5

5/40

Outline

 Definition  Method  Tools

– Logging – Debugger

 Conclusion

slide-6
SLIDE 6

6/40

Definition

A software bug is an error, flaw, failure, or fault in a computer program or system that produces an incorrect or unexpected result,

  • r causes it to behave in unintended ways.

—Wikipedia

slide-7
SLIDE 7

7/40

Definition

A software bug is an error, flaw, failure, or fault in a computer program or system that produces an incorrect or unexpected result,

  • r causes it to behave in unintended ways
  • r to have unexpected non-functional

characteristics —Wikipedia with additions Including “non-functional” behaviour, e.g., consume too much memory or perform to many method calls

slide-8
SLIDE 8

8/40

Definition

 Error, aka crash, exception…

– A difference between a computed result and the correct (expected) result

 Failure

– The (incorrect) result of a fault

 Fault, aka defect, flaw

– An incorrect step, process, or data definition includes also non-functional (design) defects

 Mistake

– A human action that produces an incorrect result

slide-9
SLIDE 9

9/40

Definition

A mistake may lead to a fault, which may lead to a failure, which may lead to an error

slide-10
SLIDE 10

10/40

Definition

A mistake may lead to a fault, which may lead to a failure, which may lead to an error

slide-11
SLIDE 11

11/40

Outline

 Definition  Method  Tools

– Logging – Debugger

 Conclusion

slide-12
SLIDE 12

12/40

How to Fix a Bug?

“Installed Firefox and it does not work at all” —https://support.mozilla.org/en- US/questions/977001

slide-13
SLIDE 13

13/40

How to Fix a Bug?

 Method

– Process to collect, analyse, understand, and fix the bug (error, failure, fault, mistake)

 Tools

– To concretely apply the process

slide-14
SLIDE 14

14/40

Method

“Installed Firefox and it does not work at all”

 Descriptive  NOT informative  Essentially useless…

slide-15
SLIDE 15

15/40

Method

 Minimum

– Crash report

 Better

– Steps to reproduce

 Even better

– Short, Self Contained, Correct Example

slide-16
SLIDE 16

16/40

Method

 Minimum

– Crash report

 Better

– Steps to reproduce

 Even better

– Short, Self Contained, Correct Example

slide-17
SLIDE 17

17/40

Method

 Short, Self Contained, Correct Example

http://sscce.org/ – Actually a (simple) test case – Descriptive – Informative – Can be use repeatedly until fixed – Can be used as regression test too

slide-18
SLIDE 18

18/40

Method

 Short, Self Contained, Correct Example

– Ockham's razor is “a principle of parsimony, economy, or succinctness used in logic and problem-solving” [Wikipedia] – Why use more when you can use less?

  • c. 1287 – 1347
slide-19
SLIDE 19

19/40

Method

 To build the SSCCE and to solve the error

(or fault or failure) illustrated by the SSCCE, follow the scientific method

slide-20
SLIDE 20

20/40

Method

 To build the SSCCE and to solve the error

(or fault or failure) illustrated by the SSCCE, follow the scientific method

slide-21
SLIDE 21

21/40

Method

 To build the SSCCE and to solve the error

(or fault or failure) illustrated by the SSCCE, follow the scientific method A method or procedure consisting in the systematic observation, measurement, and experiment, and the formulation, testing, and modification of hypotheses —Oxford English Dictionary

slide-22
SLIDE 22

22/40

Method

 Scientific method

– Daniel ( לאֵיִּנָדּ), 7th century BCE – Thales (Θαλῆς), 6th BCE – Plato (Πλάτων), 4th BCE – Aristotle (Ἀριστοτέλης), 3th BCE – … – al-Ḥasan (مﺛﯾﮭﻟا نﺑ نﺳﺣﻟا نﺑ نﺳﺣﻟا ،ﻲﻠﻋ وﺑأ), 8th c. CE – …

slide-23
SLIDE 23

23/40

Method

 Scientific method

– … – Roger Bacon, 13th century CE – Francis Bacon, 17th CE – Descartes, 17th CE – … – Charles Sanders Peirce, 19th CE – Popper, 20th CE

slide-24
SLIDE 24

24/40

Method

 Scientific method

– Falsifiability

http://karl-popper.over-blog.com

“Are all swans white?” “Do mermaids exist?”

Sir Karl Raimund Popper

28 July 1902–17 Septembre 1994

slide-25
SLIDE 25

25/40

Method

Hypothesise where the Failure / fault / mistake is From your hypothesis, set breakpoints Test your hypothesis, i.e., debug the SSCCE Analyse whether you can fix the failure / fault / mistake can Yes? Next bug No? Continue

slide-26
SLIDE 26

26/40

Outline

 Definition  Method  Tools

– Logging – Debugger

 Conclusion

slide-27
SLIDE 27

27/40

Tools

 Poor man’s debugger

– System.out.println(…);

 Better

– Logging (e.g., Log4J) logger.debug(…);

 (Even) better

– Use the debugger

slide-28
SLIDE 28

28/40

Tools

 System.out.println(…);

– Not scalable – Clutter the output

 Logging

– Scalable, levels – Off-line, remote

 Debugger

– On-line (interactive) – SSCCE

slide-29
SLIDE 29

29/40

Tools

 System.out.println(…);

– Not scalable – Clutter the output

 Logging

– Scalable, levels – Off-line, remote

 Debugger

– On-line (interactive) – SSCCE

slide-30
SLIDE 30

30/40

Outline

 Definition  Method  Tools

– Logging – Debugger

 Conclusion

slide-31
SLIDE 31

31/40

Tools

 Logging, e.g., Log4J

// Get a logger instance named "com.foo" Logger logger = Logger.getLogger("com.foo"); // Normally you do not set the level of a logger in code. logger.setLevel(Level.INFO); // This request is enabled, because WARN >= INFO. logger.warn("Low fuel level."); // This request is disabled, because DEBUG < INFO. logger.debug("Starting search for nearest gas station."); // The logger instance barlogger inherits its level from // the logger named "com.foo". This request is enabled // because INFO >= INFO. Logger barlogger = Logger.getLogger("com.foo.Bar"); barlogger.info("Located gas station."); // This request is disabled, because DEBUG < INFO. barlogger.debug("Exiting gas station search");

slide-32
SLIDE 32

32/40

Tools

DEBUG | 2008-09-06 10:51:44,817 | DefaultBeanDefinitionDocumentReader.java | 86 | Loading bean DEBUG | 2008-09-06 10:51:44,848 | AbstractBeanDefinitionReader.java | 185 | Loaded 5 bean defini INFO | 2008-09-06 10:51:44,848 | XmlBeanDefinitionReader.java | 323 | Loading XML bean definition DEBUG | 2008-09-06 10:51:44,848 | DefaultDocumentLoader.java | 72 | Using JAXP provider [com.su DEBUG | 2008-09-06 10:51:44,848 | BeansDtdResolver.java | 72 | Found beans DTD [http://www.spr DEBUG | 2008-09-06 10:51:44,864 | DefaultBeanDefinitionDocumentReader.java | 86 | Loading bean … DEBUG | 2008-09-06 10:51:45,473 | AbstractAutowireCapableBeanFactory.java | 383 | Creating insta DEBUG | 2008-09-06 10:51:45,473 | AbstractAutowireCapableBeanFactory.java | 459 | Eagerly cachi 10:51:45,473 | AbstractAutowireCapableBeanFactory.java | 411 | Finished creating instance of bean ' INFO | 2008-09-06 10:51:45,473 | SQLErrorCodesFactory.java | 128 | SQLErrorCodes loaded: [DB2, …

slide-33
SLIDE 33

33/40

Tools

 Logging, e.g., Log4J

– DEBUG: low level things, e.g., cache hit, cache miss, opening database connection… – INFO: events that have business meaning, e.g., creating a customer, charging a card… – WARN: any problem that does not stop the program, e.g., email address not found… – ERROR: unexpected problem that could prevent the program to work, e.g., failed to open a database connection...

slide-34
SLIDE 34

34/40

Outline

 Definition  Method  Tools

– Logging – Debugger

 Conclusion

slide-35
SLIDE 35

35/40

Tools

 Debugger

– “Usual” features

  • Query processor
  • Symbol resolver
  • Expression interpreter
  • Step-by-step execution
  • Stopping (breaking) execution
  • Tracking the values of variables

– Reverse debugging

  • Omniscient debugger
slide-36
SLIDE 36

36/40

Tools

 Debugger

– Hardware support for single-stepping a program

  • Popek and Goldberg’s virtualization requirements
  • In-System Programming
  • Test access ports

– Instruction set simulator – Virtual machine

  • Smalltalk again 
slide-37
SLIDE 37

37/40

Tools

slide-38
SLIDE 38

38/40

Tools

DEMO!

slide-39
SLIDE 39

39/40

Outline

 Definition  Method  Tools

– Logging – Debugger

 Conclusion

slide-40
SLIDE 40

40/40

Conclusion

 Beware of the ubiquitous term “bug”  Debug with (scientific) method

– Use SSCCE!

 Use the tools to your advantage