5
* @remark Copyright 2002, 2004 OProfile authors
6
* @remark Read the file COPYING
8
* @author Philippe Elie
16
#include "name_storage.h"
17
#include "growable_vector.h"
18
#include "sparse_array.h"
19
#include "format_flags.h"
30
/// for storing sample counts
31
typedef sparse_array<u32, count_type> count_array_t;
34
/// A simple container for a fileno:linenr location.
35
struct file_location {
36
file_location() : linenr(0) {}
37
/// empty if not valid.
38
debug_name_id filename;
39
/// 0 means invalid or code is generated internally by the compiler
42
bool operator<(file_location const & rhs) const {
43
// Note we sort on filename id not on string
44
return filename < rhs.filename ||
45
(filename == rhs.filename && linenr < rhs.linenr);
50
/// associate vma address with a file location and a samples count
52
sample_entry() : vma(0) {}
53
/// From where file location comes the samples
54
file_location file_loc;
55
/// From where virtual memory address comes the samples
62
/// associate a symbol with a file location, samples count and vma address
65
symbol_entry() : size(0) {}
66
virtual ~symbol_entry() {}
68
/// which image this symbol belongs to
69
image_name_id image_name;
70
/// owning application name: identical to image name if profiling
71
/// session did not separate samples for shared libs or if image_name
72
/// is not a shared lib
73
image_name_id app_name;
74
// index into the op_bfd symbol table
76
/// file location, vma and cumulated samples count for this symbol
80
/// symbol size as calculated by op_bfd, start of symbol is sample.vma
84
* @param fl input hint
86
* combine fl with the calculated hint. It's theoretically possible
87
* that we get a symbol where its samples pass the border line, but
88
* the start is below it, but the the hint is only used for formatting
90
column_flags output_hint(column_flags fl) const;
92
image_name_id embedding_filename;
95
* The vma_adj is set according to the corresponding op_bfd::vma_adj.
96
* See the documentation for vma_adj in op_bfd.h for why we need this.
97
* This piece of information is needed in the bowels of opannotate
98
* with the --assembly option. At that point, there is no means of
99
* obtaining the op_bfd for the given image being processed, but we
100
* do have access to symbol_entry's. Yes, it's way overkill to add
101
* this to every symbol_entry, but there isn't a better option.
107
/// a collection of sorted symbols
108
typedef std::vector<symbol_entry const *> symbol_collection;
112
* The public data for call-graph symbols. Each caller/callee has
113
* the sample counts replaced with the relevant arc counts, whilst
114
* the cg_symbol retains its self count.
116
class cg_symbol : public symbol_entry {
118
cg_symbol(symbol_entry const & sym) : symbol_entry(sym) {}
120
typedef std::vector<symbol_entry> children;
122
/// all callers of this symbol
124
/// total count of callers
125
count_array_t total_caller_count;
127
/// all symbols called by this symbol
129
/// total count of callees
130
count_array_t total_callee_count;
133
/// a collection of sorted callgraph symbol objects
134
typedef std::list<cg_symbol> cg_collection_objs;
136
/// for storing diff %ages
137
typedef growable_vector<double> diff_array_t;
141
* Data for a diffed symbol.
143
struct diff_symbol : public symbol_entry {
144
diff_symbol(symbol_entry const & sym) : symbol_entry(sym) {}
146
/// diff %age values for each profile class
151
/// a collection of diffed symbols
152
typedef std::vector<diff_symbol> diff_collection;
154
bool has_sample_counts(count_array_t const & counts, size_t lo, size_t hi);
155
std::string const & get_image_name(image_name_id id,
156
image_name_storage::image_name_type type,
157
extra_images const & extra);
160
#endif /* !SYMBOL_H */