3 * Fill up a profile_container from inverted profiles
5 * @remark Copyright 2003 OProfile authors
6 * @remark Read the file COPYING
9 * @author Philippe Elie
11 * Modified by Maynard Johnson <maynardj@us.ibm.com>
12 * (C) Copyright IBM Corporation 2007
16 #include "profile_container.h"
17 #include "arrange_profiles.h"
19 #include "op_header.h"
22 #include "image_errors.h"
32 /// load merged files for one set of sample files
34 populate_from_files(profile_t & profile, op_bfd const & abfd,
35 list<profile_sample_files> const & files)
37 list<profile_sample_files>::const_iterator it = files.begin();
38 list<profile_sample_files>::const_iterator const end = files.end();
41 // we can't handle cg files here obviously
42 for (; it != end; ++it) {
43 // A bit ugly but we must accept silently empty sample filename
44 // since we can create a profile_sample_files for cg file only
45 // (i.e no sample to the binary)
46 if (!it->sample_filename.empty()) {
47 profile.add_sample_file(it->sample_filename);
48 profile.set_offset(abfd);
60 populate_for_image(profile_container & samples, inverted_profile const & ip,
61 string_filter const & symbol_filter, bool * has_debug_info)
65 bool ok = ip.error == image_ok;
67 if (strncmp(ip.image.c_str(), KALL_SYM_FILE, strlen(ip.image.c_str())) == 0)
68 abfd = new op_bfd(ip.image, samples.extra_found_images);
71 abfd = new op_bfd(ip.image, symbol_filter,
72 samples.extra_found_images, ok);
74 if (!ok && ip.error == image_ok)
75 ip.error = image_format_failure;
77 if (ip.error == image_format_failure)
78 report_image_error(ip, false, samples.extra_found_images);
83 for (size_t i = 0; i < ip.groups.size(); ++i) {
84 list<image_set>::const_iterator it
85 = ip.groups[i].begin();
86 list<image_set>::const_iterator const end
89 // we can only share a profile_t amongst each
90 // image_set's files - this is because it->app_image
91 // changes, and the .add() would mis-attribute
92 // to the wrong app_image otherwise
93 for (; it != end; ++it) {
95 if (populate_from_files(profile, *abfd, it->files)) {
96 header = profile.get_header();
97 samples.add(profile, *abfd, it->app_image, i);
103 if (found == true && ip.error == image_ok) {
106 samples.extra_found_images.find_image_path(
107 ip.image, error, true);
108 check_mtime(filename, header);
112 *has_debug_info = abfd->has_debug_info();