diff --git a/Makefile.am b/Makefile.am index 6083ecc..2ac1445 100644 --- a/Makefile.am +++ b/Makefile.am @@ -198,8 +198,10 @@ SPINLOCK_INCLUDES = src/base/spinlock.h \ src/base/spinlock_win32-inl.h \ src/base/spinlock_linux-inl.h \ src/base/spinlock_posix-inl.h \ + src/base/synchronization_profiling.h \ src/base/atomicops-internals-macosx.h \ src/base/atomicops-internals-linuxppc.h \ + src/base/atomicops-internals-arm-gcc.h \ src/base/atomicops-internals-x86-msvc.h \ src/base/atomicops-internals-x86.h noinst_LTLIBRARIES += libspinlock.la diff --git a/Makefile.in b/Makefile.in index 055c3e6..2a929c6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -309,9 +309,11 @@ am__libprofiler_la_SOURCES_DIST = src/profiler.cc \ src/base/atomicops-internals-x86-msvc.h \ src/base/atomicops-internals-x86.h \ src/base/spinlock_win32-inl.h src/base/spinlock_linux-inl.h \ - src/base/spinlock_posix-inl.h src/base/dynamic_annotations.h \ - src/third_party/valgrind.h src/google/profiler.h \ - src/google/stacktrace.h + src/base/spinlock_posix-inl.h \ + src/base/synchronization_profiling.h \ + src/base/atomicops-internals-arm-gcc.h \ + src/base/dynamic_annotations.h src/third_party/valgrind.h \ + src/google/profiler.h src/google/stacktrace.h @WITH_CPU_PROFILER_TRUE@am__objects_2 = $(am__objects_1) \ @WITH_CPU_PROFILER_TRUE@ $(am__objects_1) @WITH_CPU_PROFILER_TRUE@am__objects_3 = $(am__objects_2) \ @@ -332,7 +334,9 @@ am__libspinlock_la_SOURCES_DIST = src/base/spinlock.cc \ src/base/atomicops-internals-x86-msvc.h \ src/base/atomicops-internals-x86.h \ src/base/spinlock_win32-inl.h src/base/spinlock_linux-inl.h \ - src/base/spinlock_posix-inl.h + src/base/spinlock_posix-inl.h \ + src/base/synchronization_profiling.h \ + src/base/atomicops-internals-arm-gcc.h @MINGW_FALSE@am_libspinlock_la_OBJECTS = spinlock.lo \ @MINGW_FALSE@ spinlock_internal.lo atomicops-internals-x86.lo \ @MINGW_FALSE@ $(am__objects_1) @@ -376,7 +380,9 @@ am__libtcmalloc_la_SOURCES_DIST = src/tcmalloc.cc src/common.h \ src/base/atomicops-internals-x86-msvc.h \ src/base/atomicops-internals-x86.h \ src/base/spinlock_win32-inl.h src/base/spinlock_linux-inl.h \ - src/base/spinlock_posix-inl.h src/tcmalloc_guard.h \ + src/base/spinlock_posix-inl.h \ + src/base/synchronization_profiling.h \ + src/base/atomicops-internals-arm-gcc.h src/tcmalloc_guard.h \ src/base/commandlineflags.h src/base/basictypes.h \ src/pagemap.h src/sampler.h src/central_freelist.h \ src/linked_list.h src/page_heap.h src/page_heap_allocator.h \ @@ -427,7 +433,9 @@ am__libtcmalloc_and_profiler_la_SOURCES_DIST = src/tcmalloc.cc \ src/base/atomicops-internals-x86-msvc.h \ src/base/atomicops-internals-x86.h \ src/base/spinlock_win32-inl.h src/base/spinlock_linux-inl.h \ - src/base/spinlock_posix-inl.h src/tcmalloc_guard.h \ + src/base/spinlock_posix-inl.h \ + src/base/synchronization_profiling.h \ + src/base/atomicops-internals-arm-gcc.h src/tcmalloc_guard.h \ src/base/commandlineflags.h src/base/basictypes.h \ src/pagemap.h src/sampler.h src/central_freelist.h \ src/linked_list.h src/page_heap.h src/page_heap_allocator.h \ @@ -481,7 +489,9 @@ am__libtcmalloc_debug_la_SOURCES_DIST = src/debugallocation.cc \ src/base/atomicops-internals-x86-msvc.h \ src/base/atomicops-internals-x86.h \ src/base/spinlock_win32-inl.h src/base/spinlock_linux-inl.h \ - src/base/spinlock_posix-inl.h src/tcmalloc_guard.h \ + src/base/spinlock_posix-inl.h \ + src/base/synchronization_profiling.h \ + src/base/atomicops-internals-arm-gcc.h src/tcmalloc_guard.h \ src/base/commandlineflags.h src/base/basictypes.h \ src/pagemap.h src/sampler.h src/central_freelist.h \ src/linked_list.h src/page_heap.h src/page_heap_allocator.h \ @@ -525,7 +535,9 @@ am__libtcmalloc_internal_la_SOURCES_DIST = src/common.cc \ src/base/atomicops-internals-x86-msvc.h \ src/base/atomicops-internals-x86.h \ src/base/spinlock_win32-inl.h src/base/spinlock_linux-inl.h \ - src/base/spinlock_posix-inl.h src/tcmalloc_guard.h \ + src/base/spinlock_posix-inl.h \ + src/base/synchronization_profiling.h \ + src/base/atomicops-internals-arm-gcc.h src/tcmalloc_guard.h \ src/base/commandlineflags.h src/base/basictypes.h \ src/pagemap.h src/sampler.h src/central_freelist.h \ src/linked_list.h src/page_heap.h src/page_heap_allocator.h \ @@ -585,7 +597,9 @@ am__libtcmalloc_minimal_la_SOURCES_DIST = src/tcmalloc.cc src/common.h \ src/base/atomicops-internals-x86-msvc.h \ src/base/atomicops-internals-x86.h \ src/base/spinlock_win32-inl.h src/base/spinlock_linux-inl.h \ - src/base/spinlock_posix-inl.h src/tcmalloc_guard.h \ + src/base/spinlock_posix-inl.h \ + src/base/synchronization_profiling.h \ + src/base/atomicops-internals-arm-gcc.h src/tcmalloc_guard.h \ src/base/commandlineflags.h src/base/basictypes.h \ src/pagemap.h src/sampler.h src/central_freelist.h \ src/linked_list.h src/page_heap.h src/page_heap_allocator.h \ @@ -612,7 +626,9 @@ am__libtcmalloc_minimal_debug_la_SOURCES_DIST = \ src/base/atomicops-internals-x86-msvc.h \ src/base/atomicops-internals-x86.h \ src/base/spinlock_win32-inl.h src/base/spinlock_linux-inl.h \ - src/base/spinlock_posix-inl.h src/tcmalloc_guard.h \ + src/base/spinlock_posix-inl.h \ + src/base/synchronization_profiling.h \ + src/base/atomicops-internals-arm-gcc.h src/tcmalloc_guard.h \ src/base/commandlineflags.h src/base/basictypes.h \ src/pagemap.h src/sampler.h src/central_freelist.h \ src/linked_list.h src/page_heap.h src/page_heap_allocator.h \ @@ -644,7 +660,9 @@ am__libtcmalloc_minimal_internal_la_SOURCES_DIST = src/common.cc \ src/base/atomicops-internals-x86-msvc.h \ src/base/atomicops-internals-x86.h \ src/base/spinlock_win32-inl.h src/base/spinlock_linux-inl.h \ - src/base/spinlock_posix-inl.h src/tcmalloc_guard.h \ + src/base/spinlock_posix-inl.h \ + src/base/synchronization_profiling.h \ + src/base/atomicops-internals-arm-gcc.h src/tcmalloc_guard.h \ src/base/commandlineflags.h src/base/basictypes.h \ src/pagemap.h src/sampler.h src/central_freelist.h \ src/linked_list.h src/page_heap.h src/page_heap_allocator.h \ @@ -881,7 +899,9 @@ am__low_level_alloc_unittest_SOURCES_DIST = \ src/base/atomicops-internals-x86-msvc.h \ src/base/atomicops-internals-x86.h \ src/base/spinlock_win32-inl.h src/base/spinlock_linux-inl.h \ - src/base/spinlock_posix-inl.h src/base/logging.h \ + src/base/spinlock_posix-inl.h \ + src/base/synchronization_profiling.h \ + src/base/atomicops-internals-arm-gcc.h src/base/logging.h \ src/base/commandlineflags.h src/base/dynamic_annotations.h \ src/third_party/valgrind.h am__objects_29 = $(am__objects_1) $(am__objects_1) @@ -1797,8 +1817,10 @@ libsysinfo_la_LIBADD = $(NANOSLEEP_LIBS) $(am__append_7) @MINGW_TRUE@ src/base/spinlock_win32-inl.h \ @MINGW_TRUE@ src/base/spinlock_linux-inl.h \ @MINGW_TRUE@ src/base/spinlock_posix-inl.h \ +@MINGW_TRUE@ src/base/synchronization_profiling.h \ @MINGW_TRUE@ src/base/atomicops-internals-macosx.h \ @MINGW_TRUE@ src/base/atomicops-internals-linuxppc.h \ +@MINGW_TRUE@ src/base/atomicops-internals-arm-gcc.h \ @MINGW_TRUE@ src/base/atomicops-internals-x86-msvc.h \ @MINGW_TRUE@ src/base/atomicops-internals-x86.h diff --git a/src/google/malloc_hook_c.h b/src/google/malloc_hook_c.h index c870dae..d19e649 100644 --- a/src/google/malloc_hook_c.h +++ b/src/google/malloc_hook_c.h @@ -40,20 +40,32 @@ #include #include +// Annoying stuff for windows -- makes sure clients can import these functions +#ifndef PERFTOOLS_DLL_DECL +# ifdef _WIN32 +# define PERFTOOLS_DLL_DECL __declspec(dllimport) +# else +# define PERFTOOLS_DLL_DECL +# endif +#endif + /* Get the current stack trace. Try to skip all routines up to and * and including the caller of MallocHook::Invoke*. * Use "skip_count" (similarly to GetStackTrace from stacktrace.h) * as a hint about how many routines to skip if better information * is not available. */ +PERFTOOLS_DLL_DECL int MallocHook_GetCallerStackTrace(void** result, int max_depth, int skip_count); typedef void (*MallocHook_NewHook)(const void* ptr, size_t size); +PERFTOOLS_DLL_DECL MallocHook_NewHook MallocHook_SetNewHook(MallocHook_NewHook hook); typedef void (*MallocHook_DeleteHook)(const void* ptr); +PERFTOOLS_DLL_DECL MallocHook_DeleteHook MallocHook_SetDeleteHook(MallocHook_DeleteHook hook); typedef void (*MallocHook_PreMmapHook)(const void *start, @@ -62,6 +74,7 @@ typedef void (*MallocHook_PreMmapHook)(const void *start, int flags, int fd, off_t offset); +PERFTOOLS_DLL_DECL MallocHook_PreMmapHook MallocHook_SetPreMmapHook(MallocHook_PreMmapHook hook); typedef void (*MallocHook_MmapHook)(const void* result, @@ -71,9 +84,11 @@ typedef void (*MallocHook_MmapHook)(const void* result, int flags, int fd, off_t offset); +PERFTOOLS_DLL_DECL MallocHook_MmapHook MallocHook_SetMmapHook(MallocHook_MmapHook hook); typedef void (*MallocHook_MunmapHook)(const void* ptr, size_t size); +PERFTOOLS_DLL_DECL MallocHook_MunmapHook MallocHook_SetMunmapHook(MallocHook_MunmapHook hook); typedef void (*MallocHook_MremapHook)(const void* result, @@ -82,12 +97,15 @@ typedef void (*MallocHook_MremapHook)(const void* result, size_t new_size, int flags, const void* new_addr); +PERFTOOLS_DLL_DECL MallocHook_MremapHook MallocHook_SetMremapHook(MallocHook_MremapHook hook); typedef void (*MallocHook_PreSbrkHook)(ptrdiff_t increment); +PERFTOOLS_DLL_DECL MallocHook_PreSbrkHook MallocHook_SetPreSbrkHook(MallocHook_PreSbrkHook hook); typedef void (*MallocHook_SbrkHook)(const void* result, ptrdiff_t increment); +PERFTOOLS_DLL_DECL MallocHook_SbrkHook MallocHook_SetSbrkHook(MallocHook_SbrkHook hook); #endif /* _MALLOC_HOOK_C_H_ */