Declarative Debugging with Buddha

  • Bernard Pope
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3622)

Abstract

Haskell is a very safe language, particularly because of its type system. However there will always be programs that do the wrong thing. Programmer fallibility, partial or incorrect specifications and typographic errors are but a few of the reasons that make bugs a fact of life. This paper is about the use and implementation of a debugger, called Buddha, which helps Haskell programmers understand why their programs misbehave. Traditional debugging tools that examine the program execution step-by-step are not suitable for Haskell because of its unorthodox evaluation strategy. Instead, a different approach is taken which abstracts away the evaluation order of the program and focuses on its high-level logical meaning.

This style of debugging is called Declarative Debugging, and it has its roots in the Logic Programming community. At the heart of the debugger is a tree which records information about the evaluation of the program in a manner which is easy to relate to the structure of the source code. It resembles a call graph annotated with the arguments and results of function applications, shown in their most evaluated form. Logical relationships between entities in the source are reflected in the links between nodes in the tree. An error diagnosis algorithm is applied to the tree in a top-down fashion in the search for causes of bugs.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Nilsson, H., Spaurd, J.: The evaluation dependence tree as a basis for lazy functional debugging. Automated Software Engineering 4, 121–150 (1997)CrossRefGoogle Scholar
  2. 2.
    Gansner, E., Koutsofios, E., North, S.: Drawing graphs with dot (2002), http://www.research.att.com/sw/tools/graphviz/dotguide.pdf
  3. 3.
    Jones, N., Mycroft, A.: Dataflow analysis of applicative programs using minimal function graphs. In: Proceedings of the 13th ACM SIGACT-SIGPLAN symposium on Principles of Programming Languages, Florida, pp. 296–306. ACM Press, New York (1986)CrossRefGoogle Scholar
  4. 4.
    Claessen, K., Hughes, J.: Quickcheck: a lightweight tool for random testing of Haskell programs. In: International Conference on Functional Programming, pp. 268–279. ACM Press, New York (2000)Google Scholar
  5. 5.
    Naish, L., Barbour, T.: Towards a portable lazy functional declarative debugger. Australian Computer Science Communications 18, 401–408 (1996)Google Scholar
  6. 6.
    Sparud, J.: Tracing and Debugging Lazy Functional Computations. PhD thesis, Chalmers University of Technology, Sweden (1999)Google Scholar
  7. 7.
    Caballero, R., Rodri’guez-Artalejo, M.: A declarative debugging system for lazy functional logic programs. In: Hanus, M. (ed.) Electronic Notes in Theoretical Computer Science, vol. 64. Elsevier Science Publishers, Amsterdam (2002)Google Scholar
  8. 8.
    Pope, B., Naish, L.: A program transformation for debugging Haskell-98. Australian Computer Science Communications 25, 227–236 (2003) ISBN:0-909925-94-1Google Scholar
  9. 9.
    Claessen, K., Runciman, C., Chitil, O., Hughes, J., Wallace, M.: Testing and Tracing Lazy Functional Programs using QuickCheck and Hat. In: Jeuring, J., Jones, S.L.P. (eds.) AFP 2002. LNCS, vol. 2638, pp. 59–99. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  10. 10.
    Pope, B., Naish, L.: Practical aspects of declarative debugging in Haskell-98. In: Fifth ACM SIGPLAN Conference on Principles and Practice of Declarative Programming, pp. 230–240 (2003) ISBN:1-58113-705-2Google Scholar
  11. 11.
    Wadler, P.: Why no one uses functional languages. SIGPLAN Notices 33, 23–27 (1998)CrossRefGoogle Scholar
  12. 12.
    Wallace, M., Chitil, O., Brehm, T., Runciman, C.: Multiple-view tracing for Haskell: a new hat. In: Preliminary Proceedings of the 2001 ACM SIGPLAN Haskell Workshop, pp. 151–170 (2001)Google Scholar
  13. 13.
    Gill, A.: Debugging Haskell by observing intermediate data structures. Technical report, University of Nottingham. In: Proceedings of the 4th Haskell Workshop (2000)Google Scholar
  14. 14.
    Nilsson, H.: Declarative Debugging for Lazy Functional Languages. PhD thesis, Department of Computer and Information Science Linköpings Universitet, S-581 83, Linköping, Sweden (1998)Google Scholar
  15. 15.
    Nilsson, H.: How to look busy while being as lazy as ever: The implementation of a lazy functional debugger. Journal of Functional Programming 11, 629–671 (2001)MATHCrossRefGoogle Scholar
  16. 16.
    Naish, L.: A declarative debugging scheme. Journal of Functional and Logic Programming  1997 (1997)Google Scholar
  17. 17.
    Naish, L., Barbour, T.: A declarative debugger for a logical-functional language. In: Forsyth, G., Ali, M. (eds.) Eighth International Conference on Industrial and Engineering Applications of Artificial Intelligence and Expert Systems — Invited and Additional Papers, Melbourne, DSTO General Document 51, vol. 2, pp. 91–99 (1995)Google Scholar
  18. 18.
    Naish, L.: Declarative debugging of lazy functional programs. Australian Computer Science Communications 15, 287–294 (1993)Google Scholar
  19. 19.
    Naish, L.: A three-valued declarative debugging scheme. Australian Computer Science Communications 22, 166–173 (2000)Google Scholar
  20. 20.
    Ennals, R., Peyton Jones, S.: Optimistic evaluation: an adaptive evaluation strategy for non-strict programs. In: Proceedings of the Eighth ACM SIGPLAN Conference on Functional Programming, pp. 287–298 (2003)Google Scholar
  21. 21.
    Ennals, R., Peyton Jones, S.: HsDebug: Debugging lazy programs by not being lazy. In: Jeuring, J. (ed.) ACM SIGPLAN 2003 Haskell Workshop, pp. 84–87. ACM Press, New York (2003)CrossRefGoogle Scholar
  22. 22.
    Shapiro, E.: Algorithmic Program Debugging. MIT Press, Cambridge (1982)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2005

Authors and Affiliations

  • Bernard Pope
    • 1
  1. 1.Department of Computer Science and Software EngineeringUniversity of MelbourneAustralia

Personalised recommendations