cse3010
play

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


  1. CSE3010: 소프트웨어패턴 이론및실험 (Software Pattern Theory and Practice) Yann-Gaël Guéhéneuc The Be a Debugger process pattern This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 3.0 Unported License

  2. Bug 2/40

  3. Bug 3/40

  4. Outline  Definition  Method  Tools – Logging – Debugger  Conclusion 4/40

  5. Outline  Definition  Method  Tools – Logging – Debugger  Conclusion 5/40

  6. Definition A software bug is an error, flaw, failure, or fault in a computer program or system that produces an incorrect or unexpected result, or causes it to behave in unintended ways.  —Wikipedia 6/40

  7. Including “non-functional” behaviour, e.g., consume too much memory or Definition perform to many method calls A software bug is an error, flaw, failure, or fault in a computer program or system that produces an incorrect or unexpected result, or causes it to behave in unintended ways or to have unexpected non-functional characteristics  —Wikipedia with additions 7/40

  8. 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 8/40

  9. Definition A mistake may lead to a fault, which may lead to a failure, which may lead to an error 9/40

  10. Definition A mistake may lead to a fault, which may lead to a failure, which may lead to an error 10/40

  11. Outline  Definition  Method  Tools – Logging – Debugger  Conclusion 11/40

  12. How to Fix a Bug? “Installed Firefox and it does not work at all” —https://support.mozilla.org/en- US/questions/977001 12/40

  13. 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 13/40

  14. Method “Installed Firefox and it does not work at all”  Descriptive  NOT informative  Essentially useless… 14/40

  15. Method  Minimum – Crash report  Better – Steps to reproduce  Even better – Short, Self Contained, Correct Example 15/40

  16. Method  Minimum – Crash report  Better – Steps to reproduce  Even better – Short, Self Contained, Correct Example 16/40

  17. 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 17/40

  18. Method  Short, Self Contained, Correct Example – Ockham's razor is “a principle of parsimony, economy, or succinctness used in logic and problem-solving” [Wikipedia] c. 1287 – 1347 – Why use more when you can use less? 18/40

  19. Method  To build the SSCCE and to solve the error (or fault or failure) illustrated by the SSCCE, follow the scientific method 19/40

  20. Method  To build the SSCCE and to solve the error (or fault or failure) illustrated by the SSCCE, follow the scientific method 20/40

  21. 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 21/40

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

  23. Method  Scientific method – … – Roger Bacon, 13th century CE – Francis Bacon, 17th CE – Descartes, 17th CE – … – Charles Sanders Peirce, 19 th CE – Popper, 20th CE 23/40

  24. Method  Scientific method Sir Karl Raimund Popper 28 July 1902–17 Septembre 1994 – Falsifiability http://karl-popper.over-blog.com “Are all swans white?” “Do mermaids exist?” 24/40

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

  26. Outline  Definition  Method  Tools – Logging – Debugger  Conclusion 26/40

  27. Tools  Poor man’s debugger – System.out.println(…);  Better – Logging (e.g., Log4J) logger.debug(…);  (Even) better – Use the debugger 27/40

  28. Tools  System.out.println(…); – Not scalable – Clutter the output  Logging – Scalable, levels – Off-line, remote  Debugger – On-line (interactive) – SSCCE 28/40

  29. Tools  System.out.println(…); – Not scalable – Clutter the output  Logging – Scalable, levels – Off-line, remote  Debugger – On-line (interactive) – SSCCE 29/40

  30. Outline  Definition  Method  Tools – Logging – Debugger  Conclusion 30/40

  31. 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"); 31/40

  32. 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, … 32/40

  33. 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... 33/40

  34. Outline  Definition  Method  Tools – Logging – Debugger  Conclusion 34/40

  35. 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 35/40

  36. 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  36/40

  37. Tools 37/40

  38. Tools DEMO! 38/40

  39. Outline  Definition  Method  Tools – Logging – Debugger  Conclusion 39/40

  40. Conclusion  Beware of the ubiquitous term “bug”  Debug with (scientific) method – Use SSCCE!  Use the tools to your advantage 40/40

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend