本文整理汇总了C++中SgGraphNode::get_name方法的典型用法代码示例。如果您正苦于以下问题:C++ SgGraphNode::get_name方法的具体用法?C++ SgGraphNode::get_name怎么用?C++ SgGraphNode::get_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgGraphNode
的用法示例。
在下文中一共展示了SgGraphNode::get_name方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getDefFor
void
CompassAnalyses::BinaryInterruptAnalysis::Traversal::getValueForDefinition(std::vector<uint64_t>& vec,
std::vector<uint64_t>& positions,
uint64_t& fpos,
SgGraphNode* node,
std::pair<X86RegisterClass, int> reg ) {
set <SgGraphNode*> defNodeSet = getDefFor(node, reg);
if (RoseBin_support::DEBUG_MODE())
cout << " size of found NodeSet = " << defNodeSet.size() <<endl;
set <SgGraphNode*>::const_iterator it = defNodeSet.begin();
for (;it!=defNodeSet.end();++it) {
SgGraphNode* defNode = *it;
if (RoseBin_support::DEBUG_MODE() && defNode)
cout << " investigating ... " << defNode->get_name() <<endl;
ROSE_ASSERT(defNode);
SgAsmx86Instruction* inst = isSgAsmx86Instruction(defNode->get_SgNode());
ROSE_ASSERT(inst);
positions.push_back(inst->get_address());
// the right hand side of the instruction is either a use or a value
bool memRef = false, regRef = false;
std::pair<X86RegisterClass, int> regRight =
check_isRegister(defNode, inst, true, memRef, regRef);
if (RoseBin_support::DEBUG_MODE()) {
string regName = unparseX86Register(RegisterDescriptor(reg.first, reg.second, 0, 64), NULL);
string regNameRight = unparseX86Register(RegisterDescriptor(regRight.first, regRight.second, 0, 64), NULL);
cout << " VarAnalysis: getValueForDef . " << regName << " right hand : " << regNameRight <<endl;
}
if (!regRef) {
// it is either a memref or a value
if (!memRef) {
// get value of right hand side instruction
uint64_t val = getValueOfInstr(inst, true);
vec.push_back(val);
fpos = inst->get_address();
if (RoseBin_support::DEBUG_MODE())
cout << " found valueOfInst = " << RoseBin_support::ToString(val) <<endl;
}
} else {
// it is a register reference. I.e we need to follow the usage edge to find the
// definition of that node
SgGraphNode* usageNode = g_algo->getDefinitionForUsage(vizzGraph,defNode);
if (usageNode && usageNode!=node) {
if (RoseBin_support::DEBUG_MODE() && usageNode)
cout << " following up usage for " << usageNode->get_name() <<endl;
getValueForDefinition(vec, positions, fpos, usageNode, regRight);
} else {
// we look at the same node.
cout << " ERROR :: Either following usage to itself or usageNode = NULL. " << usageNode << endl;
}
}
}
}
示例2: additionalNodeInfo
void
AstDOTGeneration::writeIncidenceGraphToDOTFile(SgIncidenceDirectedGraph* graph, const std::string& filename)
{
// Output all nodes
rose_graph_integer_node_hash_map & nodes = graph->get_node_index_to_node_map ();
for( rose_graph_integer_node_hash_map::iterator it = nodes.begin(); it != nodes.end(); ++it )
{
SgGraphNode* node = it->second;
if( commentOutNodeInGraph(node) == false )
{
string nodeoption;
string nodelabel=string("\\n")+node->get_name();
nodelabel += additionalNodeInfo(node);
string additionalOptions = additionalNodeOptions(node);
string x;
string y;
x += additionalOptions;
nodeoption += additionalOptions;
// dotrep.addNode(node,dotrep.traceFormat(ia.tdTracePos)+nodelabel,nodeoption);
dotrep.addNode(node,nodelabel,nodeoption);
addAdditionalNodesAndEdges(node);
}
}
// Output edges
rose_graph_integer_edge_hash_multimap & outEdges = graph->get_node_index_to_edge_multimap_edgesOut ();
for( rose_graph_integer_edge_hash_multimap::const_iterator outEdgeIt = outEdges.begin(); outEdgeIt != outEdges.end(); ++outEdgeIt )
{
// if(debug) std::cerr << " add edge from node ... " << std::endl; // debug
SgDirectedGraphEdge* graphEdge = isSgDirectedGraphEdge(outEdgeIt->second);
ROSE_ASSERT(graphEdge!=NULL);
if ( commentOutNodeInGraph(graphEdge) == false )
{
string edgelabel=string("\\n")+graphEdge->get_name();
string edgeoption = additionalEdgeOptions(graphEdge->get_from(),graphEdge->get_to(),edgelabel);
dotrep.addEdge(graphEdge->get_from(),edgelabel,graphEdge->get_to(),edgeoption + "dir=forward");
addAdditionalNodesAndEdges(graphEdge);
}
}
dotrep.writeToFileAsGraph(filename);
}
示例3: getDefMultiMapFor
void
RoseBin_DataFlowAbstract::printDefTableToFile(
std::string fileName) {
std::ofstream myfile;
myfile.open(fileName.c_str());
vector<SgGraphNode*> sorted;
tabletype::iterator it2 = deftable.begin();
for (;it2!=deftable.end();++it2) {
SgGraphNode* node = it2->first;
sorted.push_back(node);
}
std::sort(sorted.begin(), sorted.end());
// tabletype::iterator it = deftable.begin();
//for (;it!=deftable.end();++it) {
vector<SgGraphNode*>::iterator it = sorted.begin();
for (;it!=sorted.end();++it) {
// SgGraphNode* node = it->first;
SgGraphNode* node = *it;
// const multitype& type = getDefinitionsFor(node);
const multitype& type = getDefMultiMapFor(node);
multitype::const_iterator itm = type.begin();
if (node) {
string line = ""+node->get_name()+" : \n";
for (;itm!=type.end();++itm) {
std::pair<X86RegisterClass, int> code = itm->first;
SgGraphNode* nodeDef = itm->second;
string registerName = unparseX86Register(RegisterDescriptor(code.first, code.second, 0, 64));
string def = registerName+" - "+nodeDef->get_name();
line+=" "+def+"\n";
}
myfile << line ;
}
}
myfile.close();
}
示例4: isSgGraphNode
void
RoseBin_FlowAnalysis::getRootNodes(vector <SgGraphNode*>& rootNodes) {
nrOfFunctions=0;
ROSE_ASSERT(vizzGraph);
//cerr << " get Root nodes " << endl;
rose_graph_integer_node_hash_map::const_iterator itn = vizzGraph->get_node_index_to_node_map().begin();
for (; itn!=vizzGraph->get_node_index_to_node_map().end();++itn) {
// string hex_address = itn->first;
SgGraphNode* node = isSgGraphNode(itn->second);
string hex_address = node->get_name();
//ROSE_ASSERT(hex_address==hex_addr_tmp);
SgNode* internal = node->get_SgNode();
SgAsmFunction* func = isSgAsmFunction(internal);
if (func) {
rootNodes.push_back(node);
//cerr << " ............................. rootNode : " << hex_address << " " << node->get_name() << endl;
nrOfFunctions++;
}
}
}
示例5: if
void
RoseBin_GMLGraph::printNodes( bool dfg, RoseBin_FlowAnalysis* flow,bool forward_analysis,
std::ofstream& myfile, string& recursiveFunctionName) {
//bool firstFunc = true;
// traverse nodes and visualize results of graph
funcMap.clear();
nodesMap.clear();
//cerr << " Preparing graph - Nr of Nodes : " << nodes.size() << " edges : " << edges.size() << endl;
//SgGraphNodeList* gnodes = get_nodes();
// rose_graph_hash_multimap& nodes = get_nodes()->get_nodes();
rose_graph_integer_node_hash_map nodes = get_node_index_to_node_map();
int counter=nodes.size();
int count=0;
rose_graph_integer_node_hash_map::iterator itn2 = nodes.begin();
for (; itn2!=nodes.end();++itn2) {
counter++;
count++;
pair<int, SgGraphNode*> nt = *itn2;
// string hex_address = itn2->first;
SgGraphNode* node = isSgGraphNode(itn2->second);
string hex_address =node->get_name();
SgNode* internal = node->get_SgNode();
SgAsmFunction* func = isSgAsmFunction(internal);
if (func) {
vector<SgNode*> list;
FindInstructionsVisitorx86 vis;
#ifdef _MSC_VER
//#pragma message ("WARNING: Removed reference to AstQueryNamespace::querySubTree()")
// ROSE_ASSERT(false);
// CH (4/7/2010): Workaround for MSVC
vector<SgAsmX86Instruction*> temp_list;
AstQueryNamespace::querySubTree(func, std::bind2nd( vis, &temp_list ));
list.resize(temp_list.size());
std::copy(temp_list.begin(), temp_list.end(), list.begin());
#else
#if defined(__APPLE__) && defined(__MACH__)
//Pei-Hung (7/28/2016): OSX El Capitan has issue with bind2nd.
vector<SgAsmX86Instruction*> temp_list;
AstQueryNamespace::querySubTree(func, std::bind2nd( vis, &temp_list ));
list.resize(temp_list.size());
std::copy(temp_list.begin(), temp_list.end(), list.begin());
#else
AstQueryNamespace::querySubTree(func, std::bind2nd( vis, &list ));
#endif
#endif
int validInstructions = func->nrOfValidInstructions(list);
funcMap[func]=counter;
nodesMap[func]=count;
string name = func->get_name();
string text = "node [\n id " + RoseBin_support::ToString(counter) + "\n id_ " +
RoseBin_support::ToString(counter) + "\n label \"" + name + "\"\n ";
text +=" nrinstr_ "+RoseBin_support::ToString(validInstructions)+" \n";
text+= " isGroup 1\n isGroup_ 1\n ]\n";
if (name=="frame_dummy") {
//cerr << text << endl;
vector<SgNode*> succs = func->get_traversalSuccessorContainer();
vector<SgNode*>::iterator j = succs.begin();
//cerr << " ------------- free_dummy"<<endl;
int ii=0;
for (;j!=succs.end();j++) {
//SgNode* n = *j;
//cerr << " Node contained at pos:"<<ii<<" - " << n->class_name() << endl;
ii++;
}
//cerr << " number of validInstructions: " << validInstructions << endl;
}
if (grouping)
myfile << text;
}
SgAsmInstruction* bin_inst = isSgAsmInstruction(internal);
if (bin_inst)
nodesMap[bin_inst]=count;
}
//cerr << " Writing graph to GML - Nr of Nodes : " << nodes.size() << endl;
int pos=0;
rose_graph_integer_node_hash_map::iterator itn = nodes.begin();
for (; itn!=nodes.end();++itn) {
pos++;
// string hex_address = itn->first;
SgGraphNode* node = isSgGraphNode(itn->second);
string hex_address = node->get_name();
SgNode* internal = node->get_SgNode();
SgAsmFunction* func = isSgAsmFunction(internal);
string text="";
// specifies that this node has no destination address
nodest_jmp = false;
// specifies that there is a node that has a call error (calling itself)
error =false;
// specifies a call to a unknown location
nodest_call = false;
// specifies where its an int instruction
//.........这里部分代码省略.........
示例6: printGraph
void RoseBin_ControlFlowAnalysis::printGraph(std::string fileName, std::set<std::string>& filter) {
#if 1
ASSERT_not_reachable("no longer supported");
#else
std::set<std::string>::const_iterator it = filter.begin();
for (;it!=filter.end();++it) {
std::cerr << "CFG -- contains filter: ." << *it << "." << endl;
}
// typedef rose_hash::unordered_map <std::string, SgGraphNode*> nodeType;
// typedef rose_hash::unordered_map <string, SgGraphNode*,hash_stringptr> nodeType;
rose_graph_integer_node_hash_map result;
//rose_graph_hash_multimap& nodes = vizzGraph->get_node_index_to_node_map();
rose_graph_integer_node_hash_map nodes = vizzGraph->get_node_index_to_node_map();
rose_graph_integer_node_hash_map::iterator itn2 = nodes.begin();
for (; itn2 != nodes.end();++itn2) {
// string hex_address = itn2->first;
SgGraphNode* node = itn2->second;
string hex_address = node->get_name();
//string hex_addr_tmp = node->get_name();
//ROSE_ASSERT(hex_address==hex_addr_tmp);
SgNode* internal = node->get_SgNode();
SgAsmFunction* func = isSgAsmFunction(internal);
if (func) {
std::cerr << "ControlFlowAnalysis:: found function: ." << hex_address << "." <<endl;
std::set<std::string>::const_iterator it = filter.find(hex_address);
if (it!=filter.end()) {
//std::cerr << " ******************* match ********************* " << std::endl;
set<SgGraphNode*> gns;
set<std::string> names;
getCFGNodesForFunction(gns,names,node,hex_address);
if (debug)
cerr << " nodes in function: " << gns.size() << " " << names.size() <<endl;
ROSE_ASSERT(gns.size()==names.size());
set<SgGraphNode*>::const_iterator it2 = gns.begin();
set<std::string>::const_iterator it3 = names.begin();
for (;it2!=gns.end();++it2, ++it3) {
std::string name = *it3;
SgGraphNode* n = *it2;
if (debug)
cerr << " adding to result ."<<name<<"."<<endl;
result.insert(make_pair(itn2->first,n));
}
}
}
}
rose_graph_integer_node_hash_map nodesResult = nodes;
rose_graph_integer_node_hash_map::iterator itn23 = nodes.begin();
for (; itn23!=nodes.end();++itn23) {
//string hex_address = isSgGraphNode(itn23->second)->get_name();
int pos = itn23->first;
// rose_graph_integer_node_hash_map::iterator it = result.find(hex_address);
rose_graph_integer_node_hash_map::iterator it = result.find(pos);
if (it==result.end()) {
// not found in result, i.e. delete
//nodesResult.erase(hex_address);
nodesResult.erase(pos);
}
}
// vizzGraph->nodes=nodesResult;
#if 0
// vizzGraph->nodes=result;
// create file
bool forward_analysis=true;
bool multiedge=false;
std::ofstream myfile;
myfile.open(fileName.c_str());
string name = "ROSE Graph";
vizzGraph->printProlog(myfile, name);
string functionName="";
vizzGraph->setGrouping(true);
vizzGraph->printNodes(true, this, forward_analysis, myfile,functionName);
nrNodes=vizzGraph->nodes.size();
vizzGraph->printEdges(this,myfile, multiedge);
nrEdges=vizzGraph->get_node_index_to_edge_multimap_edgesOut().size();
vizzGraph->printEpilog(myfile);
myfile.close();
#endif
#if 1
RoseBin_Graph* gr = new RoseBin_DotGraph();
gr->graph = new SgIncidenceDirectedGraph("test");//SgDirectedGraph("test","test");
gr->get_node_index_to_node_map()=nodesResult;
//typedef SB_DirectedGraph::edgeType edgeType;
rose_graph_integer_edge_hash_multimap edges = vizzGraph->get_node_index_to_edge_multimap_edgesOut();
rose_graph_integer_edge_hash_multimap resultEdges;
//.........这里部分代码省略.........