Skip to main content
Log in

Dynamic slicing of lazy functional programs based on redex trails

  • Published:
Higher-Order and Symbolic Computation

Abstract

Tracing computations is a widely used methodology for program debugging. Lazy languages, however, pose new demands on tracing techniques because following the actual trace of a computation is generally useless. Typically, tracers for lazy languages rely on the construction of a redex trail, a graph that stores the reductions performed in a computation. While tracing provides a significant help for locating bugs, the task still remains complex. A well-known debugging technique for imperative programs is based on dynamic slicing, a method for finding the program statements that influence the computation of a value for a specific program input.

In this work, we introduce a novel technique for dynamic slicing in first-order lazy functional languages. Rather than starting from scratch, our technique relies on (a slight extension of) redex trails. We provide a notion of dynamic slice and introduce a method to compute it from the redex trail of a computation. We also sketch the extension of our technique to deal with a functional logic language. A clear advantage of our proposal is that one can enhance existing tracers with slicing capabilities with a modest implementation effort, since the same data structure (the redex trail) can be used for both tracing and slicing.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Albert, E., Hanus, M., Huch, F., Olvier, J., Vidal, G.: Operational semantics for declarative multi-paradigm languages. J. Symb. Comput. 40(1), 795–829 (2005)

    Article  MATH  Google Scholar 

  2. Biswas, S.: A demand-driven set-based analysis. In: Proc. of the 24th ACM Symp. on Principles of Programming Languages (POPL’97), pp. 372–385. ACM Press, New York (1997)

    Chapter  Google Scholar 

  3. Biswas, S.: Dynamic slicing in higher-order programming languages. Ph.D. thesis, Department of CIS, University of Pennsylvania (1997)

  4. Braßel, B., Hanus, M., Huch, F., Vidal, G.: A semantics for tracing declarative multi-paradigm programs. In: Proc. of the 6th Int’l Conf. on Principles and Practice of Declarative Programming (PPDP’04), pp. 179–190. ACM Press, New York (2004)

    Chapter  Google Scholar 

  5. Cheda, D., Silva, J., Vidal, G.: Static slicing of rewrite systems. In: Proc. of the 15th Int’l Workshop on Functional and (Constraint) Logic Programming (WFLP 2006). Electronic Notes in Theoretical Computer Science, vol. 177, pp. 123–136 (2007)

  6. Chitil, O.: A semantics for tracing. In: 13th Int’l Workshop on Implementation of Functional Languages (IFL 2001), pp. 249–254. Ericsson Computer Science Laboratory (2001)

  7. Chitil, O.: Source-based trace exploration. In: 16th Int’l Workshop on Implementation of Functional Languages (IFL 2004). LNCS, vol. 3474, pp. 126–141. Springer, Berlin (2005)

    Google Scholar 

  8. Ferrante, J., Ottenstein, K., Warren, J.: The program dependence graph and its use in optimization. ACM Trans. Program. Lang. Syst. 9(3), 319–349 (1987)

    Article  MATH  Google Scholar 

  9. Gill, A.: Debugging Haskell by observing intermediate data structures. Electron. Notes Theor. Comput. Sci. 41(1). Proc. of the 4th Haskell Workshop (2000)

  10. Hallgren, T.: Haskell tools from the programatica project. In: Proc. of the ACM Workshop on Haskell (Haskell’03), pp. 103–106. ACM Press, New York (2003)

    Chapter  Google Scholar 

  11. Hanus, M.: A unified computation model for functional and logic programming. In: Proc. of the 24th ACM Symp. on Principles of Programming Languages (POPL’97), pp. 80–93. ACM Press, New York (1997)

    Chapter  Google Scholar 

  12. Hanus, M.: Curry: an integrated functional logic language. Available at: http://www.informatik.uni-kiel.de/~curry/ (2000)

  13. Hanus, M., Prehofer, C.: Higher-order narrowing with definitional trees. J. Funct. Program. 9(1), 33–75 (1999)

    Article  MATH  MathSciNet  Google Scholar 

  14. Korel, B., Laski, J.: Dynamic program slicing. Inf. Process. Lett. 29(3), 155–163 (1988)

    Article  MATH  Google Scholar 

  15. Kuck, D., Kuhn, R., Padua, D., Leasure, B., Wolfe, M.: Dependence graphs and compiler optimization. In: Proc. of the 8th Symp. on the Principles of Programming Languages (POPL’81), SIGPLAN Notices, pp. 207–218 (1981)

  16. Liu, Y., Stoller, S.: Eliminating dead code on recursive data. Sci. Comput. Program. 47, 221–242 (2003)

    Article  MATH  Google Scholar 

  17. López-Fraguas, F., Sánchez-Hernández, J.: TOY: a multiparadigm declarative system. In: Proc. of the 10th Int’l Conf. on Rewriting Techniques and Applications (RTA’99). LNCS, vol. 1631, pp. 244–247. Springer, Berlin (1999)

    Google Scholar 

  18. Nilsson, H., Sparud, J.: The evaluation dependence tree as a basis for lazy functional debugging. Autom. Softw. Eng. 4(2), 121–150 (1997)

    Article  Google Scholar 

  19. Ochoa, C., Silva, J., Vidal, G.: Dynamic slicing based on redex trails. In: Proc. of the ACM SIGPLAN 2004 Symposium on Partial Evaluation and Program Manipulation (PEPM’04), pp. 123–134. ACM Press, New York (2004)

    Chapter  Google Scholar 

  20. Peyton Jones, S. (ed): Haskell 98 language and libraries. The Revised Report. Cambridge University Press, Cambridge (2003)

    Google Scholar 

  21. Pope, B.: A declarative debugger for Haskell. Ph.D. thesis, The University of Melbourne, Australia (2006)

  22. Pope, B., Naish, L.: A program transformation for debugging Haskell 98. In: Proc. of 26th Australasian Computer Science Conference (ACSC 2003). Conferences in Research and Practice in Information Technology, vol. 16, pp. 227–236. ACS, Washington (2003)

    Google Scholar 

  23. Reps, T., Turnidge, T.: Program specialization via program slicing. In: Danvy, O., Glück, R., Thiemann, P. (eds.) Partial Evaluation. Dagstuhl Castle, Germany, February 1996. LNCS, vol. 1110, pp. 409–429. Springer, Berlin (1996)

    Google Scholar 

  24. Rodrigues, N., Barbosa, L.: Slicing functional programs by calculation. In: Proc. of the Dagstuhl Seminar on Beyond Program Slicing. Seminar n. 05451, Schloss Dagstuhl (2005)

  25. Sparud, J., Runciman, C.: Tracing lazy functional computations using redex trails. In: Proc. of the 9th Int’l Symp. on Programming Languages, Implementations, Logics and Programs (PLILP’97). LNCS, vol. 1292, pp. 291–308. Springer, Berlin (1997)

    Chapter  Google Scholar 

  26. Tip, F.: A survey of program slicing techniques. J. Program. Lang. 3, 121–189 (1995)

    Google Scholar 

  27. Vidal, G.: Forward slicing of multi-paradigm declarative programs based on partial evaluation. In: Logic-based Program Synthesis and Transformation (revised and selected papers from the 12th Int’l Workshop LOPSTR 2002). LNCS, vol. 2664, pp. 219–237. Springer, Berlin (2003)

    Google Scholar 

  28. Wallace, M., Chitil, O., Brehm, T., Runciman, C.: Multiple-view tracing for Haskell: a new hat. In: Proc. of the 2001 ACM SIGPLAN Haskell Workshop. Universiteit Utrecht UU-CS-2001-23 (2001)

  29. Weiser, M.: Program slicing. IEEE Trans. Softw. Eng. 10(4), 352–357 (1984)

    Article  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Germán Vidal.

Additional information

A preliminary version of this paper appeared in the Proceedings of PEPM’04 [19]. This work has been partially supported by EU (FEDER) and Spanish MEC under grants TIN2004-00231, TIN2005-09207-C03-02, and Acción Integrada HA2006-0008.

Rights and permissions

Reprints and permissions

About this article

Cite this article

Ochoa, C., Silva, J. & Vidal, G. Dynamic slicing of lazy functional programs based on redex trails. Higher-Order Symb Comput 21, 147–192 (2008). https://doi.org/10.1007/s10990-008-9023-7

Download citation

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10990-008-9023-7

Keywords

Navigation