[0d0e60]: libpp / symbol_container.h Maximize Restore History

Download this file

symbol_container.h    92 lines (73 with data), 2.4 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
/**
* @file symbol_container.h
* Internal container for symbols
*
* @remark Copyright 2002, 2003 OProfile authors
* @remark Read the file COPYING
*
* @author Philippe Elie
* @author John Levon
*/
#ifndef SYMBOL_CONTAINER_H
#define SYMBOL_CONTAINER_H
#include <string>
#include <set>
#include "profile_container.h"
/**
* An arbitrary container of symbols. Supports lookup
* by name, by VMA, and by file location.
*
* Lookup by name or by VMA is O(n). Lookup by file location
* is O(log(n)).
*/
class symbol_container {
public:
/// container type
typedef std::set<symbol_entry, less_symbol> symbols_t;
typedef symbols_t::size_type size_type;
/// return the number of symbols stored
size_type size() const;
/**
* Insert a new symbol. If the symbol already exists in the container,
* then the sample counts are accumulated.
* Returns the newly created symbol or the existing one. This pointer
* remains valid during the whole life time of a symbol_container
* object and is warranted unique according to less_symbol comparator.
* Can only be done before any file-location based lookups, since the
* two lookup methods are not synchronised.
*/
symbol_entry const * insert(symbol_entry const &);
/// find the symbol at the given filename and line number, if any
symbol_entry const * find(debug_name_id filename,
size_t linenr) const;
/// find the symbol with the given image_name vma if any
symbol_entry const * find_by_vma(std::string const & image_name,
bfd_vma vma) const;
/// Search a symbol. Return NULL if not found.
symbol_entry const * find(symbol_entry const & symbol) const;
/// return start of symbols
symbols_t::iterator begin();
/// return end of symbols
symbols_t::iterator end();
private:
/// build the symbol by file-location cache
void build_by_loc() const;
/**
* The main container of symbols. Multiple symbols with the same
* name are allowed.
*/
symbols_t symbols;
/**
* Differently-named symbol at same file location are allowed e.g.
* template instantiation.
*/
typedef std::multiset<symbol_entry const *, less_by_file_loc>
symbols_by_loc_t;
// must be declared after the set to ensure a correct life-time.
/**
* Symbols sorted by location order. Lazily built on request,
* so mutable.
*/
mutable symbols_by_loc_t symbols_by_loc;
};
#endif /* SYMBOL_CONTAINER_H */