IBM Research CDT Static Analysis Features CDT Developer
IBM Research CDT Static Analysis Features CDT Developer Summit - Ottawa Beth Tibbitts September 20, 2006 tibbitts@us. ibm. com This work has been supported in part by the Defense Advanced Research Projects Agency (DARPA) under contract No. NBCH 30390004. © 2006 IBM Corporation
IBM Research The Problem § Static Analysis of C programs is useful § Existing Abstract Syntax Tree (AST) in Eclipse CDT provides basic navigation and information, but needs more 2 © 2006 IBM Corporation
IBM Research CDT AST Extensions § Enhance existing CASTNode and Visitor – bottom-up traversal § Add other additional graphs: – Call Graph – Control Flow Graph – Data Dependence Graph § Traversal of these new graphs available in: – Topological Order – Reverse Topological Order 3 © 2006 IBM Corporation
IBM Research Bottom-up AST traversal org. eclipse. cdt. core. dom. ast. ASTVisitor org. eclipse. cdt. core. dom. ast. c. CASTVisitor Existing: public int visit(IASTxxx. . ){ return PROCESS_CONTINUE; } New: public int leave(IASTxxx. . ){ return PROCESS_CONTINUE; } 4 © 2006 IBM Corporation
IBM Research #include "mpi. h" #include "stdio. h" Call Graph void foo(int x); void gee(int x); void kei(int x); void foo(int x){ x ++; gee(x); } main foo a gee kei void gee(int x){ x *= 3; kei(x); } void kei(int x){ x = x % 10; foo(x); } void a(int x){ x --; } int main 3(int argc, char* argv[]){ int x = 0; foo(x); a(x); } Recursive calls detected… A cycle is detected on foo, gee and kei 5 © 2006 IBM Corporation
IBM Research Control Flow Graph & Data Flow Dependence Graph – sample program if #include <stdio. h> #include <string. h> if (my_rank !=0){ #include "mpi. h" /* create message */ // Sample MPI program sprintf(message, "Greetings from process %d!", my_rank); int main(int argc, char* argv[]){ dest = 0; printf("Hello MPI World the original. n"); /* use strlen+1 so that '