4 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
8 * Woojin Jung <woojin2.jung@samsung.com>
9 * Jaewon Lim <jaewon81.lim@samsung.com>
10 * Juyoung Kim <j0.kim@samsung.com>
11 * Anastasia Lyupa <a.lyupa@samsung.com>
13 * This library is free software; you can redistribute it and/or modify it under
14 * the terms of the GNU Lesser General Public License as published by the
15 * Free Software Foundation; either version 2.1 of the License, or (at your option)
18 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
19 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
21 * License for more details.
23 * You should have received a copy of the GNU Lesser General Public License
24 * along with this library; if not, write to the Free Software Foundation, Inc., 51
25 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29 * - Samsung RnD Institute Russia
41 #include "probeinfo.h"
42 #include "dacollection.h"
43 #include "da_memory.h"
46 static enum DaOptions _sopt = OPT_ALLOC;
48 void *operator new(std::size_t size) throw (std::bad_alloc)
50 static void*(*newp)(std::size_t size);
51 DECLARE_VARIABLE_STANDARD;
54 GET_REAL_FUNCP_RTLD_NEXT_CPP(_Znwj,newp);
56 bfiltering = INTERNAL_NEW_FILTERING;
61 if(pret != NULL && getTraceState() == 0)
63 add_memory_hash(pret, size);
66 POST_PACK_PROBEBLOCK_BEGIN();
69 PACK_COMMON_BEGIN(MSG_PROBE_MEMORY,
70 API_ID_void__operator_new_std__size_t_size__throw__std__bad_alloc_,
72 PACK_COMMON_END(pret, newerrno, blockresult);
73 PACK_MEMORY(size, MEMORY_API_ALLOC, pret);
76 POST_PACK_PROBEBLOCK_END();
81 void *operator new[](std::size_t size) throw (std::bad_alloc)
83 static void*(*newp)(std::size_t size);
84 DECLARE_VARIABLE_STANDARD;
87 GET_REAL_FUNCP_RTLD_NEXT_CPP(_Znaj, newp);
89 bfiltering = INTERNAL_NEW_FILTERING;
94 if(pret != NULL && getTraceState() == 0)
96 add_memory_hash(pret, size);
99 POST_PACK_PROBEBLOCK_BEGIN();
102 PACK_COMMON_BEGIN(MSG_PROBE_MEMORY,
103 API_ID_void__operator_new___std__size_t_size__throw__std__bad_alloc_,
105 PACK_COMMON_END(pret, newerrno, blockresult);
106 PACK_MEMORY(size, MEMORY_API_ALLOC, pret);
109 POST_PACK_PROBEBLOCK_END();
114 void operator delete(void *ptr) throw()
116 static void (*deletep)(void *ptr);
117 DECLARE_VARIABLE_STANDARD;
119 GET_REAL_FUNCP_RTLD_NEXT_CPP(_ZdlPv, deletep);
121 bfiltering = INTERNAL_DELETE_FILTERING;
124 if(ptr != NULL && getTraceState() == 0)
126 del_memory_hash(ptr);
131 POST_PACK_PROBEBLOCK_BEGIN();
134 PACK_COMMON_BEGIN(MSG_PROBE_MEMORY,
135 API_ID_void_operator_delete_void__ptr__throw__,
137 PACK_COMMON_END(0, newerrno, blockresult);
138 PACK_MEMORY(0, MEMORY_API_FREE, ptr);
141 POST_PACK_PROBEBLOCK_END();
144 void operator delete[](void *ptr) throw()
146 static void (*deletep)(void *ptr);
147 DECLARE_VARIABLE_STANDARD;
149 GET_REAL_FUNCP_RTLD_NEXT_CPP(_ZdaPv, deletep);
151 bfiltering = INTERNAL_DELETE_FILTERING;
154 if(ptr != NULL && getTraceState() == 0)
156 del_memory_hash(ptr);
161 POST_PACK_PROBEBLOCK_BEGIN();
164 PACK_COMMON_BEGIN(MSG_PROBE_MEMORY,
165 API_ID_void_operator_delete___void__ptr__throw__,
167 PACK_COMMON_END(0, newerrno, blockresult);
168 PACK_MEMORY(0, MEMORY_API_FREE, ptr);
171 POST_PACK_PROBEBLOCK_END();
174 void *operator new(std::size_t size, const std::nothrow_t& nothrow) throw()
176 static void*(*newp)(std::size_t size, const std::nothrow_t& nothrow);
177 DECLARE_VARIABLE_STANDARD;
180 GET_REAL_FUNCP_RTLD_NEXT_CPP(_ZnwjRKSt9nothrow_t, newp);
182 bfiltering = INTERNAL_NEW_FILTERING;
185 pret = newp(size, nothrow);
187 if(pret != NULL && getTraceState() == 0)
189 add_memory_hash(pret, size);
192 POST_PACK_PROBEBLOCK_BEGIN();
195 PACK_COMMON_BEGIN(MSG_PROBE_MEMORY,
196 API_ID_void__operator_new_std__size_t_size__const_std__nothrow_t__nothrow__throw__,
197 "xp", size, ¬hrow);
198 PACK_COMMON_END(pret, newerrno, blockresult);
199 PACK_MEMORY(size, MEMORY_API_ALLOC, pret);
202 POST_PACK_PROBEBLOCK_END();
207 void *operator new[](std::size_t size, const std::nothrow_t& nothrow) throw()
209 static void*(*newp)(std::size_t size, const std::nothrow_t& nothrow);
210 DECLARE_VARIABLE_STANDARD;
213 GET_REAL_FUNCP_RTLD_NEXT_CPP(_ZnajRKSt9nothrow_t, newp);
215 bfiltering = INTERNAL_NEW_FILTERING;
218 pret = newp(size, nothrow);
220 if(pret != NULL && getTraceState() == 0)
222 add_memory_hash(pret, size);
225 POST_PACK_PROBEBLOCK_BEGIN();
228 PACK_COMMON_BEGIN(MSG_PROBE_MEMORY,
229 API_ID_void__operator_new___std__size_t_size__const_std__nothrow_t__nothrow__throw__,
230 "xp", size, ¬hrow);
231 PACK_COMMON_END(pret, newerrno, blockresult);
232 PACK_MEMORY(size, MEMORY_API_ALLOC, pret);
235 POST_PACK_PROBEBLOCK_END();
240 void operator delete(void *ptr, const std::nothrow_t& nothrow) throw()
242 static void (*deletep)(void *ptr, const std::nothrow_t& nothrow);
243 DECLARE_VARIABLE_STANDARD;
245 GET_REAL_FUNCP_RTLD_NEXT_CPP(_ZdlPvRKSt9nothrow_t, deletep);
247 bfiltering = INTERNAL_DELETE_FILTERING;
250 if(ptr != NULL && getTraceState() == 0)
252 del_memory_hash(ptr);
255 deletep(ptr, nothrow);
257 POST_PACK_PROBEBLOCK_BEGIN();
260 PACK_COMMON_BEGIN(MSG_PROBE_MEMORY,
261 API_ID_void_operator_delete_void__ptr__const_std__nothrow_t__nothrow__throw__,
262 "pp", ptr, ¬hrow);
263 PACK_COMMON_END(0, newerrno, blockresult);
264 PACK_MEMORY(0, MEMORY_API_FREE, ptr);
267 POST_PACK_PROBEBLOCK_END();
270 void operator delete[](void *ptr, const std::nothrow_t& nothrow) throw()
272 static void (*deletep)(void *ptr, const std::nothrow_t& nothrow);
273 DECLARE_VARIABLE_STANDARD;
275 GET_REAL_FUNCP_RTLD_NEXT_CPP(_ZdaPvRKSt9nothrow_t, deletep);
277 bfiltering = INTERNAL_DELETE_FILTERING;
280 if(ptr != NULL && getTraceState() == 0)
282 del_memory_hash(ptr);
285 deletep(ptr, nothrow);
287 POST_PACK_PROBEBLOCK_BEGIN();
290 PACK_COMMON_BEGIN(MSG_PROBE_MEMORY,
291 API_ID_void_operator_delete___void__ptr__const_std__nothrow_t__nothrow__throw__,
292 "pp", ptr, ¬hrow);
293 PACK_COMMON_END(0, newerrno, blockresult);
294 PACK_MEMORY(0, MEMORY_API_FREE, ptr);
297 POST_PACK_PROBEBLOCK_END();