<meta name="robots" content="noindex" />

How does it work?

Static_Analysis_diagram.png

Call_Graph_diagram.png

The process starts with C, Python and JavaScript source code from which separate ASTs (Abstract Syntax Tree) are dumped using Clang-Check (for C files)

C_AST.jpeg

Figure 1: Portion of a C AST file

the AST module and the file ast2json.py (for Python files),

pythonJSON.png

Figure 2: Portion of a Python AST json file

And SpiderMonkey for JavaScript files.

jsJSON.png

Figure 3: Portion of a JavaScript AST json file

The AST files have very different structures for C, Python and Javascript, but the parsers are designed to handle each kind of AST differently. Those parsers filter the AST files, detecting and recording function calls and their arguments. Initially, the program is capable of detecting literals and variables as arguments. Reaching Definition Analysis will be developed in the future in order to handle statically assigned variables as arguments to functions. The current version of the program handles part of the Python.h interface between C and Python. It only analyzes “PyRun_SimpleFile” calls. Other mechanisms for calling Python from C will also be implemented in the future. The version can also handle PyV8 's eval function to call a JavaScript program from Python. In the future, the program will be able to handle cases in which a JavaScript program is called from a C program, and both JavaScript and Python functions are called from C programs.

When the designated function used to call another program of another language, such as “PyRun_SimpleFile” or JSContext().eval(), is found, its argument (name of the Python or JavaScript file) is considered a function call and the executable portion of that file is represented as the main function in the original program. That creates the connection between the two files, which allows the subsequent programs to build the call graph.

CombineCSV.py” combines all individual csv files from the list of source files into one. This file is then used as input to “GenerateDot.py”. This program translates the csv file to a dot file, which represents the csv file as a graph. The Dot program builds the final graph via GraphViz and saves it as a PDF file. Circular nodes represent C programs, rectangular nodes represent Python programs, and hexagonal nodes represent JavaScript programs. Recursive functions are denoted by dotted nodes.

test6_callgraph.png

Figure 4: Example of a multilingual call graph

Permissions

  • Persons/group who can view/change the page:
  • Set ALLOWTOPICCHANGE = FRCVRoboticsGroup

-- (c) Fordham University Robotics and Computer Visio

Topic attachments
ISorted ascending Attachment History Action Size Date Who Comment
JPEGjpeg C_AST.jpeg r1 manage 35.9 K 2016-07-27 - 14:46 DamianLyons  
JPEGjpeg PY_AST.jpeg r1 manage 19.1 K 2016-07-27 - 14:46 DamianLyons  
PNGpng Call_Graph_diagram.png r1 manage 41.1 K 2017-04-11 - 15:28 MaggieGates  
PNGpng Static_Analysis_diagram.png r1 manage 140.7 K 2017-04-11 - 15:28 MaggieGates  
PNGpng call_graph.png r1 manage 206.5 K 2017-04-07 - 19:36 DamianLyons  
PNGpng callgraph.png r1 manage 39.2 K 2016-07-27 - 14:46 DamianLyons  
PNGpng jsJSON.png r1 manage 25.7 K 2017-04-07 - 19:27 DamianLyons javascript AST
PNGpng process_diagram.png r1 manage 43.9 K 2016-07-27 - 14:59 DamianLyons  
PNGpng pythonJSON.png r1 manage 21.0 K 2017-04-07 - 19:25 DamianLyons python AST
PNGpng test6_callgraph.png r1 manage 430.2 K 2017-07-11 - 20:45 AnneMarieBogar  
Edit | Attach | Watch | Print version | History: r9 | r7 < r6 < r5 < r4 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r5 - 2017-07-11 - AnneMarieBogar
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback