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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
#ifndef _TRACE_H
#define _TRACE_H
#include <string>
#include <map>
namespace ledger {
class timing_t;
extern bool trace_mode;
#if DEBUG_LEVEL >= 4
class string;
#else
typedef std::string string;
#endif
void trace(const string& cat, const string& str);
void trace_push(const string& cat, const string& str,
timing_t& timer);
void trace_pop(const string& cat, const string& str,
timing_t& timer);
#ifndef TRACE
#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)
#endif
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 char * name);
bool trace_dtor(void * ptr, const char * name);
void report_memory(std::ostream& out);
#ifndef TRACE_CTOR
#define TRACE_CTOR(cls) CONFIRM(ledger::trace_ctor(this, cls))
#define TRACE_DTOR(cls) CONFIRM(ledger::trace_dtor(this, cls))
#endif
#if DEBUG_LEVEL >= 4
class string : public std::string
{
public:
string();
string(const string& str);
string(const std::string& str);
string(const int len, char x);
string(const char * str);
string(const char * str, const char * end);
string(const string& str, int x);
string(const string& str, int x, int y);
string(const char * str, int x);
string(const char * str, int x, int y);
~string();
};
inline string operator+(const string& __lhs, const string& __rhs)
{
string __str(__lhs);
__str.append(__rhs);
return __str;
}
string operator+(const char* __lhs, const string& __rhs);
string operator+(char __lhs, const string& __rhs);
inline string operator+(const string& __lhs, const char* __rhs)
{
string __str(__lhs);
__str.append(__rhs);
return __str;
}
inline string operator+(const string& __lhs, char __rhs)
{
typedef string __string_type;
typedef string::size_type __size_type;
__string_type __str(__lhs);
__str.append(__size_type(1), __rhs);
return __str;
}
inline bool operator==(const string& __lhs, const string& __rhs)
{ return __lhs.compare(__rhs) == 0; }
inline bool operator==(const char* __lhs, const string& __rhs)
{ return __rhs.compare(__lhs) == 0; }
inline bool operator==(const string& __lhs, const char* __rhs)
{ return __lhs.compare(__rhs) == 0; }
inline bool operator!=(const string& __lhs, const string& __rhs)
{ return __rhs.compare(__lhs) != 0; }
inline bool operator!=(const char* __lhs, const string& __rhs)
{ return __rhs.compare(__lhs) != 0; }
inline bool operator!=(const string& __lhs, const char* __rhs)
{ return __lhs.compare(__rhs) != 0; }
#endif
} // namespace ledger
#endif // _TRACE_H
|