FlowR: A Static Program Slicer for R

  • Abstract
  • Literature Map
  • Similar Papers
Abstract
Translate article icon Translate Article Star icon

Context Many researchers rely on the R programming language to perform their statistical analyses and visualizations in the form of R scripts. However, recent research and experience show, that many of these scripts contain problems. From being hard to comprehend by combining several analyses and plots into a single source file to being non-reproducible, with a lack of analysis tools supporting the writing of correct and maintainable code. Objective In this work, we address the problem of comprehending and maintaining R scripts by proposing flowR, a program slicer and static dataflow analyzer for the R programming language, which can be integrated directly into Visual Studio Code. Given a set of variables of interest, like the generation of a single figure in a script, flowR automatically reduces the program to the parts relevant for the output of interest, like the value of a variable. Method First, we use static program analysis to construct a detailed dataflow graph of the R script. The analysis supports loops, function calls, side effects, sourcing external files, and even redefinitions of R's primitive constructs. Subsequently, we calculate the program slice by solving a reachability problem on the graph, collecting all required parts and presenting them to the user. Results Providing several interactive ways of slicing the program, we require an average of 16 ms to calculate the slice on a given dataflow graph, reducing the code by around 94% of tokens.

Similar Papers
  • Book Chapter
  • Cite Count Icon 1
  • 10.1007/978-3-642-29166-1_18
A Review of Coupling and Cohesion Measurement in OO Systems Using Program Slicing
  • Jan 1, 2012
  • Sunint Kaur Khalsa + 3 more

This paper gives an overview of various studies regarding static and dynamic Cohesion and Coupling measurement. This study has extrapolated that static measures are insufficient to measure dynamic coupling and cohesion and in order to obtain accurate results dynamic measures are required. Further the current work dwells into the fact that coupling and cohesion calculated with the help of dynamic program slicing yields better results than those calculated by conventional means. One approach to obtain static or dynamic program slicing is making dependence graphs of the system. We have also performed a comparative study on the various dependence graph required to obtain Cohesion and Coupling measurement using static and dynamic Program Slicing.

  • Research Article
  • Cite Count Icon 3
  • 10.1109/access.2018.2853153
Scenario Oriented Program Slicing for Large-Scale Software Through Constraint Logic Programming and Program Transformation
  • Jan 1, 2019
  • IEEE Access
  • Shengbing Ren + 1 more

Program slicing, as a technique of program decomposition, is widely used in the field of program testing, model checking, software verification, symbolic execution, and other fields. However, the traditional approaches of program slicing tend to produce too large slices and the static program analyses are hard to be precise enough. Scenario-oriented program slicing, which considers the actual usage of software, gives a more precise perspective of program slicing. In this paper, we propose an approach of scenario-oriented program slicing, which combines constraint logic programming and program transformation. According to the observation that the output of a program transformation is a semantically equivalent program where the properties of interest are preserved, we can apply a sequence of transformations, more powerful than those needed for program specialization, refining the slicing to the desired degree of precision. And constraint logic programming has been shown to be a powerful, flexible formalism to reason about the correctness of programs. The novel contributions of this paper are as follows: 1) converting the problem of program slicing into program transformation and retrieval; 2) presenting a set of constraint handling rules for scenario-oriented program slicing in constraint logical programming programs; and 3) deriving a scenario-oriented program slicing algorithm. The method of scenario-oriented program slicing has been implemented and we have demonstrated its effectiveness and efficiency on three open source software projects in GitHub.

  • Conference Article
  • Cite Count Icon 8
  • 10.1109/csmr.2007.53
Verifying the Concept of Union Slices on Java Programs
  • Jan 1, 2007
  • Attila Szegedi + 4 more

Static program slicing is often proposed for software maintenance-related tasks. Due to different causes static slices are in many cases overly conservative and hence too large to reduce the program-part of interest meaningfully. In this paper we further investigate the concept of union slices, which are defined as the unions of dynamic slices computed for the same (static) slicing criteria, but for different executions of the program. We verify on real-world Java programs their usefulness as a replacement to static slices. For this we investigate the sizes of a number of backward and forward dynamic and union slices, also by comparing them to the corresponding static slices. Our results show that the union slices are precise enough (backward slices are 5-20% of the program and forward slices are 5-10%, the corresponding static slices being 25-45%), and that with the saturation of the overall coverage given many different executions, union slices also reach a steady level and typically do not grow further by adding new test cases

  • Research Article
  • Cite Count Icon 2
  • 10.1145/1361213.1361216
Program slicing under UML scenario models
  • Feb 1, 2008
  • ACM SIGPLAN Notices
  • Ju Qian + 1 more

Slicing is an important decomposition technique for program understanding. However, traditional slicing methods tend to produce too large slices for human inspection as modern programs are often huge and static program analyses are hard to be precise enough. According to the state-of-the art research and our own experience, we believe a possible solution to such problem could be incorporating UML scenario models into program slicing. This paper presents a detail discussion on how scenarios can benefit slicing relevant program analyses and proposes a general scenario specified program slicing method. The analyses indicate that scenario specified program slicing may obtain smaller slices for program understanding.

  • Research Article
  • 10.14232/actacyb.20.4.2012.2
Understanding Program Slices
  • Jan 1, 2012
  • Acta Cybernetica
  • Ákos Hajnal + 1 more

Program slicing is a useful analysis for aiding differentsoftware engineering activities. In the past decades, various notionsof program slices have been evolved as well as a number of methods tocompute them. By now program slicing has numerous applications insoftware maintenance, program comprehension, reverse engineering,program integration, and software testing. Usability of program slicingfor real world programs depends on many factors such as precision,speed, and scalability, which have already been addressed in theliterature. However, only a little attention has been brought to thepractical demand: when the slices are large or difficult to understand,which often occur in the case of larger programs, how to give anexplanation for the user why a particular element has been includedin the resulting slice. This paper describes a reasoning method aboutelements of static program slices.

  • Book Chapter
  • Cite Count Icon 84
  • 10.1007/3-540-48153-2_22
Program Slicing of Hardware Description Languages
  • Jan 1, 1999
  • E M Clarke + 5 more

Hardware description languages (HDLs) are used today to describe circuits at all levels. In large HDL programs, there is a need for source code reduction techniques to address a myriad of problems in formal verification, design, simulation, and testing. Program slicing is a static program analysis technique that allows an analyst to automatically extract portions of programs relevant to the aspects being analyzed. We extend program slicing to HDLs, thus allowing for automatic program reduction to allow the user to focus on relevant code portions. We have implemented a VHDL slicing tool composed of a general inter-procedural slicer and a front-end that captures VHDL execution semantics. This paper provides an overview of program slicing, a discussion of how to slice VHDL programs, a description of the resulting tool, and a brief overview of some applications and experimental results.

  • Conference Article
  • Cite Count Icon 4
  • 10.1145/170791.170798
An interactive debugging tool for C based on dynamic slicing and dicing
  • Jan 1, 1993
  • M Samadzadeh + 1 more

Static Program Slicing has gained wide recognition in both academic and practical arenas. Several debugging tools have been developed that utilize static program slicing. Dynamic slicing has also gained considerable popularity in recent years. Due to the several advantages of dynamic slicing over static slicing, the objective of this work was to develop a debugging tool for C programs, called C-Debug, using dynamic slicing and dicing techniques. This paper reports the design considerations of C-Debug and the data structures used in the implementation of C-Debug. Based on the usage experiments with the C-Debug debugging tool, limitations and possible future enhancements are also outlined.

  • Research Article
  • Cite Count Icon 9
  • 10.1145/3649814
A Learning-Based Approach to Static Program Slicing
  • Apr 29, 2024
  • Proceedings of the ACM on Programming Languages
  • Aashish Yadavally + 3 more

Traditional program slicing techniques are crucial for early bug detection and manual/automated debugging of online code snippets. Nevertheless, their inability to handle incomplete code hinders their real-world applicability in such scenarios. To overcome these challenges, we present NS-Slicer, a novel learning-based approach that predicts static program slices for both complete and partial code Our tool leverages a pre-trained language model to exploit its understanding of fine-grained variable-statement dependencies within source code. With this knowledge, given a variable at a specific location and a statement in a code snippet, NS-Slicer determines whether the statement belongs to the backward slice or forward slice, respectively. We conducted a series of experiments to evaluate NS-Slicer's performance. On complete code, it predicts the backward and forward slices with an F1-score of 97.41% and 95.82%, respectively, while achieving an overall F1-score of 96.77%. Notably, in 85.20% of the cases, the static program slices predicted by NS-Slicer exactly match entire slices from the oracle. For partial programs, it achieved an F1-score of 96.77%–97.49% for backward slicing, 92.14%–95.40% for forward slicing, and an overall F1-score of 94.66%–96.62%. Furthermore, we demonstrate NS-Slicer's utility in vulnerability detection (VD), integrating its predicted slices into an automated VD tool. In this setup, the tool detected vulnerabilities in Java code with a high F1-score of 73.38%. We also include the analyses studying NS-Slicer’s promising performance and limitations, providing insights into its understanding of intrinsic code properties such as variable aliasing, leading to better slicing.

  • Research Article
  • Cite Count Icon 109
  • 10.1145/226295.226310
Critical slicing for software fault localization
  • May 1, 1996
  • ACM SIGSOFT Software Engineering Notes
  • Richard A Demillo + 2 more

Developing effective debugging strategies to guarantee the reliability of software is important. By analyzing the debugging process used by experienced programmers, we have found that four distinct tasks are consistently performed: (1) determining statements involved in program failures, (2) selecting suspicious statements that might contain faults, (3) making hypotheses about suspicious faults (variables and locations), and (4) restoring program state to a specific statement for verification. This research focuses support for the second task, reducing the search domain for faults, which we refer to as fault localization. We explored a new approach to enhancing the process of fault localization based on dynamic program slicing and mutation-based testing. In this new approach, we have developed the technique of Critical Slicing to enable debuggers to highlight suspicious statements and thus to confine the search domain to a small region. The Critical Slicing technique is partly based on "statement deletion" mutant operator of the mutation-based testing methodology. We have explored properties of Critical Slicing, such as the relationship among Critical Slicing, Dynamic Program Slicing, and Executable Static Program Slicing; the cost to construct critical slices; and the effectiveness of Critical Slicing. Results of experiments support our conjecture as to the effectiveness and feasibility of using Critical Slicing for fault localization.This paper explains our technique and summarizes some of our findings. From these, we conclude that a debugger equipped with our proposed fault localization method can reduce human interaction time significantly and aid in the debugging of complex software.

  • Conference Article
  • Cite Count Icon 83
  • 10.1145/229000.226310
Critical slicing for software fault localization
  • May 1, 1996
  • Richard A Demillo + 2 more

Developing effective debugging strategies to guarantee the reliability of software is important. By analyzing the debugging process used by experienced programmers, we have found that four distinct tasks are consistently performed: (1) determining statements involved in program failures, (2) selecting suspicious statements that might contain faults, (3) making hypotheses about suspicious faults (variables and locations), and (4) restoring program state to a specific statement for verification. This research focuses support for the second task, reducing the search domain for faults, which we refer to as fault localization.We explored a new approach to enhancing the process of fault localization based on dynamic program slicing and mutation-based testing. In this new approach, we have developed the technique of Critical Slicing to enable debuggers to highlight suspicious statements and thus to confine the search domain to a small region. The Critical Slicing technique is partly based on "statement deletion" mutant operator of the mutation-based testing methodology. We have explored properties of Critical Slicing, such as the relationship among Critical Slicing, Dynamic Program Slicing, and Executable Static Program Slicing; the cost to construct critical slices; and the effectiveness of Critical Slicing. Results of experiments support our conjecture as to the effectiveness and feasibility of using Critical Slicing for fault localization.This paper explains our technique and summarizes some of our findings. From these, we conclude that a debugger equipped with our proposed fault localization method can reduce human interaction time significantly and aid in the debugging of complex software.

  • Research Article
  • Cite Count Icon 104
  • 10.1145/183432.183438
Static slicing in the presence of goto statements
  • Jul 1, 1994
  • ACM Transactions on Programming Languages and Systems
  • Jong-Deok Choi + 1 more

A static program slice is an extract of a program which can help our understanding of the behavior of the program; it has been proposed for use in debugging, optimization, parallelization, and integration of programs. This article considers two types of static slices: executable and nonexecutable. Efficient and well-founded methods have been developed to construct executable slices for programs without goto statements; it would be tempting to assume these methods would apply as well in programs with arbitrary goto statements. We show why previous methods do not work in this more general setting, and describe our solutions that correctly and efficiently compute executable slices for programs even with arbitrary goto statements. Our conclusion is that goto statements can be accommodated in generating executable static slices.

  • Research Article
  • Cite Count Icon 13
  • 10.1007/s11390-020-9754-4
SymPas: Symbolic Program Slicing
  • Mar 31, 2021
  • Journal of Computer Science and Technology
  • Ying-Zhou Zhang

Program slicing is a technique for simplifying programs by focusing on selected aspects of their behavior. Current mainstream static slicing methods operate on dependence graph PDG (program dependence graph) or SDG (system dependence graph), but these friendly graph representations may be a bit expensive for some users. In this paper we attempt to study a light-weight approach of static program slicing, called Symbolic Program Slicing (SymPas), which works as a dataflow analysis on LLVM (low-level virtual machine). In our SymPas approach, slices are stored in symbolic forms, not in procedures being re-analyzed (cf. procedure summaries). Instead of re-analyzing a procedure multiple times to find its slices for each callling context, we calculate a single symbolic slice which can be instantiated at call sites avoiding re-analysis; SymPas is implemented with LLVM to perform slicing on LLVM intermediate representation (IR). For comparison, we systematically adapt IFDS (interprocedural finite distributive subset) analysis and the SDG-based slicing method (SDG-IFDS) to statically slice IR programs. Evaluated on open-source and benchmark programs, our backward SymPas shows a factor-of-6 reduction in time cost and a factor-of-4 reduction in space cost, compared with backward SDG-IFDS, thus being more efficient. In addition, the result shows that after studying slices from 66 programs, ranging up to 336 800 IR instructions in size, SymPas is highly size-scalable.

  • Conference Article
  • Cite Count Icon 6
  • 10.1109/iccrd.2010.182
Program Slicing Based Software Metrics towards Code Restructuring
  • Jan 1, 2010
  • Shaikh Mohsin + 1 more

Software Code Restructuring is one of pivotal application of software metrics. Traditionally metrics based approaches have failed to develop efficient mechanism for insuring code quality and code comprehension. Software metrics with the standard technical implication is key combination towards reverse engineering of program code. In this work we have suggested an approach which explores effective code comprehension by combining Software metrics and technique called Program Slicing. Program slicing is static program analysis process for code automation which can develop efficient measures for coupling, cohesion, complexity. Such novel design of software metrics with analytical approach can insure reliable development of software system.

  • Research Article
  • Cite Count Icon 28
  • 10.1016/0165-6074(93)90203-w
Three approaches to interprocedural dynamic slicing
  • Sep 1, 1993
  • Microprocessing and Microprogramming
  • Mariam Kamkar + 2 more

Three approaches to interprocedural dynamic slicing

  • Research Article
  • Cite Count Icon 36
  • 10.1002/smr.533
A demand‐driven approach to slicing legacy COBOL systems
  • Mar 17, 2011
  • Journal of Software: Evolution and Process
  • Ákos Hajnal + 1 more

SUMMARYMaintenance of aging legacy COBOL systems is labor‐intensive and is becoming a more and more difficult problem. Program slicing is a potentially useful analysis for aiding different maintenance activities, including program comprehension, reverse engineering, debugging, and testing. Numerous techniques have been proposed in the past decades; however, in interactive contexts, we found none of them suitable for slicing industrial‐scale COBOL systems due to their large space or preprocessing requirements. This paper proposes a novel static program slicing approach, which is based on context‐sensitive token propagation over control flow graphs (CFGs). CFGs require less space compared with program dependence graphs (PDGs) used by other techniques, and the token propagation method computes the necessary information only, on demand. Algorithms are presented for data flow and full slicing to calculate precise program slices. Preliminary application experiences on industrial‐scale COBOL systems are also summarized. Copyright © 2011 John Wiley & Sons, Ltd.

Save Icon
Up Arrow
Open/Close