CS 404/504: Program Monitoring and Visualization HW#1

Due: Sunday January 27.
  1. Install Unicon on a machine of your choosing.
  2. Write a Unicon program that implements the first part of Hirose's static analysis for one programming language of your choice. Some later assignments in this semester will require that the target program we monitor is a Unicon program, but for this assignment you can target C++, Java, Python or whatever you like. Your assignment itself should be written in Unicon, since the point of the exercise is to learn Unicon. However, you are welcome to investigate (and call, from your Unicon program) 3rd party tools that will do part or all of the work for you. For example, the "tags" family of tools (ctags, etags, itags) generates a file that includes some of the information called for. GNU cflow does more (for C language). Similar tools are available for most languages.

    Input: Your program should take take as input command line arguments the names of source file(s) of interest.

    Output: Your program should write a JSON file containing a "dictionary" whose keys are filenames, and whose values are a dictionary whose keys are function or class names. If the object is a function, per Hirose the dictionary value should be a list of the names of functions called. If the object is a class, the value should be a dictionary whose keys are member function names and whose values are are a list of names of functions called by that member function.

    Example #1: for a "hello, world" program named hello.icn, the program would be invoked as hirose hello.icn and the output might look like:

    {"hello.icn" :
      {"main" : ["write"]}
    }
    

    Example #2: for a program with modules a.cpp, b.cpp, and c.cpp, with a.cpp containing a() which calls b() in b.cpp, which calls c() in c.cpp, the output might look like:

    {"a.cpp":
      {"a" : ["b"]},
     "b.cpp":
      {"b" : ["c"]},
     "c.cpp":
      {"c" : []}
    }
    

    Example #3: for the "Linked Robots" program from chapter 7 of Terence Soule's "A Project Based Introduction to C++", a larger C++ example that contains a class might look like:

    {"main.cpp":
      {"main" : ["robot", "linkedlist::insert", "linkedlist::print", "linkedlist::turnLeft", "linkedlist::remove"]},
     "node.h":
      {},
     "linkedlist.h":
      {"linkedlist" :
        {"linkedlist": [],
         "insert" : ["node::set_data", "node::set_next"],
         "print": [],
         "turnLeft": [],
         "remove": ["node::get_data", "robot::getID", "node::get_next", "node::remove_data", "node::remove"]
        }
      }
    }