本文整理汇总了C++中Functions::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Functions::size方法的具体用法?C++ Functions::size怎么用?C++ Functions::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Functions
的用法示例。
在下文中一共展示了Functions::size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: analyze
// Detect functions that are semantically similar by running multiple iterations of partition_functions().
void analyze() {
RTS_Message *m = thread->tracing(TRACE_MISC);
Functions functions = find_functions(m, thread->get_process());
PointerDetectors pointers = detect_pointers(m, thread, functions);
PartitionForest partition;
while (partition.nlevels()<MAX_ITERATIONS) {
InputValues inputs = choose_inputs(3, 3);
size_t level = partition.new_level(inputs);
m->mesg("####################################################################################################");
m->mesg("%s: fuzz testing %zu function%s at level %zu", name, functions.size(), 1==functions.size()?"":"s", level);
m->mesg("%s: using these input values:\n%s", name, inputs.toString().c_str());
if (0==level) {
partition_functions(m, partition, functions, pointers, inputs, NULL);
} else {
const PartitionForest::Vertices &parent_vertices = partition.vertices_at_level(level-1);
for (PartitionForest::Vertices::const_iterator pvi=parent_vertices.begin(); pvi!=parent_vertices.end(); ++pvi) {
PartitionForest::Vertex *parent_vertex = *pvi;
if (parent_vertex->functions.size()>MAX_SIMSET_SIZE)
partition_functions(m, partition, parent_vertex->functions, pointers, inputs, parent_vertex);
}
}
// If the new level doesn't contain any vertices then we must not have needed to repartition anything and we're all
// done.
if (partition.vertices_at_level(level).empty())
break;
}
m->mesg("==========================================================================================");
m->mesg("%s: The entire partition forest follows...", name);
m->mesg("%s", StringUtility::prefixLines(partition.toString(), std::string(name)+": ").c_str());
m->mesg("==========================================================================================");
m->mesg("%s: Final function similarity sets are:", name);
PartitionForest::Vertices leaves = partition.get_leaves();
size_t setno=0;
for (PartitionForest::Vertices::iterator vi=leaves.begin(); vi!=leaves.end(); ++vi, ++setno) {
PartitionForest::Vertex *leaf = *vi;
const Functions &functions = leaf->get_functions();
m->mesg("%s: set #%zu at level %zu has %zu function%s:",
name, setno, leaf->get_level(), functions.size(), 1==functions.size()?"":"s");
for (Functions::const_iterator fi=functions.begin(); fi!=functions.end(); ++fi)
m->mesg("%s: 0x%08"PRIx64" <%s>", name, (*fi)->get_entry_va(), (*fi)->get_name().c_str());
}
m->mesg("%s: dumping final similarity sets to clones.sql", name);
partition.dump("clones.sql", "NO_USER", "NO_PASSWD");
}
示例2: rand
pair<FunctionId,FunctionPtr> FunctionSet::getRandomFunction(int argumentsNumber) const
{
Functions argFunctions;
Functions::const_iterator it = functions_.begin();
//Rewrite funciton with the same number of arguments as argumentsNumber
for(auto it = functions_.begin(); it != functions_.end();)
{
if(it->second.first == argumentsNumber)
argFunctions.insert(make_pair(it->first,it->second));
++it;
}
if (argFunctions.size() < 1)
{
string exception = "Nie ma zadnej funkcji o takiej liczbie argumentow";
throw exception;
}
it = argFunctions.begin();
std::advance(it, rand() % argFunctions.size() );
return this->conversion(it);
}