34 // Allocation to this memory address was already added. |
34 // Allocation to this memory address was already added. |
35 LOG_STRING( "CATAllocs: Allocating same address again, address: " << sAddress ); |
35 LOG_STRING( "CATAllocs: Allocating same address again, address: " << sAddress ); |
36 } |
36 } |
37 } |
37 } |
38 |
38 |
39 void CATAllocs::AllocH( const string& sAllocHString, const string& aTimeString ) |
39 void CATAllocs::AllocH( const string& sAllocHString ) |
40 { |
40 { |
41 LOG_LOW_FUNC_ENTRY("CATAllocs::AllocH"); |
41 LOG_LOW_FUNC_ENTRY("CATAllocs::AllocH"); |
42 string sAllocH( sAllocHString ); |
42 string sAllocH( sAllocHString ); |
43 // Parse alloc & create new allocation. |
43 // Parse alloc & create new allocation. |
44 CATAlloc alloc; |
44 CATAlloc alloc; |
45 alloc.m_sTime = aTimeString; |
|
46 string sAddress = GetStringUntilNextSpace( sAllocH, true ); |
45 string sAddress = GetStringUntilNextSpace( sAllocH, true ); |
47 alloc.m_sSize = GetStringUntilNextSpace( sAllocH, true ); |
46 alloc.m_sTime = GetStringUntilNextSpace( sAllocH, true ); |
48 alloc.m_iThreadId = GetStringUntilNextSpace ( sAllocH, true ); |
|
49 alloc.m_iCSCount = _httoi( string( GetStringUntilNextSpace( sAllocH, true ) ).c_str() ); |
|
50 // Insert call stack fragment as "first" 1 because we are header. |
|
51 if ( alloc.m_iCSCount > 0 ) |
|
52 alloc.m_vCallStack.insert( pair<unsigned long,string>( 0, sAllocH ) ); |
|
53 // Add allocation |
|
54 pair< map<string,CATAlloc>::iterator, bool> ret; |
|
55 ret = m_vAllocs.insert( pair<string, CATAlloc>( sAddress, alloc ) ); |
|
56 if( ret.second == false ) |
|
57 { |
|
58 // Allocation to this memory address was already added. |
|
59 LOG_STRING( "CATAllocs: Allocating same address again, address: " << sAddress ); |
|
60 } |
|
61 } |
|
62 |
|
63 void CATAllocs::AllocF( const string& sAllocFString, const string& aTimeString ) |
|
64 { |
|
65 LOG_LOW_FUNC_ENTRY("CATAllocs::AllocF"); |
|
66 string sAllocF( sAllocFString ); |
|
67 string sAddress = GetStringUntilNextSpace( sAllocF, true ); |
|
68 string sTime = aTimeString; |
|
69 unsigned long iNumber = _httoi( string( GetStringUntilNextSpace( sAllocF, true ) ).c_str() ); |
|
70 string sCallSstack = sAllocF; |
|
71 // Find correct allocation into which add call stack fragment. |
|
72 map<string, CATAlloc>::iterator it; |
|
73 it = m_vAllocs.find( sAddress ); |
|
74 // TODO: If cannot find, create new in cache. |
|
75 if ( it == m_vAllocs.end() ) |
|
76 { |
|
77 LOG_STRING( "CATAllocs: Allocate fragment without header: " << sAddress ); |
|
78 return; |
|
79 } |
|
80 pair< map<unsigned long,string>::iterator, bool> ret; |
|
81 // Add call stack to it. |
|
82 ret = it->second.m_vCallStack.insert( pair<unsigned long,string>( iNumber, sCallSstack ) ); |
|
83 if( ret.second == false ) |
|
84 { |
|
85 LOG_STRING( "CATAllocs: Same allocation fragment again: " << sAddress ); |
|
86 } |
|
87 } |
|
88 |
|
89 // ReallocH. |
|
90 void CATAllocs::ReallocH( const string& sReallocHString, const string& aTimeString ) |
|
91 { |
|
92 LOG_LOW_FUNC_ENTRY("CATAllocs::ReallocH"); |
|
93 string sAllocH( sReallocHString ); |
|
94 // Parse alloc & create new allocation. |
|
95 CATAlloc alloc; |
|
96 string sAddress = GetStringUntilNextSpace( sAllocH, true ); |
|
97 alloc.m_sTime = aTimeString; |
|
98 alloc.m_sSize = GetStringUntilNextSpace( sAllocH, true ); |
47 alloc.m_sSize = GetStringUntilNextSpace( sAllocH, true ); |
99 alloc.m_iCSCount = _httoi( string( GetStringUntilNextSpace( sAllocH, true ) ).c_str() ); |
48 alloc.m_iCSCount = _httoi( string( GetStringUntilNextSpace( sAllocH, true ) ).c_str() ); |
100 // Insert call stack fragment as "first" 1 because we are header. |
49 // Insert call stack fragment as "first" 1 because we are header. |
101 if ( alloc.m_iCSCount > 0 ) |
50 if ( alloc.m_iCSCount > 0 ) |
102 alloc.m_vCallStack.insert( pair<unsigned long,string>( 0, sAllocH ) ); |
51 alloc.m_vCallStack.insert( pair<unsigned long,string>( 0, sAllocH ) ); |
108 // Allocation to this memory address was already added. |
57 // Allocation to this memory address was already added. |
109 LOG_STRING( "CATAllocs: Allocating same address again, address: " << sAddress ); |
58 LOG_STRING( "CATAllocs: Allocating same address again, address: " << sAddress ); |
110 } |
59 } |
111 } |
60 } |
112 |
61 |
113 // ReallocF. |
62 void CATAllocs::AllocF( const string& sAllocFString ) |
114 void CATAllocs::ReallocF( const string& sReallocFString, const string& aTimeString ) |
|
115 { |
63 { |
116 LOG_LOW_FUNC_ENTRY("CATAllocs::ReallocF"); |
64 LOG_LOW_FUNC_ENTRY("CATAllocs::AllocF"); |
117 string sAllocF( sReallocFString ); |
65 string sAllocF( sAllocFString ); |
118 string sAddress = GetStringUntilNextSpace( sAllocF, true ); |
66 string sAddress = GetStringUntilNextSpace( sAllocF, true ); |
119 string sTime = aTimeString; |
67 string sTime = GetStringUntilNextSpace( sAllocF, true ); |
120 unsigned long iNumber = _httoi( string( GetStringUntilNextSpace( sAllocF, true ) ).c_str() ); |
68 unsigned long iNumber = _httoi( string( GetStringUntilNextSpace( sAllocF, true ) ).c_str() ); |
121 string sCallSstack = sAllocF; |
69 string sCallSstack = sAllocF; |
122 // Find correct allocation into which add call stack fragment. |
70 // Find correct allocation into which add call stack fragment. |
123 map<string, CATAlloc>::iterator it; |
71 map<string, CATAlloc>::iterator it; |
124 it = m_vAllocs.find( sAddress ); |
72 it = m_vAllocs.find( sAddress ); |
154 // Delete it. |
102 // Delete it. |
155 m_vAllocs.erase( it ); |
103 m_vAllocs.erase( it ); |
156 } |
104 } |
157 |
105 |
158 // FreeH. |
106 // FreeH. |
159 void CATAllocs::FreeH( const string& sFreeH, const string& aTimeString ) |
107 void CATAllocs::FreeH( const string& sFreeH ) |
160 { |
108 { |
161 LOG_LOW_FUNC_ENTRY("CATAllocs::FreeH"); |
109 LOG_LOW_FUNC_ENTRY("CATAllocs::FreeH"); |
162 // Current implementation does not use call stack of |
110 // Current implementation does not use call stack of |
163 // free message to anything. |
111 // free message to anything. |
164 string sFree( sFreeH ); |
112 string sFree( sFreeH ); |
165 string sKey = GetStringUntilNextSpace( sFree ); |
113 string sKey = GetStringUntilNextSpace( sFree ); |
166 // Time stamp. (not used currently) |
114 // Time stamp. (not used currently) |
167 // Thread ID. (not used currently) |
|
168 // Call stack count. (not used currently) |
115 // Call stack count. (not used currently) |
169 // Call stack data. (not used currently) |
116 // Call stack data. (not used currently) |
170 |
117 |
171 // Find related allocation. |
118 // Find related allocation. |
172 map<string, CATAlloc>::iterator it; |
119 map<string, CATAlloc>::iterator it; |