Abstract:Dynamic program slicing is an important program analysis technique that extracts code statements that actually influence a given slicing criterion under specific program inputs and execution traces. It has important practical value in tasks such as program debugging, fault localization, and program comprehension. However, existing dynamic program slicing approaches still face challenges when applied to large-scale software systems, including high analysis costs, complex dependency modeling, and difficulties with interprocedural dependency analysis. Recent studies have explored the use of large language models to generate dynamic program slices, but most existing approaches focus on small-scale programs and lack execution information constraints, resulting in limited slicing accuracy. To address these issues, this study proposes AgentDSlicer, a multi-agent collaborative framework for dynamic program slicing generation. Through collaboration among multiple agents, including agents for program execution reasoning, slice generation, result verification, and slice refinement, the proposed method generates execution-aware dynamic program slices without relying on real program execution information. To support systematic evaluation, this study further constructs DySliceBench, a manually annotated dynamic program slicing dataset that contains 2 543 dynamic slicing instances collected from CodeNet and open-source GitHub projects and covers two programming languages, Java and Python. Experimental results show that, on the DySliceBench dataset, AgentDSlicer improves slicing accuracy by 30.4% on average compared with existing methods and by 32.1% compared with the current state-of-the-art LLM-based dynamic slicing method ND-Slicer. In large-scale program scenarios, the accuracy improvement reaches 60.1%. In addition, experiments in application scenarios such as program debugging and fault localization further validate the effectiveness of the proposed method. The results show that AgentDSlicer can effectively improve the applicability of dynamic program slicing to real-world software projects while ensuring analysis accuracy.