165 std::ofstream nost(output_names.c_str());
166 std::ofstream tost(output_tree.c_str());
167 std::ofstream sost(output_totals.c_str());
175 std::pair<VertexSet::iterator,bool> irc,prev_irc;
176 std::pair<PathSet::iterator,bool> prc;
189 while (
r.nextSample(v)) {
194 VoidVec::reverse_iterator
c(v.rbegin()),
e(v.rend());
195 bool first_pass=
true;
202 void* addr =
static_cast<void*
>(
value);
204 if(dladdr(addr,&info) != 0) {
208 last_good_entry.
library_ = info.dli_fname;
209 last_good_entry.
id_ = 0;
210 void* function_address = info.dli_saddr;
215 last_good_entry.
addr_ =
216 function_address ? function_address :
value;
218 entry = &last_good_entry;
226 std::ostringstream oss;
227 oss <<
"lookup_failure_" << addr;
228 last_none_entry.
name_ = oss.str();
229 last_none_entry.
library_ =
"unknown";
233 entry = &last_none_entry;
240 irc.first->incTotal();
241 ptrack.
tree_.push_back(irc.first->id_);
243 if(!first_pass) ++prev_irc.first->edges_[irc.first->id_];
244 else first_pass=
false;
250 irc.first->incLeaf();
251 prc = pathset.insert(ptrack);
255 prc.first->incTotal();
260 int setsize = symset.size();
263 vsyms.reserve(setsize);
266 VertexSet::const_iterator isym(symset.begin()),esym(symset.end());
269 vsyms.push_back(isym);
281 PathSet::const_iterator pat_it_beg(pathset.begin()),
282 pat_it_end(pathset.end());
284 while(pat_it_beg!=pat_it_end) {
286 ULVec pathcopy(pat_it_beg->tree_);
288 std::sort(pathcopy.begin(), pathcopy.end());
289 ULVec::iterator iter = unique(pathcopy.begin(),pathcopy.end());
290 ULVec::iterator cop_beg(pathcopy.begin());
292 while(cop_beg!=iter) {
294 Viter::iterator sym_iter = upper_bound(vsyms.begin(),vsyms.end(),
296 if(sym_iter==vsyms.begin()) {
305 (*sym_iter)->incPath(pat_it_beg->total_);
313 VertexSet::iterator ver_iter(symset.begin()),ver_iter_end(symset.end());
314 float ftotal = (total != 0 ? (float)total : 1.0);
315 while(ver_iter != ver_iter_end) {
316 ver_iter->percent_leaf_ = (float)ver_iter->total_as_leaf_ / ftotal;
317 ver_iter->percent_path_ = (
float)ver_iter->in_path_ / ftotal;
326 Viter::reverse_iterator vvi(vsyms.rbegin()),vve(vsyms.rend());
328 nost << *(*vvi) <<
"\n";
335 int pathsize = pathset.size();
337 vpaths.reserve(pathsize);
339 PathSet::const_iterator ipath(pathset.begin()),epath(pathset.end());
340 while(ipath != epath) {
341 vpaths.push_back(ipath);
348 Piter::reverse_iterator ppi(vpaths.rbegin()),ppe(vpaths.rend());
350 tost << *(*ppi) <<
"\n";
355 sost <<
"total_samples " << total <<
"\n"
356 <<
"total_functions " << setsize <<
"\n"
357 <<
"total_paths " << pathsize <<
"\n"
358 <<
"total_edges " << edgesize << std::endl
359 <<
"total_failed_lookups " << total_failed << std::endl
360 <<
"total_missing_sym_entries " << total_missing << std::endl;
static bool idSort(const VertexSet::const_iterator &a, const VertexSet::const_iterator &b)
std::vector< VertexSet::const_iterator > Viter
static bool idComp(unsigned int id, const VertexSet::const_iterator &b)
static bool symSort(const VertexSet::const_iterator &a, const VertexSet::const_iterator &b)
std::pair< std::string, MonitorElement * > entry
std::string make_name(Dl_info const &info, void *where, std::string const &prefix)
std::vector< void * > VoidVec
std::vector< PathSet::const_iterator > Piter
std::vector< unsigned int > ULVec
void verifyFile(std::ostream &ost, const std::string &name)
std::set< VertexTracker > VertexSet
static bool pathSort(const PathSet::const_iterator &a, const PathSet::const_iterator &b)
std::set< PathTracker > PathSet