Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SapMachine (11) #1550: Implement new malloc trace for SapMachine 11 #1745

Open
wants to merge 8 commits into
base: sapmachine11
Choose a base branch
from
13 changes: 13 additions & 0 deletions make/copy/Copy-java.base.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,16 @@ $(eval $(call SetupTextFileProcessing, CREATE_CLASSFILE_CONSTANTS_H, \
TARGETS += $(CREATE_CLASSFILE_CONSTANTS_H)

################################################################################
# SapMachine 2023-11-28: Copy mallochook.h

ifeq ($(call isTargetOs, linux macosx), true)

$(eval $(call SetupCopyFiles, CREATE_MALLOC_HOOKS_H, \
FILES := $(TOPDIR)/src/java.base/unix/native/libmallochooks/mallochooks.h, \
DEST := $(SUPPORT_OUTPUTDIR)/modules_include/java.base/, \
))

TARGETS += $(CREATE_MALLOC_HOOKS_H)
endif

################################################################################
15 changes: 15 additions & 0 deletions make/lib/CoreLibraries.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,18 @@ ifeq ($(call isTargetOs, aix), true)
TARGETS += $(BUILD_LIBJLI_STATIC)

endif

# SapMachine 2023-11-28: build libmallochooks

ifeq ($(call isTargetOs, linux macosx), true)
$(eval $(call SetupJdkLibrary, BUILD_LIBMALLOCHOOKS, \
NAME := mallochooks, \
OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
OPTIMIZATION := LOW, \
CFLAGS := $(CFLAGS_JDKLIB), \
LDFLAGS := $(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN), \
LIBS := -ldl, \
))

TARGETS += $(BUILD_LIBMALLOCHOOKS)
endif
3 changes: 3 additions & 0 deletions make/test/JtregNativeHotspot.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,9 @@ ifeq ($(call isTargetOs, linux), true)
BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exestack-gap := -ljvm -lpthread
BUILD_TEST_exeinvoke_exeinvoke.c_OPTIMIZATION := NONE
BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exeFPRegs := -ldl
# SapMachine 2023-10-04: Added link flags for malloc hooks tests
BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exetestmallochooks := -ldl
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libtestmallochooks := -ldl
else
BUILD_HOTSPOT_JTREG_EXCLUDE += libtest-rw.c libtest-rwx.c libTestJNI.c \
exeinvoke.c exestack-gap.c
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/os/linux/malloctrace/mallocTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "malloctrace/assertHandling.hpp"
#include "malloctrace/locker.hpp"
#include "malloctrace/mallocTrace.hpp"
#include "malloctrace/mallocTracePosix.hpp"
#include "malloctrace/siteTable.hpp"
#include "memory/allocation.hpp"
#include "runtime/globals.hpp"
Expand Down Expand Up @@ -129,6 +130,9 @@ class HookControl : public AllStatic {

static void enable() {
DEBUG_ONLY(verify();)
#if defined(MALLOC_TRACE_AVAILABLE)
MallocStatistic::disable(NULL);
#endif
malloctrace_assert(!hooks_are_active(), "Sanity");
_old_malloc_hook = __malloc_hook;
__malloc_hook = my_malloc_hook;
Expand Down
Loading
Loading