diff options
author | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:35:00 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:35:00 -0400 |
commit | 42f43b7686038e4cbca16d8d2118b139544e6de3 (patch) | |
tree | 52c5473401c57282242d66b8dd75f4c07bf41d07 /trace.h | |
parent | c7b4370ff9c8ab5c96f15b1e712e6db6bdab6324 (diff) | |
download | ledger-42f43b7686038e4cbca16d8d2118b139544e6de3.tar.gz ledger-42f43b7686038e4cbca16d8d2118b139544e6de3.tar.bz2 ledger-42f43b7686038e4cbca16d8d2118b139544e6de3.zip |
Check in all changes made so far toward 3.0.
Diffstat (limited to 'trace.h')
-rw-r--r-- | trace.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/trace.h b/trace.h new file mode 100644 index 00000000..367910ad --- /dev/null +++ b/trace.h @@ -0,0 +1,51 @@ +#ifndef _TRACE_H +#define _TRACE_H + +#include "timing.h" + +#include <string> +#include <map> + +namespace ledger { + +extern bool trace_mode; + +void trace(const std::string& cat, const std::string& str); +void trace_push(const std::string& cat, const std::string& str, + timing_t& timer); +void trace_pop(const std::string& cat, const std::string& str, + timing_t& timer); + +#define TRACE(cat, msg) if (trace_mode) trace(#cat, msg) +#define TRACE_(cat, msg) if (trace_mode) trace(#cat, msg) + +#define TRACE_PUSH(cat, msg) \ + timing_t timer_ ## cat(#cat); \ + if (trace_mode) trace_push(#cat, msg, timer_ ## cat) + +#define TRACE_POP(cat, msg) \ + if (trace_mode) trace_pop(#cat, msg, timer_ ## cat) + +typedef std::multimap<void *, std::string> live_objects_map; +typedef std::pair<void *, std::string> live_objects_pair; +typedef std::map<std::string, int> object_count_map; +typedef std::pair<std::string, int> object_count_pair; + +extern live_objects_map live_objects; +extern object_count_map ctor_count; +extern object_count_map object_count; +extern object_count_map live_count; + +extern bool tracing_active; + +bool trace_ctor(void * ptr, const std::string& name); +bool trace_dtor(void * ptr, const std::string& name); + +void report_memory(std::ostream& out); + +#define TRACE_CTOR(cls) CONFIRM(ledger::trace_ctor(this, cls)) +#define TRACE_DTOR(cls) CONFIRM(ledger::trace_dtor(this, cls)) + +} // namespace ledger + +#endif // _TRACE_H |