本文整理汇总了C++中SgProject::get_projectSpecificDatabaseFile方法的典型用法代码示例。如果您正苦于以下问题:C++ SgProject::get_projectSpecificDatabaseFile方法的具体用法?C++ SgProject::get_projectSpecificDatabaseFile怎么用?C++ SgProject::get_projectSpecificDatabaseFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgProject
的用法示例。
在下文中一共展示了SgProject::get_projectSpecificDatabaseFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( int argc, char * argv[] ) {
if(argc < 4){
Usage(argc, argv);
}
int numTraces = 0;
try
{
numTraces = boost::lexical_cast<int>(argv[1]);
}
catch(...) {
Usage(argc, argv);
}
FILE * roseTraceFilePtrs[numTraces];
char * roseTraceFiles[numTraces];
FILE * roseProjectDBFilePtr;
const char * roseProjectDBFile;
for(int i = 0 ; i < numTraces; i++) {
roseTraceFiles[i] = argv[i+2];
if(!(roseTraceFilePtrs[i] = fopen(roseTraceFiles[i], "rb"))){
fprintf(stderr, "\n Failed to read TraceFile %s",roseTraceFiles[i]);
exit(-1);
}
}
// patch argv
for(int i = numTraces + 2 ; i < argc; i++){
argv[i - 1 - numTraces] = argv[i];
}
int patchedArgc = argc - (numTraces + 1);
// Generate the ROSE AST.
SgProject* project = frontend(patchedArgc ,argv);
// AST consistency tests (optional for users, but this enforces more of our tests)
AstTests::runAllTests(project);
// Open the DB file... DOn't need lock for reading.
roseProjectDBFile = project->get_projectSpecificDatabaseFile().c_str();
if(!(roseProjectDBFilePtr = fopen(roseProjectDBFile, "r"))){
fprintf(stderr, "\n Failed to read roseDBFile %s", roseProjectDBFile);
exit(-1);
}
char fileName[PATH_MAX];
// Read DB file and assign file Ids
while(fgets(fileName, PATH_MAX, roseProjectDBFilePtr)){
// kill \n
fileName[strlen(fileName)-1] = '\0';
idToFile.push_back(string(fileName));
}
fclose(roseProjectDBFilePtr);
// Build node to trace id map.
for(int i = 0 ; i < project->numberOfFiles(); i++) {
SgFile & file = project->get_file(i);
IdToNodeMapper mapper(&file, project->get_projectSpecificDatabaseFile());
}
// Read all trace records from all traces
uint64_t traceId;
boost::unordered_map<uint64_t, SgNode*>::iterator it;
vector<SgNode *> traceRecordVector[numTraces];
for(int curTraceNo = 0 ; curTraceNo < numTraces ; curTraceNo++) {
while(fread(&traceId, sizeof(uint64_t), 1, roseTraceFilePtrs[curTraceNo])){
uint32_t fileId = traceId >> 32;
uint32_t nodeId = (traceId & 0xffffffff);
if (fileId > idToFile.size()) {
cout<<"\n"<< std::hex << traceId << " MISSING FILE!!!! id" << std::hex << fileId;
traceRecordVector[curTraceNo].push_back(NULL);
} else {
it = idToNodeMap.find(traceId);
if(it == idToNodeMap.end()){
cout<<"\n"<< std::hex << traceId << " can't map back!!!" << std::hex << fileId << std::hex << nodeId;
traceRecordVector[curTraceNo].push_back(NULL);
} else {
cout<<"\n"<< std::hex << traceId << ":"<< idToFile[fileId] << ":" << std::hex << (*it).second << ":" << ((*it).second)->class_name();
traceRecordVector[curTraceNo].push_back((*it).second);
}
}
}
fclose(roseTraceFilePtrs[curTraceNo]);
}
// Now, compare traces till they start to diverge and populate them in a vector so that one can iterate over them.
vector<SgNode *> commonPrefix;
uint64_t minTraceSize = -1;
//.........这里部分代码省略.........