#include <profile.h>
Data Structures | |
class | const_iterator |
Public Types | |
typedef std::pair < const_iterator, const_iterator > | iterator_pair |
Public Member Functions | |
profile_t () | |
bool | empty () const |
return true if no sample file has been loaded | |
opd_header const & | get_header () const |
return the header of the last opened samples file | |
void | add_sample_file (std::string const &filename) |
void | set_offset (op_bfd const &abfd) |
Set an appropriate start offset, see comments below. | |
iterator_pair | samples_range (odb_key_t start, odb_key_t end) const |
iterator_pair | samples_range () const |
return a pair of iterator for all samples | |
Static Public Member Functions | |
static count_type | sample_count (std::string const &filename) |
static enum profile_type | is_spu_sample_file (std::string const &filename) |
Private Types | |
typedef std::map< odb_key_t, count_type > | ordered_samples_t |
storage type for samples sorted by eip | |
Static Private Member Functions | |
static void | open_sample_file (std::string const &filename, odb_t &) |
Private Attributes | |
scoped_ptr< opd_header > | file_header |
copy of the samples file header | |
ordered_samples_t | ordered_samples |
u64 | start_offset |
Class containing a single sample file contents. i.e. set of count values for VMA offsets for a particular binary.
Definition at line 33 of file profile.h.
typedef std::pair<const_iterator, const_iterator> profile_t::iterator_pair |
typedef std::map<odb_key_t, count_type> profile_t::ordered_samples_t [private] |
profile_t::profile_t | ( | ) |
profile_t - construct an empty profile_t object
Definition at line 34 of file profile.cpp.
void profile_t::add_sample_file | ( | std::string const & | filename | ) |
cumulate sample file to our container of samples
filename | sample file name |
store samples for one sample file, sample file header is sanitized.
all error are fatal
bool profile_t::empty | ( | ) | const [inline] |
return true if no sample file has been loaded
Definition at line 41 of file profile.h.
References file_header, and scoped_ptr< T >::get().
opd_header const& profile_t::get_header | ( | ) | const [inline] |
return the header of the last opened samples file
Definition at line 44 of file profile.h.
References file_header.
Referenced by populate_for_image(), and set_offset().
static enum profile_type profile_t::is_spu_sample_file | ( | std::string const & | filename | ) | [static] |
Indicate if given sample file is from a Cell Broadband Engine SPU profile
filename | sample filename |
Convenience interface put here so all access to samples files go through profile_t static or non static member.
Referenced by is_spu_profile().
static void profile_t::open_sample_file | ( | std::string const & | filename, | |
odb_t & | ||||
) | [static, private] |
helper for sample_count() and add_sample_file(). All error launch an exception.
static count_type profile_t::sample_count | ( | std::string const & | filename | ) | [static] |
count samples count w/o recording them
filename | sample filename |
convenience interface for raw access to sample count w/o recording them. It's placed here so all access to samples files go through profile_t static or non static member.
profile_t::iterator_pair profile_t::samples_range | ( | ) | const |
return a pair of iterator for all samples
Definition at line 180 of file profile.cpp.
References ordered_samples, and start_offset.
profile_t::iterator_pair profile_t::samples_range | ( | odb_key_t | start, | |
odb_key_t | end | |||
) | const |
start | start offset | |
end | end offset |
return an iterator pair to [start, end) range
Definition at line 147 of file profile.cpp.
References ordered_samples, and start_offset.
void profile_t::set_offset | ( | op_bfd const & | abfd | ) |
Set an appropriate start offset, see comments below.
Definition at line 128 of file profile.cpp.
References opd_header::anon_start, cverb, get_header(), op_bfd::get_start_offset(), opd_header::is_kernel, start_offset, op_bfd::valid(), and vdebug.
scoped_ptr<opd_header> profile_t::file_header [private] |
copy of the samples file header
Definition at line 103 of file profile.h.
Referenced by empty(), and get_header().
ordered_samples_t profile_t::ordered_samples [private] |
Samples are stored in hash table, iterating over hash table don't provide any ordering, the above count() interface rely on samples ordered by eip. This map is only a temporary storage where samples are ordered by eip.
Definition at line 114 of file profile.h.
Referenced by samples_range().
u64 profile_t::start_offset [private] |
For certain profiles, such as kernel/modules, and anon regions with a matching binary, this value is non-zero, and represents the file offset of the relevant section.
For kernel profiles, this is done because we use the information provided in /proc/ksyms, which only gives the mapped position of .text, and the symbol _text from vmlinux. This value is used to fix up the sample offsets for kernel code as a result of this difference
In user-space samples, the sample offset is from the start of the mapped file, as seen in /proc/pid/maps. This is fine for mappings of permanent files, but with anon mappings, we need to adjust the key values to be a file offset against the *binary* (if there is one). This can obviously be different. So we pass our anon mapping start VMA to op_bfd, which looks for a section with that VMA, then returns the section's filepos. So all is good.
Finally, note that for cg we can't use this inside the profile_t, as we're storing two offsets in the key value. So we do it later in that case.
Phew.
Definition at line 141 of file profile.h.
Referenced by samples_range(), and set_offset().