[b12f64]: pp / oparchive_options.cpp  Maximize  Restore  History

Download this file

131 lines (104 with data), 3.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
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**
* @file oparchive_options.cpp
* Options for oparchive tool
*
* @remark Copyright 2002, 2003, 2004 OProfile authors
* @remark Read the file COPYING
*
* @author William Cohen
* @author Philippe Elie
*/
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <fstream>
#include <string.h>
#include "op_config.h"
#include "profile_spec.h"
#include "arrange_profiles.h"
#include "oparchive_options.h"
#include "popt_options.h"
#include "string_filter.h"
#include "file_manip.h"
#include "cverb.h"
using namespace std;
profile_classes classes;
list<string> sample_files;
namespace options {
demangle_type demangle = dmt_normal;
bool exclude_dependent;
merge_option merge_by;
string outdirectory;
bool list_files;
}
namespace {
vector<string> mergespec;
popt::option options_array[] = {
popt::option(options::outdirectory, "output-directory", 'o',
"output to the given directory", "directory"),
popt::option(options::exclude_dependent, "exclude-dependent", 'x',
"exclude libs, kernel, and module samples for applications"),
popt::option(options::list_files, "list-files", 'l',
"just list the files necessary, don't produce the archive")
};
/**
* check incompatible or meaningless options
*
*/
void check_options()
{
using namespace options;
/* output directory is required */
if (!list_files) {
if (outdirectory.size() == 0) {
cerr << "Requires --output-directory option." << endl;
exit(EXIT_FAILURE);
}
string realpath = op_realpath(outdirectory);
if (realpath == "/") {
cerr << "Invalid --output-directory: /" << endl;
exit(EXIT_FAILURE);
}
}
}
} // anonymous namespace
void handle_options(options::spec const & spec)
{
using namespace options;
if (spec.first.size()) {
cerr << "differential profiles not allowed" << endl;
exit(EXIT_FAILURE);
}
// merging doesn't occur in oparchive but we must allow it to avoid
// triggering sanity checking in arrange_profiles()
merge_by.cpu = true;
merge_by.lib = true;
merge_by.tid = true;
merge_by.tgid = true;
merge_by.unitmask = true;
check_options();
profile_spec const pspec =
profile_spec::create(spec.common, image_path, root_path);
if (!was_session_dir_supplied())
cerr << "Using " << op_samples_dir << " for session-dir" << endl;
sample_files = pspec.generate_file_list(exclude_dependent, false);
cverb << vsfile << "Matched sample files: " << sample_files.size()
<< endl;
copy(sample_files.begin(), sample_files.end(),
ostream_iterator<string>(cverb << vsfile, "\n"));
classes = arrange_profiles(sample_files, merge_by,
pspec.extra_found_images);
cverb << vsfile << "profile_classes:\n" << classes << endl;
if (classes.v.empty()) {
cerr << "error: no sample files found: profile specification "
"too strict ?" << endl;
exit(EXIT_FAILURE);
}
if (strncmp(op_session_dir, "/var/lib/oprofile", strlen("/var/lib/oprofile")))
cerr << "NOTE: The sample data in this archive is located at " << op_session_dir << endl
<< "instead of the standard location of /var/lib/oprofile. Hence, when using opreport" << endl
<< "and other post-processing tools on this archive, you must pass the following option:" << endl
<< "\t--session-dir=" << op_session_dir << endl;
}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks