populate_for_spu.cpp
Go to the documentation of this file.00001
00013 #include "profile.h"
00014 #include "profile_container.h"
00015 #include "arrange_profiles.h"
00016 #include "op_bfd.h"
00017 #include "op_header.h"
00018 #include "populate.h"
00019 #include "populate_for_spu.h"
00020
00021 #include "image_errors.h"
00022
00023 #include <iostream>
00024
00025 using namespace std;
00026
00027 namespace {
00028
00029 static int spu_profile = unknown_profile;
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 void
00047 populate_spu_profile_from_files(list<profile_sample_files> const & files,
00048 string const app_image,
00049 profile_container & samples,
00050 inverted_profile const & ip,
00051 string_filter const & symbol_filter,
00052 size_t ip_grp_num, bool * has_debug_info)
00053 {
00054 string archive_path = samples.extra_found_images.get_archive_path();
00055 bool ok = ip.error == image_ok;
00056 op_bfd * abfd = NULL;
00057 string fname_to_check;
00058 list<profile_sample_files>::const_iterator it = files.begin();
00059 list<profile_sample_files>::const_iterator const end = files.end();
00060 for (; it != end; ++it) {
00061 profile_t profile;
00062 if (it->sample_filename.empty())
00063 continue;
00064
00065 profile.add_sample_file(it->sample_filename);
00066 opd_header header = profile.get_header();
00067 if (header.embedded_offset) {
00068 abfd = new op_bfd(header.embedded_offset,
00069 ip.image,
00070 symbol_filter,
00071 samples.extra_found_images,
00072 ok);
00073 fname_to_check = ip.image;
00074 } else {
00075 abfd = new op_bfd(ip.image,
00076 symbol_filter,
00077 samples.extra_found_images,
00078 ok);
00079 fname_to_check = abfd->get_filename();
00080 }
00081 profile.set_offset(*abfd);
00082 if (!ok && ip.error == image_ok)
00083 ip.error = image_format_failure;
00084
00085 if (ip.error == image_format_failure)
00086 report_image_error(ip, false,
00087 samples.extra_found_images);
00088
00089 samples.add(profile, *abfd, app_image, ip_grp_num);
00090 if (ip.error == image_ok) {
00091 image_error error;
00092 string filename =
00093 samples.extra_found_images.find_image_path(
00094 fname_to_check, error, true);
00095 check_mtime(filename, profile.get_header());
00096 }
00097
00098 if (has_debug_info && !*has_debug_info)
00099 *has_debug_info = abfd->has_debug_info();
00100 delete abfd;
00101 }
00102 }
00103 }
00104
00105 void
00106 populate_for_spu_image(profile_container & samples,
00107 inverted_profile const & ip,
00108 string_filter const & symbol_filter,
00109 bool * has_debug_info)
00110 {
00111
00112 for (size_t i = 0; i < ip.groups.size(); ++i) {
00113 list < image_set >::const_iterator it=
00114 ip.groups[i].begin();
00115 list < image_set >::const_iterator const end
00116 = ip.groups[i].end();
00117
00118 for (; it != end; ++it)
00119 populate_spu_profile_from_files(it->files,
00120 it->app_image, samples, ip,
00121 symbol_filter, i, has_debug_info);
00122 }
00123 }
00124
00125 bool is_spu_profile(inverted_profile const & ip)
00126 {
00127 bool retval = false;
00128 string sfname = "";
00129 if (spu_profile != unknown_profile)
00130 return spu_profile;
00131
00132 if (!ip.groups.size())
00133 return false;
00134
00135 for (size_t i = 0; i < ip.groups.size(); ++i) {
00136 list<image_set>::const_iterator grp_it
00137 = ip.groups[i].begin();
00138 list<image_set>::const_iterator const grp_end
00139 = ip.groups[i].end();
00140
00141 for (; grp_it != grp_end; ++grp_it) {
00142 list<profile_sample_files>::const_iterator sfiles_it =
00143 grp_it->files.begin();
00144 list<profile_sample_files>::const_iterator sfiles_end =
00145 grp_it->files.end();
00146 for (; sfiles_it != sfiles_end; ++sfiles_it) {
00147 if (!sfiles_it->sample_filename.empty()) {
00148 sfname = sfiles_it->sample_filename;
00149 goto do_check;
00150 }
00151 }
00152 }
00153 }
00154 goto out;
00155
00156 do_check:
00157 spu_profile = profile_t::is_spu_sample_file(sfname);
00158
00159 if (spu_profile == cell_spu_profile)
00160 retval = true;
00161
00162 out:
00163 return retval;
00164 }
00165
00166