image_errors.cpp

Go to the documentation of this file.
00001 
00011 #include "image_errors.h"
00012 
00013 #include "arrange_profiles.h"
00014 #include "string_manip.h"
00015 #include "locate_images.h"
00016 
00017 #include <iostream>
00018 #include <set>
00019 
00020 using namespace std;
00021 
00022 namespace {
00023 
00024 set<string> reported_images_error;
00025 
00026 }
00027 
00028 void report_image_error(string const & image, image_error error, bool fatal,
00029             extra_images const & extra)
00030 {
00031     if (error == image_ok)
00032         return;
00033 
00034     string image_name = extra.get_archive_path() + image;
00035 
00036     if (reported_images_error.find(image_name) ==
00037         reported_images_error.end()) {
00038         reported_images_error.insert(image_name);
00039 
00040         // FIXME: hacky
00041         if (error == image_not_found && is_prefix(image, "anon "))
00042             return;
00043 
00044         cerr << (fatal ? "error: " : "warning: ");
00045         cerr << image_name << ' ';
00046 
00047         switch (error) {
00048             case image_not_found:
00049                 cerr << "could not be found.\n";
00050                 break;
00051 
00052             case image_unreadable:
00053                 cerr << "could not be read.\n";
00054                 break;
00055 
00056             case image_multiple_match:
00057                 cerr << "matches more than one file: "
00058                     "detailed profile will not be provided.\n";
00059                 break;
00060 
00061             case image_format_failure:
00062                 cerr << "is not in a usable binary format.\n";
00063                 break;
00064 
00065             case image_ok:
00066                 break;
00067         }
00068     }
00069 }
00070 
00071 
00072 void report_image_error(inverted_profile const & profile, bool fatal,
00073             extra_images const & extra)
00074 {
00075     report_image_error(profile.image, profile.error, fatal, extra);
00076 }
00077 
00078 
00079 void report_image_errors(list<inverted_profile> const & plist,
00080              extra_images const & extra)
00081 {
00082     list<inverted_profile>::const_iterator it = plist.begin();
00083     list<inverted_profile>::const_iterator const end = plist.end();
00084 
00085     for (; it != end; ++it)
00086         report_image_error(*it, false, extra);
00087 }

Generated on 8 Nov 2012 for Oprofile by  doxygen 1.6.1