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.
Similar content being viewed by others
References
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)
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)
Biswas, S.: Dynamic slicing in higher-order programming languages. Ph.D. thesis, Department of CIS, University of Pennsylvania (1997)
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)
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)
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)
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)
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)
Gill, A.: Debugging Haskell by observing intermediate data structures. Electron. Notes Theor. Comput. Sci. 41(1). Proc. of the 4th Haskell Workshop (2000)
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)
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)
Hanus, M.: Curry: an integrated functional logic language. Available at: http://www.informatik.uni-kiel.de/~curry/ (2000)
Hanus, M., Prehofer, C.: Higher-order narrowing with definitional trees. J. Funct. Program. 9(1), 33–75 (1999)
Korel, B., Laski, J.: Dynamic program slicing. Inf. Process. Lett. 29(3), 155–163 (1988)
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)
Liu, Y., Stoller, S.: Eliminating dead code on recursive data. Sci. Comput. Program. 47, 221–242 (2003)
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)
Nilsson, H., Sparud, J.: The evaluation dependence tree as a basis for lazy functional debugging. Autom. Softw. Eng. 4(2), 121–150 (1997)
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)
Peyton Jones, S. (ed): Haskell 98 language and libraries. The Revised Report. Cambridge University Press, Cambridge (2003)
Pope, B.: A declarative debugger for Haskell. Ph.D. thesis, The University of Melbourne, Australia (2006)
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)
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)
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)
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)
Tip, F.: A survey of program slicing techniques. J. Program. Lang. 3, 121–189 (1995)
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)
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)
Weiser, M.: Program slicing. IEEE Trans. Softw. Eng. 10(4), 352–357 (1984)
Author information
Authors and Affiliations
Corresponding author
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
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
Published:
Issue Date:
DOI: https://doi.org/10.1007/s10990-008-9023-7