Declarative Debugging with Buddha
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.
Unable to display preview. Download preview PDF.
- 2.Gansner, E., Koutsofios, E., North, S.: Drawing graphs with dot (2002), http://www.research.att.com/sw/tools/graphviz/dotguide.pdf
- 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.Naish, L., Barbour, T.: Towards a portable lazy functional declarative debugger. Australian Computer Science Communications 18, 401–408 (1996)Google Scholar
- 6.Sparud, J.: Tracing and Debugging Lazy Functional Computations. PhD thesis, Chalmers University of Technology, Sweden (1999)Google Scholar
- 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.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
- 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
- 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.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.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
- 16.Naish, L.: A declarative debugging scheme. Journal of Functional and Logic Programming 1997 (1997)Google Scholar
- 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.Naish, L.: Declarative debugging of lazy functional programs. Australian Computer Science Communications 15, 287–294 (1993)Google Scholar
- 19.Naish, L.: A three-valued declarative debugging scheme. Australian Computer Science Communications 22, 166–173 (2000)Google Scholar
- 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
- 22.Shapiro, E.: Algorithmic Program Debugging. MIT Press, Cambridge (1982)Google Scholar