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 && gProbeBlockCount == 0)
63 add_memory_hash(pret, size, MEMTYPE_NEW, blockresult ? MEM_EXTERNAL : MEM_INTERNAL);
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_,
71 "x", (uint64_t)(size));
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 && gProbeBlockCount == 0)
96 add_memory_hash(pret, size, MEMTYPE_NEW, blockresult ? MEM_EXTERNAL : MEM_INTERNAL);
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_,
104 "x", (uint64_t)(size));
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;
118 unsigned short caller;
120 GET_REAL_FUNCP_RTLD_NEXT_CPP(_ZdlPv, deletep);
122 bfiltering = INTERNAL_DELETE_FILTERING;
125 if(ptr != NULL && gProbeBlockCount == 0)
128 ret = del_memory_hash(ptr, MEMTYPE_DELETE, &caller);
129 if(blockresult == 0 && ret == 0 && caller == MEM_EXTERNAL)
131 setProbePoint(&probeInfo);
140 POST_PACK_PROBEBLOCK_BEGIN();
143 PACK_COMMON_BEGIN(MSG_PROBE_MEMORY,
144 API_ID_void_operator_delete_void__ptr__throw__,
145 "p", voidp_to_uint64(ptr));
146 PACK_COMMON_END(0, newerrno, blockresult);
147 PACK_MEMORY(0, MEMORY_API_FREE, ptr);
150 POST_PACK_PROBEBLOCK_END();
153 void operator delete[](void *ptr) throw()
155 static void (*deletep)(void *ptr);
156 DECLARE_VARIABLE_STANDARD;
157 unsigned short caller;
159 GET_REAL_FUNCP_RTLD_NEXT_CPP(_ZdaPv, deletep);
161 bfiltering = INTERNAL_DELETE_FILTERING;
164 if(ptr != NULL && gProbeBlockCount == 0)
167 ret = del_memory_hash(ptr, MEMTYPE_DELETE, &caller);
168 if(blockresult == 0 && ret == 0 && caller == MEM_EXTERNAL)
170 setProbePoint(&probeInfo);
179 POST_PACK_PROBEBLOCK_BEGIN();
182 PACK_COMMON_BEGIN(MSG_PROBE_MEMORY,
183 API_ID_void_operator_delete___void__ptr__throw__,
184 "p", voidp_to_uint64(ptr));
185 PACK_COMMON_END(0, newerrno, blockresult);
186 PACK_MEMORY(0, MEMORY_API_FREE, ptr);
189 POST_PACK_PROBEBLOCK_END();
192 void *operator new(std::size_t size, const std::nothrow_t& nothrow) throw()
194 static void*(*newp)(std::size_t size, const std::nothrow_t& nothrow);
195 DECLARE_VARIABLE_STANDARD;
198 GET_REAL_FUNCP_RTLD_NEXT_CPP(_ZnwjRKSt9nothrow_t, newp);
200 bfiltering = INTERNAL_NEW_FILTERING;
203 pret = newp(size, nothrow);
205 if(pret != NULL && gProbeBlockCount == 0)
207 add_memory_hash(pret, size, MEMTYPE_NEW, blockresult ? MEM_EXTERNAL : MEM_INTERNAL);
210 POST_PACK_PROBEBLOCK_BEGIN();
213 PACK_COMMON_BEGIN(MSG_PROBE_MEMORY,
214 API_ID_void__operator_new_std__size_t_size__const_std__nothrow_t__nothrow__throw__,
215 "xp", (uint64_t)(size), voidp_to_uint64(¬hrow));
216 PACK_COMMON_END(pret, newerrno, blockresult);
217 PACK_MEMORY(size, MEMORY_API_ALLOC, pret);
220 POST_PACK_PROBEBLOCK_END();
225 void *operator new[](std::size_t size, const std::nothrow_t& nothrow) throw()
227 static void*(*newp)(std::size_t size, const std::nothrow_t& nothrow);
228 DECLARE_VARIABLE_STANDARD;
231 GET_REAL_FUNCP_RTLD_NEXT_CPP(_ZnajRKSt9nothrow_t, newp);
233 bfiltering = INTERNAL_NEW_FILTERING;
236 pret = newp(size, nothrow);
238 if(pret != NULL && gProbeBlockCount == 0)
240 add_memory_hash(pret, size, MEMTYPE_NEW, blockresult ? MEM_EXTERNAL : MEM_INTERNAL);
243 POST_PACK_PROBEBLOCK_BEGIN();
246 PACK_COMMON_BEGIN(MSG_PROBE_MEMORY,
247 API_ID_void__operator_new___std__size_t_size__const_std__nothrow_t__nothrow__throw__,
248 "xp", (uint64_t)(size), voidp_to_uint64(¬hrow));
249 PACK_COMMON_END(pret, newerrno, blockresult);
250 PACK_MEMORY(size, MEMORY_API_ALLOC, pret);
253 POST_PACK_PROBEBLOCK_END();
258 void operator delete(void *ptr, const std::nothrow_t& nothrow) throw()
260 static void (*deletep)(void *ptr, const std::nothrow_t& nothrow);
261 DECLARE_VARIABLE_STANDARD;
262 unsigned short caller;
264 GET_REAL_FUNCP_RTLD_NEXT_CPP(_ZdlPvRKSt9nothrow_t, deletep);
266 bfiltering = INTERNAL_DELETE_FILTERING;
269 if(ptr != NULL && gProbeBlockCount == 0)
272 ret = del_memory_hash(ptr, MEMTYPE_DELETE, &caller);
273 if(blockresult == 0 && ret == 0 && caller == MEM_EXTERNAL)
275 setProbePoint(&probeInfo);
282 deletep(ptr, nothrow);
284 POST_PACK_PROBEBLOCK_BEGIN();
287 PACK_COMMON_BEGIN(MSG_PROBE_MEMORY,
288 API_ID_void_operator_delete_void__ptr__const_std__nothrow_t__nothrow__throw__,
289 "pp", voidp_to_uint64(ptr), voidp_to_uint64(¬hrow));
290 PACK_COMMON_END(0, newerrno, blockresult);
291 PACK_MEMORY(0, MEMORY_API_FREE, ptr);
294 POST_PACK_PROBEBLOCK_END();
297 void operator delete[](void *ptr, const std::nothrow_t& nothrow) throw()
299 static void (*deletep)(void *ptr, const std::nothrow_t& nothrow);
300 DECLARE_VARIABLE_STANDARD;
301 unsigned short caller;
303 GET_REAL_FUNCP_RTLD_NEXT_CPP(_ZdaPvRKSt9nothrow_t, deletep);
305 bfiltering = INTERNAL_DELETE_FILTERING;
308 if(ptr != NULL && gProbeBlockCount == 0)
311 ret = del_memory_hash(ptr, MEMTYPE_DELETE, &caller);
312 if(blockresult == 0 && ret == 0 && caller == MEM_EXTERNAL)
314 setProbePoint(&probeInfo);
321 deletep(ptr, nothrow);
323 POST_PACK_PROBEBLOCK_BEGIN();
326 PACK_COMMON_BEGIN(MSG_PROBE_MEMORY,
327 API_ID_void_operator_delete___void__ptr__const_std__nothrow_t__nothrow__throw__,
328 "pp", voidp_to_uint64(ptr), voidp_to_uint64(¬hrow));
329 PACK_COMMON_END(0, newerrno, blockresult);
330 PACK_MEMORY(0, MEMORY_API_FREE, ptr);
333 POST_PACK_PROBEBLOCK_END();