CallPathManager.h

Go to the documentation of this file.
00001 //===-- CallPathManager.h ---------------------------------------*- C++ -*-===//
00002 //
00003 //                     The KLEE Symbolic Virtual Machine
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #ifndef __UTIL_CALLPATHMANAGER_H__
00011 #define __UTIL_CALLPATHMANAGER_H__
00012 
00013 #include "klee/Statistics.h"
00014 
00015 #include <map>
00016 #include <vector>
00017 
00018 namespace llvm {
00019   class Instruction;
00020   class Function;
00021 }
00022 
00023 namespace klee {
00024   class StatisticRecord;
00025 
00026   struct CallSiteInfo {
00027     unsigned count;
00028     StatisticRecord statistics;
00029 
00030   public:
00031     CallSiteInfo() : count(0) {}
00032   };
00033 
00034   typedef std::map<llvm::Instruction*,
00035                    std::map<llvm::Function*, CallSiteInfo> > CallSiteSummaryTable;    
00036   
00037   class CallPathNode {
00038     friend class CallPathManager;
00039 
00040   public:
00041     typedef std::map<std::pair<llvm::Instruction*, 
00042                                llvm::Function*>, CallPathNode*> children_ty;
00043 
00044     // form list of (callSite,function) path
00045     CallPathNode *parent;
00046     llvm::Instruction *callSite;
00047     llvm::Function *function;
00048     children_ty children;
00049 
00050     StatisticRecord statistics;
00051     StatisticRecord summaryStatistics;
00052     unsigned count;
00053 
00054   public:
00055     CallPathNode(CallPathNode *parent, 
00056                  llvm::Instruction *callSite,
00057                  llvm::Function *function);
00058 
00059     void print();
00060   };
00061 
00062   class CallPathManager {
00063     CallPathNode root;
00064     std::vector<CallPathNode*> paths;
00065 
00066   private:
00067     CallPathNode *computeCallPath(CallPathNode *parent, 
00068                                   llvm::Instruction *callSite,
00069                                   llvm::Function *f);
00070     
00071   public:
00072     CallPathManager();
00073     ~CallPathManager();
00074 
00075     void getSummaryStatistics(CallSiteSummaryTable &result);
00076     
00077     CallPathNode *getCallPath(CallPathNode *parent, 
00078                               llvm::Instruction *callSite,
00079                               llvm::Function *f);
00080   };
00081 }
00082 
00083 #endif

Generated on Fri Jun 5 03:31:31 2009 for klee by  doxygen 1.5.8