Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[0d0e60]: pp / opannotate_options.cpp Maximize Restore History

Download this file

opannotate_options.cpp    133 lines (107 with data), 4.0 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
131
132
/**
* @file opannotate_options.cpp
* Options for opannotate tool
*
* @remark Copyright 2003 OProfile authors
* @remark Read the file COPYING
*
* @author John Levon
* @author Philippe Elie
*/
#include <vector>
#include <list>
#include <iterator>
#include <iostream>
#include "profile_spec.h"
#include "arrange_profiles.h"
#include "op_exception.h"
#include "opannotate_options.h"
#include "popt_options.h"
#include "cverb.h"
using namespace std;
profile_classes classes;
namespace options {
demangle_type demangle = dmt_normal;
string output_dir;
vector<string> search_dirs;
vector<string> base_dirs;
merge_option merge_by;
path_filter file_filter;
string_filter symbol_filter;
bool source;
bool assembly;
vector<string> objdump_params;
bool exclude_dependent;
}
namespace {
string include_symbols;
string exclude_symbols;
string include_file;
string exclude_file;
string demangle_option = "normal";
vector<string> mergespec;
popt::option options_array[] = {
popt::option(demangle_option, "demangle", '\0',
"demangle GNU C++ symbol names (default normal)",
"none|normal|smart"),
popt::option(options::output_dir, "output-dir", 'o',
"output directory", "directory name"),
popt::option(options::search_dirs, "search-dirs", 'd',
"directories to look for source files", "comma-separated paths"),
popt::option(options::base_dirs, "base-dirs", 'b',
"source file prefixes to strip", "comma-separated paths"),
popt::option(include_file, "include-file", '\0',
"include these comma separated filename", "filenames"),
popt::option(exclude_file, "exclude-file", '\0',
"exclude these comma separated filename", "filenames"),
popt::option(include_symbols, "include-symbols", 'i',
"include these comma separated symbols", "symbols"),
popt::option(exclude_symbols, "exclude-symbols", 'e',
"exclude these comma separated symbols", "symbols"),
popt::option(options::objdump_params, "objdump-params", '\0',
"additionnal params to pass to objdump", "parameters"),
popt::option(options::exclude_dependent, "exclude-dependent", 'x',
"exclude libs, kernel, and module samples for applications"),
popt::option(mergespec, "merge", 'm',
"comma separated list", "cpu,tid,tgid,unitmask,all"),
popt::option(options::source, "source", 's', "output source"),
popt::option(options::assembly, "assembly", 'a', "output assembly"),
};
} // anonymous namespace
void handle_options(vector<string> const & non_options)
{
using namespace options;
if (!assembly && !source) {
cerr << "you must specify at least --source or --assembly\n";
exit(EXIT_FAILURE);
}
if (!objdump_params.empty() && !assembly) {
cerr << "--objdump-params is meaningless without --assembly\n";
exit(EXIT_FAILURE);
}
if (search_dirs.empty() && !base_dirs.empty()) {
cerr << "--base-dirs is useless unless you specify an "
"alternative source location with --search-dirs"
<< endl;
exit(EXIT_FAILURE);
}
options::symbol_filter = string_filter(include_symbols, exclude_symbols);
options::file_filter = path_filter(include_file, exclude_file);
profile_spec const spec =
profile_spec::create(non_options, options::extra_found_images);
list<string> sample_files = spec.generate_file_list(exclude_dependent, true);
cverb << "Matched sample files: " << sample_files.size() << endl;
copy(sample_files.begin(), sample_files.end(),
ostream_iterator<string>(cverb, "\n"));
demangle = handle_demangle_option(demangle_option);
// we always merge but this have no effect on output since at source
// or assembly point of view the result will be merged anyway
merge_by = handle_merge_option(mergespec, false, exclude_dependent);
classes = arrange_profiles(sample_files, merge_by);
cverb << "profile_classes:\n" << classes << endl;
if (classes.v.empty()) {
cerr << "error: no sample files found: profile specification "
"too strict ?" << endl;
exit(EXIT_FAILURE);
}
}