1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
#
# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
ifeq ($(call check-jvm-feature, dtrace), true)
ifeq ($(call isTargetOs, solaris), true)
############################################################################
# Integrate with libjvm. Here we generate two object files which are
# linked with libjvm.so. This step is complicated from a dependency
# perspective. We add these two files to the linking of libjvm using
# EXTRA_OBJECT_FILES, but they need to be created outside the call to
# SetupNativeCompilation. Also, one of the files is dependent on compiled
# object files from the libjvm compilation, so this generation must happen
# as a part of the libjvm compilation.
DTRACE_OBJ := $(JVM_OUTPUTDIR)/objs/dtrace.o
DTRACE_JHELPER_OBJ := $(JVM_OUTPUTDIR)/objs/dtrace_jhelper.o
DTRACE_EXTRA_OBJECT_FILES := $(DTRACE_OBJ) $(DTRACE_JHELPER_OBJ)
############################################################################
# Generate DTRACE_OBJ which is linked with libjvm.so. It depends on a set of
# object files from the compilation.
# Concatenate all *.d files into a single file
DTRACE_SOURCE_FILES := $(addprefix $(TOPDIR)/src/hotspot/os/posix/dtrace/, \
hotspot_jni.d \
hotspot.d \
hs_private.d \
)
$(JVM_OUTPUTDIR)/objs/dtrace.d: $(DTRACE_SOURCE_FILES)
$(call LogInfo, Generating $(@F))
$(call MakeDir, $(@D))
$(CAT) $^ > $@
DTRACE_INSTRUMENTED_OBJS := $(addprefix $(JVM_OUTPUTDIR)/objs/, \
ciEnv.o \
classLoadingService.o \
compileBroker.o \
hashtable.o \
instanceKlass.o \
java.o \
jni.o \
jvm.o \
memoryManager.o \
nmethod.o \
objectMonitor.o \
runtimeService.o \
sharedRuntime.o \
synchronizer.o \
thread.o \
unsafe.o \
vmThread.o \
vmGCOperations.o \
)
ifeq ($(call check-jvm-feature, cmsgc), true)
DTRACE_INSTRUMENTED_OBJS += $(addprefix $(JVM_OUTPUTDIR)/objs/, \
vmCMSOperations.o \
)
endif
ifeq ($(call check-jvm-feature, parallelgc), true)
DTRACE_INSTRUMENTED_OBJS += $(addprefix $(JVM_OUTPUTDIR)/objs/, \
vmPSOperations.o \
)
endif
DTRACE_FLAGS := -64 -G
DTRACE_CPP_FLAGS := -D_LP64
# Make sure we run our selected compiler for preprocessing instead of letting
# the dtrace tool pick it on it's own.
$(DTRACE_OBJ): $(JVM_OUTPUTDIR)/objs/dtrace.d $(DTRACE_INSTRUMENTED_OBJS)
$(call LogInfo, Generating $(@F) from $(<F) and object files)
$(call MakeDir, $(DTRACE_SUPPORT_DIR))
$(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, \
($(CPP) $(DTRACE_CPP_FLAGS) $< > $(DTRACE_SUPPORT_DIR)/$(@F).d))
$(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -xlazyload -o $@ \
-s $(DTRACE_SUPPORT_DIR)/$(@F).d $(sort $(DTRACE_INSTRUMENTED_OBJS)))
############################################################################
# Generate DTRACE_JHELPER_OBJ which is linked with libjvm.so.
JHELPER_DTRACE_SRC := $(TOPDIR)/src/hotspot/os/solaris/dtrace/jhelper.d
# jhelper.d includes JvmOffsetsIndex.h which was created by the gensrc step.
DTRACE_GENSRC_DIR := $(JVM_VARIANT_OUTPUTDIR)/gensrc/dtracefiles
JVM_OFFSETS_INDEX_H := $(DTRACE_GENSRC_DIR)/JvmOffsetsIndex.h
# Unfortunately dtrace generates incorrect types for some symbols in
# dtrace_jhelper.o, resulting in "warning: symbol X has differing types"
# See JDK-6890703 for details.
# We work around this by fixing the types for these symbols using elfedit,
# after dtrace has generated the .o file.
GetElfeditCommands = \
$(foreach symbol, \
$(shell $(GREP) ^extern $(JHELPER_DTRACE_SRC) | $(AWK) '{ gsub(";","") ; print $$3 }'), \
-e 'sym:st_type $(symbol) 1')
# Make sure we run our selected compiler for preprocessing instead of letting
# the dtrace tool pick it on it's own.
$(DTRACE_JHELPER_OBJ): $(JHELPER_DTRACE_SRC) $(JVM_OFFSETS_INDEX_H)
$(call LogInfo, Running dtrace for $(<F))
$(call MakeDir, $(DTRACE_SUPPORT_DIR))
$(call ExecuteWithLog, $(DTRACE_SUPPORT_DIR)/$(@F).d, \
($(CPP) $(DTRACE_CPP_FLAGS) -I$(DTRACE_GENSRC_DIR) $^ \
> $(DTRACE_SUPPORT_DIR)/$(@F).d))
$(call ExecuteWithLog, $@, $(DTRACE) $(DTRACE_FLAGS) -o $@ \
-s $(DTRACE_SUPPORT_DIR)/$(@F).d)
ifeq ($(call isTargetCpuArch, sparc), true)
$(call ExecuteWithLog, $@.elfedit, $(ELFEDIT) $(call GetElfeditCommands) $@)
endif
endif
endif
|