[0d0e60]: libpp / populate.cpp Maximize Restore History

Download this file

populate.cpp    93 lines (75 with data), 2.3 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
* @file populate.cpp
* Fill up a profile_container from inverted profiles
*
* @remark Copyright 2003 OProfile authors
* @remark Read the file COPYING
*
* @author John Levon
* @author Philippe Elie
*/
#include "profile.h"
#include "profile_container.h"
#include "arrange_profiles.h"
#include "op_bfd.h"
#include "op_header.h"
#include "populate.h"
#include "image_errors.h"
using namespace std;
namespace {
/// load merged files for one set of sample files
bool
populate_from_files(profile_t & profile,
list<profile_sample_files> const & files, u32 offset)
{
list<profile_sample_files>::const_iterator it = files.begin();
list<profile_sample_files>::const_iterator const end = files.end();
bool found = false;
// we can't handle cg files here obviously
for (; it != end; ++it) {
// A bit ugly but we must acept silently empty sample filename
// since we can create a profile_sample_files for cg file only
// (i.e no sample to the binary)
if (!it->sample_filename.empty()) {
profile.add_sample_file(it->sample_filename, offset);
found = true;
}
}
return found;
}
} // anon namespace
bool
populate_for_image(profile_container & samples, inverted_profile const & ip,
string_filter const & symbol_filter)
{
bool ok = ip.error == image_ok;
op_bfd abfd(ip.image, symbol_filter, ok);
if (!ok && ip.error == image_ok)
ip.error = image_format_failure;
if (ip.error == image_format_failure)
report_image_error(ip, false);
u32 offset = abfd.get_start_offset();
opd_header header;
bool found = false;
for (size_t i = 0; i < ip.groups.size(); ++i) {
list<image_set>::const_iterator it
= ip.groups[i].begin();
list<image_set>::const_iterator const end
= ip.groups[i].end();
// we can only share a profile_t amongst each
// image_set's files - this is because it->app_image
// changes, and the .add() would mis-attribute
// to the wrong app_image otherwise
for (; it != end; ++it) {
profile_t profile;
if (populate_from_files(profile, it->files, offset)) {
header = profile.get_header();
samples.add(profile, abfd, it->app_image, i);
found = true;
}
}
}
if (found == true && ip.error == image_ok)
check_mtime(abfd.get_filename(), header);
return abfd.has_debug_info();
}