18 #ifndef LIBCWD_CLASS_FUNCTION_H 19 #define LIBCWD_CLASS_FUNCTION_H 41 struct FunctionChunkKey {
49 class FunctionInstance;
50 typedef std::pair<FunctionChunkKey const, FunctionInstance*> FunctionChunk;
71 operator<(FunctionChunkKey
const& chunk1, FunctionChunkKey
const& chunk2)
74 return chunk1.M_end <= chunk2.M_start;
80 struct FunctionRootInstanceKey {
81 char const* M_mangled_name;
89 operator<(FunctionRootInstanceKey key1, FunctionRootInstanceKey key2)
91 return std::strcmp(key1.M_mangled_name, key2.M_mangled_name);
103 class FunctionRootInstanceInfo;
104 typedef std::pair<FunctionRootInstanceKey const, FunctionRootInstanceInfo> FunctionRootInstance;
123 class FunctionInstance {
126 void const* M_highpc;
127 FunctionRootInstance* M_root;
128 FunctionInstance* M_inlined_by;
131 FunctionInstance(
void const* lowpc,
void const* highpc, FunctionRootInstance* root, FunctionInstance* inlined_by) :
132 M_lowpc(lowpc), M_highpc(highpc), M_root(root), M_inlined_by(inlined_by) { }
134 void const* lowpc()
const {
return M_lowpc; }
135 void const* highpc()
const {
return M_highpc; }
136 inline FunctionRootInstance
const* root()
const;
137 inline FunctionInstance
const* inlined_by()
const;
148 typedef std::map<FunctionChunkKey, FunctionInstance*, std::less<FunctionChunkKey>,
149 _private_::internal_allocator::rebind<FunctionChunk>::other> FunctionChunkMap;
151 typedef std::map<FunctionChunkKey, FunctionInstance*, std::less<FunctionChunkKey> > FunctionChunkMap;
153 extern FunctionChunkMap functionChunkMap;
157 class FunctionRootInstanceInfo {
159 FunctionInstance M_instance;
160 std::string M_demangled_name;
161 std::vector<FunctionInstance> M_inlined_instances;
164 FunctionRootInstanceInfo(
void const* lowpc,
void const* highpc, std::string
const& demangled_name);
165 void const* lowpc()
const {
return M_instance.lowpc(); }
166 void const* highpc()
const {
return M_instance.highpc(); }
167 std::string
const& demangled_name()
const {
return M_demangled_name; }
168 std::vector<FunctionInstance>
const& inlined_instances()
const {
return M_inlined_instances; }
169 std::vector<FunctionInstance>& inlined_instances() {
return M_inlined_instances; }
176 typedef std::map<FunctionRootInstanceKey, FunctionRootInstanceInfo, std::less<FunctionRootInstanceKey>,
177 _private_::internal_allocator::rebind<FunctionRootInstance>::other> FunctionRootsMap;
179 typedef std::map<FunctionRootInstanceKey, FunctionRootInstanceInfo, std::less<FunctionRootInstanceKey> > FunctionRootsMap;
182 FunctionRootInstance
const*
183 FunctionInstance::root()
const 188 FunctionInstance
const*
189 FunctionInstance::inlined_by()
const 203 int volatile M_initialized;
204 unsigned int M_flags;
206 _private_::FunctionRootInstance* M_root;
210 char const* label()
const {
return M_label; }
211 bool is_initialized()
const {
return M_initialized; }
215 void M_init(Function&
function);
216 void M_init(
char const* expr,
unsigned int flags);
219 static unsigned int const nofail = 1;
220 static unsigned int const c_linkage = 2;
221 static unsigned int const cpp_linkage = 4;
222 static unsigned int const mangled = 8;
223 static unsigned int const regexp = 16;
224 static unsigned int const exactmatch = 32;
226 Function() : M_initialized(false), M_flags(0) { }
227 Function(
unsigned int flags) : M_initialized(false), M_flags(flags) { }
229 void init() {
if (!M_initialized) M_init(); }
230 void init(Function&
function) {
if (!
function.is_initialized()) M_init(
function); }
231 void init(
char const* expr,
unsigned int flags = mangled|cpp_linkage) {
if (!M_initialized) M_init(expr, flags); }
233 void label(
char const* lbl) { M_label = lbl; }
234 void rmlabel() { M_label = NULL; }
239 #endif // LIBCWD_CLASS_FUNCTION_H namespace for libcwd.
Definition: debug.cc:87