From 0a248a897c2800c3d0040f2d0acb4f6f7e7047de Mon Sep 17 00:00:00 2001 From: Anastasia Lyupa Date: Fri, 21 Jun 2013 18:24:34 +0400 Subject: [PATCH] add memory probes in libdanew.cpp --- probe_memory/libdanew.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/probe_memory/libdanew.cpp b/probe_memory/libdanew.cpp index 7f4b49e..3c9597c 100644 --- a/probe_memory/libdanew.cpp +++ b/probe_memory/libdanew.cpp @@ -100,6 +100,13 @@ void *operator new[](std::size_t size) throw (std::bad_alloc) POST_PROBEBLOCK_BEGIN_MEM(LC_MEMORY, "new", VT_PTR, pret, "%u", size); POST_PROBEBLOCK_MIDDLE_MEM(size, MEMORY_API_ALLOC, pret); APPEND_LOG_CALLSTACK(); + + PREPARE_LOCAL_BUF(); + PACK_COMMON_BEGIN(MSG_PROBE_MEMORY, LC_MEMORY, "d", size); + PACK_COMMON_END(pret, newerrno, blockresult); + PACK_MEMORY(size, MEMORY_API_ALLOC, pret); + FLUSH_LOCAL_BUF(); + POST_PROBEBLOCK_END(); return pret; @@ -125,6 +132,13 @@ void operator delete(void *ptr) throw() POST_PROBEBLOCK_BEGIN_MEM(LC_MEMORY, "delete", VT_NULL, NULL, "%p", ptr); POST_PROBEBLOCK_MIDDLE_MEM(0, MEMORY_API_FREE, ptr); POST_PROBEBLOCK_CALLSTACK(); + + PREPARE_LOCAL_BUF(); + PACK_COMMON_BEGIN(MSG_PROBE_MEMORY, LC_MEMORY, "p", ptr); + PACK_COMMON_END(0, newerrno, blockresult); + PACK_MEMORY(0, MEMORY_API_FREE, ptr); + FLUSH_LOCAL_BUF(); + POST_PROBEBLOCK_END(); } @@ -148,6 +162,13 @@ void operator delete[](void *ptr) throw() POST_PROBEBLOCK_BEGIN_MEM(LC_MEMORY, "delete", VT_NULL, NULL, "%p", ptr); POST_PROBEBLOCK_MIDDLE_MEM(0, MEMORY_API_FREE, ptr); POST_PROBEBLOCK_CALLSTACK(); + + PREPARE_LOCAL_BUF(); + PACK_COMMON_BEGIN(MSG_PROBE_MEMORY, LC_MEMORY, "p", ptr); + PACK_COMMON_END(0, newerrno, blockresult); + PACK_MEMORY(0, MEMORY_API_FREE, ptr); + FLUSH_LOCAL_BUF(); + POST_PROBEBLOCK_END(); } @@ -172,6 +193,13 @@ void *operator new(std::size_t size, const std::nothrow_t& nothrow) throw() POST_PROBEBLOCK_BEGIN_MEM(LC_MEMORY, "new", VT_PTR, pret, "%u", size); POST_PROBEBLOCK_MIDDLE_MEM(size, MEMORY_API_ALLOC, pret); APPEND_LOG_CALLSTACK(); + + PREPARE_LOCAL_BUF(); + PACK_COMMON_BEGIN(MSG_PROBE_MEMORY, LC_MEMORY, "dp", size, ¬hrow); + PACK_COMMON_END(pret, newerrno, blockresult); + PACK_MEMORY(size, MEMORY_API_ALLOC, pret); + FLUSH_LOCAL_BUF(); + POST_PROBEBLOCK_END(); return pret; @@ -198,6 +226,13 @@ void *operator new[](std::size_t size, const std::nothrow_t& nothrow) throw() POST_PROBEBLOCK_BEGIN_MEM(LC_MEMORY, "new", VT_PTR, pret, "%u", size); POST_PROBEBLOCK_MIDDLE_MEM(size, MEMORY_API_ALLOC, pret); APPEND_LOG_CALLSTACK(); + + PREPARE_LOCAL_BUF(); + PACK_COMMON_BEGIN(MSG_PROBE_MEMORY, LC_MEMORY, "dp", size, ¬hrow); + PACK_COMMON_END(pret, newerrno, blockresult); + PACK_MEMORY(size, MEMORY_API_ALLOC, pret); + FLUSH_LOCAL_BUF(); + POST_PROBEBLOCK_END(); return pret; @@ -223,6 +258,13 @@ void operator delete(void *ptr, const std::nothrow_t& nothrow) throw() POST_PROBEBLOCK_BEGIN_MEM(LC_MEMORY, "delete", VT_NULL, NULL, "%p", ptr); POST_PROBEBLOCK_MIDDLE_MEM(0, MEMORY_API_FREE, ptr); POST_PROBEBLOCK_CALLSTACK(); + + PREPARE_LOCAL_BUF(); + PACK_COMMON_BEGIN(MSG_PROBE_MEMORY, LC_MEMORY, "pp", ptr, ¬hrow); + PACK_COMMON_END(0, newerrno, blockresult); + PACK_MEMORY(0, MEMORY_API_FREE, ptr); + FLUSH_LOCAL_BUF(); + POST_PROBEBLOCK_END(); } @@ -246,6 +288,13 @@ void operator delete[](void *ptr, const std::nothrow_t& nothrow) throw() POST_PROBEBLOCK_BEGIN_MEM(LC_MEMORY, "delete", VT_NULL, NULL, "%p", ptr); POST_PROBEBLOCK_MIDDLE_MEM(0, MEMORY_API_FREE, ptr); POST_PROBEBLOCK_CALLSTACK(); + + PREPARE_LOCAL_BUF(); + PACK_COMMON_BEGIN(MSG_PROBE_MEMORY, LC_MEMORY, "pp", ptr, ¬hrow); + PACK_COMMON_END(0, newerrno, blockresult); + PACK_MEMORY(0, MEMORY_API_FREE, ptr); + FLUSH_LOCAL_BUF(); + POST_PROBEBLOCK_END(); } -- 2.7.4