摘要

Dynamic program slicing is useful in software debugging, testing and maintenance, because it can extract more precise results than those obtained by static slicing. In this paper, we propose a precise approach for dynamic program slicing, monadic dynamic slicing, which is based on modular monadic semantics. Firstly, we abstract the computation of dynamic slicing as an object of independent language, dynamic slice-monad transformer. Then we discuss and illustrate a modular monadic dynamic slice algorithm in detail. In this monadic algorithm, dynamic slices are computed on abstract syntax directly, without the need to explicitly construct intermediate structures such as dependence graphs, or to record an execution history. Finally, we address the implementation and complexity analysis of this algorithm. We conclude that the monadic approach has excellent flexibility, combinability and parallelizability properties.